Fix:4895 【商城小程序】用户看完新消息后,首页红点数字提示未消除

This commit is contained in:
linxi
2026-02-05 16:11:17 +08:00
parent 65ede45e47
commit 810ee7f5b8
6 changed files with 32 additions and 5 deletions
+21 -1
View File
@@ -124,6 +124,7 @@ export default {
this.fetchUnreadCount()
} else {
this.unreadCount = 0
uni.$emit('updateUnreadMessageCount', 0)
}
}
},
@@ -133,8 +134,23 @@ export default {
if (this.isLogin) {
this.fetchUnreadCount()
}
uni.$on('updateUnreadMessageCount', this.handleUpdateUnreadMessageCount)
},
beforeDestroy() {
uni.$off('updateUnreadMessageCount', this.handleUpdateUnreadMessageCount)
},
methods: {
handleUpdateUnreadMessageCount(count) {
if (!this.isLogin) {
this.unreadCount = 0
return
}
if (typeof count === 'number') {
this.unreadCount = count
} else {
this.fetchUnreadCount()
}
},
getElementData(el) {
const query = uni.createSelectorQuery().in(this)
query.select(el).boundingClientRect().exec((res)=> {
@@ -155,12 +171,16 @@ export default {
getUnreadMessageCount().then(res => {
const { success, data } = res
if (success) {
this.unreadCount = data || 0
const count = data || 0
this.unreadCount = count
uni.$emit('updateUnreadMessageCount', count)
} else {
this.unreadCount = 0
uni.$emit('updateUnreadMessageCount', 0)
}
}).catch(() => {
this.unreadCount = 0
uni.$emit('updateUnreadMessageCount', 0)
})
},
gotoPage(url, type = 1, index) {