From 04dcbdf33162a48ff5060e1dafcd3093472508cc Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Tue, 25 Mar 2025 10:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=9C=AA=E8=AF=BB=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=95=B0=E9=87=8F=E5=9C=BA=E6=99=AF=E8=A1=A5=E5=85=A8?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/dialog/index.vue | 1 + src/pages/index/components/chatItem.vue | 20 ++++++++++---------- src/pages/index/index.vue | 20 ++++++++++---------- src/store/modules/dialogue.js | 5 +++++ 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/pages/dialog/index.vue b/src/pages/dialog/index.vue index 0d60671..8a01036 100644 --- a/src/pages/dialog/index.vue +++ b/src/pages/dialog/index.vue @@ -603,6 +603,7 @@ uniOnUnload(() => { index_name: talkParams.index_name, unread_num: 0, }) + dialogueStore.clearUnreadNum() }) }) const handleEmojiPanel = () => { diff --git a/src/pages/index/components/chatItem.vue b/src/pages/index/components/chatItem.vue index 7e194cf..61a0200 100644 --- a/src/pages/index/components/chatItem.vue +++ b/src/pages/index/components/chatItem.vue @@ -135,16 +135,16 @@ const cellClick = () => { // 清空消息未读数 if (props.data.unread_num > 0) { - //不在此处维护未读消息数量 - // ServeClearTalkUnreadNum({ - // talk_type: props.data.talk_type, - // receiver_id: props.data.receiver_id, - // },dialogueParams.unReadNum).then(() => { - // talkStore.updateItem({ - // index_name: props.data.index_name, - // unread_num: 0, - // }) - // }) + ServeClearTalkUnreadNum({ + talk_type: props.data.talk_type, + receiver_id: props.data.receiver_id, + },dialogueParams.unReadNum).then(() => { + talkStore.updateItem({ + index_name: props.data.index_name, + unread_num: 0, + }) + dialogueStore.clearUnreadNum() + }) } uni.navigateTo({ url: `/pages/dialog/index?sessionId=${props.data.id}`, diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 8422900..5e2859a 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -244,16 +244,16 @@ onLoad((options) => { setTimeout(() => { dialogueStore.setDialogue(openSession) if (openSession.unread_num > 0) { - //不在此处维护未读消息数量 - // ServeClearTalkUnreadNum({ - // talk_type: openSession.talk_type, - // receiver_id: openSession.receiver_id, - // },dialogueParams.unReadNum).then(() => { - // talkStore.updateItem({ - // index_name: openSession.index_name, - // unread_num: 0, - // }) - // }) + ServeClearTalkUnreadNum({ + talk_type: openSession.talk_type, + receiver_id: openSession.receiver_id, + },dialogueParams.unReadNum).then(() => { + talkStore.updateItem({ + index_name: openSession.index_name, + unread_num: 0, + }) + dialogueStore.clearUnreadNum() + }) } uni.navigateTo({ url: `/pages/dialog/index?sessionId=${openSession.id}`, diff --git a/src/store/modules/dialogue.js b/src/store/modules/dialogue.js index 1f568e8..07f64ad 100644 --- a/src/store/modules/dialogue.js +++ b/src/store/modules/dialogue.js @@ -93,6 +93,11 @@ export const useDialogueStore = defineStore('dialogue', { this.online = status }, + // 更新未读消息数量-清空未读 + clearUnreadNum() { + this.unreadNum = 0 + }, + // 更新对话信息 setDialogue(data = {}) { this.online = data.is_online == 1