24 lines
423 B
JavaScript
24 lines
423 B
JavaScript
|
|
import {
|
||
|
|
useChatStore
|
||
|
|
} from '@/store/modules/chat'
|
||
|
|
export default {
|
||
|
|
onShow() {
|
||
|
|
this.setTabBarBadge()
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
setTabBarBadge() {
|
||
|
|
const chatStore = useChatStore()
|
||
|
|
const badgeNum = chatStore.getBadgeNum || 0
|
||
|
|
if (badgeNum) {
|
||
|
|
uni.setTabBarBadge({
|
||
|
|
index: 2,
|
||
|
|
text: badgeNum > 99 ? '99+' : badgeNum.toString()
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
uni.removeTabBarBadge({
|
||
|
|
index: 2
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|