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