no message

This commit is contained in:
wangdongbo 2026-02-09 14:55:29 +08:00
parent c836420191
commit 53a53c7b6d
5 changed files with 126 additions and 62 deletions

View File

@ -92,9 +92,11 @@
<button
v-if="fromChat"
class="action-btn send-btn"
:class="{ loading: sendingFollowUp }"
:disabled="sendingFollowUp"
@click.stop="sendFollowUp(i)"
>
发送
{{ sendingFollowUp ? "发送中..." : "发送" }}
</button>
</view>
<view v-if="i.status === 'treated'" class="result"
@ -276,6 +278,7 @@ const pages = ref(1);
const loading = ref(false);
const userNameMap = ref({});
const sendingFollowUp = ref(false);
const moreStatus = computed(() => {
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;

View File

@ -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 {

View File

@ -782,6 +782,16 @@ onShow(() => {
// 访
uni.$on("send-followup-message", handleSendFollowUpMessage);
//
uni.onKeyboardHeightChange((res) => {
if (res.height > 0) {
//
setTimeout(() => {
scrollToBottom(true);
}, 100);
}
});
});
// 访

View File

@ -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;

View File

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