From 00478235e719f80d76a0b5243e45d8fa3f98c7d5 Mon Sep 17 00:00:00 2001
From: wangdongbo <949818794@qq.com>
Date: Mon, 9 Feb 2026 11:52:40 +0800
Subject: [PATCH 01/13] no message
---
pages/message/index.vue | 7 +
pages/message/message.vue | 140 +++++++----
pages/work/team/invite/invite-teammate.vue | 257 +++++++++++----------
utils/tim-chat.js | 9 +-
4 files changed, 254 insertions(+), 159 deletions(-)
diff --git a/pages/message/index.vue b/pages/message/index.vue
index d74ca56..a2fac16 100644
--- a/pages/message/index.vue
+++ b/pages/message/index.vue
@@ -769,6 +769,13 @@ onShow(() => {
checkLoginAndInitTIM();
} else if (timChatManager.tim && !timChatManager.isLoggedIn) {
timChatManager.ensureIMConnection();
+ } else if (timChatManager.tim && timChatManager.isLoggedIn && chatInfo.value.conversationID) {
+ // 页面从后台返回时,重新加载消息列表
+ console.log("页面从后台返回,重新加载消息列表");
+ messageList.value = [];
+ isCompleted.value = false;
+ lastFirstMessageId.value = "";
+ loadMessageList();
}
startIMMonitoring(30000);
diff --git a/pages/message/message.vue b/pages/message/message.vue
index bfd156a..5adc1f9 100644
--- a/pages/message/message.vue
+++ b/pages/message/message.vue
@@ -67,10 +67,7 @@
医生信息未获取,请稍后重试
@@ -165,12 +162,78 @@ const handleAddPatient = withInfo(() => {
});
});
+// 立即更新未读徽章
+const updateUnreadBadgeImmediately = async () => {
+ try {
+ if (!globalTimChatManager || !globalTimChatManager.tim) {
+ console.warn("TIM实例不存在,无法更新徽章");
+ return;
+ }
+
+ const response = await globalTimChatManager.tim.getConversationList();
+
+ if (!response || !response.data || !response.data.conversationList) {
+ console.warn("获取会话列表返回数据异常");
+ return;
+ }
+
+ // 计算群聊总未读数
+ const totalUnreadCount = response.data.conversationList
+ .filter(
+ (conv) => conv.conversationID && conv.conversationID.startsWith("GROUP")
+ )
+ .reduce((sum, conv) => sum + (conv.unreadCount || 0), 0);
+
+ // 更新 tabBar 徽章 - 添加错误处理,防止在非TabBar页面调用时出错
+ try {
+ if (totalUnreadCount > 0) {
+ uni.setTabBarBadge({
+ index: 1,
+ text: totalUnreadCount > 99 ? "99+" : String(totalUnreadCount),
+ });
+ console.log("已更新 tabBar 徽章:", totalUnreadCount);
+ } else {
+ uni.removeTabBarBadge({
+ index: 1,
+ });
+ console.log("已移除 tabBar 徽章");
+ }
+ } catch (badgeError) {
+ // 在非TabBar页面上调用时会出错,这是正常的,不需要处理
+ if (badgeError.errMsg && badgeError.errMsg.includes("not TabBar page")) {
+ console.log("当前不是TabBar页面,跳过徽章更新");
+ } else {
+ console.error("更新TabBar徽章失败:", badgeError);
+ }
+ }
+ } catch (error) {
+ console.error("更新未读徽章失败:", error);
+ }
+};
+
// 初始化IM
const initIM = async () => {
- if (!isIMInitialized.value) {
+ // 关键修复:不仅检查 isIMInitialized,还要检查实际连接状态
+ const needsInit =
+ !isIMInitialized.value ||
+ !globalTimChatManager ||
+ !globalTimChatManager.isLoggedIn;
+
+ if (needsInit) {
uni.showLoading({
title: "连接中...",
});
+
+ // 如果已初始化但连接断开,先清理旧实例
+ if (
+ isIMInitialized.value &&
+ globalTimChatManager &&
+ !globalTimChatManager.isLoggedIn
+ ) {
+ console.log("IM已初始化但连接已断开,清理旧实例后重新初始化");
+ await globalTimChatManager.cleanupOldInstance();
+ }
+
const success = await initIMAfterLogin();
uni.hideLoading();
@@ -191,30 +254,6 @@ const initIM = async () => {
});
return false;
}
- } else if (globalTimChatManager && !globalTimChatManager.isLoggedIn) {
- uni.showLoading({
- title: "重连中...",
- });
- const reconnected = await globalTimChatManager.ensureIMConnection();
- uni.hideLoading();
-
- if (!reconnected) {
- // 显示重试提示
- uni.showModal({
- title: "IM连接失败",
- content:
- "连接失败,请检查网络后重试。如果IM连接失败,请重新登陆IM再连接",
- confirmText: "重新登陆",
- cancelText: "取消",
- success: (res) => {
- if (res.confirm) {
- // 重新登陆
- handleReloginIM();
- }
- },
- });
- return false;
- }
}
return true;
};
@@ -281,7 +320,7 @@ const loadConversationList = async () => {
}
}
- // 检查是否已登录
+ // 检查是否已登录 - 这是关键检查
if (!globalTimChatManager.isLoggedIn) {
console.warn("IM未登录,尝试重新连接");
const reconnected = await globalTimChatManager.ensureIMConnection();
@@ -294,7 +333,19 @@ const loadConversationList = async () => {
throw new Error("IM管理器方法不可用");
}
- const result = await globalTimChatManager.getGroupList();
+ // 添加超时控制,防止永久等待
+ const timeoutPromise = new Promise((_, reject) => {
+ setTimeout(
+ () => reject(new Error("加载会话列表超时,请检查网络连接")),
+ 35000
+ );
+ });
+
+ const result = await Promise.race([
+ globalTimChatManager.getGroupList(),
+ timeoutPromise,
+ ]);
+
if (result && result.success && result.groupList) {
// 合并后端群组详细信息(已包含格式化和排序)
conversationList.value = await mergeConversationWithGroupDetails(
@@ -317,17 +368,26 @@ const loadConversationList = async () => {
);
} else {
console.error("加载群聊列表失败:", result);
- uni.showToast({
- title: "加载失败,请重试",
- icon: "none",
- });
+ throw new Error(result?.message || "加载失败,请重试");
}
} catch (error) {
console.error("加载会话列表失败:", error);
- uni.showToast({
- title: error.message || "加载失败,请重试",
- icon: "none",
- });
+
+ // 如果是超时或连接错误,提示用户重试
+ if (
+ error.message &&
+ (error.message.includes("超时") || error.message.includes("连接"))
+ ) {
+ uni.showToast({
+ title: "网络连接不稳定,请重试",
+ icon: "none",
+ });
+ } else {
+ uni.showToast({
+ title: error.message || "加载失败,请重试",
+ icon: "none",
+ });
+ }
} finally {
loading.value = false;
}
@@ -605,7 +665,7 @@ onShow(async () => {
// 加载团队列表
await getTeams();
- // 初始化IM
+ // 初始化IM - 关键修复:确保IM连接状态正确
const imReady = await initIM();
if (!imReady) {
console.error("IM初始化失败");
diff --git a/pages/work/team/invite/invite-teammate.vue b/pages/work/team/invite/invite-teammate.vue
index 73ad092..363b906 100644
--- a/pages/work/team/invite/invite-teammate.vue
+++ b/pages/work/team/invite/invite-teammate.vue
@@ -1,118 +1,141 @@
-
-
-
-
- {{ team.name }}
-
-
- 成员邀请码
-
-
-
-
-
- 微信扫一扫上面的二维码
-
-
- 加入我的团队,协同开展患者管理服务
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/utils/tim-chat.js b/utils/tim-chat.js
index 158e904..14d8ed4 100644
--- a/utils/tim-chat.js
+++ b/utils/tim-chat.js
@@ -1032,6 +1032,8 @@ class TimChatManager {
return new Promise((resolve, reject) => {
// 检查userId是否存在,不存在则不需要初始化
if (!this.currentUserID) {
+ console.error('currentUserID不存在,无法获取群聊列表')
+ reject(new Error('用户ID不存在'))
return
}
@@ -1076,12 +1078,13 @@ class TimChatManager {
if (timeoutHandle) clearTimeout(timeoutHandle)
this.getGroupListInternal().then(resolve).catch(reject)
} else if (waitTime >= maxWaitTime) {
- console.error('等待SDK就绪超时')
+ console.error('等待SDK就绪超时,当前isLoggedIn:', this.isLoggedIn)
if (timeoutHandle) clearTimeout(timeoutHandle)
+ // 超时时返回错误而不是继续等待
reject(new Error('SDK初始化超时,请检查网络连接'))
} else {
waitTime += checkInterval
- console.log(`等待SDK就绪... (${Math.floor(waitTime / 1000)}/${Math.floor(maxWaitTime / 1000)}秒)`)
+ console.log(`等待SDK就绪... (${Math.floor(waitTime / 1000)}/${Math.floor(maxWaitTime / 1000)}秒, isLoggedIn: ${this.isLoggedIn})`)
timeoutHandle = setTimeout(checkSDKReady, checkInterval)
}
}
@@ -2758,6 +2761,7 @@ class TimChatManager {
// 标记会话为已读
markConversationAsRead(conversationID) {
+
if (!this.tim || !this.isLoggedIn) {
console.log('⚠️ TIM未初始化或未登录,无法标记会话已读');
return;
@@ -2777,6 +2781,7 @@ class TimChatManager {
}
}
+
// 更新会话列表
updateConversationListOnNewMessage(message) {
try {
From f1f148d8a175707efedadb7badead7597bbaecc0 Mon Sep 17 00:00:00 2001
From: wangdongbo <949818794@qq.com>
Date: Mon, 9 Feb 2026 12:01:03 +0800
Subject: [PATCH 02/13] no message
---
.env.production | 10 +
pages/case/ai-medical-case-form.vue | 473 ++++++++++++++++++
.../components/ai-assistant-buttons.vue | 2 +-
3 files changed, 484 insertions(+), 1 deletion(-)
create mode 100644 .env.production
create mode 100644 pages/case/ai-medical-case-form.vue
diff --git a/.env.production b/.env.production
new file mode 100644
index 0000000..4b5a015
--- /dev/null
+++ b/.env.production
@@ -0,0 +1,10 @@
+MP_API_BASE_URL=https://ytk.youcan365.com
+MP_IMAGE_URL=https://ytk.youcan365.com
+MP_CACHE_PREFIX=production
+MP_WX_APP_ID=wx1d8337a40c11d66c
+MP_CORP_ID=wpLgjyawAA8N0gWmXgyJq8wpjGcOT7fg
+MP_TIM_SDK_APP_ID=1600123876
+MP_INVITE_TEAMMATE_QRCODE=https://ykt.youcan365.com/invite-teammate
+MP_INVITE_PATIENT_QRCODE=https://ykt.youcan365.com/invite-patient
+MP_PATIENT_PAGE_BASE_URL= 'https://www.youcan365.com/h5/#/'
+MP_SURVEY_URL= 'https://www.youcan365.com/surveyDev/#/pages/survey/survey'
diff --git a/pages/case/ai-medical-case-form.vue b/pages/case/ai-medical-case-form.vue
new file mode 100644
index 0000000..532e89b
--- /dev/null
+++ b/pages/case/ai-medical-case-form.vue
@@ -0,0 +1,473 @@
+
+
+
+
+
+ {{ field.label }}
+
+
+
+
+ {{ formData[field.key] || "暂无" }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/message/components/ai-assistant-buttons.vue b/pages/message/components/ai-assistant-buttons.vue
index aa8900b..40b93af 100644
--- a/pages/message/components/ai-assistant-buttons.vue
+++ b/pages/message/components/ai-assistant-buttons.vue
@@ -348,7 +348,7 @@ const handleNextFromProgress = (data) => {
// 跳转到病历填写页面
uni.navigateTo({
- url: `/pages/case/medical-case-form?caseType=${data.caseType}&patientId=${
+ url: `/pages/case/ai-medical-case-form?caseType=${data.caseType}&patientId=${
props.patientId
}&groupId=${props.groupId}&formData=${encodeURIComponent(
JSON.stringify(extractedData)
From c836420191178cddc9c2418435e4a6c4bddca9bd Mon Sep 17 00:00:00 2001
From: wangdongbo <949818794@qq.com>
Date: Mon, 9 Feb 2026 14:06:35 +0800
Subject: [PATCH 03/13] no message
---
pages.json | 6 +
pages/case/ai-medical-case-form.vue | 14 +-
pages/home/message-home.vue | 239 ++++++--
pages/message/chat.scss | 4 +-
pages/message/message.vue | 856 ----------------------------
5 files changed, 220 insertions(+), 899 deletions(-)
delete mode 100644 pages/message/message.vue
diff --git a/pages.json b/pages.json
index 4cf1292..1114629 100644
--- a/pages.json
+++ b/pages.json
@@ -238,6 +238,12 @@
"navigationBarTitleText": "添加病历"
}
},
+ {
+ "path": "ai-medical-case-form",
+ "style": {
+ "navigationBarTitleText": "添加病历"
+ }
+ },
{
"path": "service-record-detail",
"style": {
diff --git a/pages/case/ai-medical-case-form.vue b/pages/case/ai-medical-case-form.vue
index 532e89b..89e7790 100644
--- a/pages/case/ai-medical-case-form.vue
+++ b/pages/case/ai-medical-case-form.vue
@@ -103,7 +103,7 @@ const FIELD_CONFIG = {
key: "visitTime",
label: FIELD_LABELS.visitTime,
type: "date",
- required: false,
+ required: true,
},
{
key: "diagnosisName",
@@ -141,13 +141,13 @@ const FIELD_CONFIG = {
key: "inhosDate",
label: FIELD_LABELS.inhosDate,
type: "date",
- required: false,
+ required: true,
},
{
key: "diagnosisName",
label: "住院主诊断",
type: "textarea",
- required: false,
+ required: true,
},
{
key: "operation",
@@ -197,7 +197,7 @@ const FIELD_CONFIG = {
key: "inspectTime",
label: FIELD_LABELS.inspectTime,
type: "date",
- required: false,
+ required: true,
},
{
key: "inspectSummary",
@@ -217,19 +217,19 @@ const FIELD_CONFIG = {
key: "chiefComplaint",
label: FIELD_LABELS.chiefComplaint,
type: "textarea",
- required: false,
+ required: true,
},
{
key: "presentIllnessHistory",
label: FIELD_LABELS.presentIllnessHistory,
type: "textarea",
- required: false,
+ required: true,
},
{
key: "pastMedicalHistory",
label: FIELD_LABELS.pastMedicalHistory,
type: "textarea",
- required: false,
+ required: true,
},
],
};
diff --git a/pages/home/message-home.vue b/pages/home/message-home.vue
index b4cc82e..2d97669 100644
--- a/pages/home/message-home.vue
+++ b/pages/home/message-home.vue
@@ -6,7 +6,6 @@
@team-change="handleTeamChange"
@add-patient="handleAddPatient"
/>
-
@@ -53,7 +52,7 @@
{{
- conversation.lastMessage || "暂无消息"
+ cleanMessageText(conversation.lastMessage) || "暂无消息"
}}
@@ -61,7 +60,14 @@
+
+ 暂无会话
+
+
@@ -92,7 +98,7 @@ 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";
+import MessageHeader from "../home/components/message-header.vue";
// 获取登录状态
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
@@ -156,46 +162,191 @@ const handleAddPatient = withInfo(() => {
});
});
+// 立即更新未读徽章
+const updateUnreadBadgeImmediately = async () => {
+ try {
+ if (!globalTimChatManager || !globalTimChatManager.tim) {
+ console.warn("TIM实例不存在,无法更新徽章");
+ return;
+ }
+
+ const response = await globalTimChatManager.tim.getConversationList();
+
+ if (!response || !response.data || !response.data.conversationList) {
+ console.warn("获取会话列表返回数据异常");
+ return;
+ }
+
+ // 计算群聊总未读数
+ const totalUnreadCount = response.data.conversationList
+ .filter(
+ (conv) => conv.conversationID && conv.conversationID.startsWith("GROUP")
+ )
+ .reduce((sum, conv) => sum + (conv.unreadCount || 0), 0);
+
+ // 更新 tabBar 徽章 - 添加错误处理,防止在非TabBar页面调用时出错
+ try {
+ if (totalUnreadCount > 0) {
+ uni.setTabBarBadge({
+ index: 1,
+ text: totalUnreadCount > 99 ? "99+" : String(totalUnreadCount),
+ });
+ console.log("已更新 tabBar 徽章:", totalUnreadCount);
+ } else {
+ uni.removeTabBarBadge({
+ index: 1,
+ });
+ console.log("已移除 tabBar 徽章");
+ }
+ } catch (badgeError) {
+ // 在非TabBar页面上调用时会出错,这是正常的,不需要处理
+ if (badgeError.errMsg && badgeError.errMsg.includes("not TabBar page")) {
+ console.log("当前不是TabBar页面,跳过徽章更新");
+ } else {
+ console.error("更新TabBar徽章失败:", badgeError);
+ }
+ }
+ } catch (error) {
+ console.error("更新未读徽章失败:", error);
+ }
+};
+
// 初始化IM
const initIM = async () => {
- if (!isIMInitialized.value) {
+ // 关键修复:不仅检查 isIMInitialized,还要检查实际连接状态
+ const needsInit =
+ !isIMInitialized.value ||
+ !globalTimChatManager ||
+ !globalTimChatManager.isLoggedIn;
+
+ if (needsInit) {
uni.showLoading({
title: "连接中...",
});
+
+ // 如果已初始化但连接断开,先清理旧实例
+ if (
+ isIMInitialized.value &&
+ globalTimChatManager &&
+ !globalTimChatManager.isLoggedIn
+ ) {
+ console.log("IM已初始化但连接已断开,清理旧实例后重新初始化");
+ await globalTimChatManager.cleanupOldInstance();
+ }
+
const success = await initIMAfterLogin();
uni.hideLoading();
- // if (!success) {
- // uni.showToast({
- // title: "IM连接失败,请重试",
- // icon: "none",
- // });
- // return false;
- // }
- } else if (globalTimChatManager && !globalTimChatManager.isLoggedIn) {
- uni.showLoading({
- title: "重连中...",
- });
- const reconnected = await globalTimChatManager.ensureIMConnection();
- uni.hideLoading();
- if (!reconnected) {
- return false;
+ if (!success) {
+ handleReloginIM();
+ // // 显示重试提示
+ // uni.showModal({
+ // title: "IM连接失败",
+ // content:
+ // "连接失败,请检查网络后重试。如果IM连接失败,请重新登陆IM再连接",
+ // confirmText: "重新登陆",
+ // cancelText: "取消",
+ // success: (res) => {
+ // if (res.confirm) {
+ // // 重新登陆
+ // handleReloginIM();
+ // }
+ // },
+ // });
+ // return false;
}
}
return true;
};
+// 重新登陆IM
+const handleReloginIM = async () => {
+ try {
+ uni.showLoading({
+ title: "重新登陆中...",
+ });
+
+ // 清理旧的IM实例
+ if (globalTimChatManager) {
+ await globalTimChatManager.cleanupOldInstance();
+ }
+
+ // 重新初始化IM
+ const { initIMAfterLogin } = useAccountStore();
+ const success = await initIMAfterLogin();
+ uni.hideLoading();
+
+ if (success) {
+ // uni.showToast({
+ // title: "IM连接成功",
+ // icon: "success",
+ // });
+ // 重新加载会话列表
+ await loadConversationList();
+ setupConversationListener();
+ } else {
+ // uni.showToast({
+ // title: "IM连接失败,请检查网络",
+ // icon: "none",
+ // });
+ }
+ } catch (error) {
+ uni.hideLoading();
+ console.error("重新登陆IM失败:", error);
+ // uni.showToast({
+ // title: "重新登陆失败",
+ // icon: "none",
+ // });
+ }
+};
+
// 加载会话列表
const loadConversationList = async () => {
if (loading.value) return;
loading.value = true;
try {
console.log("开始加载群聊列表");
- if (!globalTimChatManager || !globalTimChatManager.getGroupList) {
- loading.value = false;
- return;
+
+ // 确保 IM 已连接
+ if (!globalTimChatManager) {
+ throw new Error("IM管理器未初始化");
}
- const result = await globalTimChatManager.getGroupList();
+
+ // 检查 TIM 实例是否存在
+ if (!globalTimChatManager.tim) {
+ console.warn("TIM实例不存在,尝试重新初始化IM");
+ const reinitialized = await initIMAfterLogin();
+ if (!reinitialized) {
+ throw new Error("IM重新初始化失败");
+ }
+ }
+
+ // 检查是否已登录 - 这是关键检查
+ if (!globalTimChatManager.isLoggedIn) {
+ console.warn("IM未登录,尝试重新连接");
+ const reconnected = await globalTimChatManager.ensureIMConnection();
+ if (!reconnected) {
+ throw new Error("IM重新连接失败");
+ }
+ }
+
+ if (!globalTimChatManager.getGroupList) {
+ throw new Error("IM管理器方法不可用");
+ }
+
+ // 添加超时控制,防止永久等待
+ const timeoutPromise = new Promise((_, reject) => {
+ setTimeout(
+ () => reject(new Error("加载会话列表超时,请检查网络连接")),
+ 35000
+ );
+ });
+
+ const result = await Promise.race([
+ globalTimChatManager.getGroupList(),
+ timeoutPromise,
+ ]);
+
if (result && result.success && result.groupList) {
// 合并后端群组详细信息(已包含格式化和排序)
conversationList.value = await mergeConversationWithGroupDetails(
@@ -218,17 +369,26 @@ const loadConversationList = async () => {
);
} else {
console.error("加载群聊列表失败:", result);
- uni.showToast({
- title: "加载失败,请重试",
- icon: "none",
- });
+ throw new Error(result?.message || "加载失败,请重试");
}
} catch (error) {
console.error("加载会话列表失败:", error);
- uni.showToast({
- title: error.message || "加载失败,请重试",
- icon: "none",
- });
+
+ // 如果是超时或连接错误,提示用户重试
+ if (
+ error.message &&
+ (error.message.includes("超时") || error.message.includes("连接"))
+ ) {
+ uni.showToast({
+ title: "网络连接不稳定,请重试",
+ icon: "none",
+ });
+ } else {
+ uni.showToast({
+ title: error.message || "加载失败,请重试",
+ icon: "none",
+ });
+ }
} finally {
loading.value = false;
}
@@ -389,6 +549,12 @@ const setupConversationListener = () => {
});
};
+// 清理消息文本(移除换行符)
+const cleanMessageText = (text) => {
+ if (!text) return "";
+ return text.replace(/[\r\n]+/g, " ").trim();
+};
+
// 格式化患者姓名
const formatPatientName = (conversation) => {
return conversation.patientName || "未知患者";
@@ -506,7 +672,7 @@ onShow(async () => {
// 加载团队列表
await getTeams();
- // 初始化IM
+ // 初始化IM - 关键修复:确保IM连接状态正确
const imReady = await initIM();
if (!imReady) {
console.error("IM初始化失败");
@@ -682,7 +848,10 @@ onHide(() => {
color: #999;
overflow: hidden;
text-overflow: ellipsis;
- white-space: nowrap;
+ display: -webkit-box;
+ -webkit-line-clamp: 1;
+ -webkit-box-orient: vertical;
+ word-break: break-all;
}
.load-more {
diff --git a/pages/message/chat.scss b/pages/message/chat.scss
index aa26749..a0124af 100644
--- a/pages/message/chat.scss
+++ b/pages/message/chat.scss
@@ -15,7 +15,8 @@ $primary-color: #0877F1;
/* 患者信息栏样式 */
.patient-info-bar {
- position: relative;
+ position: sticky;
+ top: 0;
background: #fff;
border-bottom: 1rpx solid #f0f0f0;
padding: 20rpx 32rpx;
@@ -87,6 +88,7 @@ $primary-color: #0877F1;
flex: 1;
box-sizing: border-box;
overflow-x: hidden;
+ overflow-y: auto;
min-height: 0;
}
diff --git a/pages/message/message.vue b/pages/message/message.vue
deleted file mode 100644
index 5adc1f9..0000000
--- a/pages/message/message.vue
+++ /dev/null
@@ -1,856 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- {{
- conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
- }}
-
-
-
-
-
-
- {{
- conversation.lastMessage || "暂无消息"
- }}
-
-
-
-
-
-
-
- 医生信息未获取,请稍后重试
-
-
-
- {{
- activeTab === "processing" ? "暂无处理中的会话" : "暂无已结束的会话"
- }}
-
-
-
-
- {{
- loadingMore ? "加载中..." : "上拉加载更多"
- }}
-
-
-
-
-
-
-
-
\ No newline at end of file
From 53a53c7b6d99460ba37a68d42a809f0c59985cee Mon Sep 17 00:00:00 2001
From: wangdongbo <949818794@qq.com>
Date: Mon, 9 Feb 2026 14:55:29 +0800
Subject: [PATCH 04/13] no message
---
.../archive-detail/follow-up-manage-tab.vue | 158 +++++++++++-------
pages/message/chat.scss | 16 +-
pages/message/index.vue | 10 ++
store/account.js | 3 +-
utils/send-message-helper.js | 1 +
5 files changed, 126 insertions(+), 62 deletions(-)
diff --git a/pages/case/components/archive-detail/follow-up-manage-tab.vue b/pages/case/components/archive-detail/follow-up-manage-tab.vue
index be97c5c..a4d9f62 100644
--- a/pages/case/components/archive-detail/follow-up-manage-tab.vue
+++ b/pages/case/components/archive-detail/follow-up-manage-tab.vue
@@ -92,9 +92,11 @@
{
if (loading.value) return "loading";
@@ -512,73 +515,88 @@ function toDetail(todo) {
}
async function sendFollowUp(todo) {
+ if (sendingFollowUp.value) {
+ toast("正在发送中,请稍候...");
+ return;
+ }
+
if (!todo.sendContent && (!todo.fileList || todo.fileList.length === 0)) {
toast("没有发送内容");
return;
}
- const messages = [];
+ sendingFollowUp.value = true;
+ try {
+ const messages = [];
- // 1. 发送文字内容
- if (todo.sendContent) {
- messages.push({
- type: "text",
- content: todo.sendContent,
- });
- }
- console.log("==============>fileList", todo.fileList);
+ // 1. 发送文字内容
+ if (todo.sendContent) {
+ messages.push({
+ type: "text",
+ content: todo.sendContent,
+ });
+ }
+ console.log("==============>fileList", todo.fileList);
- // 2. 处理文件列表(图片、宣教文章、问卷)
- if (Array.isArray(todo.fileList)) {
- for (const file of todo.fileList) {
- if (file.type === "image" && file.URL) {
- // 发送图片
- messages.push({
- type: "image",
- content: file.URL,
- name: file.file?.name || file.name || "图片",
- });
- } else if (file.file.type === "article" && file.file?.url) {
- // 发送宣教文章 - 从 URL 中解析 id
- const articleId = extractIdFromUrl(file.file.url);
- messages.push({
- type: "article",
- content: {
- _id: articleId,
- title: file.file?.name || "宣教文章",
- url: file.file?.url || file.URL,
- subtitle: file.file?.subtitle || "",
- cover: file.file?.cover || "",
- articleId: articleId,
- },
- });
- } else if (file.file.type === "questionnaire" && file.file?.surveryId) {
- // 发送问卷
- messages.push({
- type: "questionnaire",
- content: {
- _id: file.file?._id || file._id,
- name: file.file?.name || file.name || "问卷",
- surveryId: file.file?.surveryId || file.surveryId,
- url: file.file?.url || file.URL,
- },
- });
+ // 2. 处理文件列表(图片、宣教文章、问卷)
+ if (Array.isArray(todo.fileList)) {
+ for (const file of todo.fileList) {
+ if (file.type === "image" && file.URL) {
+ // 发送图片
+ messages.push({
+ type: "image",
+ content: file.URL,
+ name: file.file?.name || file.name || "图片",
+ });
+ } else if (file.file.type === "article" && file.file?.url) {
+ // 发送宣教文章 - 从 URL 中解析 id
+ const articleId = extractIdFromUrl(file.file.url);
+ messages.push({
+ type: "article",
+ content: {
+ _id: articleId,
+ title: file.file?.name || "宣教文章",
+ url: file.file?.url || file.URL,
+ subtitle: file.file?.subtitle || "",
+ cover: file.file?.cover || "",
+ articleId: articleId,
+ },
+ });
+ } else if (
+ file.file.type === "questionnaire" &&
+ (file.file?.url || file.URL)
+ ) {
+ // 发送问卷 - 从 URL 中解析 surveryId
+ const surveryUrl = file.file?.url || file.URL;
+ const surveryId = extractSurveryIdFromUrl(surveryUrl);
+ messages.push({
+ type: "questionnaire",
+ content: {
+ _id: surveryId,
+ name: file.file?.name || file.name || "问卷",
+ surveryId: surveryId,
+ url: surveryUrl,
+ },
+ });
+ }
}
}
- }
- // 调用统一的消息发送处理函数
- const success = await handleFollowUpMessages(messages, {
- userId: getUserId(),
- customerId: props.archiveId,
- customerName: props.data?.name || "",
- corpId: getCorpId(),
- env: __VITE_ENV__,
- });
+ // 调用统一的消息发送处理函数
+ const success = await handleFollowUpMessages(messages, {
+ userId: getUserId(),
+ customerId: props.archiveId,
+ customerName: props.data?.name || "",
+ corpId: getCorpId(),
+ env: __VITE_ENV__,
+ });
- if (success) {
- toast("消息已发送");
- uni.navigateBack();
+ if (success) {
+ toast("消息已发送");
+ uni.navigateBack();
+ }
+ } finally {
+ sendingFollowUp.value = false;
}
}
@@ -606,6 +624,24 @@ function extractIdFromUrl(url) {
}
}
+/**
+ * 从问卷 URL 中提取 surveryId 参数
+ * @param {string} url - 完整的 URL,格式如: https://www.youcan365.com/patientDeploy/#/pages/survery/fill?corpId=wwe3fb2faa52cf9dfb&surveryId=9ji5kg2oa9x52oyg9w4rj5k81769510562099
+ * @returns {string} 提取出的 surveryId 值
+ */
+function extractSurveryIdFromUrl(url) {
+ if (!url) return "";
+ try {
+ // 使用正则表达式提取 surveryId 参数
+ // 处理格式: ?surveryId=xxx 或 &surveryId=xxx
+ const match = url.match(/[?&]surveryId=([^&]+)/);
+ return match ? decodeURIComponent(match[1]) : "";
+ } catch (error) {
+ console.error("解析问卷 URL 失败:", error);
+ return "";
+ }
+}
+
// ---- filter popup ----
const filterPopupRef = ref(null);
const state = ref(null);
@@ -976,6 +1012,14 @@ watch(
color: #fff;
}
+.send-btn.loading {
+ opacity: 0.6;
+}
+
+.send-btn:disabled {
+ opacity: 0.6;
+}
+
.empty {
padding: 120px 0;
text-align: center;
diff --git a/pages/message/chat.scss b/pages/message/chat.scss
index a0124af..320ab16 100644
--- a/pages/message/chat.scss
+++ b/pages/message/chat.scss
@@ -11,17 +11,23 @@ $primary-color: #0877F1;
height: 100vh;
background-color: #f5f5f5;
overflow: hidden;
+ position: relative;
+ width: 100%;
}
-/* 患者信息栏样式 */
+/* 患者信息栏样式 - 固定在顶部 */
.patient-info-bar {
- position: sticky;
+ position: fixed;
top: 0;
+ left: 0;
+ right: 0;
background: #fff;
border-bottom: 1rpx solid #f0f0f0;
padding: 20rpx 32rpx;
- z-index: 10;
+ z-index: 100;
flex-shrink: 0; /* 防止被压缩 */
+ width: 100%;
+ box-sizing: border-box;
}
.patient-info-content {
@@ -90,6 +96,10 @@ $primary-color: #0877F1;
overflow-x: hidden;
overflow-y: auto;
min-height: 0;
+ margin-top: 120rpx;
+ margin-bottom: 0;
+ position: relative;
+ z-index: 1;
}
.chat-content-compressed {
diff --git a/pages/message/index.vue b/pages/message/index.vue
index a2fac16..127ff71 100644
--- a/pages/message/index.vue
+++ b/pages/message/index.vue
@@ -782,6 +782,16 @@ onShow(() => {
// 监听回访任务发送事件
uni.$on("send-followup-message", handleSendFollowUpMessage);
+
+ // 监听键盘高度变化,自动滚动到底部
+ uni.onKeyboardHeightChange((res) => {
+ if (res.height > 0) {
+ // 键盘弹出,延迟滚动到底部
+ setTimeout(() => {
+ scrollToBottom(true);
+ }, 100);
+ }
+ });
});
// 处理发送回访任务消息
diff --git a/store/account.js b/store/account.js
index a618b95..82d41d9 100644
--- a/store/account.js
+++ b/store/account.js
@@ -109,8 +109,7 @@ export default defineStore("accountStore", () => {
async function initIMAfterLogin() {
if (isIMInitialized.value) return true;
if (!doctorInfo.value) {
- console.error('医生信息未获取,无法初始化IM');
- return false;
+ await getDoctorInfo();
}
try {
const userID = doctorInfo.value.userid;
diff --git a/utils/send-message-helper.js b/utils/send-message-helper.js
index 9790add..01bc69a 100644
--- a/utils/send-message-helper.js
+++ b/utils/send-message-helper.js
@@ -358,6 +358,7 @@ export async function handleFollowUpMessages(messages, context = {}) {
corpId: context.corpId,
});
} else if (msg.type === 'questionnaire') {
+
success = await sendSurveyMessage(msg.content, {
userId: context.userId,
customerId: context.customerId,
From c34602655f7f54114d5f0b334b0e3643811a179c Mon Sep 17 00:00:00 2001
From: wangdongbo <949818794@qq.com>
Date: Mon, 9 Feb 2026 15:11:36 +0800
Subject: [PATCH 05/13] no message
---
pages/case/ai-medical-case-form.vue | 7 +++++++
pages/message/components/medical-case-progress.vue | 1 +
2 files changed, 8 insertions(+)
diff --git a/pages/case/ai-medical-case-form.vue b/pages/case/ai-medical-case-form.vue
index 89e7790..5a09324 100644
--- a/pages/case/ai-medical-case-form.vue
+++ b/pages/case/ai-medical-case-form.vue
@@ -92,6 +92,7 @@ const FIELD_LABELS = {
inspectSummary: "体检小结",
positiveFind: "阳性发现及处理意见",
// 预问诊记录
+ consultationDate: "问诊日期",
presentIllnessHistory: "现病史",
pastMedicalHistory: "既往史",
};
@@ -213,6 +214,12 @@ const FIELD_CONFIG = {
},
],
preConsultation: [
+ {
+ key: "consultationDate",
+ label: FIELD_LABELS.consultationDate,
+ type: "date",
+ required: true,
+ },
{
key: "chiefComplaint",
label: FIELD_LABELS.chiefComplaint,
diff --git a/pages/message/components/medical-case-progress.vue b/pages/message/components/medical-case-progress.vue
index c2803ab..5e9ff82 100644
--- a/pages/message/components/medical-case-progress.vue
+++ b/pages/message/components/medical-case-progress.vue
@@ -93,6 +93,7 @@ const FIELD_LABELS = {
inspectSummary: "体检小结",
positiveFind: "阳性发现及处理意见",
// 预问诊记录
+ consultationDate: "问诊日期",
presentIllnessHistory: "现病史",
pastMedicalHistory: "既往史",
};
From dc4d8f9b1b5a468eddac46ac59ac91c3faefd777 Mon Sep 17 00:00:00 2001
From: wangdongbo <949818794@qq.com>
Date: Mon, 9 Feb 2026 15:40:11 +0800
Subject: [PATCH 06/13] no message
---
.../components/archive-detail/follow-up-manage-tab.vue | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/pages/case/components/archive-detail/follow-up-manage-tab.vue b/pages/case/components/archive-detail/follow-up-manage-tab.vue
index a4d9f62..6d84d42 100644
--- a/pages/case/components/archive-detail/follow-up-manage-tab.vue
+++ b/pages/case/components/archive-detail/follow-up-manage-tab.vue
@@ -90,7 +90,7 @@