|
|
@@ -7,6 +7,7 @@ interface ConsultMessage {
|
|
|
messageContent?: string; // 消息内容
|
|
|
sendTime?: string; // 发送消息的时间
|
|
|
}
|
|
|
+import I18nBehavior from "../../../../i18n/behavior";
|
|
|
import { Post } from "../../../../lib/request/method";
|
|
|
import { upload } from "../../../../lib/request/upload";
|
|
|
import dayjs from "dayjs";
|
|
|
@@ -57,8 +58,13 @@ function transformMessage(item: AnyObject): ConsultMessage {
|
|
|
}
|
|
|
|
|
|
Component({
|
|
|
+ behaviors: [I18nBehavior],
|
|
|
properties: {},
|
|
|
data: {
|
|
|
+ title: '',
|
|
|
+ i18n: {
|
|
|
+ consultChat: { _: '聊天' }
|
|
|
+ },
|
|
|
messages: [] as ConsultMessage[],
|
|
|
inputText: "",
|
|
|
inputFocus: true,
|
|
|
@@ -71,7 +77,11 @@ Component({
|
|
|
_pollTimer: 0 as any, // 5秒轮询最新消息定时器
|
|
|
textareaHeight: 80, // textarea 高度(rpx),初始值与 min-height 一致
|
|
|
},
|
|
|
-
|
|
|
+ observers: {
|
|
|
+ 'i18n.consultChat._'(this: any, title: string) {
|
|
|
+ this.setData({ title });
|
|
|
+ },
|
|
|
+ },
|
|
|
lifetimes: {
|
|
|
async attached() {
|
|
|
const safeBottomRpx = calculateSafeBottomRpx();
|
|
|
@@ -224,8 +234,8 @@ Component({
|
|
|
this._hideKeyboardAndUpdatePosition();
|
|
|
wx.showModal({
|
|
|
title: "",
|
|
|
- content: "确定要结束本次咨询?",
|
|
|
- cancelText: "继续咨询",
|
|
|
+ content: `确定要结束本次?${this.data.title}`,
|
|
|
+ cancelText: `继续${this.data.title}`,
|
|
|
confirmText: "结束",
|
|
|
}).then((res: any) => {
|
|
|
if (res.confirm) {
|
|
|
@@ -248,7 +258,7 @@ Component({
|
|
|
sender: "system",
|
|
|
sendType: "3",
|
|
|
messageType: "1",
|
|
|
- messageContent: "咨询结束",
|
|
|
+ messageContent: `${this.data.title}结束`,
|
|
|
sendTime: endDate,
|
|
|
});
|
|
|
|
|
|
@@ -258,7 +268,7 @@ Component({
|
|
|
await Post(`/consultManage/end/${consultId}`);
|
|
|
} catch (error: any) {
|
|
|
wx.showToast({
|
|
|
- title: error?.errMsg || "结束咨询失败",
|
|
|
+ title: error?.errMsg || `结束${this.data.title}失败`,
|
|
|
icon: "none",
|
|
|
});
|
|
|
}
|
|
|
@@ -435,7 +445,7 @@ Component({
|
|
|
async _sendMessage(messageType: "1" | "2", messageContent: string) {
|
|
|
const consultId = wx.getStorageSync("consultId");
|
|
|
if (!consultId) {
|
|
|
- wx.showToast({ title: "咨询ID不存在", icon: "none" });
|
|
|
+ wx.showToast({ title: `${this.data.title}ID不存在`, icon: "none" });
|
|
|
return;
|
|
|
}
|
|
|
try {
|