From a4473cf0e55537c11f3b5d7d5678407a0dc46ffa Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Fri, 5 Dec 2025 11:10:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pageChat/chat.vue | 15 +- pageChat/index.vue | 38 +++-- store/chat.js | 339 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 307 insertions(+), 85 deletions(-) diff --git a/pageChat/chat.vue b/pageChat/chat.vue index 586cd8b..b7971f7 100644 --- a/pageChat/chat.vue +++ b/pageChat/chat.vue @@ -174,7 +174,7 @@ import { onReady, onReachBottom, - onLoad, + onLoad,onShow, onPageScroll, } from "@dcloudio/uni-app"; import { @@ -243,7 +243,6 @@ chatStore.onReceiveMsg = (msg) => { scrollView.intoView = "msg-0"; }); }; -chatStore.connectSocket(); const msg = ref(""); const shopInfo = uni.getStorageSync("shopInfo"); @@ -477,6 +476,18 @@ onLoad((opt) => { // #endif }); +onMounted(() => { + chatStore.connectSocket(); + // 确保状态监听已初始化 + if (!chatStore._listenersInitialized) { + chatStore.initStateListeners(); + chatStore._listenersInitialized = true; + } +}); + +onShow(() => { +}); + function toMore() { go.to("PAGES_CHAT_GROUP_INFO", { group_id: groupInfo.value.id, diff --git a/pageChat/index.vue b/pageChat/index.vue index b0583b8..557c449 100644 --- a/pageChat/index.vue +++ b/pageChat/index.vue @@ -56,24 +56,36 @@