diff --git a/pages/message/article-list.vue b/pages/message/article-list.vue
index e04e432..b6a7334 100644
--- a/pages/message/article-list.vue
+++ b/pages/message/article-list.vue
@@ -123,8 +123,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("");
@@ -334,6 +350,7 @@ const sendArticle = async (article) => {
try {
const { doctorInfo } = useAccountStore();
+ await ensureTeamId();
// 使用统一的消息发送助手
const success = await sendArticleMessage(
{
@@ -348,6 +365,7 @@ const sendArticle = async (article) => {
userId: doctorInfo?.userid,
customerId: pageParams.value.patientId,
corpId: corpId,
+ teamId: pageParams.value.teamId,
}
);
@@ -383,6 +401,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 4b6a92c..9620917 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: "" },
orderStatus: { type: String, default: "" },
@@ -381,14 +382,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}`,
});
};
@@ -510,4 +511,4 @@ onUnmounted(() => {
\ No newline at end of file
+
diff --git a/pages/message/index.vue b/pages/message/index.vue
index af3b417..2dcb4b8 100644
--- a/pages/message/index.vue
+++ b/pages/message/index.vue
@@ -160,6 +160,7 @@
: ''
"
:userId="openid"
+ :teamId="teamId"
:patientId="patientId"
:corpId="corpId"
:patientInfo="patientInfo"
@@ -249,6 +250,7 @@ const patientInfo = ref({
// 患者ID
const patientId = ref("");
+const teamId = ref("");
// 计算弹框显示状态 - 只有 pending 状态才显示接受问诊组件
const showConsultAccept = computed(() => orderStatus.value === "pending");
@@ -314,6 +316,8 @@ const fetchGroupOrderStatus = async () => {
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) {
patientInfo.value = {
@@ -1018,4 +1022,4 @@ onUnmounted(() => {
\ No newline at end of file
+
diff --git a/pages/message/survey-list.vue b/pages/message/survey-list.vue
index a95be47..0507766 100644
--- a/pages/message/survey-list.vue
+++ b/pages/message/survey-list.vue
@@ -102,6 +102,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("");
@@ -126,8 +143,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();
});
@@ -335,6 +355,7 @@ const sendSurvey = async (survey) => {
const doctorInfo = accountStore.doctorInfo;
userId.value = doctorInfo?.userid;
+ await ensureTeamId();
// 使用统一的消息发送助手
const success = await sendSurveyMessage(
{
@@ -348,6 +369,7 @@ const sendSurvey = async (survey) => {
customerId: customerId.value,
customerName: customerName.value,
corpId: corpId,
+ teamId: teamId.value,
}
);
diff --git a/utils/send-message-helper.js b/utils/send-message-helper.js
index 05f477a..19331d9 100644
--- a/utils/send-message-helper.js
+++ b/utils/send-message-helper.js
@@ -109,12 +109,16 @@ export async function sendArticleMessage(article, options = {}) {
if (result?.success) {
// 记录文章发送记录(异步,不阻塞)
if (options.articleId && options.userId && options.customerId && options.corpId) {
- api('addArticleSendRecord', {
+ const params = {
articleId: options.articleId,
userId: options.userId,
customerId: options.customerId,
corpId: options.corpId,
- }).catch((err) => {
+ };
+ if (options.teamId) {
+ params.teamId = options.teamId;
+ }
+ api('addArticleSendRecord', params).catch((err) => {
console.error('记录文章发送失败:', err);
});
}
@@ -151,15 +155,20 @@ export async function sendSurveyMessage(survey, options = {}) {
// 生成发送ID
const sendSurveyId = generateRandomString(10);
- // 创建问卷记录
- const createRecordRes = await api('createSurveyRecord', {
+ const recordParams = {
corpId: options.corpId,
userId: options.userId,
surveryId: survey._id,
memberId: options.customerId,
customer: options.customerName,
sendSurveyId: sendSurveyId,
- });
+ };
+ if (options.teamId) {
+ recordParams.teamId = options.teamId;
+ }
+
+ // 创建问卷记录
+ const createRecordRes = await api('createSurveyRecord', recordParams);
if (!createRecordRes?.success) {
toast(createRecordRes?.message || '创建问卷记录失败');