no message
This commit is contained in:
parent
c836420191
commit
53a53c7b6d
@ -92,9 +92,11 @@
|
|||||||
<button
|
<button
|
||||||
v-if="fromChat"
|
v-if="fromChat"
|
||||||
class="action-btn send-btn"
|
class="action-btn send-btn"
|
||||||
|
:class="{ loading: sendingFollowUp }"
|
||||||
|
:disabled="sendingFollowUp"
|
||||||
@click.stop="sendFollowUp(i)"
|
@click.stop="sendFollowUp(i)"
|
||||||
>
|
>
|
||||||
发送
|
{{ sendingFollowUp ? "发送中..." : "发送" }}
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="i.status === 'treated'" class="result"
|
<view v-if="i.status === 'treated'" class="result"
|
||||||
@ -276,6 +278,7 @@ const pages = ref(1);
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const userNameMap = ref({});
|
const userNameMap = ref({});
|
||||||
|
const sendingFollowUp = ref(false);
|
||||||
|
|
||||||
const moreStatus = computed(() => {
|
const moreStatus = computed(() => {
|
||||||
if (loading.value) return "loading";
|
if (loading.value) return "loading";
|
||||||
@ -512,73 +515,88 @@ function toDetail(todo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function sendFollowUp(todo) {
|
async function sendFollowUp(todo) {
|
||||||
|
if (sendingFollowUp.value) {
|
||||||
|
toast("正在发送中,请稍候...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!todo.sendContent && (!todo.fileList || todo.fileList.length === 0)) {
|
if (!todo.sendContent && (!todo.fileList || todo.fileList.length === 0)) {
|
||||||
toast("没有发送内容");
|
toast("没有发送内容");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const messages = [];
|
sendingFollowUp.value = true;
|
||||||
|
try {
|
||||||
|
const messages = [];
|
||||||
|
|
||||||
// 1. 发送文字内容
|
// 1. 发送文字内容
|
||||||
if (todo.sendContent) {
|
if (todo.sendContent) {
|
||||||
messages.push({
|
messages.push({
|
||||||
type: "text",
|
type: "text",
|
||||||
content: todo.sendContent,
|
content: todo.sendContent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log("==============>fileList", todo.fileList);
|
console.log("==============>fileList", todo.fileList);
|
||||||
|
|
||||||
// 2. 处理文件列表(图片、宣教文章、问卷)
|
// 2. 处理文件列表(图片、宣教文章、问卷)
|
||||||
if (Array.isArray(todo.fileList)) {
|
if (Array.isArray(todo.fileList)) {
|
||||||
for (const file of todo.fileList) {
|
for (const file of todo.fileList) {
|
||||||
if (file.type === "image" && file.URL) {
|
if (file.type === "image" && file.URL) {
|
||||||
// 发送图片
|
// 发送图片
|
||||||
messages.push({
|
messages.push({
|
||||||
type: "image",
|
type: "image",
|
||||||
content: file.URL,
|
content: file.URL,
|
||||||
name: file.file?.name || file.name || "图片",
|
name: file.file?.name || file.name || "图片",
|
||||||
});
|
});
|
||||||
} else if (file.file.type === "article" && file.file?.url) {
|
} else if (file.file.type === "article" && file.file?.url) {
|
||||||
// 发送宣教文章 - 从 URL 中解析 id
|
// 发送宣教文章 - 从 URL 中解析 id
|
||||||
const articleId = extractIdFromUrl(file.file.url);
|
const articleId = extractIdFromUrl(file.file.url);
|
||||||
messages.push({
|
messages.push({
|
||||||
type: "article",
|
type: "article",
|
||||||
content: {
|
content: {
|
||||||
_id: articleId,
|
_id: articleId,
|
||||||
title: file.file?.name || "宣教文章",
|
title: file.file?.name || "宣教文章",
|
||||||
url: file.file?.url || file.URL,
|
url: file.file?.url || file.URL,
|
||||||
subtitle: file.file?.subtitle || "",
|
subtitle: file.file?.subtitle || "",
|
||||||
cover: file.file?.cover || "",
|
cover: file.file?.cover || "",
|
||||||
articleId: articleId,
|
articleId: articleId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if (file.file.type === "questionnaire" && file.file?.surveryId) {
|
} else if (
|
||||||
// 发送问卷
|
file.file.type === "questionnaire" &&
|
||||||
messages.push({
|
(file.file?.url || file.URL)
|
||||||
type: "questionnaire",
|
) {
|
||||||
content: {
|
// 发送问卷 - 从 URL 中解析 surveryId
|
||||||
_id: file.file?._id || file._id,
|
const surveryUrl = file.file?.url || file.URL;
|
||||||
name: file.file?.name || file.name || "问卷",
|
const surveryId = extractSurveryIdFromUrl(surveryUrl);
|
||||||
surveryId: file.file?.surveryId || file.surveryId,
|
messages.push({
|
||||||
url: file.file?.url || file.URL,
|
type: "questionnaire",
|
||||||
},
|
content: {
|
||||||
});
|
_id: surveryId,
|
||||||
|
name: file.file?.name || file.name || "问卷",
|
||||||
|
surveryId: surveryId,
|
||||||
|
url: surveryUrl,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 调用统一的消息发送处理函数
|
// 调用统一的消息发送处理函数
|
||||||
const success = await handleFollowUpMessages(messages, {
|
const success = await handleFollowUpMessages(messages, {
|
||||||
userId: getUserId(),
|
userId: getUserId(),
|
||||||
customerId: props.archiveId,
|
customerId: props.archiveId,
|
||||||
customerName: props.data?.name || "",
|
customerName: props.data?.name || "",
|
||||||
corpId: getCorpId(),
|
corpId: getCorpId(),
|
||||||
env: __VITE_ENV__,
|
env: __VITE_ENV__,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
toast("消息已发送");
|
toast("消息已发送");
|
||||||
uni.navigateBack();
|
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 ----
|
// ---- filter popup ----
|
||||||
const filterPopupRef = ref(null);
|
const filterPopupRef = ref(null);
|
||||||
const state = ref(null);
|
const state = ref(null);
|
||||||
@ -976,6 +1012,14 @@ watch(
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.send-btn.loading {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.send-btn:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
padding: 120px 0;
|
padding: 120px 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@ -11,17 +11,23 @@ $primary-color: #0877F1;
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 患者信息栏样式 */
|
/* 患者信息栏样式 - 固定在顶部 */
|
||||||
.patient-info-bar {
|
.patient-info-bar {
|
||||||
position: sticky;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-bottom: 1rpx solid #f0f0f0;
|
border-bottom: 1rpx solid #f0f0f0;
|
||||||
padding: 20rpx 32rpx;
|
padding: 20rpx 32rpx;
|
||||||
z-index: 10;
|
z-index: 100;
|
||||||
flex-shrink: 0; /* 防止被压缩 */
|
flex-shrink: 0; /* 防止被压缩 */
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.patient-info-content {
|
.patient-info-content {
|
||||||
@ -90,6 +96,10 @@ $primary-color: #0877F1;
|
|||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
margin-top: 120rpx;
|
||||||
|
margin-bottom: 0;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-content-compressed {
|
.chat-content-compressed {
|
||||||
|
|||||||
@ -782,6 +782,16 @@ onShow(() => {
|
|||||||
|
|
||||||
// 监听回访任务发送事件
|
// 监听回访任务发送事件
|
||||||
uni.$on("send-followup-message", handleSendFollowUpMessage);
|
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() {
|
async function initIMAfterLogin() {
|
||||||
if (isIMInitialized.value) return true;
|
if (isIMInitialized.value) return true;
|
||||||
if (!doctorInfo.value) {
|
if (!doctorInfo.value) {
|
||||||
console.error('医生信息未获取,无法初始化IM');
|
await getDoctorInfo();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const userID = doctorInfo.value.userid;
|
const userID = doctorInfo.value.userid;
|
||||||
|
|||||||
@ -358,6 +358,7 @@ export async function handleFollowUpMessages(messages, context = {}) {
|
|||||||
corpId: context.corpId,
|
corpId: context.corpId,
|
||||||
});
|
});
|
||||||
} else if (msg.type === 'questionnaire') {
|
} else if (msg.type === 'questionnaire') {
|
||||||
|
|
||||||
success = await sendSurveyMessage(msg.content, {
|
success = await sendSurveyMessage(msg.content, {
|
||||||
userId: context.userId,
|
userId: context.userId,
|
||||||
customerId: context.customerId,
|
customerId: context.customerId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user