diff --git a/pages/message/index.vue b/pages/message/index.vue index 8cb1442..d6add75 100644 --- a/pages/message/index.vue +++ b/pages/message/index.vue @@ -85,7 +85,6 @@ }} - - - - - + { stopIMMonitoring(); }); - const sendCommonPhrase = (content) => { if (chatInputRef.value) { chatInputRef.value.sendTextMessageFromPhrase(content); @@ -717,52 +705,27 @@ defineExpose({ const handleCancelConsult = async () => { try { uni.showModal({ - title: '提示', - content: '确定要取消咨询申请吗?', + title: "提示", + content: "确定要取消咨询申请吗?", success: async (res) => { if (res.confirm) { uni.showLoading({ title: "处理中...", }); - try { - // 发送取消申请的系统消息 - const customMessage = { - data: JSON.stringify({ - type: "system_message", - messageType: "consult_cancelled", - content: "患者已取消咨询申请", - timestamp: Date.now(), - }), - description: "系统消息标记", - extension: "", - }; - - const message = timChatManager.tim.createCustomMessage({ - to: chatInfo.value.conversationID.replace("GROUP", ""), - conversationType: timChatManager.TIM.TYPES.CONV_GROUP, - payload: customMessage, + // 调用取消咨询申请接口 + const result = await api("cancelConsultApplication", { + groupId: groupId.value, + corpId: corpId, }); - - const sendResult = await timChatManager.tim.sendMessage(message); - - if (sendResult.code === 0) { + uni.hideLoading(); + if (result.success) { showConsultCancel.value = false; - uni.hideLoading(); - uni.showToast({ - title: "已取消申请", - icon: "success", - duration: 1500, + uni.switchTab({ + url: "/pages/home/home", }); - - // 延迟返回首页 - setTimeout(() => { - uni.switchTab({ - url: "/pages/home/home", - }); - }, 1500); } else { - throw new Error(sendResult.message || "发送失败"); + throw new Error(result.message || "取消申请失败"); } } catch (error) { console.error("取消申请失败:", error); @@ -773,7 +736,7 @@ const handleCancelConsult = async () => { }); } } - } + }, }); } catch (error) { console.error("取消申请失败:", error); @@ -791,7 +754,7 @@ const handleEndConsult = async () => { title: "处理中...", }); // 调用结束问诊接口,直接传入 groupId - const result = await api('endConsultation', { + const result = await api("endConsultation", { groupId: groupId.value, adminAccount: account.value?.userId || "", extraData: { @@ -832,7 +795,6 @@ onUnmounted(() => { uni.$off("sendSurvey"); }); - // 监听问卷发送事件 uni.$on("sendSurvey", async (data) => { const { survey, corpId, userId, sendSurveyId } = data; diff --git a/utils/api.js b/utils/api.js index 42e729c..332109c 100644 --- a/utils/api.js +++ b/utils/api.js @@ -50,13 +50,14 @@ const urlsConfig = { addContactWay: 'addContactWay' }, im: { - getUserSig: 'getUserSig', + getUserSig: 'getUserSig', sendSystemMessage: "sendSystemMessage", getChatRecordsByGroupId: "getChatRecordsByGroupId", sendConsultRejectedMessage: "sendConsultRejectedMessage", endConsultation: "endConsultation", getGroupListByGroupId: "getGroupListByGroupId", - createConsultGroup: "createConsultGroup" + createConsultGroup: "createConsultGroup", + cancelConsultApplication: "cancelConsultApplication" } } const urls = Object.keys(urlsConfig).reduce((acc, path) => {