no message
This commit is contained in:
parent
c836420191
commit
53a53c7b6d
@ -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;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -782,6 +782,16 @@ onShow(() => {
|
||||
|
||||
// 监听回访任务发送事件
|
||||
uni.$on("send-followup-message", handleSendFollowUpMessage);
|
||||
|
||||
// 监听键盘高度变化,自动滚动到底部
|
||||
uni.onKeyboardHeightChange((res) => {
|
||||
if (res.height > 0) {
|
||||
// 键盘弹出,延迟滚动到底部
|
||||
setTimeout(() => {
|
||||
scrollToBottom(true);
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 处理发送回访任务消息
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user