新消息提醒机制,调整为uni.$emit全局事件,网络状态变化亦然

This commit is contained in:
2022-01-28 11:39:26 +08:00
parent f9e2819cc7
commit a97a5fd0ca
4 changed files with 32 additions and 48 deletions

View File

@@ -101,8 +101,19 @@
}
}
},
onLoad() {
if (this.isShown) {
uni.$on('onReceiveMessage', (msg) => {
console.log(msg);
this.getConversationList()
})
uni.$on('onConnectionStatusChange', (status) => {
this.connection = status
})
}
},
onShow() {
if (this.$store.state.token !== '') {
if (this.$store.state.token !== '') {
this.getConversationList()
}
this.isShown = true
@@ -125,16 +136,6 @@
}
}
},
watch: {
'$store.getters.newMessage': function(n, o) {
if (this.isShown) {
this.getConversationList()
}
},
'$store.getters.connection': function(n, o) {
this.connection = n
}
},
methods: {
hidePop() {
this.showPop = false