diff --git a/App.vue b/App.vue index b4a9dbf..e02d1be 100644 --- a/App.vue +++ b/App.vue @@ -40,7 +40,7 @@ export default { if (success) { console.log("IM 初始化成功"); // IM 初始化成功后,设置全局未读消息监听 - globalUnreadListenerManager.setup(); + // globalUnreadListenerManager.setup(); } else { console.warn("IM 初始化失败"); } diff --git a/pages/article/article-detail.vue b/pages/article/article-detail.vue index 5e1e900..4de34d3 100644 --- a/pages/article/article-detail.vue +++ b/pages/article/article-detail.vue @@ -1,31 +1,34 @@ @@ -26,6 +25,8 @@ const handleCancel = () => { padding: 20rpx 32rpx; background-color: #f5f5f5; box-sizing: border-box; + position: absolute; + bottom: 40rpx; } .cancel-card { diff --git a/pages/message/hooks/use-group-chat.js b/pages/message/hooks/use-group-chat.js index 310cafe..6e7014c 100644 --- a/pages/message/hooks/use-group-chat.js +++ b/pages/message/hooks/use-group-chat.js @@ -47,7 +47,7 @@ export default function useGroupChat(groupID) { const getUserAvatar = (userId) => { const member = chatMember.value[userId] if (!member) { - return userId === openid.value ? '/static/default-patient-avatar.png' : '/static/default-avatar.png' + return userId === openid.value ? '/static/default-patient-avatar.png' : '/static/default-avatar.svg' } // 如果有头像且不为空字符串,返回头像 @@ -55,11 +55,11 @@ export default function useGroupChat(groupID) { return member.avatar } - return member.isTeamMember ? '/static/default-avatar.png' : '/static/default-patient-avatar.png' + return member.isTeamMember ? '/static/default-avatar.svg' : '/static/default-patient-avatar.png' } // 获取群聊信息和成员头像 - async function getGroupInfo() { - const gid = typeof groupID === 'string' ? groupID : groupID.value + async function getGroupInfo(id) { + const gid = id || groupID; if (!gid) return try { @@ -73,10 +73,8 @@ export default function useGroupChat(groupID) { status: groupResult.data.orderStatus || 'active', teamId: groupResult.data.teamId } - // 2. 如果有teamId,获取团队成员头像和名称 if (groupResult.data.teamId) { - const memberMap = await teamStore.getTeamMemberAvatarsAndName(groupResult.data.teamId) // 3. 存储团队成员ID列表 @@ -112,13 +110,14 @@ export default function useGroupChat(groupID) { } } - onShow(() => { - getGroupInfo() - }) + // onShow(() => { - onUnload(() => { - // 清理资源 - }) + // getGroupInfo() + // }) + + // onUnload(() => { + // // 清理资源 + // }) return { groupInfo, diff --git a/pages/message/index.vue b/pages/message/index.vue index e97a2c1..3dd1fb0 100644 --- a/pages/message/index.vue +++ b/pages/message/index.vue @@ -444,7 +444,7 @@ function getBubbleClass(message) { } // 页面加载 -onLoad((options) => { +onLoad(async (options) => { groupId.value = options.groupID || ""; messageList.value = []; isLoading.value = false; @@ -456,7 +456,7 @@ onLoad((options) => { if (options.userID) { chatInfo.value.userID = options.userID; } - + await getGroupInfo(groupId.value); // 监听键盘高度变化 uni.onKeyboardHeightChange((res) => { console.log("键盘高度变化:", res.height); @@ -473,6 +473,8 @@ onLoad((options) => { } }); + // 先获取群组信息和成员信息,确保 chatMember 已初始化 + checkLoginAndInitTIM(); updateNavigationTitle(); }); @@ -563,7 +565,7 @@ const initTIMCallbacks = async () => { .then(async () => { console.log("✓ 收到新消息后已标记为已读"); // 标记为已读后,立即刷新 tabBar 徽章 - await globalUnreadListenerManager.refreshBadge(); + // await globalUnreadListenerManager.refreshBadge(); }) .catch((error) => { console.error("✗ 标记已读失败:", error); @@ -717,7 +719,7 @@ const loadMessageList = async () => { .then(async () => { console.log("✓ 会话已标记为已读:", chatInfo.value.conversationID); // 标记为已读后,立即刷新 tabBar 徽章 - await globalUnreadListenerManager.refreshBadge(); + // await globalUnreadListenerManager.refreshBadge(); }) .catch((error) => { console.error("✗ 标记会话已读失败:", error); @@ -913,10 +915,10 @@ onHide(() => { timChatManager.currentConversationID = null; console.log("✓ 页面隐藏,已清空当前会话ID"); - // 页面隐藏时刷新 tabBar 徽章,确保显示正确的未读数 - if (globalUnreadListenerManager.isInitialized) { - globalUnreadListenerManager.refreshBadge(); - } + // // 页面隐藏时刷新 tabBar 徽章,确保显示正确的未读数 + // if (globalUnreadListenerManager.isInitialized) { + // globalUnreadListenerManager.refreshBadge(); + // } }); // 处理取消申请 diff --git a/pages/message/message.vue b/pages/message/message.vue index 005fd2f..6c12c30 100644 --- a/pages/message/message.vue +++ b/pages/message/message.vue @@ -380,8 +380,8 @@ const setupConversationListener = () => { // 将回调添加到全局未读监听器的回调链中 // 这样不会覆盖全局未读监听器,而是与之共存 if (globalUnreadListenerManager.isInitialized) { - globalUnreadListenerManager.addCallback("onConversationListUpdated", handleConversationListUpdate); - globalUnreadListenerManager.addCallback("onMessageReceived", handleMessageReceived); + // globalUnreadListenerManager.addCallback("onConversationListUpdated", handleConversationListUpdate); + // globalUnreadListenerManager.addCallback("onMessageReceived", handleMessageReceived); console.log("【消息列表页】已添加回调到全局监听器回调链"); } else { console.warn("【消息列表页】全局未读监听器未初始化,使用直接回调方式"); @@ -454,7 +454,7 @@ const handleClickConversation = async (conversation) => { console.log("✓ 已标记会话为已读:", conversation.conversationID); // 立即刷新 tabBar 徽章 - await globalUnreadListenerManager.refreshBadge(); + // await globalUnreadListenerManager.refreshBadge(); } catch (error) { console.error("✗ 标记会话已读失败:", error); } @@ -514,9 +514,9 @@ const cleanMessageText = (text) => { // 页面显示 onShow(async () => { // 页面显示时刷新 tabBar 徽章 - if (globalUnreadListenerManager.isInitialized) { - await globalUnreadListenerManager.refreshBadge(); - } + // if (globalUnreadListenerManager.isInitialized) { + // await globalUnreadListenerManager.refreshBadge(); + // } }); // 页面隐藏 @@ -544,12 +544,12 @@ onUnmounted(() => { updateTimer = null; } - // 从全局未读监听器的回调链中移除本页面的回调 - if (globalUnreadListenerManager.isInitialized) { - globalUnreadListenerManager.removeCallback("onConversationListUpdated", handleConversationListUpdate); - globalUnreadListenerManager.removeCallback("onMessageReceived", handleMessageReceived); - console.log("【消息列表页】已从回调链移除回调"); - } + // // 从全局未读监听器的回调链中移除本页面的回调 + // if (globalUnreadListenerManager.isInitialized) { + // globalUnreadListenerManager.removeCallback("onConversationListUpdated", handleConversationListUpdate); + // globalUnreadListenerManager.removeCallback("onMessageReceived", handleMessageReceived); + // console.log("【消息列表页】已从回调链移除回调"); + // } }); diff --git a/store/account.js b/store/account.js index 0c62dd8..21ed7f8 100644 --- a/store/account.js +++ b/store/account.js @@ -79,7 +79,7 @@ export default defineStore("accountStore", () => { console.log('IM 初始化成功'); // IM 初始化成功后,设置全局未读消息监听 - globalUnreadListenerManager.setup(); + // globalUnreadListenerManager.setup(); return true; } catch (error) { @@ -99,7 +99,7 @@ export default defineStore("accountStore", () => { // 清除全局未读监听 if (globalUnreadListenerManager.isInitialized) { - globalUnreadListenerManager.destroy(); + // globalUnreadListenerManager.destroy(); } } catch (error) { console.error('退出腾讯IM失败:', error); diff --git a/store/team.js b/store/team.js index 0b1956e..63661ac 100644 --- a/store/team.js +++ b/store/team.js @@ -40,10 +40,10 @@ export default defineStore("teamStore", () => { // 获取团队成员头像和名称映射 async function getTeamMemberAvatarsAndName(teamId) { - if (!teamId || !account.value?.corpId) return {}; + + if (!teamId) return {}; const res = await api('getTeamMemberAvatarsAndName', { - teamId, - corpId: account.value.corpId + teamId }, false); if (res && res.success && res.data) { return res.data;