no message

This commit is contained in:
wangdongbo 2026-02-11 17:46:30 +08:00
parent fcb1632244
commit 24d80e69f6
4 changed files with 69 additions and 24 deletions

View File

@ -25,7 +25,6 @@ export default function useGroupAvatars() {
console.warn(`群聊 ${groupID} 没有 teamId无法获取头像`)
return []
}
// 获取团队成员的头像和名称
const memberMap = await teamStore.getTeamMemberAvatarsAndName(teamId)

View File

@ -76,6 +76,7 @@ export default function useGroupChat(groupID) {
// 2. 如果有teamId获取团队成员头像和名称
if (groupResult.data.teamId) {
const memberMap = await teamStore.getTeamMemberAvatarsAndName(groupResult.data.teamId)
// 3. 存储团队成员ID列表

View File

@ -1,5 +1,7 @@
<template>
<page-meta :page-style="'overflow:' + (keyboardHeight > 0 ? 'hidden' : 'visible')"></page-meta>
<page-meta
:page-style="'overflow:' + (keyboardHeight > 0 ? 'hidden' : 'visible')"
></page-meta>
<view class="chat-page" :style="{ paddingBottom: keyboardHeight + 'px' }">
<!-- 患者信息栏 -->
<view class="patient-info-bar" v-if="patientInfo.name">
@ -23,7 +25,9 @@
<!-- 聊天消息区域 -->
<scroll-view
class="chat-content"
:style="{ bottom: (keyboardHeight > 0 ? keyboardHeight + 60 : 60) + 'px' }"
:style="{
bottom: (keyboardHeight > 0 ? keyboardHeight + 60 : 60) + 'px',
}"
scroll-y="true"
enhanced="true"
bounces="false"
@ -263,6 +267,7 @@ const scrollIntoView = ref("");
const isLoadingMore = ref(false);
const isCompleted = ref(false);
const lastFirstMessageId = ref("");
const isCallbacksInitialized = ref(false); //
//
function isSystemMessage(message) {
@ -294,10 +299,13 @@ function isSystemMessage(message) {
//
const fetchGroupOrderStatus = async () => {
try {
const result = await api("getGroupListByGroupId", {
const result = await api(
"getGroupListByGroupId",
{
groupId: groupId.value,
});
},
false
);
if (result.success && result.data) {
orderStatus.value = result.data.orderStatus || "";
corpId.value = result.data.corpId || "";
@ -499,12 +507,14 @@ const checkLoginAndInitTIM = async () => {
// IM
const initTIMCallbacks = async () => {
//
isCallbacksInitialized.value = true;
timChatManager.setCallback("onSDKReady", () => {
if (messageList.value.length === 0 && !isLoading.value) {
loadMessageList();
}
});
timChatManager.setCallback("onSDKNotReady", () => {});
timChatManager.setCallback("onMessageReceived", (message) => {
@ -851,17 +861,49 @@ onShow(() => {
});
return;
}
if (!isIMInitialized.value) {
checkLoginAndInitTIM();
} else if (timChatManager.tim && !timChatManager.isLoggedIn) {
timChatManager.ensureIMConnection();
// IM
timChatManager.ensureIMConnection().then(() => {
//
if (timChatManager.isLoggedIn && chatInfo.value.conversationID) {
console.log("✓ 重连成功,重新注册消息监听回调");
initTIMCallbacks();
timChatManager.setConversationID(chatInfo.value.conversationID);
}
});
} else if (
timChatManager.tim &&
timChatManager.isLoggedIn &&
chatInfo.value.conversationID
)
) {
// IMID
console.log("✓ 页面显示重新设置当前会话ID");
timChatManager.setConversationID(chatInfo.value.conversationID);
//
if (!isCallbacksInitialized.value) {
console.log("✓ 回调未初始化,进行初始化");
initTIMCallbacks();
}
//
if (timChatManager.tim && timChatManager.isLoggedIn) {
timChatManager.tim
.setMessageRead({
conversationID: chatInfo.value.conversationID,
})
.then(() => {
console.log("✓ 页面显示时已标记会话为已读");
})
.catch((error) => {
console.error("✗ 标记会话已读失败:", error);
});
}
startIMMonitoring(30000);
}
});
//
@ -944,10 +986,13 @@ const handleApplyConsult = async () => {
});
try {
// IDcorpId
const groupInfo = await api("getGroupListByGroupId", {
const groupInfo = await api(
"getGroupListByGroupId",
{
groupId: groupId.value,
});
},
false
);
if (!groupInfo.success || !groupInfo.data) {
throw new Error("获取群组信息失败");
}

View File

@ -44,7 +44,7 @@ export default defineStore("teamStore", () => {
const res = await api('getTeamMemberAvatarsAndName', {
teamId,
corpId: account.value.corpId
});
}, false);
if (res && res.success && res.data) {
return res.data;
}