Merge remote-tracking branch 'origin/dev-wdb'
This commit is contained in:
commit
39847cbad4
2
App.vue
2
App.vue
@ -40,7 +40,7 @@ export default {
|
|||||||
if (success) {
|
if (success) {
|
||||||
console.log("IM 初始化成功");
|
console.log("IM 初始化成功");
|
||||||
// IM 初始化成功后,设置全局未读消息监听
|
// IM 初始化成功后,设置全局未读消息监听
|
||||||
globalUnreadListenerManager.setup();
|
// globalUnreadListenerManager.setup();
|
||||||
} else {
|
} else {
|
||||||
console.warn("IM 初始化失败");
|
console.warn("IM 初始化失败");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,31 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="article-detail-page">
|
<full-page mainClass="bg-white">
|
||||||
<view v-if="loading" class="loading-container">
|
<view class="article-detail-page">
|
||||||
<uni-icons type="spinner-cycle" size="40" color="#999" />
|
<view v-if="loading" class="loading-container">
|
||||||
<text class="loading-text">加载中...</text>
|
<uni-icons type="spinner-cycle" size="40" color="#999" />
|
||||||
</view>
|
<text class="loading-text">加载中...</text>
|
||||||
|
|
||||||
<view v-else-if="error" class="error-container">
|
|
||||||
<text class="error-text">{{ error }}</text>
|
|
||||||
<button class="retry-btn" @click="loadArticle">重试</button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<scroll-view v-else scroll-y class="article-content">
|
|
||||||
<view class="article-header">
|
|
||||||
<text class="article-title">{{ articleData.title }}</text>
|
|
||||||
<text class="article-date">{{ articleData.date }}</text>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="article-body">
|
|
||||||
<view class="rich-text-wrapper">
|
<view v-else-if="error" class="error-container">
|
||||||
<rich-text :nodes="articleData.content"></rich-text>
|
<text class="error-text">{{ error }}</text>
|
||||||
|
<button class="retry-btn" @click="loadArticle">重试</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<scroll-view v-else scroll-y class="article-content">
|
||||||
|
<view class="article-header">
|
||||||
|
<text class="article-title">{{ articleData.title }}</text>
|
||||||
|
<text class="article-date">{{ articleData.date }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<view class="article-body">
|
||||||
</scroll-view>
|
<view class="rich-text-wrapper">
|
||||||
</view>
|
<rich-text :nodes="articleData.content"></rich-text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</full-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import FullPage from "@/components/full-page.vue";
|
||||||
import api from "@/utils/api.js";
|
import api from "@/utils/api.js";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@ -40,7 +43,7 @@ const articleData = ref({
|
|||||||
});
|
});
|
||||||
|
|
||||||
let articleId = "";
|
let articleId = "";
|
||||||
const corpId = ref('')
|
const corpId = ref("");
|
||||||
|
|
||||||
const markArticleRead = async () => {
|
const markArticleRead = async () => {
|
||||||
const unionid = account.value?.unionid;
|
const unionid = account.value?.unionid;
|
||||||
@ -91,7 +94,10 @@ const loadArticle = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
error.value = "";
|
error.value = "";
|
||||||
try {
|
try {
|
||||||
const res = await api("getArticle", { id: articleId, corpId: corpId.value });
|
const res = await api("getArticle", {
|
||||||
|
id: articleId,
|
||||||
|
corpId: corpId.value,
|
||||||
|
});
|
||||||
|
|
||||||
if (res.success && res.data) {
|
if (res.success && res.data) {
|
||||||
// 格式化日期
|
// 格式化日期
|
||||||
|
|||||||
@ -407,7 +407,7 @@ $primary-color: #0877F1;
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 12rpx 20rpx;
|
padding: 12rpx 20rpx;
|
||||||
padding-bottom: env(safe-area-inset-bottom);
|
padding-bottom: 40rpx;
|
||||||
gap: 12rpx;
|
gap: 12rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,7 +514,7 @@ $primary-color: #0877F1;
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-top: 1rpx solid #eee;
|
border-top: 1rpx solid #eee;
|
||||||
padding: 20rpx 0 20rpx 60rpx;
|
padding: 20rpx 0 20rpx 60rpx;
|
||||||
padding-bottom: env(safe-area-inset-bottom);
|
padding-bottom: 40rpx;
|
||||||
gap: 40rpx 50rpx;
|
gap: 40rpx 50rpx;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
@ -544,7 +544,7 @@ $primary-color: #0877F1;
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
border-top: 1rpx solid #e0e0e0;
|
border-top: 1rpx solid #e0e0e0;
|
||||||
padding: 16rpx;
|
padding: 16rpx;
|
||||||
margin-bottom: env(safe-area-inset-bottom);
|
margin-bottom: 40rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@ -689,7 +689,7 @@ $primary-color: #0877F1;
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: 80vh;
|
max-height: 80vh;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
|
padding-bottom: calc(20rpx + 40rpx);
|
||||||
position: relative;
|
position: relative;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -821,7 +821,7 @@ $primary-color: #0877F1;
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
width: auto;
|
width: auto;
|
||||||
padding: 32rpx 20rpx 48rpx 20rpx;
|
padding: 32rpx 20rpx 48rpx 20rpx;
|
||||||
padding-bottom: calc(48rpx + env(safe-area-inset-bottom));
|
padding-bottom: calc(48rpx + 40rpx);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@ -36,6 +36,8 @@ const handleApply = () => {
|
|||||||
padding: 20rpx 32rpx;
|
padding: 20rpx 32rpx;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
position:absolute;
|
||||||
|
bottom: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.apply-card {
|
.apply-card {
|
||||||
|
|||||||
@ -12,11 +12,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
const emit = defineEmits(["cancel"]);
|
||||||
const emit = defineEmits(['cancel']);
|
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
emit('cancel');
|
emit("cancel");
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -26,6 +25,8 @@ const handleCancel = () => {
|
|||||||
padding: 20rpx 32rpx;
|
padding: 20rpx 32rpx;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cancel-card {
|
.cancel-card {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ export default function useGroupChat(groupID) {
|
|||||||
const getUserAvatar = (userId) => {
|
const getUserAvatar = (userId) => {
|
||||||
const member = chatMember.value[userId]
|
const member = chatMember.value[userId]
|
||||||
if (!member) {
|
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.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() {
|
async function getGroupInfo(id) {
|
||||||
const gid = typeof groupID === 'string' ? groupID : groupID.value
|
const gid = id || groupID;
|
||||||
if (!gid) return
|
if (!gid) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -73,10 +73,8 @@ export default function useGroupChat(groupID) {
|
|||||||
status: groupResult.data.orderStatus || 'active',
|
status: groupResult.data.orderStatus || 'active',
|
||||||
teamId: groupResult.data.teamId
|
teamId: groupResult.data.teamId
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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列表
|
||||||
@ -112,13 +110,14 @@ export default function useGroupChat(groupID) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow(() => {
|
// onShow(() => {
|
||||||
getGroupInfo()
|
|
||||||
})
|
|
||||||
|
|
||||||
onUnload(() => {
|
// getGroupInfo()
|
||||||
// 清理资源
|
// })
|
||||||
})
|
|
||||||
|
// onUnload(() => {
|
||||||
|
// // 清理资源
|
||||||
|
// })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
groupInfo,
|
groupInfo,
|
||||||
|
|||||||
@ -444,7 +444,7 @@ function getBubbleClass(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 页面加载
|
// 页面加载
|
||||||
onLoad((options) => {
|
onLoad(async (options) => {
|
||||||
groupId.value = options.groupID || "";
|
groupId.value = options.groupID || "";
|
||||||
messageList.value = [];
|
messageList.value = [];
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
@ -456,7 +456,7 @@ onLoad((options) => {
|
|||||||
if (options.userID) {
|
if (options.userID) {
|
||||||
chatInfo.value.userID = options.userID;
|
chatInfo.value.userID = options.userID;
|
||||||
}
|
}
|
||||||
|
await getGroupInfo(groupId.value);
|
||||||
// 监听键盘高度变化
|
// 监听键盘高度变化
|
||||||
uni.onKeyboardHeightChange((res) => {
|
uni.onKeyboardHeightChange((res) => {
|
||||||
console.log("键盘高度变化:", res.height);
|
console.log("键盘高度变化:", res.height);
|
||||||
@ -473,6 +473,8 @@ onLoad((options) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 先获取群组信息和成员信息,确保 chatMember 已初始化
|
||||||
|
|
||||||
checkLoginAndInitTIM();
|
checkLoginAndInitTIM();
|
||||||
updateNavigationTitle();
|
updateNavigationTitle();
|
||||||
});
|
});
|
||||||
@ -563,7 +565,7 @@ const initTIMCallbacks = async () => {
|
|||||||
.then(async () => {
|
.then(async () => {
|
||||||
console.log("✓ 收到新消息后已标记为已读");
|
console.log("✓ 收到新消息后已标记为已读");
|
||||||
// 标记为已读后,立即刷新 tabBar 徽章
|
// 标记为已读后,立即刷新 tabBar 徽章
|
||||||
await globalUnreadListenerManager.refreshBadge();
|
// await globalUnreadListenerManager.refreshBadge();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("✗ 标记已读失败:", error);
|
console.error("✗ 标记已读失败:", error);
|
||||||
@ -717,7 +719,7 @@ const loadMessageList = async () => {
|
|||||||
.then(async () => {
|
.then(async () => {
|
||||||
console.log("✓ 会话已标记为已读:", chatInfo.value.conversationID);
|
console.log("✓ 会话已标记为已读:", chatInfo.value.conversationID);
|
||||||
// 标记为已读后,立即刷新 tabBar 徽章
|
// 标记为已读后,立即刷新 tabBar 徽章
|
||||||
await globalUnreadListenerManager.refreshBadge();
|
// await globalUnreadListenerManager.refreshBadge();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("✗ 标记会话已读失败:", error);
|
console.error("✗ 标记会话已读失败:", error);
|
||||||
@ -913,10 +915,10 @@ onHide(() => {
|
|||||||
timChatManager.currentConversationID = null;
|
timChatManager.currentConversationID = null;
|
||||||
console.log("✓ 页面隐藏,已清空当前会话ID");
|
console.log("✓ 页面隐藏,已清空当前会话ID");
|
||||||
|
|
||||||
// 页面隐藏时刷新 tabBar 徽章,确保显示正确的未读数
|
// // 页面隐藏时刷新 tabBar 徽章,确保显示正确的未读数
|
||||||
if (globalUnreadListenerManager.isInitialized) {
|
// if (globalUnreadListenerManager.isInitialized) {
|
||||||
globalUnreadListenerManager.refreshBadge();
|
// globalUnreadListenerManager.refreshBadge();
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
// 处理取消申请
|
// 处理取消申请
|
||||||
|
|||||||
@ -380,8 +380,8 @@ const setupConversationListener = () => {
|
|||||||
// 将回调添加到全局未读监听器的回调链中
|
// 将回调添加到全局未读监听器的回调链中
|
||||||
// 这样不会覆盖全局未读监听器,而是与之共存
|
// 这样不会覆盖全局未读监听器,而是与之共存
|
||||||
if (globalUnreadListenerManager.isInitialized) {
|
if (globalUnreadListenerManager.isInitialized) {
|
||||||
globalUnreadListenerManager.addCallback("onConversationListUpdated", handleConversationListUpdate);
|
// globalUnreadListenerManager.addCallback("onConversationListUpdated", handleConversationListUpdate);
|
||||||
globalUnreadListenerManager.addCallback("onMessageReceived", handleMessageReceived);
|
// globalUnreadListenerManager.addCallback("onMessageReceived", handleMessageReceived);
|
||||||
console.log("【消息列表页】已添加回调到全局监听器回调链");
|
console.log("【消息列表页】已添加回调到全局监听器回调链");
|
||||||
} else {
|
} else {
|
||||||
console.warn("【消息列表页】全局未读监听器未初始化,使用直接回调方式");
|
console.warn("【消息列表页】全局未读监听器未初始化,使用直接回调方式");
|
||||||
@ -454,7 +454,7 @@ const handleClickConversation = async (conversation) => {
|
|||||||
console.log("✓ 已标记会话为已读:", conversation.conversationID);
|
console.log("✓ 已标记会话为已读:", conversation.conversationID);
|
||||||
|
|
||||||
// 立即刷新 tabBar 徽章
|
// 立即刷新 tabBar 徽章
|
||||||
await globalUnreadListenerManager.refreshBadge();
|
// await globalUnreadListenerManager.refreshBadge();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("✗ 标记会话已读失败:", error);
|
console.error("✗ 标记会话已读失败:", error);
|
||||||
}
|
}
|
||||||
@ -514,9 +514,9 @@ const cleanMessageText = (text) => {
|
|||||||
// 页面显示
|
// 页面显示
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
// 页面显示时刷新 tabBar 徽章
|
// 页面显示时刷新 tabBar 徽章
|
||||||
if (globalUnreadListenerManager.isInitialized) {
|
// if (globalUnreadListenerManager.isInitialized) {
|
||||||
await globalUnreadListenerManager.refreshBadge();
|
// await globalUnreadListenerManager.refreshBadge();
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
// 页面隐藏
|
// 页面隐藏
|
||||||
@ -544,12 +544,12 @@ onUnmounted(() => {
|
|||||||
updateTimer = null;
|
updateTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从全局未读监听器的回调链中移除本页面的回调
|
// // 从全局未读监听器的回调链中移除本页面的回调
|
||||||
if (globalUnreadListenerManager.isInitialized) {
|
// if (globalUnreadListenerManager.isInitialized) {
|
||||||
globalUnreadListenerManager.removeCallback("onConversationListUpdated", handleConversationListUpdate);
|
// globalUnreadListenerManager.removeCallback("onConversationListUpdated", handleConversationListUpdate);
|
||||||
globalUnreadListenerManager.removeCallback("onMessageReceived", handleMessageReceived);
|
// globalUnreadListenerManager.removeCallback("onMessageReceived", handleMessageReceived);
|
||||||
console.log("【消息列表页】已从回调链移除回调");
|
// console.log("【消息列表页】已从回调链移除回调");
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -79,7 +79,7 @@ export default defineStore("accountStore", () => {
|
|||||||
console.log('IM 初始化成功');
|
console.log('IM 初始化成功');
|
||||||
|
|
||||||
// IM 初始化成功后,设置全局未读消息监听
|
// IM 初始化成功后,设置全局未读消息监听
|
||||||
globalUnreadListenerManager.setup();
|
// globalUnreadListenerManager.setup();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -99,7 +99,7 @@ export default defineStore("accountStore", () => {
|
|||||||
|
|
||||||
// 清除全局未读监听
|
// 清除全局未读监听
|
||||||
if (globalUnreadListenerManager.isInitialized) {
|
if (globalUnreadListenerManager.isInitialized) {
|
||||||
globalUnreadListenerManager.destroy();
|
// globalUnreadListenerManager.destroy();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('退出腾讯IM失败:', error);
|
console.error('退出腾讯IM失败:', error);
|
||||||
|
|||||||
@ -40,10 +40,10 @@ export default defineStore("teamStore", () => {
|
|||||||
|
|
||||||
// 获取团队成员头像和名称映射
|
// 获取团队成员头像和名称映射
|
||||||
async function getTeamMemberAvatarsAndName(teamId) {
|
async function getTeamMemberAvatarsAndName(teamId) {
|
||||||
if (!teamId || !account.value?.corpId) return {};
|
|
||||||
|
if (!teamId) return {};
|
||||||
const res = await api('getTeamMemberAvatarsAndName', {
|
const res = await api('getTeamMemberAvatarsAndName', {
|
||||||
teamId,
|
teamId
|
||||||
corpId: account.value.corpId
|
|
||||||
}, false);
|
}, false);
|
||||||
if (res && res.success && res.data) {
|
if (res && res.success && res.data) {
|
||||||
return res.data;
|
return res.data;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user