Fix:4897 【商城小程序】用户收到客服消息,消息图标未显示红点提示

This commit is contained in:
linxi
2026-02-10 11:30:53 +08:00
parent 86fc52a62e
commit d6d8222831
3 changed files with 44 additions and 16 deletions
+1
View File
@@ -26,3 +26,4 @@ export function getMessageList(params) {
export function replyMessage(data) { export function replyMessage(data) {
return request.post("/user/reply/add", data, {login: true}) return request.post("/user/reply/add", data, {login: true})
} }
+19 -4
View File
@@ -54,7 +54,7 @@
<script> <script>
import store from '@/store' import store from '@/store'
import { getUnreadMessageCount } from '@/api/rooms' import { getUnreadMessageCount, getUnreadMessageCountForSeller } from '@/api/rooms'
export default { export default {
name: 'XddTabbar', name: 'XddTabbar',
props: { props: {
@@ -168,12 +168,21 @@ export default {
}) })
}, },
fetchUnreadCount() { fetchUnreadCount() {
uni.request({
url: this.$SERVICE_API_URL + '/unread-num',
method: 'POST',
data: {
uid: store.getters.userInfo.uid
},
success:(res)=>{
if(res.data.status_code === 200) {
const count = res.data.content || 0
getUnreadMessageCount().then(res => { getUnreadMessageCount().then(res => {
const { success, data } = res const { success, data } = res
if (success) { if (success) {
const count = data || 0 const _count = data || 0
this.unreadCount = count this.unreadCount = count + _count
uni.$emit('updateUnreadMessageCount', count) uni.$emit('updateUnreadMessageCount', this.unreadCount)
} else { } else {
this.unreadCount = 0 this.unreadCount = 0
uni.$emit('updateUnreadMessageCount', 0) uni.$emit('updateUnreadMessageCount', 0)
@@ -182,6 +191,12 @@ export default {
this.unreadCount = 0 this.unreadCount = 0
uni.$emit('updateUnreadMessageCount', 0) uni.$emit('updateUnreadMessageCount', 0)
}) })
} else {
this.unreadCount = 0
}
},
})
}, },
gotoPage(url, type = 1, index) { gotoPage(url, type = 1, index) {
if (this.currIndex === index) return if (this.currIndex === index) return
+12
View File
@@ -123,7 +123,19 @@ export default {
getUnreadMessageCount().then(res => { getUnreadMessageCount().then(res => {
const count = res.data || 0 const count = res.data || 0
this.unreadNum = count this.unreadNum = count
uni.request({
url: this.$SERVICE_API_URL + '/customer-chat-list',
method: 'POST',
data: {uid: this.uid},
success: res => {
if (res.data.status_code === 200) {
const _count = res.data.content + count
uni.$emit('updateUnreadMessageCount', _count)
} else {
uni.$emit('updateUnreadMessageCount', count) uni.$emit('updateUnreadMessageCount', count)
}
}
})
}) })
}, },
goRoom(item) { goRoom(item) {