Merge remote-tracking branch 'origin/dev-wdb'
This commit is contained in:
commit
031cc0703c
@ -25,7 +25,6 @@ export default function useGroupAvatars() {
|
|||||||
console.warn(`群聊 ${groupID} 没有 teamId,无法获取头像`)
|
console.warn(`群聊 ${groupID} 没有 teamId,无法获取头像`)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取团队成员的头像和名称
|
// 获取团队成员的头像和名称
|
||||||
const memberMap = await teamStore.getTeamMemberAvatarsAndName(teamId)
|
const memberMap = await teamStore.getTeamMemberAvatarsAndName(teamId)
|
||||||
|
|
||||||
|
|||||||
@ -76,6 +76,7 @@ export default function useGroupChat(groupID) {
|
|||||||
|
|
||||||
// 2. 如果有teamId,获取团队成员头像和名称
|
// 2. 如果有teamId,获取团队成员头像和名称
|
||||||
if (groupResult.data.teamId) {
|
if (groupResult.data.teamId) {
|
||||||
|
|
||||||
const memberMap = await teamStore.getTeamMemberAvatarsAndName(groupResult.data.teamId)
|
const memberMap = await teamStore.getTeamMemberAvatarsAndName(groupResult.data.teamId)
|
||||||
|
|
||||||
// 3. 存储团队成员ID列表
|
// 3. 存储团队成员ID列表
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<template>
|
<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="chat-page" :style="{ paddingBottom: keyboardHeight + 'px' }">
|
||||||
<!-- 患者信息栏 -->
|
<!-- 患者信息栏 -->
|
||||||
<view class="patient-info-bar" v-if="patientInfo.name">
|
<view class="patient-info-bar" v-if="patientInfo.name">
|
||||||
@ -23,7 +25,9 @@
|
|||||||
<!-- 聊天消息区域 -->
|
<!-- 聊天消息区域 -->
|
||||||
<scroll-view
|
<scroll-view
|
||||||
class="chat-content"
|
class="chat-content"
|
||||||
:style="{ bottom: (keyboardHeight > 0 ? keyboardHeight + 60 : 60) + 'px' }"
|
:style="{
|
||||||
|
bottom: (keyboardHeight > 0 ? keyboardHeight + 60 : 60) + 'px',
|
||||||
|
}"
|
||||||
scroll-y="true"
|
scroll-y="true"
|
||||||
enhanced="true"
|
enhanced="true"
|
||||||
bounces="false"
|
bounces="false"
|
||||||
@ -263,6 +267,7 @@ const scrollIntoView = ref("");
|
|||||||
const isLoadingMore = ref(false);
|
const isLoadingMore = ref(false);
|
||||||
const isCompleted = ref(false);
|
const isCompleted = ref(false);
|
||||||
const lastFirstMessageId = ref("");
|
const lastFirstMessageId = ref("");
|
||||||
|
const isCallbacksInitialized = ref(false); // 标记回调是否已初始化
|
||||||
|
|
||||||
// 判断是否为系统消息
|
// 判断是否为系统消息
|
||||||
function isSystemMessage(message) {
|
function isSystemMessage(message) {
|
||||||
@ -294,10 +299,13 @@ function isSystemMessage(message) {
|
|||||||
// 获取群组订单状态
|
// 获取群组订单状态
|
||||||
const fetchGroupOrderStatus = async () => {
|
const fetchGroupOrderStatus = async () => {
|
||||||
try {
|
try {
|
||||||
const result = await api("getGroupListByGroupId", {
|
const result = await api(
|
||||||
groupId: groupId.value,
|
"getGroupListByGroupId",
|
||||||
});
|
{
|
||||||
|
groupId: groupId.value,
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
orderStatus.value = result.data.orderStatus || "";
|
orderStatus.value = result.data.orderStatus || "";
|
||||||
corpId.value = result.data.corpId || "";
|
corpId.value = result.data.corpId || "";
|
||||||
@ -454,7 +462,7 @@ onLoad((options) => {
|
|||||||
console.log("键盘高度变化:", res.height);
|
console.log("键盘高度变化:", res.height);
|
||||||
const oldHeight = keyboardHeight.value;
|
const oldHeight = keyboardHeight.value;
|
||||||
keyboardHeight.value = res.height;
|
keyboardHeight.value = res.height;
|
||||||
|
|
||||||
// 键盘弹出时(从0变为非0),自动滚动到底部
|
// 键盘弹出时(从0变为非0),自动滚动到底部
|
||||||
if (oldHeight === 0 && res.height > 0) {
|
if (oldHeight === 0 && res.height > 0) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@ -499,12 +507,14 @@ const checkLoginAndInitTIM = async () => {
|
|||||||
|
|
||||||
// 初始化IM回调函数
|
// 初始化IM回调函数
|
||||||
const initTIMCallbacks = async () => {
|
const initTIMCallbacks = async () => {
|
||||||
|
// 标记回调已初始化
|
||||||
|
isCallbacksInitialized.value = true;
|
||||||
|
|
||||||
timChatManager.setCallback("onSDKReady", () => {
|
timChatManager.setCallback("onSDKReady", () => {
|
||||||
if (messageList.value.length === 0 && !isLoading.value) {
|
if (messageList.value.length === 0 && !isLoading.value) {
|
||||||
loadMessageList();
|
loadMessageList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
timChatManager.setCallback("onSDKNotReady", () => {});
|
timChatManager.setCallback("onSDKNotReady", () => {});
|
||||||
|
|
||||||
timChatManager.setCallback("onMessageReceived", (message) => {
|
timChatManager.setCallback("onMessageReceived", (message) => {
|
||||||
@ -851,17 +861,49 @@ onShow(() => {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isIMInitialized.value) {
|
if (!isIMInitialized.value) {
|
||||||
checkLoginAndInitTIM();
|
checkLoginAndInitTIM();
|
||||||
} else if (timChatManager.tim && !timChatManager.isLoggedIn) {
|
} 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 (
|
} else if (
|
||||||
timChatManager.tim &&
|
timChatManager.tim &&
|
||||||
timChatManager.isLoggedIn &&
|
timChatManager.isLoggedIn &&
|
||||||
chatInfo.value.conversationID
|
chatInfo.value.conversationID
|
||||||
)
|
) {
|
||||||
|
// IM已登录,只需要重新设置会话ID,不重新注册回调(避免影响正在发送的消息)
|
||||||
|
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);
|
startIMMonitoring(30000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 页面隐藏
|
// 页面隐藏
|
||||||
@ -870,7 +912,7 @@ onHide(() => {
|
|||||||
// 清空当前会话ID,避免离开页面后收到的消息被错误标记为已读
|
// 清空当前会话ID,避免离开页面后收到的消息被错误标记为已读
|
||||||
timChatManager.currentConversationID = null;
|
timChatManager.currentConversationID = null;
|
||||||
console.log("✓ 页面隐藏,已清空当前会话ID");
|
console.log("✓ 页面隐藏,已清空当前会话ID");
|
||||||
|
|
||||||
// 页面隐藏时刷新 tabBar 徽章,确保显示正确的未读数
|
// 页面隐藏时刷新 tabBar 徽章,确保显示正确的未读数
|
||||||
if (globalUnreadListenerManager.isInitialized) {
|
if (globalUnreadListenerManager.isInitialized) {
|
||||||
globalUnreadListenerManager.refreshBadge();
|
globalUnreadListenerManager.refreshBadge();
|
||||||
@ -944,10 +986,13 @@ const handleApplyConsult = async () => {
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
// 获取当前群组信息,提取客户ID和corpId
|
// 获取当前群组信息,提取客户ID和corpId
|
||||||
const groupInfo = await api("getGroupListByGroupId", {
|
const groupInfo = await api(
|
||||||
groupId: groupId.value,
|
"getGroupListByGroupId",
|
||||||
});
|
{
|
||||||
|
groupId: groupId.value,
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
if (!groupInfo.success || !groupInfo.data) {
|
if (!groupInfo.success || !groupInfo.data) {
|
||||||
throw new Error("获取群组信息失败");
|
throw new Error("获取群组信息失败");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export default defineStore("teamStore", () => {
|
|||||||
return memberLeaderList.includes(userid);
|
return memberLeaderList.includes(userid);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
async function getTeam(teamId) {
|
async function getTeam(teamId) {
|
||||||
if (!teamId || !account.value?.corpId) return;
|
if (!teamId || !account.value?.corpId) return;
|
||||||
const res = await api('getTeamData', { teamId, corpId: account.value.corpId });
|
const res = await api('getTeamData', { teamId, corpId: account.value.corpId });
|
||||||
@ -28,7 +28,7 @@ export default defineStore("teamStore", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function getTeams() {
|
async function getTeams() {
|
||||||
const corpId = account.value?.corpId;
|
const corpId = account.value?.corpId;
|
||||||
@ -41,12 +41,12 @@ export default defineStore("teamStore", () => {
|
|||||||
// 获取团队成员头像和名称映射
|
// 获取团队成员头像和名称映射
|
||||||
async function getTeamMemberAvatarsAndName(teamId) {
|
async function getTeamMemberAvatarsAndName(teamId) {
|
||||||
if (!teamId || !account.value?.corpId) return {};
|
if (!teamId || !account.value?.corpId) return {};
|
||||||
const res = await api('getTeamMemberAvatarsAndName', {
|
const res = await api('getTeamMemberAvatarsAndName', {
|
||||||
teamId,
|
teamId,
|
||||||
corpId: account.value.corpId
|
corpId: account.value.corpId
|
||||||
});
|
}, false);
|
||||||
if (res && res.success && res.data) {
|
if (res && res.success && res.data) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user