初始提交
This commit is contained in:
24
pages/index/mixin.js
Normal file
24
pages/index/mixin.js
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user