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] 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,