From 0bfdcdf6afabcc491934336d06901ef8ccaf4776 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 7 Feb 2022 17:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8=E5=88=B7?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/im/index.vue | 12 +++++++----- pages/im/private/chat.nvue | 3 --- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pages/im/index.vue b/pages/im/index.vue index 4682bb9..a25ab95 100644 --- a/pages/im/index.vue +++ b/pages/im/index.vue @@ -103,9 +103,6 @@ } }, onLoad() { - uni.$on('onReceiveMessage', (msg) => { - this.getConversationList() - }) uni.$on('onConnectionStatusChange', (status) => { this.connection = status }) @@ -113,10 +110,15 @@ onShow() { if (this.$store.state.token !== '') { this.getConversationList() - } + } + uni.$on('onReceiveMessage', (msg) => { + console.log('收到消息,刷新列表'); + this.getConversationList() + }) this.isShown = true }, - onHide() { + onHide() { + uni.$off('onReceiveMessage') this.isShown = false }, onNavigationBarButtonTap(e) { diff --git a/pages/im/private/chat.nvue b/pages/im/private/chat.nvue index 4d7e5f5..8808851 100644 --- a/pages/im/private/chat.nvue +++ b/pages/im/private/chat.nvue @@ -108,9 +108,6 @@ } }) }, - beforeDestroy() { - uni.$off('onReceiveMessage') - }, methods: { initMessageList() { this.getMessageList()