Compare commits
No commits in common. "24f201729b8a988ebeecb17d8e8aa51dd4aed222" and "9a251ddcb0d937b0104cf1de656169fcd1e5d382" have entirely different histories.
24f201729b
...
9a251ddcb0
@ -1,34 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="message-page">
|
<view class="message-page">
|
||||||
<!-- 头部组件 -->
|
<!-- 头部组件 -->
|
||||||
<message-header
|
<message-header v-model:activeTab="activeTab" @team-change="handleTeamChange" @add-patient="handleAddPatient" />
|
||||||
v-model:activeTab="activeTab"
|
|
||||||
@team-change="handleTeamChange"
|
|
||||||
@add-patient="handleAddPatient"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 消息列表 -->
|
<!-- 消息列表 -->
|
||||||
<scroll-view
|
<scroll-view class="message-list" scroll-y="true" refresher-enabled :refresher-triggered="refreshing"
|
||||||
class="message-list"
|
@refresherrefresh="handleRefresh" @scrolltolower="handleLoadMore">
|
||||||
scroll-y="true"
|
|
||||||
refresher-enabled
|
|
||||||
:refresher-triggered="refreshing"
|
|
||||||
@refresherrefresh="handleRefresh"
|
|
||||||
@scrolltolower="handleLoadMore"
|
|
||||||
>
|
|
||||||
<!-- 消息列表项 -->
|
<!-- 消息列表项 -->
|
||||||
<view
|
<view v-for="conversation in filteredConversationList"
|
||||||
v-for="conversation in filteredConversationList"
|
:key="conversation.groupID || conversation.conversationID" class="message-item"
|
||||||
:key="conversation.groupID || conversation.conversationID"
|
@click="handleClickConversation(conversation)">
|
||||||
class="message-item"
|
|
||||||
@click="handleClickConversation(conversation)"
|
|
||||||
>
|
|
||||||
<view class="avatar-container">
|
<view class="avatar-container">
|
||||||
<image
|
<image class="avatar" :src="conversation.avatar || '/static/default-avatar.png'"
|
||||||
class="avatar"
|
mode="aspectFill" />
|
||||||
:src="conversation.avatar || '/static/default-avatar.png'"
|
|
||||||
mode="aspectFill"
|
|
||||||
/>
|
|
||||||
<view v-if="conversation.unreadCount > 0" class="unread-badge">
|
<view v-if="conversation.unreadCount > 0" class="unread-badge">
|
||||||
<text class="unread-text">{{
|
<text class="unread-text">{{
|
||||||
conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
|
conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
|
||||||
@ -40,10 +24,7 @@
|
|||||||
<view class="header">
|
<view class="header">
|
||||||
<view class="name-info">
|
<view class="name-info">
|
||||||
<text class="name">{{ formatPatientName(conversation) }}</text>
|
<text class="name">{{ formatPatientName(conversation) }}</text>
|
||||||
<text
|
<text v-if="conversation.patientSex || conversation.patientAge" class="patient-info">
|
||||||
v-if="conversation.patientSex || conversation.patientAge"
|
|
||||||
class="patient-info"
|
|
||||||
>
|
|
||||||
{{ formatPatientInfo(conversation) }}
|
{{ formatPatientInfo(conversation) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
@ -60,10 +41,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 空状态 -->
|
<!-- 空状态 -->
|
||||||
<view
|
<view v-if="!loading && filteredConversationList.length === 0" class="empty-container">
|
||||||
v-if="filteredConversationList.length === 0"
|
|
||||||
class="empty-container"
|
|
||||||
>
|
|
||||||
<image class="empty-image" src="/static/empty.svg" mode="aspectFit" />
|
<image class="empty-image" src="/static/empty.svg" mode="aspectFit" />
|
||||||
<text class="empty-text">{{
|
<text class="empty-text">{{
|
||||||
activeTab === "processing" ? "暂无处理中的会话" : "暂无已结束的会话"
|
activeTab === "processing" ? "暂无处理中的会话" : "暂无已结束的会话"
|
||||||
@ -71,10 +49,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 加载更多 -->
|
<!-- 加载更多 -->
|
||||||
<view
|
<view v-if="hasMore && filteredConversationList.length > 0" class="load-more">
|
||||||
v-if="hasMore && filteredConversationList.length > 0"
|
|
||||||
class="load-more"
|
|
||||||
>
|
|
||||||
<text class="load-more-text">{{
|
<text class="load-more-text">{{
|
||||||
loadingMore ? "加载中..." : "上拉加载更多"
|
loadingMore ? "加载中..." : "上拉加载更多"
|
||||||
}}</text>
|
}}</text>
|
||||||
@ -84,40 +59,63 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from "vue";
|
import {
|
||||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
ref,
|
||||||
import { storeToRefs } from "pinia";
|
computed
|
||||||
import useAccountStore from "@/store/account.js";
|
} from "vue";
|
||||||
import useTeamStore from "@/store/team.js";
|
import {
|
||||||
import useInfoCheck from "@/hooks/useInfoCheck.js";
|
onLoad,
|
||||||
import { globalTimChatManager } from "@/utils/tim-chat.js";
|
onShow,
|
||||||
import { mergeConversationWithGroupDetails } from "@/utils/conversation-merger.js";
|
onHide
|
||||||
import MessageHeader from "./components/message-header.vue";
|
} from "@dcloudio/uni-app";
|
||||||
|
import {
|
||||||
|
storeToRefs
|
||||||
|
} from "pinia";
|
||||||
|
import useAccountStore from "@/store/account.js";
|
||||||
|
import useTeamStore from "@/store/team.js";
|
||||||
|
import useInfoCheck from "@/hooks/useInfoCheck.js";
|
||||||
|
import {
|
||||||
|
globalTimChatManager
|
||||||
|
} from "@/utils/tim-chat.js";
|
||||||
|
import {
|
||||||
|
mergeConversationWithGroupDetails
|
||||||
|
} from "@/utils/conversation-merger.js";
|
||||||
|
import MessageHeader from "./components/message-header.vue";
|
||||||
|
|
||||||
// 获取登录状态
|
// 获取登录状态
|
||||||
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
|
const {
|
||||||
const { initIMAfterLogin } = useAccountStore();
|
account,
|
||||||
|
openid,
|
||||||
|
isIMInitialized
|
||||||
|
} = storeToRefs(useAccountStore());
|
||||||
|
const {
|
||||||
|
initIMAfterLogin
|
||||||
|
} = useAccountStore();
|
||||||
|
|
||||||
// 获取团队信息
|
// 获取团队信息
|
||||||
const teamStore = useTeamStore();
|
const teamStore = useTeamStore();
|
||||||
const { getTeams } = teamStore;
|
const {
|
||||||
|
getTeams
|
||||||
|
} = teamStore;
|
||||||
|
|
||||||
// 信息完善检查
|
// 信息完善检查
|
||||||
const { withInfo } = useInfoCheck();
|
const {
|
||||||
|
withInfo
|
||||||
|
} = useInfoCheck();
|
||||||
|
|
||||||
// 团队相关状态
|
// 团队相关状态
|
||||||
const currentTeamId = ref(""); // 空字符串表示"全部会话消息"
|
const currentTeamId = ref(""); // 空字符串表示"全部会话消息"
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
const conversationList = ref([]);
|
const conversationList = ref([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const loadingMore = ref(false);
|
const loadingMore = ref(false);
|
||||||
const hasMore = ref(false);
|
const hasMore = ref(false);
|
||||||
const refreshing = ref(false);
|
const refreshing = ref(false);
|
||||||
const activeTab = ref("processing");
|
const activeTab = ref("processing");
|
||||||
|
|
||||||
// 根据 orderStatus 过滤会话列表
|
// 根据 orderStatus 过滤会话列表
|
||||||
const filteredConversationList = computed(() => {
|
const filteredConversationList = computed(() => {
|
||||||
let filtered = [];
|
let filtered = [];
|
||||||
|
|
||||||
if (activeTab.value === "processing") {
|
if (activeTab.value === "processing") {
|
||||||
@ -141,36 +139,37 @@ const filteredConversationList = computed(() => {
|
|||||||
filtered = filtered.filter((conv) => conv.teamId === currentTeamId.value);
|
filtered = filtered.filter((conv) => conv.teamId === currentTeamId.value);
|
||||||
}
|
}
|
||||||
return filtered;
|
return filtered;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 处理团队切换
|
// 处理团队切换
|
||||||
const handleTeamChange = (teamId) => {
|
const handleTeamChange = (teamId) => {
|
||||||
currentTeamId.value = teamId;
|
currentTeamId.value = teamId;
|
||||||
console.log("切换到团队ID:", teamId);
|
console.log("切换到团队ID:", teamId);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 邀请患者 - 使用 withInfo 包装,确保信息完善后才能使用
|
// 邀请患者 - 使用 withInfo 包装,确保信息完善后才能使用
|
||||||
const handleAddPatient = withInfo(() => {
|
const handleAddPatient = withInfo(() => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/work/team/invite/invite-patient",
|
url: "/pages/work/team/invite/invite-patient",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 初始化IM
|
// 初始化IM
|
||||||
const initIM = async () => {
|
const initIM = async () => {
|
||||||
if (!isIMInitialized.value) {
|
if (!isIMInitialized.value) {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "连接中...",
|
title: "连接中...",
|
||||||
});
|
});
|
||||||
const success = await initIMAfterLogin();
|
const success = await initIMAfterLogin();
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
// if (!success) {
|
|
||||||
// uni.showToast({
|
if (!success) {
|
||||||
// title: "IM连接失败,请重试",
|
uni.showToast({
|
||||||
// icon: "none",
|
title: "IM连接失败,请重试",
|
||||||
// });
|
icon: "none",
|
||||||
// return false;
|
});
|
||||||
// }
|
return false;
|
||||||
|
}
|
||||||
} else if (globalTimChatManager && !globalTimChatManager.isLoggedIn) {
|
} else if (globalTimChatManager && !globalTimChatManager.isLoggedIn) {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "重连中...",
|
title: "重连中...",
|
||||||
@ -183,17 +182,16 @@ const initIM = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载会话列表
|
// 加载会话列表
|
||||||
const loadConversationList = async () => {
|
const loadConversationList = async () => {
|
||||||
if (loading.value) return;
|
if (loading.value) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
console.log("开始加载群聊列表");
|
console.log("开始加载群聊列表");
|
||||||
if (!globalTimChatManager || !globalTimChatManager.getGroupList) {
|
if (!globalTimChatManager || !globalTimChatManager.getGroupList) {
|
||||||
loading.value = false;
|
throw new Error("IM管理器未初始化");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const result = await globalTimChatManager.getGroupList();
|
const result = await globalTimChatManager.getGroupList();
|
||||||
if (result && result.success && result.groupList) {
|
if (result && result.success && result.groupList) {
|
||||||
@ -232,13 +230,13 @@ const loadConversationList = async () => {
|
|||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 防抖更新定时器
|
// 防抖更新定时器
|
||||||
let updateTimer = null;
|
let updateTimer = null;
|
||||||
|
|
||||||
// 设置会话列表监听,实时更新列表
|
// 设置会话列表监听,实时更新列表
|
||||||
const setupConversationListener = () => {
|
const setupConversationListener = () => {
|
||||||
if (!globalTimChatManager) return;
|
if (!globalTimChatManager) return;
|
||||||
|
|
||||||
// 监听会话列表更新事件
|
// 监听会话列表更新事件
|
||||||
@ -309,7 +307,8 @@ const setupConversationListener = () => {
|
|||||||
const existing = conversationList.value[existingIndex];
|
const existing = conversationList.value[existingIndex];
|
||||||
if (
|
if (
|
||||||
existing.lastMessage !== conversationData.lastMessage ||
|
existing.lastMessage !== conversationData.lastMessage ||
|
||||||
existing.lastMessageTime !== conversationData.lastMessageTime ||
|
existing.lastMessageTime !== conversationData
|
||||||
|
.lastMessageTime ||
|
||||||
existing.unreadCount !== conversationData.unreadCount ||
|
existing.unreadCount !== conversationData.unreadCount ||
|
||||||
existing.patientName !== conversationData.patientName ||
|
existing.patientName !== conversationData.patientName ||
|
||||||
existing.patientSex !== conversationData.patientSex ||
|
existing.patientSex !== conversationData.patientSex ||
|
||||||
@ -387,15 +386,15 @@ const setupConversationListener = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 格式化患者姓名
|
// 格式化患者姓名
|
||||||
const formatPatientName = (conversation) => {
|
const formatPatientName = (conversation) => {
|
||||||
return conversation.patientName || "未知患者";
|
return conversation.patientName || "未知患者";
|
||||||
};
|
};
|
||||||
|
|
||||||
// 格式化患者信息(性别 + 年龄)
|
// 格式化患者信息(性别 + 年龄)
|
||||||
const formatPatientInfo = (conversation) => {
|
const formatPatientInfo = (conversation) => {
|
||||||
const parts = [];
|
const parts = [];
|
||||||
|
|
||||||
// 性别
|
// 性别
|
||||||
@ -411,10 +410,10 @@ const formatPatientInfo = (conversation) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return parts.join(" ");
|
return parts.join(" ");
|
||||||
};
|
};
|
||||||
|
|
||||||
// 格式化消息时间
|
// 格式化消息时间
|
||||||
const formatMessageTime = (timestamp) => {
|
const formatMessageTime = (timestamp) => {
|
||||||
if (!timestamp) return "";
|
if (!timestamp) return "";
|
||||||
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
@ -453,10 +452,10 @@ const formatMessageTime = (timestamp) => {
|
|||||||
|
|
||||||
// 其他
|
// 其他
|
||||||
return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`;
|
return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点击会话
|
// 点击会话
|
||||||
const handleClickConversation = (conversation) => {
|
const handleClickConversation = (conversation) => {
|
||||||
console.log("点击会话:", conversation);
|
console.log("点击会话:", conversation);
|
||||||
|
|
||||||
// 立即清空本地未读数(优化用户体验)
|
// 立即清空本地未读数(优化用户体验)
|
||||||
@ -472,10 +471,10 @@ const handleClickConversation = (conversation) => {
|
|||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/message/index?conversationID=${conversation.conversationID}&groupID=${conversation.groupID}`,
|
url: `/pages/message/index?conversationID=${conversation.conversationID}&groupID=${conversation.groupID}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载更多
|
// 加载更多
|
||||||
const handleLoadMore = () => {
|
const handleLoadMore = () => {
|
||||||
if (loadingMore.value || !hasMore.value) return;
|
if (loadingMore.value || !hasMore.value) return;
|
||||||
|
|
||||||
loadingMore.value = true;
|
loadingMore.value = true;
|
||||||
@ -483,25 +482,25 @@ const handleLoadMore = () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loadingMore.value = false;
|
loadingMore.value = false;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 下拉刷新
|
// 下拉刷新
|
||||||
const handleRefresh = async () => {
|
const handleRefresh = async () => {
|
||||||
refreshing.value = true;
|
refreshing.value = true;
|
||||||
try {
|
try {
|
||||||
await loadConversationList();
|
await loadConversationList();
|
||||||
} finally {
|
} finally {
|
||||||
refreshing.value = false;
|
refreshing.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 页面加载
|
// 页面加载
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
console.log("消息列表页面加载");
|
console.log("消息列表页面加载");
|
||||||
});
|
});
|
||||||
|
|
||||||
// 页面显示
|
// 页面显示
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
try {
|
try {
|
||||||
// 加载团队列表
|
// 加载团队列表
|
||||||
await getTeams();
|
await getTeams();
|
||||||
@ -525,10 +524,10 @@ onShow(async () => {
|
|||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 页面隐藏
|
// 页面隐藏
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
// 清除防抖定时器
|
// 清除防抖定时器
|
||||||
if (updateTimer) {
|
if (updateTimer) {
|
||||||
clearTimeout(updateTimer);
|
clearTimeout(updateTimer);
|
||||||
@ -540,49 +539,49 @@ onHide(() => {
|
|||||||
globalTimChatManager.setCallback("onConversationListUpdated", null);
|
globalTimChatManager.setCallback("onConversationListUpdated", null);
|
||||||
globalTimChatManager.setCallback("onMessageReceived", null);
|
globalTimChatManager.setCallback("onMessageReceived", null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.message-page {
|
.message-page {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-list {
|
.message-list {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-container,
|
.loading-container,
|
||||||
.empty-container {
|
.empty-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 100rpx 0;
|
padding: 100rpx 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-text {
|
.loading-text {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-image {
|
.empty-image {
|
||||||
width: 200rpx;
|
width: 200rpx;
|
||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-text {
|
.empty-text {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-item {
|
.message-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 24rpx 32rpx;
|
padding: 24rpx 32rpx;
|
||||||
@ -592,21 +591,21 @@ onHide(() => {
|
|||||||
&:active {
|
&:active {
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar-container {
|
.avatar-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-right: 24rpx;
|
margin-right: 24rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
width: 96rpx;
|
width: 96rpx;
|
||||||
height: 96rpx;
|
height: 96rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unread-badge {
|
.unread-badge {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -8rpx;
|
top: -8rpx;
|
||||||
right: -8rpx;
|
right: -8rpx;
|
||||||
@ -618,37 +617,37 @@ onHide(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unread-text {
|
.unread-text {
|
||||||
font-size: 20rpx;
|
font-size: 20rpx;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-bottom: 8rpx;
|
margin-bottom: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.name-info {
|
.name-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
@ -656,42 +655,42 @@ onHide(() => {
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-shrink: 1;
|
flex-shrink: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.patient-info {
|
.patient-info {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
padding-left: 12rpx;
|
padding-left: 12rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.time {
|
.time {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
margin-left: 16rpx;
|
margin-left: 16rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-preview {
|
.message-preview {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.preview-text {
|
.preview-text {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-more {
|
.load-more {
|
||||||
padding: 20rpx 0;
|
padding: 20rpx 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-more-text {
|
.load-more-text {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -5,13 +5,7 @@
|
|||||||
<view class="mt-12 text-base text-dark">全周期健康管理伙伴</view>
|
<view class="mt-12 text-base text-dark">全周期健康管理伙伴</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="login-btn-wrap">
|
<view class="login-btn-wrap">
|
||||||
<button
|
<button v-if="checked" class="login-btn" type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
|
||||||
v-if="checked"
|
|
||||||
class="login-btn"
|
|
||||||
type="primary"
|
|
||||||
open-type="getPhoneNumber"
|
|
||||||
@getphonenumber="getPhoneNumber"
|
|
||||||
>
|
|
||||||
手机号快捷登录
|
手机号快捷登录
|
||||||
</button>
|
</button>
|
||||||
<!-- <button v-if="checked" class="login-btn" type="primary" @click="getPhoneNumber()">
|
<!-- <button v-if="checked" class="login-btn" type="primary" @click="getPhoneNumber()">
|
||||||
@ -21,10 +15,7 @@
|
|||||||
手机号快捷登录
|
手机号快捷登录
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="flex items-center justify-center mt-12 px-15" @click="checked = !checked">
|
||||||
class="flex items-center justify-center mt-12 px-15"
|
|
||||||
@click="checked = !checked"
|
|
||||||
>
|
|
||||||
<checkbox :checked="checked" style="transform: scale(0.7)" />
|
<checkbox :checked="checked" style="transform: scale(0.7)" />
|
||||||
<view class="text-sm text-gray">我已阅读并同意</view>
|
<view class="text-sm text-gray">我已阅读并同意</view>
|
||||||
<view class="text-sm text-primary">《用户协议》、</view>
|
<view class="text-sm text-primary">《用户协议》、</view>
|
||||||
@ -85,8 +76,8 @@ async function getPhoneNumber(e) {
|
|||||||
await attempToPage(redirectUrl.value);
|
await attempToPage(redirectUrl.value);
|
||||||
} else if (res && !(doctorInfo.value && doctorInfo.value.anotherName)) {
|
} else if (res && !(doctorInfo.value && doctorInfo.value.anotherName)) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pages/work/profile",
|
url: '/pages/work/profile'
|
||||||
});
|
})
|
||||||
} else if (res) {
|
} else if (res) {
|
||||||
toHome();
|
toHome();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SCSS 变量定义
|
// SCSS 变量定义
|
||||||
$font-size-text: 30rpx;
|
$font-size-text: 28rpx;
|
||||||
$font-size-tip: 28rpx;
|
$font-size-tip: 24rpx;
|
||||||
$font-size-title: 32rpx;
|
$font-size-title: 32rpx;
|
||||||
$text-color-sub: #999;
|
$text-color-sub: #999;
|
||||||
$primary-color: #0877F1;
|
$primary-color: #0877F1;
|
||||||
@ -331,7 +331,7 @@ $primary-color: #0877F1;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.message-text {
|
.message-text {
|
||||||
font-size: 30rpx;
|
font-size: $font-size-text;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
|||||||
@ -393,13 +393,13 @@ const checkLoginAndInitTIM = async () => {
|
|||||||
});
|
});
|
||||||
const success = await initIMAfterLogin();
|
const success = await initIMAfterLogin();
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
// if (!success) {
|
if (!success) {
|
||||||
// uni.showToast({
|
uni.showToast({
|
||||||
// title: "IM连接失败,请重试",
|
title: "IM连接失败,请重试",
|
||||||
// icon: "none",
|
icon: "none",
|
||||||
// });
|
});
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
} else if (!timChatManager.isLoggedIn) {
|
} else if (!timChatManager.isLoggedIn) {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "重连中...",
|
title: "重连中...",
|
||||||
|
|||||||
@ -1,33 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="message-page">
|
<view class="message-page">
|
||||||
<!-- 头部组件 -->
|
<!-- 头部组件 -->
|
||||||
<message-header
|
<message-header v-model:activeTab="activeTab" @team-change="handleTeamChange" @add-patient="handleAddPatient" />
|
||||||
v-model:activeTab="activeTab"
|
|
||||||
@team-change="handleTeamChange"
|
|
||||||
@add-patient="handleAddPatient"
|
|
||||||
/>
|
|
||||||
<!-- 消息列表 -->
|
<!-- 消息列表 -->
|
||||||
<scroll-view
|
<scroll-view class="message-list" scroll-y="true" refresher-enabled :refresher-triggered="refreshing"
|
||||||
class="message-list"
|
@refresherrefresh="handleRefresh" @scrolltolower="handleLoadMore">
|
||||||
scroll-y="true"
|
|
||||||
refresher-enabled
|
|
||||||
:refresher-triggered="refreshing"
|
|
||||||
@refresherrefresh="handleRefresh"
|
|
||||||
@scrolltolower="handleLoadMore"
|
|
||||||
>
|
|
||||||
<!-- 消息列表项 -->
|
<!-- 消息列表项 -->
|
||||||
<view
|
<view v-for="conversation in filteredConversationList"
|
||||||
v-for="conversation in filteredConversationList"
|
:key="conversation.groupID || conversation.conversationID" class="message-item"
|
||||||
:key="conversation.groupID || conversation.conversationID"
|
@click="handleClickConversation(conversation)">
|
||||||
class="message-item"
|
|
||||||
@click="handleClickConversation(conversation)"
|
|
||||||
>
|
|
||||||
<view class="avatar-container">
|
<view class="avatar-container">
|
||||||
<image
|
<image class="avatar" :src="conversation.avatar || '/static/default-patient-avatar.png'"
|
||||||
class="avatar"
|
mode="aspectFill" />
|
||||||
:src="conversation.avatar || '/static/default-patient-avatar.png'"
|
|
||||||
mode="aspectFill"
|
|
||||||
/>
|
|
||||||
<view v-if="conversation.unreadCount > 0" class="unread-badge">
|
<view v-if="conversation.unreadCount > 0" class="unread-badge">
|
||||||
<text class="unread-text">{{
|
<text class="unread-text">{{
|
||||||
conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
|
conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
|
||||||
@ -39,10 +24,7 @@
|
|||||||
<view class="header">
|
<view class="header">
|
||||||
<view class="name-info">
|
<view class="name-info">
|
||||||
<text class="name">{{ formatPatientName(conversation) }}</text>
|
<text class="name">{{ formatPatientName(conversation) }}</text>
|
||||||
<text
|
<text v-if="conversation.patientSex || conversation.patientAge" class="patient-info">
|
||||||
v-if="conversation.patientSex || conversation.patientAge"
|
|
||||||
class="patient-info"
|
|
||||||
>
|
|
||||||
{{ formatPatientInfo(conversation) }}
|
{{ formatPatientInfo(conversation) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
@ -59,20 +41,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 空状态 -->
|
<!-- 空状态 -->
|
||||||
<view
|
<view v-if="!loading && filteredConversationList.length === 0" class="empty-container">
|
||||||
v-if="!loading && conversationList.length === 0"
|
|
||||||
class="empty-container"
|
|
||||||
>
|
|
||||||
<image class="empty-image" src="/static/empty.svg" mode="aspectFit" />
|
|
||||||
<text class="empty-text">医生信息未获取,请稍后重试</text>
|
|
||||||
</view>
|
|
||||||
<view
|
|
||||||
v-else-if="
|
|
||||||
!loading &&
|
|
||||||
filteredConversationList.length === 0
|
|
||||||
"
|
|
||||||
class="empty-container"
|
|
||||||
>
|
|
||||||
<image class="empty-image" src="/static/empty.svg" mode="aspectFit" />
|
<image class="empty-image" src="/static/empty.svg" mode="aspectFit" />
|
||||||
<text class="empty-text">{{
|
<text class="empty-text">{{
|
||||||
activeTab === "processing" ? "暂无处理中的会话" : "暂无已结束的会话"
|
activeTab === "processing" ? "暂无处理中的会话" : "暂无已结束的会话"
|
||||||
@ -80,10 +49,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 加载更多 -->
|
<!-- 加载更多 -->
|
||||||
<view
|
<view v-if="hasMore && filteredConversationList.length > 0" class="load-more">
|
||||||
v-if="hasMore && filteredConversationList.length > 0"
|
|
||||||
class="load-more"
|
|
||||||
>
|
|
||||||
<text class="load-more-text">{{
|
<text class="load-more-text">{{
|
||||||
loadingMore ? "加载中..." : "上拉加载更多"
|
loadingMore ? "加载中..." : "上拉加载更多"
|
||||||
}}</text>
|
}}</text>
|
||||||
@ -93,40 +59,63 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from "vue";
|
import {
|
||||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
ref,
|
||||||
import { storeToRefs } from "pinia";
|
computed
|
||||||
import useAccountStore from "@/store/account.js";
|
} from "vue";
|
||||||
import useTeamStore from "@/store/team.js";
|
import {
|
||||||
import useInfoCheck from "@/hooks/useInfoCheck.js";
|
onLoad,
|
||||||
import { globalTimChatManager } from "@/utils/tim-chat.js";
|
onShow,
|
||||||
import { mergeConversationWithGroupDetails } from "@/utils/conversation-merger.js";
|
onHide
|
||||||
import MessageHeader from "../home/components/message-header.vue";
|
} from "@dcloudio/uni-app";
|
||||||
|
import {
|
||||||
|
storeToRefs
|
||||||
|
} from "pinia";
|
||||||
|
import useAccountStore from "@/store/account.js";
|
||||||
|
import useTeamStore from "@/store/team.js";
|
||||||
|
import useInfoCheck from "@/hooks/useInfoCheck.js";
|
||||||
|
import {
|
||||||
|
globalTimChatManager
|
||||||
|
} from "@/utils/tim-chat.js";
|
||||||
|
import {
|
||||||
|
mergeConversationWithGroupDetails
|
||||||
|
} from "@/utils/conversation-merger.js";
|
||||||
|
import MessageHeader from "../home/components/message-header.vue";
|
||||||
|
|
||||||
// 获取登录状态
|
// 获取登录状态
|
||||||
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
|
const {
|
||||||
const { initIMAfterLogin } = useAccountStore();
|
account,
|
||||||
|
openid,
|
||||||
|
isIMInitialized
|
||||||
|
} = storeToRefs(useAccountStore());
|
||||||
|
const {
|
||||||
|
initIMAfterLogin
|
||||||
|
} = useAccountStore();
|
||||||
|
|
||||||
// 获取团队信息
|
// 获取团队信息
|
||||||
const teamStore = useTeamStore();
|
const teamStore = useTeamStore();
|
||||||
const { getTeams } = teamStore;
|
const {
|
||||||
|
getTeams
|
||||||
|
} = teamStore;
|
||||||
|
|
||||||
// 信息完善检查
|
// 信息完善检查
|
||||||
const { withInfo } = useInfoCheck();
|
const {
|
||||||
|
withInfo
|
||||||
|
} = useInfoCheck();
|
||||||
|
|
||||||
// 团队相关状态
|
// 团队相关状态
|
||||||
const currentTeamId = ref(""); // 空字符串表示"全部会话消息"
|
const currentTeamId = ref(""); // 空字符串表示"全部会话消息"
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
const conversationList = ref([]);
|
const conversationList = ref([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const loadingMore = ref(false);
|
const loadingMore = ref(false);
|
||||||
const hasMore = ref(false);
|
const hasMore = ref(false);
|
||||||
const refreshing = ref(false);
|
const refreshing = ref(false);
|
||||||
const activeTab = ref("processing");
|
const activeTab = ref("processing");
|
||||||
|
|
||||||
// 根据 orderStatus 过滤会话列表
|
// 根据 orderStatus 过滤会话列表
|
||||||
const filteredConversationList = computed(() => {
|
const filteredConversationList = computed(() => {
|
||||||
let filtered = [];
|
let filtered = [];
|
||||||
|
|
||||||
if (activeTab.value === "processing") {
|
if (activeTab.value === "processing") {
|
||||||
@ -150,23 +139,23 @@ const filteredConversationList = computed(() => {
|
|||||||
filtered = filtered.filter((conv) => conv.teamId === currentTeamId.value);
|
filtered = filtered.filter((conv) => conv.teamId === currentTeamId.value);
|
||||||
}
|
}
|
||||||
return filtered;
|
return filtered;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 处理团队切换
|
// 处理团队切换
|
||||||
const handleTeamChange = (teamId) => {
|
const handleTeamChange = (teamId) => {
|
||||||
currentTeamId.value = teamId;
|
currentTeamId.value = teamId;
|
||||||
console.log("切换到团队ID:", teamId);
|
console.log("切换到团队ID:", teamId);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 邀请患者 - 使用 withInfo 包装,确保信息完善后才能使用
|
// 邀请患者 - 使用 withInfo 包装,确保信息完善后才能使用
|
||||||
const handleAddPatient = withInfo(() => {
|
const handleAddPatient = withInfo(() => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/work/team/invite/invite-patient",
|
url: "/pages/work/team/invite/invite-patient",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 初始化IM
|
// 初始化IM
|
||||||
const initIM = async () => {
|
const initIM = async () => {
|
||||||
if (!isIMInitialized.value) {
|
if (!isIMInitialized.value) {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "连接中...",
|
title: "连接中...",
|
||||||
@ -178,8 +167,7 @@ const initIM = async () => {
|
|||||||
// 显示重试提示
|
// 显示重试提示
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: "IM连接失败",
|
title: "IM连接失败",
|
||||||
content:
|
content: "连接失败,请检查网络后重试。如果IM连接失败,请重新登陆IM再连接",
|
||||||
"连接失败,请检查网络后重试。如果IM连接失败,请重新登陆IM再连接",
|
|
||||||
confirmText: "重新登陆",
|
confirmText: "重新登陆",
|
||||||
cancelText: "取消",
|
cancelText: "取消",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@ -187,7 +175,7 @@ const initIM = async () => {
|
|||||||
// 重新登陆
|
// 重新登陆
|
||||||
handleReloginIM();
|
handleReloginIM();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -202,8 +190,7 @@ const initIM = async () => {
|
|||||||
// 显示重试提示
|
// 显示重试提示
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: "IM连接失败",
|
title: "IM连接失败",
|
||||||
content:
|
content: "连接失败,请检查网络后重试。如果IM连接失败,请重新登陆IM再连接",
|
||||||
"连接失败,请检查网络后重试。如果IM连接失败,请重新登陆IM再连接",
|
|
||||||
confirmText: "重新登陆",
|
confirmText: "重新登陆",
|
||||||
cancelText: "取消",
|
cancelText: "取消",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@ -211,16 +198,16 @@ const initIM = async () => {
|
|||||||
// 重新登陆
|
// 重新登陆
|
||||||
handleReloginIM();
|
handleReloginIM();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重新登陆IM
|
// 重新登陆IM
|
||||||
const handleReloginIM = async () => {
|
const handleReloginIM = async () => {
|
||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "重新登陆中...",
|
title: "重新登陆中...",
|
||||||
@ -258,10 +245,10 @@ const handleReloginIM = async () => {
|
|||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载会话列表
|
// 加载会话列表
|
||||||
const loadConversationList = async () => {
|
const loadConversationList = async () => {
|
||||||
if (loading.value) return;
|
if (loading.value) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
@ -331,13 +318,13 @@ const loadConversationList = async () => {
|
|||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 防抖更新定时器
|
// 防抖更新定时器
|
||||||
let updateTimer = null;
|
let updateTimer = null;
|
||||||
|
|
||||||
// 设置会话列表监听,实时更新列表
|
// 设置会话列表监听,实时更新列表
|
||||||
const setupConversationListener = () => {
|
const setupConversationListener = () => {
|
||||||
if (!globalTimChatManager) return;
|
if (!globalTimChatManager) return;
|
||||||
|
|
||||||
// 监听会话列表更新事件
|
// 监听会话列表更新事件
|
||||||
@ -408,7 +395,8 @@ const setupConversationListener = () => {
|
|||||||
const existing = conversationList.value[existingIndex];
|
const existing = conversationList.value[existingIndex];
|
||||||
if (
|
if (
|
||||||
existing.lastMessage !== conversationData.lastMessage ||
|
existing.lastMessage !== conversationData.lastMessage ||
|
||||||
existing.lastMessageTime !== conversationData.lastMessageTime ||
|
existing.lastMessageTime !== conversationData
|
||||||
|
.lastMessageTime ||
|
||||||
existing.unreadCount !== conversationData.unreadCount ||
|
existing.unreadCount !== conversationData.unreadCount ||
|
||||||
existing.patientName !== conversationData.patientName ||
|
existing.patientName !== conversationData.patientName ||
|
||||||
existing.patientSex !== conversationData.patientSex ||
|
existing.patientSex !== conversationData.patientSex ||
|
||||||
@ -486,15 +474,15 @@ const setupConversationListener = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 格式化患者姓名
|
// 格式化患者姓名
|
||||||
const formatPatientName = (conversation) => {
|
const formatPatientName = (conversation) => {
|
||||||
return conversation.patientName || "未知患者";
|
return conversation.patientName || "未知患者";
|
||||||
};
|
};
|
||||||
|
|
||||||
// 格式化患者信息(性别 + 年龄)
|
// 格式化患者信息(性别 + 年龄)
|
||||||
const formatPatientInfo = (conversation) => {
|
const formatPatientInfo = (conversation) => {
|
||||||
const parts = [];
|
const parts = [];
|
||||||
|
|
||||||
// 性别
|
// 性别
|
||||||
@ -510,10 +498,10 @@ const formatPatientInfo = (conversation) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return parts.join(" ");
|
return parts.join(" ");
|
||||||
};
|
};
|
||||||
|
|
||||||
// 格式化消息时间
|
// 格式化消息时间
|
||||||
const formatMessageTime = (timestamp) => {
|
const formatMessageTime = (timestamp) => {
|
||||||
if (!timestamp) return "";
|
if (!timestamp) return "";
|
||||||
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
@ -552,10 +540,10 @@ const formatMessageTime = (timestamp) => {
|
|||||||
|
|
||||||
// 其他
|
// 其他
|
||||||
return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`;
|
return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点击会话
|
// 点击会话
|
||||||
const handleClickConversation = (conversation) => {
|
const handleClickConversation = (conversation) => {
|
||||||
console.log("点击会话:", conversation);
|
console.log("点击会话:", conversation);
|
||||||
|
|
||||||
// 立即清空本地未读数(优化用户体验)
|
// 立即清空本地未读数(优化用户体验)
|
||||||
@ -571,10 +559,10 @@ const handleClickConversation = (conversation) => {
|
|||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/message/index?conversationID=${conversation.conversationID}&groupID=${conversation.groupID}`,
|
url: `/pages/message/index?conversationID=${conversation.conversationID}&groupID=${conversation.groupID}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载更多
|
// 加载更多
|
||||||
const handleLoadMore = () => {
|
const handleLoadMore = () => {
|
||||||
if (loadingMore.value || !hasMore.value) return;
|
if (loadingMore.value || !hasMore.value) return;
|
||||||
|
|
||||||
loadingMore.value = true;
|
loadingMore.value = true;
|
||||||
@ -582,25 +570,25 @@ const handleLoadMore = () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loadingMore.value = false;
|
loadingMore.value = false;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 下拉刷新
|
// 下拉刷新
|
||||||
const handleRefresh = async () => {
|
const handleRefresh = async () => {
|
||||||
refreshing.value = true;
|
refreshing.value = true;
|
||||||
try {
|
try {
|
||||||
await loadConversationList();
|
await loadConversationList();
|
||||||
} finally {
|
} finally {
|
||||||
refreshing.value = false;
|
refreshing.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 页面加载
|
// 页面加载
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
console.log("消息列表页面加载");
|
console.log("消息列表页面加载");
|
||||||
});
|
});
|
||||||
|
|
||||||
// 页面显示
|
// 页面显示
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
try {
|
try {
|
||||||
// 加载团队列表
|
// 加载团队列表
|
||||||
await getTeams();
|
await getTeams();
|
||||||
@ -624,10 +612,10 @@ onShow(async () => {
|
|||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 页面隐藏
|
// 页面隐藏
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
// 清除防抖定时器
|
// 清除防抖定时器
|
||||||
if (updateTimer) {
|
if (updateTimer) {
|
||||||
clearTimeout(updateTimer);
|
clearTimeout(updateTimer);
|
||||||
@ -639,49 +627,49 @@ onHide(() => {
|
|||||||
globalTimChatManager.setCallback("onConversationListUpdated", null);
|
globalTimChatManager.setCallback("onConversationListUpdated", null);
|
||||||
globalTimChatManager.setCallback("onMessageReceived", null);
|
globalTimChatManager.setCallback("onMessageReceived", null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.message-page {
|
.message-page {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-list {
|
.message-list {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-container,
|
.loading-container,
|
||||||
.empty-container {
|
.empty-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 100rpx 0;
|
padding: 100rpx 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-text {
|
.loading-text {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-image {
|
.empty-image {
|
||||||
width: 200rpx;
|
width: 200rpx;
|
||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-text {
|
.empty-text {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-item {
|
.message-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 24rpx 32rpx;
|
padding: 24rpx 32rpx;
|
||||||
@ -691,21 +679,21 @@ onHide(() => {
|
|||||||
&:active {
|
&:active {
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar-container {
|
.avatar-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-right: 24rpx;
|
margin-right: 24rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
width: 96rpx;
|
width: 96rpx;
|
||||||
height: 96rpx;
|
height: 96rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unread-badge {
|
.unread-badge {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -8rpx;
|
top: -8rpx;
|
||||||
right: -8rpx;
|
right: -8rpx;
|
||||||
@ -717,37 +705,37 @@ onHide(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unread-text {
|
.unread-text {
|
||||||
font-size: 20rpx;
|
font-size: 20rpx;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-bottom: 8rpx;
|
margin-bottom: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.name-info {
|
.name-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
@ -755,42 +743,42 @@ onHide(() => {
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-shrink: 1;
|
flex-shrink: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.patient-info {
|
.patient-info {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
padding-left: 12rpx;
|
padding-left: 12rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.time {
|
.time {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
margin-left: 16rpx;
|
margin-left: 16rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-preview {
|
.message-preview {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.preview-text {
|
.preview-text {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-more {
|
.load-more {
|
||||||
padding: 20rpx 0;
|
padding: 20rpx 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-more-text {
|
.load-more-text {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -41,7 +41,6 @@ export default defineStore("accountStore", () => {
|
|||||||
|
|
||||||
async function loginByCode(phoneCode = '') {
|
async function loginByCode(phoneCode = '') {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const { code } = await uni.login({
|
const { code } = await uni.login({
|
||||||
appid,
|
appid,
|
||||||
provider: "weixin",
|
provider: "weixin",
|
||||||
@ -62,12 +61,13 @@ export default defineStore("accountStore", () => {
|
|||||||
}
|
}
|
||||||
account.value = res.data;
|
account.value = res.data;
|
||||||
openid.value = res.data.openid;
|
openid.value = res.data.openid;
|
||||||
|
|
||||||
// 持久化账户信息
|
// 持久化账户信息
|
||||||
cache.set(CACHE_KEYS.ACCOUNT, res.data);
|
cache.set(CACHE_KEYS.ACCOUNT, res.data);
|
||||||
cache.set(CACHE_KEYS.OPENID, res.data.openid);
|
cache.set(CACHE_KEYS.OPENID, res.data.openid);
|
||||||
|
|
||||||
// 登录成功后初始化腾讯IM
|
// 登录成功后初始化腾讯IM
|
||||||
await getDoctorInfo({ openid: openid.value });
|
await getDoctorInfo(openid.value);
|
||||||
await initIMAfterLogin();
|
await initIMAfterLogin();
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
|
|||||||
@ -283,6 +283,7 @@ function generateSendLink(survey, answerId, customerId, customerName, sendSurvey
|
|||||||
const { corpId, userId } = context;
|
const { corpId, userId } = context;
|
||||||
const isSystem = survey.createBy === 'system';
|
const isSystem = survey.createBy === 'system';
|
||||||
let url = '';
|
let url = '';
|
||||||
|
debugger
|
||||||
if (isSystem) {
|
if (isSystem) {
|
||||||
// 系统问卷:使用 VITE_SURVEY_URL
|
// 系统问卷:使用 VITE_SURVEY_URL
|
||||||
url = `${env?.MP_SURVEY_URL}?corpId=${corpId}&surveryId=${survey.surveryId}&memberId=${customerId}&sendSurveyId=${sendSurveyId}&userId=${userId}`;
|
url = `${env?.MP_SURVEY_URL}?corpId=${corpId}&surveryId=${survey.surveryId}&memberId=${customerId}&sendSurveyId=${sendSurveyId}&userId=${userId}`;
|
||||||
|
|||||||
@ -1030,11 +1030,6 @@ class TimChatManager {
|
|||||||
// 获取群聊列表
|
// 获取群聊列表
|
||||||
getGroupList() {
|
getGroupList() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 检查userId是否存在,不存在则不需要初始化
|
|
||||||
if (!this.currentUserID) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果 TIM 实例不存在,等待初始化
|
// 如果 TIM 实例不存在,等待初始化
|
||||||
if (!this.tim) {
|
if (!this.tim) {
|
||||||
console.log('TIM实例不存在,等待初始化...')
|
console.log('TIM实例不存在,等待初始化...')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user