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 <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,11 +515,18 @@ 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;
} }
sendingFollowUp.value = true;
try {
const messages = []; const messages = [];
// 1. // 1.
@ -552,15 +562,20 @@ async function sendFollowUp(todo) {
articleId: articleId, articleId: articleId,
}, },
}); });
} else if (file.file.type === "questionnaire" && file.file?.surveryId) { } 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({ messages.push({
type: "questionnaire", type: "questionnaire",
content: { content: {
_id: file.file?._id || file._id, _id: surveryId,
name: file.file?.name || file.name || "问卷", name: file.file?.name || file.name || "问卷",
surveryId: file.file?.surveryId || file.surveryId, surveryId: surveryId,
url: file.file?.url || file.URL, url: surveryUrl,
}, },
}); });
} }
@ -580,6 +595,9 @@ async function sendFollowUp(todo) {
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;

View File

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

View File

@ -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);
}
});
}); });
// 访 // 访

View File

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

View File

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