From c755ff3eb0fa09a026af61f18d13757ed1874105 Mon Sep 17 00:00:00 2001 From: ch Date: Mon, 13 Jun 2022 19:50:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=BD=AC=E7=A7=BB=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E4=B8=8D=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/chat/chat.js | 18 ++++++++++-------- src/utils/im.js | 2 +- src/utils/msb-im.js | 14 ++++++++------ src/views/chat/index.vue | 21 +++++++++++++-------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/store/modules/chat/chat.js b/src/store/modules/chat/chat.js index 1585d5a..c32a560 100644 --- a/src/store/modules/chat/chat.js +++ b/src/store/modules/chat/chat.js @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2022-06-07 15:41:05 * @LastEditors: ch - * @LastEditTime: 2022-06-13 16:30:57 + * @LastEditTime: 2022-06-13 17:16:27 * @Description: file content */ import * as api from '@/api/chat'; @@ -65,7 +65,7 @@ const getters = { payload = '[解析异常]'; } } else if (type === 7) { - payload = '[撤回消息]'; + payload = payload.text; } else { payload = '[未知类型]'; } @@ -155,12 +155,14 @@ const actions = { * 提交转移会话 */ submitTransferSession: ({}, data) => { - api.transferCustomerService({ - storeId: 1, - ...data, - }).then((res) => { - console.log(res, 'resresres'); - }); + return api + .transferCustomerService({ + storeId: 1, + ...data, + }) + .then((res) => { + console.log(res, 'resresres'); + }); }, }; export default { diff --git a/src/utils/im.js b/src/utils/im.js index 4017e7e..d369ebf 100644 --- a/src/utils/im.js +++ b/src/utils/im.js @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2022-06-07 15:52:37 * @LastEditors: ch - * @LastEditTime: 2022-06-13 16:18:45 + * @LastEditTime: 2022-06-13 17:32:19 * @Description: file content */ import * as api from '@/api/chat'; diff --git a/src/utils/msb-im.js b/src/utils/msb-im.js index b94d6bb..ab6b843 100644 --- a/src/utils/msb-im.js +++ b/src/utils/msb-im.js @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2022-05-18 14:54:47 * @LastEditors: ch - * @LastEditTime: 2022-06-13 15:16:50 + * @LastEditTime: 2022-06-13 18:54:30 * @Description: file content */ import '@/utils/poto-req'; @@ -193,9 +193,9 @@ class MsbIm { newData = [ ...historyData, { - fromAvatar: ctx.fromAvatar, + fromAvatar: ctx.session.fromAvatar, fromId: ctx.fromId, - fromNickname: ctx.fromNickname, + fromNickname: ctx.session.fromNickname, id: ctx.sessionId, lastMessage: ctx, messageList: [ctx], @@ -270,6 +270,7 @@ class MsbIm { return Promise.reject(error); } const { content } = result; + let newData = []; content.sessionVOS.forEach((item) => { if (item.lastMessage) { @@ -280,13 +281,14 @@ class MsbIm { if (hisIndex >= 0) { historyData[hisIndex].lastMessage = item.lastMessage; historyData[hisIndex].unreadCount++; - this.setSessionData(historyData); + newData.push(historyData); } else { item.messageList = []; - const newData = [...historyData, item]; - this.setSessionData(newData); + newData = [...newData, item]; } }); + + this.setSessionData(newData); return Promise.resolve(result); } /** diff --git a/src/views/chat/index.vue b/src/views/chat/index.vue index 5cc2f24..cc3d89b 100644 --- a/src/views/chat/index.vue +++ b/src/views/chat/index.vue @@ -49,7 +49,7 @@ -
+
@@ -178,7 +178,7 @@ message: '', }); const sessionList = computed(() => store.state.chat.sessionData); - const currentSession = computed(() => sessionList.value.find((item) => item.id === currentSessionId.value)); + const currentSession = computed(() => sessionList.value.find((item) => item.id === currentSessionId.value) || {}); const handleChangeSession = (id) => { currentSessionId.value = id; // 设置实例对象当前会话ID @@ -209,7 +209,7 @@ : 0; nextTick(() => { // if (!old?.length || value.indexOf(old[0]) === 0) { - refsMessageList.value.setScrollTop(refsMessageList.value.resize$.scrollHeight); + refsMessageList.value && refsMessageList.value.setScrollTop(refsMessageList.value.resize$.scrollHeight); // } else { // refsMessageList.value.setScrollTop(refsMessageList.value.resize$.scrollHeight - offset); // } @@ -293,11 +293,16 @@ confirmButtonText: '确定', }); if (res.action === 'confirm') { - store.dispatch('chat/submitTransferSession', { - toWaiterId: row.waiterId, - sessionId: unref(currentSessionId), - reason: res.value, - }); + store + .dispatch('chat/submitTransferSession', { + toWaiterId: row.waiterId, + sessionId: unref(currentSessionId), + reason: res.value, + }) + .then((res) => { + Im.setCurSessionId(null); + Im.getSessionList(); + }); transferVisible.value = false; } } catch (e) {