This commit is contained in:
JiXinHui 2026-03-20 09:09:20 +08:00
commit 8a35f79902
4 changed files with 81 additions and 48 deletions

61
App.vue
View File

@ -230,33 +230,35 @@ export default {
receiverId: data.ReceiverId, receiverId: data.ReceiverId,
sendDate: data.SendDate, sendDate: data.SendDate,
message: data.Message, message: data.Message,
sendUserType: data.SendUserType, // 0 AI 1 2 3
}; };
const id = data.Id || data.id || Math.random().toString(36).substring(2); const id =
const msg = { data.Id || data.id || Math.random().toString(36).substring(2);
...processData, const msg = {
messageType: 0, ...processData,
filePath: "", messageType: 0,
id, filePath: "",
}; id,
const storeState = (this.$store && this.$store.state) || {}; };
const isTransferChat = !!storeState.vuex_isTransferChat; const storeState = (this.$store && this.$store.state) || {};
const activeDialogueId = const isTransferChat = !!storeState.vuex_isTransferChat;
storeState.vuex_msgUser?.dialogueManagementId || const activeDialogueId =
storeState.vuex_msgUser?.friendId || storeState.vuex_msgUser?.dialogueManagementId ||
storeState.vuex_msgUser?.id; storeState.vuex_msgUser?.friendId ||
const isActiveChat = storeState.vuex_msgUser?.id;
activeDialogueId && const isActiveChat =
String(activeDialogueId) === String(processData.dialogueManagementId); activeDialogueId &&
String(activeDialogueId) === String(processData.dialogueManagementId);
if (isTransferChat) {
if (isActiveChat) { if (isTransferChat) {
this.$store.commit("push_AiLiveAgentMsg", msg); if (isActiveChat) {
} this.$store.commit("push_AiLiveAgentMsg", msg);
} else { }
if (isActiveChat) { } else {
this.$store.commit("push_Msg", msg); if (isActiveChat) {
} this.$store.commit("push_Msg", msg);
} }
}
// / / // / /
if (processData.dialogueManagementId) { if (processData.dialogueManagementId) {
@ -402,9 +404,10 @@ uni-page-body {
body { body {
margin: 0; margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", font-family:
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
"Microsoft Yahei", sans-serif; "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "Microsoft Yahei",
sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
// max-width: 1536rpx; // max-width: 1536rpx;

View File

@ -118,10 +118,18 @@
{{ formatShowTime(message.sendDate) }} {{ formatShowTime(message.sendDate) }}
</view> </view>
<!-- 提示 -->
<!-- message.sendUserType 0 AI 1 学生 2 教师 3 提示目前只有2和3有用 -->
<view class="message-tip" v-if="message.sendUserType === 3">
{{ message.message }}
</view>
<!-- 0 发送消息 --> <!-- 0 发送消息 -->
<view <view
class="message-right" class="message-right"
v-if="message.senderId === vuex_user.Id" v-if="
message.senderId === vuex_user.Id && message.sendUserType === 2
"
:id="'msg-' + message.id" :id="'msg-' + message.id"
> >
<view class="message-content"> <view class="message-content">
@ -137,7 +145,11 @@
<!-- 1 收到消息 --> <!-- 1 收到消息 -->
<view <view
class="message-left" class="message-left"
v-if="message.senderId !== vuex_user.Id" v-if="
message.senderId !== vuex_user.Id &&
message.sendUserType !== 2 &&
message.sendUserType !== 3
"
:id="'msg-' + message.id" :id="'msg-' + message.id"
> >
<image <image
@ -309,7 +321,6 @@ export default {
this.$u.api this.$u.api
.SendMessage_PrivateApi(message) .SendMessage_PrivateApi(message)
.then((res) => { .then((res) => {
console.log(res, "发送消息成功");
if (res.succeed) { if (res.succeed) {
// //
const msgUserData = { const msgUserData = {
@ -331,6 +342,14 @@ export default {
// this.$nextTick(() => { // this.$nextTick(() => {
// this.scrollToBottom(); // this.scrollToBottom();
// }); // });
} else {
//
this.messageValue = "";
//
uni.showToast({
title: res.error || "发送失败",
icon: "none",
});
} }
}) })
.catch((error) => { .catch((error) => {
@ -568,6 +587,12 @@ export default {
color: #999999; color: #999999;
padding: 20rpx; padding: 20rpx;
} }
.message-tip {
text-align: center;
font-size: 24rpx;
color: #999999;
padding-bottom: 40rpx;
}
.message-left, .message-left,
.message-right { .message-right {

View File

@ -160,6 +160,7 @@
</view> </view>
<!-- 提示 --> <!-- 提示 -->
<!-- message.sendUserType 0 AI 1 学生 2 教师 3 提示目前只有2和3有用 -->
<view class="message-tip" v-if="message.sendUserType === 3"> <view class="message-tip" v-if="message.sendUserType === 3">
{{ message.message }} {{ message.message }}
</view> </view>
@ -229,10 +230,13 @@
<!-- 用户消息 --> <!-- 用户消息 -->
<!-- 0 用户消息 --> <!-- 0 用户消息 -->
<!-- 排除sendUserType 2 教师 3 提示 -->
<view <view
class="message-right" class="message-right"
v-else-if=" v-else-if="
message.interactMode === 0 && message.sendUserType !== 3 message.interactMode === 0 &&
message.sendUserType !== 3 &&
message.sendUserType !== 2
" "
:id="'msg-' + message.id" :id="'msg-' + message.id"
> >
@ -241,7 +245,7 @@
</view> </view>
<image <image
class="user-avatar" class="user-avatar"
:src="headSculptureUrl" :src="$getHeadImgUrl(vuex_user.HeadSculptureUrl)"
mode="scaleToFill" mode="scaleToFill"
/> />
</view> </view>
@ -361,16 +365,17 @@
</view> </view>
<!-- 转人工消息 --> <!-- 转人工消息 -->
<!-- 8 人工回复 --> <!-- 8 人工回复 message.interactMode === 8 -->
<!-- 改成 message.sendUserType === 2 -->
<view <view
class="message-left" class="message-left"
v-else-if="message.interactMode === 8" v-else-if="message.sendUserType === 2"
:id="'msg-' + message.id" :id="'msg-' + message.id"
> >
<view class="message-content-container-Teacher"> <view class="message-content-container-Teacher">
<image <image
class="ai-avatar" class="ai-avatar"
:src="receiverHeadSculptureUrl" :src="getReceiverHeadSculptureUrl(message)"
mode="scaleToFill" mode="scaleToFill"
/> />
<view <view
@ -635,12 +640,6 @@ export default {
}, },
computed: { computed: {
headSculptureUrl() {
return this.$getHeadImgUrl(this.vuex_user.HeadSculptureUrl);
},
receiverHeadSculptureUrl() {
return this.$getHeadImgUrl(this.vuex_msgUser.headSculptureUrl);
},
aiMessageGroups() { aiMessageGroups() {
return Array.isArray(this.vuex_aiMessageGroups) return Array.isArray(this.vuex_aiMessageGroups)
? this.vuex_aiMessageGroups ? this.vuex_aiMessageGroups
@ -663,11 +662,11 @@ export default {
}); });
}, },
isLiveAgentChat() { isLiveAgentChat() {
if (!this.vuex_isTransferChat) return false; return !!(
const current = this.currentDMid || ""; this.vuex_isTransferChat &&
const active = this.vuex_msgUser?.dialogueManagementId &&
this.vuex_msgUser && this.vuex_msgUser.dialogueManagementId; this.vuex_msgUser?.receiverId
return !!(current && active && String(active) === String(current)); );
}, },
}, },
@ -706,6 +705,11 @@ export default {
}, },
methods: { methods: {
//
getReceiverHeadSculptureUrl(message) {
return this.$getHeadImgUrl(message.headSculptureUrl);
},
async handleLeftClick() { async handleLeftClick() {
await this.getChatHistoryList(); await this.getChatHistoryList();
await this.GetDialogueList_User(); await this.GetDialogueList_User();

View File

@ -223,6 +223,7 @@ const store = new Vuex.Store({
isRead: true, isRead: true,
interactMode: isSelf ? 0 : 8, interactMode: isSelf ? 0 : 8,
messageType: msg.messageType || msg.MessageType || 0, messageType: msg.messageType || msg.MessageType || 0,
sendUserType: msg.sendUserType,
timeLabel: 0, timeLabel: 0,
displayTime: "", displayTime: "",
}); });