Fix:4895 【商城小程序】用户看完新消息后,首页红点数字提示未消除
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user