From 4cd0953b0f9adda290ffe5e422946c5429458123 Mon Sep 17 00:00:00 2001 From: Jafeng <2998840497@qq.com> Date: Wed, 4 Feb 2026 18:39:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=9B=A2?= =?UTF-8?q?=E9=98=9FID=E6=94=AF=E6=8C=81=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=BB=84=E4=BB=B6=E4=BB=A5=E4=BC=A0=E9=80=92?= =?UTF-8?q?=E5=9B=A2=E9=98=9F=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/message/article-list.vue | 22 ++++++++ pages/message/components/chat-input.vue | 7 +-- pages/message/index.vue | 70 +++++++++++++------------ pages/message/survey-list.vue | 23 ++++++++ 4 files changed, 86 insertions(+), 36 deletions(-) diff --git a/pages/message/article-list.vue b/pages/message/article-list.vue index b9df060..ee835f9 100644 --- a/pages/message/article-list.vue +++ b/pages/message/article-list.vue @@ -122,8 +122,24 @@ const pageParams = ref({ groupId: "", patientId: "", corpId: "", + teamId: "", }); +const ensureTeamId = async () => { + if (pageParams.value.teamId) return pageParams.value.teamId; + if (!pageParams.value.groupId) return ""; + try { + const res = await api("getGroupListByGroupId", { groupId: pageParams.value.groupId }, false); + const team = res?.data?.team || {}; + const resolved = res?.data?.teamId || team.teamId || team._id || ""; + if (resolved) pageParams.value.teamId = resolved; + return pageParams.value.teamId; + } catch (err) { + console.error("ensureTeamId failed:", err); + return ""; + } +}; + const isSelectMode = ref(false); const selectEventName = ref(""); @@ -383,11 +399,13 @@ const sendArticle = async (article) => { // 3. 记录文章发送记录 try { + await ensureTeamId(); await api("addArticleSendRecord", { articleId: article._id, userId: doctorInfo.userid, customerId: pageParams.value.patientId, corpId: corpId, + teamId: pageParams.value.teamId, }); } catch (recordError) { console.error("记录文章发送失败:", recordError); @@ -426,6 +444,10 @@ onLoad((options) => { if (options.corpId) { pageParams.value.corpId = options.corpId; } + if (options.teamId) { + pageParams.value.teamId = options.teamId; + } + ensureTeamId(); }); onMounted(() => { diff --git a/pages/message/components/chat-input.vue b/pages/message/components/chat-input.vue index 391e1bf..3dc193d 100644 --- a/pages/message/components/chat-input.vue +++ b/pages/message/components/chat-input.vue @@ -76,6 +76,7 @@ const props = defineProps({ formatTime: { type: Function, required: true }, groupId: { type: String, default: "" }, userId: { type: String, default: "" }, + teamId: { type: String, default: "" }, patientId: { type: String, default: "" }, corpId: { type: String, default: "" }, }); @@ -375,14 +376,14 @@ const showFollowUpTasks = () => { // 跳转到宣教文章页面 const goToArticleList = () => { uni.navigateTo({ - url: `/pages/message/article-list?groupId=${props.groupId}&patientId=${props.patientId}&corpId=${props.corpId}`, + url: `/pages/message/article-list?groupId=${props.groupId}&patientId=${props.patientId}&corpId=${props.corpId}&teamId=${props.teamId}`, }); }; // 跳转到问卷列表页面 const goToSurveyList = () => { uni.navigateTo({ - url: `/pages/message/survey-list?groupId=${props.groupId}&patientId=${props.patientId}&corpId=${props.corpId}&customerName=${props.patientInfo.name}`, + url: `/pages/message/survey-list?groupId=${props.groupId}&patientId=${props.patientId}&corpId=${props.corpId}&teamId=${props.teamId}&customerName=${props.patientInfo.name}`, }); }; @@ -466,4 +467,4 @@ onUnmounted(() => { \ No newline at end of file + diff --git a/pages/message/index.vue b/pages/message/index.vue index a4061d8..4692a2b 100644 --- a/pages/message/index.vue +++ b/pages/message/index.vue @@ -149,24 +149,25 @@ /> - + :userId="openid" + :teamId="teamId" + :patientId="patientId" + :corpId="corpId" + :patientInfo="patientInfo" + @scrollToBottom="() => scrollToBottom(true)" + @messageSent="() => scrollToBottom(true)" + @endConsult="handleEndConsult" + /> @@ -246,7 +247,8 @@ const patientInfo = ref({ }); // 患者ID -const patientId = ref(""); +const patientId = ref(""); +const teamId = ref(""); // 计算弹框显示状态 - 只有 pending 状态才显示接受问诊组件 const showConsultAccept = computed(() => orderStatus.value === "pending"); @@ -299,18 +301,20 @@ function isSystemMessage(message) { } // 获取群组订单状态 -const fetchGroupOrderStatus = async () => { - try { - const result = await api("getGroupListByGroupId", { - groupId: groupId.value, - }); - - if (result.success && result.data) { - orderStatus.value = result.data.orderStatus || ""; - - // 更新导航栏标题为团队名称 - const teamName = result.data.team?.name || "群聊"; - updateNavigationTitle(teamName); +const fetchGroupOrderStatus = async () => { + try { + const result = await api("getGroupListByGroupId", { + groupId: groupId.value, + }); + + if (result.success && result.data) { + orderStatus.value = result.data.orderStatus || ""; + + // 更新导航栏标题为团队名称 + const teamName = result.data.team?.name || "群聊"; + updateNavigationTitle(teamName); + + teamId.value = result.data.teamId || result.data.team?.teamId || result.data.team?._id || ""; // 更新患者信息 if (result.data.patient) { @@ -326,12 +330,12 @@ const fetchGroupOrderStatus = async () => { patientId.value = result.data.patientId.toString(); } - console.log("获取群组订单状态:", { - orderStatus: orderStatus.value, - teamName: teamName, - patientInfo: patientInfo.value, - groupId: groupId.value, - }); + console.log("获取群组订单状态:", { + orderStatus: orderStatus.value, + teamName: teamName, + patientInfo: patientInfo.value, + groupId: groupId.value, + }); } else { console.error("获取群组订单状态失败:", result.message); } @@ -979,4 +983,4 @@ onUnmounted(() => { \ No newline at end of file + diff --git a/pages/message/survey-list.vue b/pages/message/survey-list.vue index 380b2de..8c07d96 100644 --- a/pages/message/survey-list.vue +++ b/pages/message/survey-list.vue @@ -101,6 +101,23 @@ const timChatManager = globalTimChatManager; // 从上一页传递的客户信息 const customerId = ref(""); const customerName = ref(""); +const teamId = ref(""); +const groupId = ref(""); + +const ensureTeamId = async () => { + if (teamId.value) return teamId.value; + if (!groupId.value) return ""; + try { + const res = await api("getGroupListByGroupId", { groupId: groupId.value }, false); + const team = res?.data?.team || {}; + const resolved = res?.data?.teamId || team.teamId || team._id || ""; + if (resolved) teamId.value = resolved; + return teamId.value; + } catch (err) { + console.error("ensureTeamId failed:", err); + return ""; + } +}; // 搜索关键词 const searchName = ref(""); @@ -125,8 +142,11 @@ const selectEventName = ref(""); onLoad((options) => { isSelectMode.value = String(options?.select || '') === '1'; selectEventName.value = String(options?.eventName || ''); + groupId.value = options?.groupId || ""; customerId.value = options?.patientId || ""; customerName.value = options?.customerName || ""; + teamId.value = options?.teamId || ""; + ensureTeamId(); getCategoryList(); loadSurveyList(); }); @@ -337,6 +357,8 @@ const sendSurvey = async (survey) => { // 生成发送ID const sendSurveyId = generateRandomString(10); + await ensureTeamId(); + // 创建问卷记录 const createRecordRes = await api("createSurveyRecord", { corpId: corpId, @@ -345,6 +367,7 @@ const sendSurvey = async (survey) => { memberId: customerId.value, customer: customerName.value, sendSurveyId: sendSurveyId, + teamId: teamId.value, }); if (!createRecordRes.success) { From 4b75ebf647e2a4403fdb48fc59fe76b7df371de5 Mon Sep 17 00:00:00 2001 From: wangdongbo <949818794@qq.com> Date: Fri, 6 Feb 2026 13:57:11 +0800 Subject: [PATCH 2/2] no message --- .env.development | 2 +- .env.ip | 2 +- .env.localhost | 2 +- App.vue | 21 ++++++++++++--------- store/account.js | 8 ++++++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.env.development b/.env.development index 4160666..cce72c5 100644 --- a/.env.development +++ b/.env.development @@ -1,7 +1,7 @@ MP_API_BASE_URL=https://patient.youcan365.com MP_IMAGE_URL=https://patient.youcan365.com MP_CACHE_PREFIX=development -MP_WX_APP_ID=wx6ee11733526b4f04 +MP_WX_APP_ID=wx1d8337a40c11d66c MP_CORP_ID=wwe3fb2faa52cf9dfb MP_TIM_SDK_APP_ID=1600123876 MP_INVITE_TEAMMATE_QRCODE=https://patient.youcan365.com/invite-teammate diff --git a/.env.ip b/.env.ip index 921439a..22cd3e5 100644 --- a/.env.ip +++ b/.env.ip @@ -1,7 +1,7 @@ MP_API_BASE_URL=http://192.168.60.2:8080 MP_IMAGE_URL=https://patient.youcan365.com MP_CACHE_PREFIX=development -MP_WX_APP_ID=wx6ee11733526b4f04 +MP_WX_APP_ID=wx1d8337a40c11d66c MP_CORP_ID=wwe3fb2faa52cf9dfb MP_TIM_SDK_APP_ID=1600123876 MP_INVITE_TEAMMATE_QRCODE=https://patient.youcan365.com/invite-teammate diff --git a/.env.localhost b/.env.localhost index 301ded7..3d46ace 100644 --- a/.env.localhost +++ b/.env.localhost @@ -1,7 +1,7 @@ MP_API_BASE_URL=http://localhost:8080 MP_IMAGE_URL=https://patient.youcan365.com MP_CACHE_PREFIX=development -MP_WX_APP_ID=wx6ee11733526b4f04 +MP_WX_APP_ID=wx1d8337a40c11d66c MP_CORP_ID=wwe3fb2faa52cf9dfb MP_TIM_SDK_APP_ID=1600123876 MP_INVITE_TEAMMATE_QRCODE=https://patient.youcan365.com/invite-teammate diff --git a/App.vue b/App.vue index 133cbaf..c711911 100644 --- a/App.vue +++ b/App.vue @@ -5,18 +5,21 @@ import { globalTimChatManager } from "@/utils/tim-chat.js"; export default { onLaunch: function () { // 需在 pinia 安装后再获取 store,避免 getActivePinia 报错 - const { account, login, initIMAfterLogin } = useAccountStore(); - + const { account, login, initIMAfterLogin, getDoctorInfo } = + useAccountStore(); + // 如果已有缓存的账户信息,尝试初始化 IM,否则重新登录 + debugger; if (account && account.openid) { console.log("App Launch: 已有登录信息,初始化 IM"); - initIMAfterLogin().catch(err => { - console.error('IM初始化失败:', err); + initIMAfterLogin().catch((err) => { + console.error("IM初始化失败:", err); }); + getDoctorInfo(); } else { console.log("App Launch: 无登录信息,开始登录"); - login().catch(err => { - console.error('自动登录失败:', err); + login().catch((err) => { + console.error("自动登录失败:", err); }); } }, @@ -40,7 +43,7 @@ export default {