Compare commits

..

No commits in common. "e6a924846fe27ee047551e89017816ff3bd78def" and "b6fe4e9877389c362fca6f504ad83160f7d4f170" have entirely different histories.

9 changed files with 168 additions and 172 deletions

View File

@ -5,5 +5,3 @@ MP_WX_APP_ID=wx1d8337a40c11d66c
MP_CORP_ID=wwe3fb2faa52cf9dfb MP_CORP_ID=wwe3fb2faa52cf9dfb
MP_TIM_SDK_APP_ID=1600123876 MP_TIM_SDK_APP_ID=1600123876
MP_INVITE_TEAMMATE_QRCODE=https://patient.youcan365.com/invite-teammate MP_INVITE_TEAMMATE_QRCODE=https://patient.youcan365.com/invite-teammate
MP_PATIENT_PAGE_BASE_URL= 'https://www.youcan365.com/patientDeploy/#/'
MP_SURVEY_URL= 'https://www.youcan365.com/surveyDev/#/pages/survey/survey'

View File

@ -5,5 +5,4 @@ MP_WX_APP_ID=wx93af55767423938e
MP_CORP_ID=wwe3fb2faa52cf9dfb MP_CORP_ID=wwe3fb2faa52cf9dfb
MP_TIM_SDK_APP_ID=1600123876 MP_TIM_SDK_APP_ID=1600123876
MP_INVITE_TEAMMATE_QRCODE=https://patient.youcan365.com/invite-teammate MP_INVITE_TEAMMATE_QRCODE=https://patient.youcan365.com/invite-teammate
MP_PATIENT_PAGE_BASE_URL= 'https://www.youcan365.com/patientDeploy/#/'
MP_SURVEY_URL= 'https://www.youcan365.com/surveyDev/#/pages/survey/survey'

View File

@ -5,5 +5,3 @@ MP_WX_APP_ID=wx1d8337a40c11d66c
MP_CORP_ID=wwe3fb2faa52cf9dfb MP_CORP_ID=wwe3fb2faa52cf9dfb
MP_TIM_SDK_APP_ID=1600123876 MP_TIM_SDK_APP_ID=1600123876
MP_INVITE_TEAMMATE_QRCODE=https://patient.youcan365.com/invite-teammate MP_INVITE_TEAMMATE_QRCODE=https://patient.youcan365.com/invite-teammate
MP_PATIENT_PAGE_BASE_URL= 'https://www.youcan365.com/patientDeploy/#/'
MP_SURVEY_URL= 'https://www.youcan365.com/surveyDev/#/pages/survey/survey'

View File

@ -8,8 +8,7 @@
<view class="input-area"> <view class="input-area">
<textarea v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..." <textarea v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..."
@confirm="sendTextMessage" @focus="handleInputFocus" @input="handleInput" @confirm="sendTextMessage" @focus="handleInputFocus" @input="handleInput"
:auto-height="true" :show-confirm-bar="false" :adjust-position="true" :auto-height="true" :show-confirm-bar="false" :adjust-position="true" />
placeholder-style="line-height: 80rpx;" />
<input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord" <input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord"
@touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled> @touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled>
</input> </input>
@ -74,10 +73,10 @@ const props = defineProps({
patientInfo: { type: Object, default: () => ({}) }, patientInfo: { type: Object, default: () => ({}) },
chatRoomBusiness: { type: Object, default: () => ({}) }, chatRoomBusiness: { type: Object, default: () => ({}) },
formatTime: { type: Function, required: true }, formatTime: { type: Function, required: true },
groupId: { type: String, default: "" }, groupId: { type: String, default: '' },
userId: { type: String, default: "" }, userId: { type: String, default: '' },
patientId: { type: String, default: "" }, patientId: { type: String, default: '' },
corpId: { type: String, default: "" }, corpId: { type: String, default: '' },
}); });
// Emits // Emits
@ -179,7 +178,7 @@ const setInputText = (text) => {
// //
const clearInputText = () => { const clearInputText = () => {
inputText.value = ""; inputText.value = '';
}; };
// //
@ -187,7 +186,7 @@ defineExpose({
sendTextMessageFromPhrase, sendTextMessageFromPhrase,
appendStreamText, appendStreamText,
setInputText, setInputText,
clearInputText, clearInputText
}); });
// //
@ -358,42 +357,61 @@ const cancelRecord = () => {
stopRecordUtil(recorderManager); stopRecordUtil(recorderManager);
}; };
//
const sendSurveyMessage = async () => {
const surveyMessage = createCustomMessage(
"survey",
{
content: "医生发送了问卷调查",
surveyTitle: "治疗效果评估",
surveyDescription: "您好,为了帮助了解您的病情变化,请您如实填写问卷。",
surveyMessage: "慢性病患者生活质量评估问卷",
estimatedTime: "约3-5分钟",
reward: "积分奖励10分",
note: "问卷内容涉及您的症状变化、用药情况等,请根据实际情况填写。",
},
props.formatTime
);
await sendCustomMessage(surveyMessage);
};
// //
const goToCommonPhrases = () => { const goToCommonPhrases = () => {
uni.navigateTo({ uni.navigateTo({
url: "/pages/message/common-phrases", url: '/pages/message/common-phrases'
}); });
}; };
// //
const goToArticleList = () => { const goToArticleList = () => {
uni.navigateTo({ 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}`
}); });
}; };
// //
const goToSurveyList = () => { const goToSurveyList = () => {
uni.navigateTo({ 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'
}); });
}; };
// //
const handleEndConsult = () => { const handleEndConsult = () => {
uni.showModal({ uni.showModal({
title: "确认结束问诊", title: '确认结束问诊',
content: "确定要结束本次问诊吗?结束后将无法继续对话。", content: '确定要结束本次问诊吗?结束后将无法继续对话。',
confirmText: "确定结束", confirmText: '确定结束',
cancelText: "取消", cancelText: '取消',
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
// //
showMorePanel.value = false; showMorePanel.value = false;
// //
emit("endConsult"); emit('endConsult');
}
} }
},
}); });
}; };

View File

@ -66,23 +66,20 @@ export default function useGroupChat(groupID) {
teamId: groupResult.data.teamId teamId: groupResult.data.teamId
} }
// 2. 如果有teamId获取团队成员头像和名称 // 2. 如果有teamId获取团队成员头像
if (groupResult.data.teamId) { if (groupResult.data.teamId) {
const memberMap = await teamStore.getTeamMemberAvatarsAndName(groupResult.data.teamId) const avatarMap = await teamStore.getTeamMemberAvatars(groupResult.data.teamId)
// 3. 存储团队成员ID列表 // 3. 存储团队成员ID列表
teamMemberIds.value = Object.keys(memberMap) teamMemberIds.value = Object.keys(avatarMap)
// 4. 构建团队成员列表(从返回的 { userId: { avatar, name } } 中提取) // 4. 构建团队成员列表
members.value = teamMemberIds.value.map(userId => { members.value = teamMemberIds.value.map(userId => ({
const memberInfo = memberMap[userId] || {}
return {
id: userId, id: userId,
name: memberInfo.name || userId, // 使用返回的 name如果没有则用 userId name: userId, // 这里可以从其他地方获取真实姓名
avatar: memberInfo.avatar || '', // 使用返回的 avatar avatar: avatarMap[userId] || '',
isTeamMember: true isTeamMember: true
} }))
})
// 5. 添加患者信息(使用默认患者头像) // 5. 添加患者信息(使用默认患者头像)
if (groupResult.data.patient) { if (groupResult.data.patient) {

View File

@ -162,7 +162,6 @@
:userId="openid" :userId="openid"
:patientId="patientId" :patientId="patientId"
:corpId="corpId" :corpId="corpId"
:patientInfo="patientInfo"
@scrollToBottom="() => scrollToBottom(true)" @scrollToBottom="() => scrollToBottom(true)"
@messageSent="() => scrollToBottom(true)" @messageSent="() => scrollToBottom(true)"
@endConsult="handleEndConsult" @endConsult="handleEndConsult"
@ -945,6 +944,92 @@ onUnmounted(() => {
timChatManager.setCallback("onMessageReceived", null); timChatManager.setCallback("onMessageReceived", null);
timChatManager.setCallback("onMessageListLoaded", null); timChatManager.setCallback("onMessageListLoaded", null);
timChatManager.setCallback("onError", null); timChatManager.setCallback("onError", null);
//
uni.$off("sendSurvey");
});
//
uni.$on("sendSurvey", async (data) => {
const { survey, corpId, userId, sendSurveyId } = data;
if (!survey || !survey._id) {
uni.showToast({
title: "问卷信息不完整",
icon: "none",
});
return;
}
try {
//
const env = __VITE_ENV__;
const baseUrl = env.VITE_PATIENT_PAGE_BASE_URL || "";
const surveyUrl = env.VITE_SURVEY_URL || "";
//
const customerId = patientId.value || "";
const customerName = patientInfo.value.name || "";
//
const recordRes = await api("createSurveyRecord", {
corpId,
userId,
surveryId: survey._id,
memberId: customerId,
customer: customerName,
sendSurveyId,
});
if (!recordRes.success) {
throw new Error(recordRes.message || "创建问卷记录失败");
}
const answerId = recordRes.data?.id || "";
//
let surveyLink = "";
if (survey.createBy === "system") {
//
surveyLink = `${surveyUrl}?corpId=${corpId}&surveyId=${survey.surveyId}&memberId=${customerId}&sendSurveyId=${sendSurveyId}&userId=${userId}`;
} else {
//
surveyLink = `${baseUrl}pages/survery/fill?corpId=${corpId}&surveryId=${
survey._id
}&memberId=${customerId}&answerId=${answerId}&name=${encodeURIComponent(
customerName
)}`;
}
//
const customMessage = {
data: JSON.stringify({
type: "survey",
title: survey.name || "填写问卷",
desc: "请填写问卷",
url: surveyLink,
imgUrl:
"https://796f-youcan-clouddev-1-8ewcqf31dbb2b5-1317294507.tcb.qcloud.la/other/19-%E9%97%AE%E5%8D%B7.png?sign=55a4cd77c418b2c548b65792a2cf6bce&t=1701328694",
}),
description: "SURVEY",
extension: "",
};
// 使 timChatManager sendCustomMessage
const result = await timChatManager.sendCustomMessage(customMessage, "SURVEY");
if (result.success) {
// sendCustomMessage
uni.showToast({
title: "发送成功",
icon: "success",
});
} else {
throw new Error(result.error || "发送失败");
}
} catch (error) {
console.error("发送问卷失败:", error);
uni.showToast({
title: error.message || "发送失败",
icon: "none",
});
}
}); });
</script> </script>

View File

@ -89,18 +89,12 @@
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
import api from "@/utils/api.js"; import api from "@/utils/api.js";
import useAccountStore from "@/store/account.js"; import useAccountStore from "@/store/account.js";
import { globalTimChatManager } from "@/utils/tim-chat.js";
import EmptyData from "@/components/empty-data.vue"; import EmptyData from "@/components/empty-data.vue";
import { onLoad } from "@dcloudio/uni-app";
const env = __VITE_ENV__; const env = __VITE_ENV__;
const accountStore = useAccountStore(); const accountStore = useAccountStore();
const corpId = env.MP_CORP_ID; const corpId = env.MP_CORP_ID;
const userId = ref(""); const userId = ref("");
const timChatManager = globalTimChatManager;
//
const customerId = ref("");
const customerName = ref("");
// //
const searchName = ref(""); const searchName = ref("");
@ -118,14 +112,6 @@ const pageSize = 30;
const total = ref(0); const total = ref(0);
const emptyText = ref(""); const emptyText = ref("");
//
onLoad((options) => {
customerId.value = options?.patientId || "";
customerName.value = options?.customerName || "";
getCategoryList();
loadSurveyList();
});
// //
const getCategoryList = async () => { const getCategoryList = async () => {
try { try {
@ -218,31 +204,16 @@ const loadMore = () => {
// //
const previewSurvey = (survey) => { const previewSurvey = (survey) => {
if (!survey.surveryId) {
uni.showToast({
title: "问卷ID不存在",
icon: "none",
});
return;
}
const timestamp = Date.now(); const timestamp = Date.now();
const previewUrl = `https://www.youcan365.com/surveyDev/#/pages/survey/survey?surveryId=${survey.surveryId}&t=${timestamp}`; const previewUrl = `https://www.youcan365.com/surveyDev/#/pages/survey/survey?surveyId=${survey.surveyId}&t=${timestamp}`;
// #ifdef H5 // #ifdef H5
window.open(previewUrl, "_blank"); window.open(previewUrl, '_blank');
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
uni.navigateTo({ uni.navigateTo({
url: `/pages/webview/webview?url=${encodeURIComponent(previewUrl)}`, url: `/pages/webview/webview?url=${encodeURIComponent(previewUrl)}`
fail: (err) => {
console.error("导航失败:", err);
uni.showToast({
title: "打开失败,请重试",
icon: "none",
});
},
}); });
// #endif // #endif
@ -262,48 +233,6 @@ const generateRandomString = (length) => {
return result; return result;
}; };
//
const generateSendLink = (
survey,
answerId,
customerId,
customerName,
sendSurveyId
) => {
const isSystem = survey.createBy === "system";
let url = "";
if (isSystem) {
// 使 VITE_SURVEY_URL
url = `${env.MP_SURVEY_URL}?corpId=${corpId}&surveryId=${survey.surveryId}&memberId=${customerId}&sendSurveyId=${sendSurveyId}&userId=${userId.value}`;
} else {
url = `${
env.MP_PATIENT_PAGE_BASE_URL
}pages/survery/fill?corpId=${corpId}&surveryId=${
survey._id
}&memberId=${customerId}&unionid=unionid&answerId=${answerId}&name=${
customerName || ""
}`;
}
return url;
};
//
const buildSurveyMessage = (survey, surveyLink) => {
return {
data: JSON.stringify({
type: "survey",
title: survey.name || "填写问卷",
desc: "请填写问卷",
url: surveyLink,
imgUrl:
"https://796f-youcan-clouddev-1-8ewcqf31dbb2b5-1317294507.tcb.qcloud.la/other/19-%E9%97%AE%E5%8D%B7.png?sign=55a4cd77c418b2c548b65792a2cf6bce&t=1701328694",
}),
description: "SURVEY",
extension: "",
};
};
// //
const sendSurvey = async (survey) => { const sendSurvey = async (survey) => {
if (loading.value) return; if (loading.value) return;
@ -313,61 +242,33 @@ const sendSurvey = async (survey) => {
// //
const doctorInfo = accountStore.doctorInfo; const doctorInfo = accountStore.doctorInfo;
userId.value = doctorInfo?.userid; userId.value = doctorInfo?.userid || accountStore.openid;
// ID // ID
const sendSurveyId = generateRandomString(10); const sendSurveyId = generateRandomString(10);
// //
const createRecordRes = await api("createSurveyRecord", { const pages = getCurrentPages();
const prevPage = pages[pages.length - 2];
//
// 使
uni.$emit("sendSurvey", {
survey: survey,
corpId: corpId, corpId: corpId,
userId: userId.value, userId: userId.value,
surveryId: survey._id,
memberId: customerId.value,
customer: customerName.value,
sendSurveyId: sendSurveyId, sendSurveyId: sendSurveyId,
}); });
if (!createRecordRes.success) {
uni.showToast({ uni.showToast({
title: createRecordRes.message || "创建问卷记录失败", title: "已选择问卷",
icon: "none",
});
loading.value = false;
return;
}
const answerId = createRecordRes?.id || "";
//
const sendLink = generateSendLink(
survey,
answerId,
customerId.value,
customerName.value,
sendSurveyId
);
//
const customMessage = buildSurveyMessage(survey, sendLink);
// IM
const result = await timChatManager.sendCustomMessage(
customMessage,
"SURVEY"
);
if (result.success) {
uni.showToast({
title: "发送成功",
icon: "success", icon: "success",
}); });
// //
setTimeout(() => { setTimeout(() => {
uni.navigateBack(); uni.navigateBack();
}, 500); }, 500);
} else {
throw new Error(result.error || "发送失败");
}
} catch (error) { } catch (error) {
console.error("发送问卷失败:", error); console.error("发送问卷失败:", error);
uni.showToast({ uni.showToast({

View File

@ -34,18 +34,18 @@ export default defineStore("teamStore", () => {
teams.value = res && Array.isArray(res.data) ? res.data : []; teams.value = res && Array.isArray(res.data) ? res.data : [];
} }
// 获取团队成员头像和名称映射 // 获取团队成员头像映射
async function getTeamMemberAvatarsAndName(teamId) { async function getTeamMemberAvatars(teamId) {
if (!teamId || !account.value?.corpId) return {}; if (!teamId || !account.value?.corpId) return {};
const res = await api('getTeamMemberAvatarsAndName', { const res = await api('getTeamMemberAvatars', {
teamId, teamId,
corpId: account.value.corpId corpId: account.value.corpId
}); });
if (res && res.success && res.data) { if (res && res.success && res.data) {
return res.data; // 返回 { userId: { avatar: "url", name: "医生名称" } } 的映射对象 return res.data; // 返回 { userId: avatar } 的映射对象
} }
return {}; return {};
} }
return { teams, chargeTeams, getTeam, getTeams, getTeamMemberAvatarsAndName } return { teams, chargeTeams, getTeam, getTeams, getTeamMemberAvatars }
}) })

View File

@ -26,7 +26,7 @@ const urlsConfig = {
removeTeammate: "removeTeammate", removeTeammate: "removeTeammate",
toggleTeamLeaderRole: "toggleTeamLeaderRole", toggleTeamLeaderRole: "toggleTeamLeaderRole",
joinTheInvitedTeam: 'joinTheInvitedTeam', joinTheInvitedTeam: 'joinTheInvitedTeam',
getTeamMemberAvatarsAndName: 'getTeamMemberAvatarsAndName' getTeamMemberAvatars: 'getTeamMemberAvatars'
}, },
knowledgeBase: { knowledgeBase: {