Compare commits
7 Commits
43ddbdbb5f
...
d75b8fb8cf
| Author | SHA1 | Date | |
|---|---|---|---|
| d75b8fb8cf | |||
| e6a924846f | |||
| c2da3c00af | |||
| b6fe4e9877 | |||
| 2b86ffd1bb | |||
| df39d0e987 | |||
| 44b6610a9f |
@ -1,7 +1,9 @@
|
|||||||
MP_API_BASE_URL=http://localhost:8080
|
MP_API_BASE_URL=https://patient.youcan365.com
|
||||||
MP_IMAGE_URL=https://patient.youcan365.com
|
MP_IMAGE_URL=https://patient.youcan365.com
|
||||||
MP_CACHE_PREFIX=development
|
MP_CACHE_PREFIX=development
|
||||||
MP_WX_APP_ID=wx1d8337a40c11d66c
|
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'
|
||||||
3
.env.ip
3
.env.ip
@ -5,4 +5,5 @@ 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'
|
||||||
|
|||||||
@ -5,3 +5,5 @@ 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'
|
||||||
@ -5,38 +5,45 @@
|
|||||||
<text v-if="required" class="required">*</text>
|
<text v-if="required" class="required">*</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<view class="value" :class="{ muted: !displayText }">{{ displayText || placeholder }}</view>
|
<view class="value" :class="{ muted: !displayText }">{{
|
||||||
|
displayText || placeholder
|
||||||
|
}}</view>
|
||||||
<uni-icons type="arrowright" size="16" color="#999" />
|
<uni-icons type="arrowright" size="16" color="#999" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onUnmounted, ref } from 'vue';
|
import { computed, onUnmounted, ref } from "vue";
|
||||||
|
|
||||||
const emits = defineEmits(['change']);
|
const emits = defineEmits(["change"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
form: { type: Object, default: () => ({}) },
|
form: { type: Object, default: () => ({}) },
|
||||||
name: { default: '' },
|
name: { default: "" },
|
||||||
required: { type: Boolean, default: false },
|
required: { type: Boolean, default: false },
|
||||||
title: { default: '' },
|
title: { default: "" },
|
||||||
disableChange: { type: Boolean, default: false },
|
disableChange: { type: Boolean, default: false },
|
||||||
placeholder: { default: '' },
|
placeholder: { default: "" },
|
||||||
mult: { type: Boolean, default: false },
|
mult: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const placeholder = computed(() => (props.placeholder ? String(props.placeholder) : `请选择${props.name || ''}`));
|
const placeholder = computed(() =>
|
||||||
|
props.placeholder ? String(props.placeholder) : `请选择${props.name || ""}`
|
||||||
|
);
|
||||||
const rawValue = computed(() => props.form?.[props.title]);
|
const rawValue = computed(() => props.form?.[props.title]);
|
||||||
const displayText = computed(() => {
|
const displayText = computed(() => {
|
||||||
const v = rawValue.value;
|
const v = rawValue.value;
|
||||||
if (Array.isArray(v)) return v.filter((i) => i !== null && i !== undefined && String(i).trim()).join(',');
|
if (Array.isArray(v))
|
||||||
return v ? String(v) : '';
|
return v
|
||||||
|
.filter((i) => i !== null && i !== undefined && String(i).trim())
|
||||||
|
.join(",");
|
||||||
|
return v ? String(v) : "";
|
||||||
});
|
});
|
||||||
|
|
||||||
const activeEventName = ref('');
|
const activeEventName = ref("");
|
||||||
function clearListener() {
|
function clearListener() {
|
||||||
if (activeEventName.value) uni.$off(activeEventName.value);
|
if (activeEventName.value) uni.$off(activeEventName.value);
|
||||||
activeEventName.value = '';
|
activeEventName.value = "";
|
||||||
}
|
}
|
||||||
onUnmounted(clearListener);
|
onUnmounted(clearListener);
|
||||||
|
|
||||||
@ -45,16 +52,20 @@ function open() {
|
|||||||
clearListener();
|
clearListener();
|
||||||
activeEventName.value = `diagnosis-change_${Date.now()}`;
|
activeEventName.value = `diagnosis-change_${Date.now()}`;
|
||||||
uni.$on(activeEventName.value, (data) => {
|
uni.$on(activeEventName.value, (data) => {
|
||||||
emits('change', { title: props.title, value: data });
|
emits("change", { title: props.title, value: data });
|
||||||
});
|
});
|
||||||
|
|
||||||
if (props.mult) {
|
if (props.mult) {
|
||||||
const cur = Array.isArray(rawValue.value) ? rawValue.value : [];
|
const cur = Array.isArray(rawValue.value) ? rawValue.value : [];
|
||||||
uni.setStorageSync('diagnosis-list-selection', cur);
|
uni.setStorageSync("diagnosis-list-selection", cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/library/diagnosis-list?eventName=${encodeURIComponent(activeEventName.value)}&mult=${props.mult ? 'YES' : 'NO'}&value=${encodeURIComponent(displayText.value || '')}`,
|
url: `/pages/library/diagnosis-list?eventName=${encodeURIComponent(
|
||||||
|
activeEventName.value
|
||||||
|
)}&mult=${props.mult ? "YES" : "NO"}&value=${encodeURIComponent(
|
||||||
|
displayText.value || ""
|
||||||
|
)}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -156,7 +156,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "/todo/todo-detail",
|
"path": "todo/todo-detail",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "待办详情"
|
"navigationBarTitleText": "待办详情"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,8 @@
|
|||||||
<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>
|
||||||
@ -73,10 +74,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
|
||||||
@ -178,7 +179,7 @@ const setInputText = (text) => {
|
|||||||
|
|
||||||
// 清空输入框
|
// 清空输入框
|
||||||
const clearInputText = () => {
|
const clearInputText = () => {
|
||||||
inputText.value = '';
|
inputText.value = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
// 暴露方法给父组件调用
|
// 暴露方法给父组件调用
|
||||||
@ -186,7 +187,7 @@ defineExpose({
|
|||||||
sendTextMessageFromPhrase,
|
sendTextMessageFromPhrase,
|
||||||
appendStreamText,
|
appendStreamText,
|
||||||
setInputText,
|
setInputText,
|
||||||
clearInputText
|
clearInputText,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 发送图片消息
|
// 发送图片消息
|
||||||
@ -357,61 +358,42 @@ 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'
|
url: `/pages/message/survey-list?groupId=${props.groupId}&patientId=${props.patientId}&corpId=${props.corpId}&customerName=${props.patientInfo.name}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 结束问诊
|
// 结束问诊
|
||||||
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");
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,14 @@ export default function useGroupChat(groupID) {
|
|||||||
avatar: member.avatar,
|
avatar: member.avatar,
|
||||||
isTeamMember: member.isTeamMember // 标记是否为团队成员
|
isTeamMember: member.isTeamMember // 标记是否为团队成员
|
||||||
}
|
}
|
||||||
|
// 如果成员有 miniAppId(患者的聊天 userID),也添加一个映射(用于消息的 from 字段)
|
||||||
|
if (member.miniAppId) {
|
||||||
|
res[member.miniAppId] = {
|
||||||
|
name: member.name,
|
||||||
|
avatar: member.avatar,
|
||||||
|
isTeamMember: member.isTeamMember
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
@ -66,20 +74,23 @@ 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 avatarMap = await teamStore.getTeamMemberAvatars(groupResult.data.teamId)
|
const memberMap = await teamStore.getTeamMemberAvatarsAndName(groupResult.data.teamId)
|
||||||
|
|
||||||
// 3. 存储团队成员ID列表
|
// 3. 存储团队成员ID列表
|
||||||
teamMemberIds.value = Object.keys(avatarMap)
|
teamMemberIds.value = Object.keys(memberMap)
|
||||||
|
|
||||||
// 4. 构建团队成员列表
|
// 4. 构建团队成员列表(从返回的 { userId: { avatar, name } } 中提取)
|
||||||
members.value = teamMemberIds.value.map(userId => ({
|
members.value = teamMemberIds.value.map(userId => {
|
||||||
id: userId,
|
const memberInfo = memberMap[userId] || {}
|
||||||
name: userId, // 这里可以从其他地方获取真实姓名
|
return {
|
||||||
avatar: avatarMap[userId] || '',
|
id: userId,
|
||||||
isTeamMember: true
|
name: memberInfo.name || userId, // 使用返回的 name,如果没有则用 userId
|
||||||
}))
|
avatar: memberInfo.avatar || '', // 使用返回的 avatar
|
||||||
|
isTeamMember: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// 5. 添加患者信息(使用默认患者头像)
|
// 5. 添加患者信息(使用默认患者头像)
|
||||||
if (groupResult.data.patient) {
|
if (groupResult.data.patient) {
|
||||||
@ -89,7 +100,8 @@ export default function useGroupChat(groupID) {
|
|||||||
id: pid,
|
id: pid,
|
||||||
name: groupResult.data.patient.name || '患者',
|
name: groupResult.data.patient.name || '患者',
|
||||||
avatar: '', // 患者不设置头像,使用默认
|
avatar: '', // 患者不设置头像,使用默认
|
||||||
isTeamMember: false
|
isTeamMember: false,
|
||||||
|
miniAppId: groupResult.data.patient.miniAppId || '' // 患者的聊天 userID
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,6 +162,7 @@
|
|||||||
: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"
|
||||||
@ -174,7 +175,7 @@ import { ref, onUnmounted, nextTick, watch, computed } from "vue";
|
|||||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import useAccountStore from "@/store/account.js";
|
import useAccountStore from "@/store/account.js";
|
||||||
import { globalTimChatManager } from "@/utils/tim-chat.js";
|
import { globalTimChatManager, TIM } from "@/utils/tim-chat.js";
|
||||||
import {
|
import {
|
||||||
startIMMonitoring,
|
startIMMonitoring,
|
||||||
stopIMMonitoring,
|
stopIMMonitoring,
|
||||||
@ -944,99 +945,6 @@ 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 = chatInfo.value.userID || "";
|
|
||||||
const customerName = chatInfo.value.customerName || "";
|
|
||||||
|
|
||||||
// 创建问卷记录
|
|
||||||
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: "",
|
|
||||||
};
|
|
||||||
|
|
||||||
// 发送自定义消息
|
|
||||||
const message = timChatManager.tim.createCustomMessage({
|
|
||||||
to: chatInfo.value.conversationID.replace("GROUP", ""),
|
|
||||||
conversationType: timChatManager.TIM.TYPES.CONV_GROUP,
|
|
||||||
payload: customMessage,
|
|
||||||
});
|
|
||||||
|
|
||||||
const sendResult = await timChatManager.tim.sendMessage(message);
|
|
||||||
|
|
||||||
if (sendResult.code === 0) {
|
|
||||||
uni.showToast({
|
|
||||||
title: "发送成功",
|
|
||||||
icon: "success",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw new Error(sendResult.message || "发送失败");
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("发送问卷失败:", error);
|
|
||||||
uni.showToast({
|
|
||||||
title: error.message || "发送失败",
|
|
||||||
icon: "none",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -89,12 +89,18 @@
|
|||||||
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("");
|
||||||
@ -112,6 +118,14 @@ 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 {
|
||||||
@ -204,16 +218,31 @@ 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?surveyId=${survey.surveyId}&t=${timestamp}`;
|
const previewUrl = `https://www.youcan365.com/surveyDev/#/pages/survey/survey?surveryId=${survey.surveryId}&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
|
||||||
|
|
||||||
@ -233,6 +262,48 @@ 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;
|
||||||
@ -242,33 +313,61 @@ const sendSurvey = async (survey) => {
|
|||||||
|
|
||||||
// 获取医生信息
|
// 获取医生信息
|
||||||
const doctorInfo = accountStore.doctorInfo;
|
const doctorInfo = accountStore.doctorInfo;
|
||||||
userId.value = doctorInfo?.userid || accountStore.openid;
|
userId.value = doctorInfo?.userid;
|
||||||
|
|
||||||
// 生成发送ID
|
// 生成发送ID
|
||||||
const sendSurveyId = generateRandomString(10);
|
const sendSurveyId = generateRandomString(10);
|
||||||
|
|
||||||
// 获取当前聊天的客户信息(从上一页传递)
|
// 创建问卷记录
|
||||||
const pages = getCurrentPages();
|
const createRecordRes = await api("createSurveyRecord", {
|
||||||
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,
|
||||||
});
|
});
|
||||||
|
|
||||||
uni.showToast({
|
if (!createRecordRes.success) {
|
||||||
title: "已选择问卷",
|
uni.showToast({
|
||||||
icon: "success",
|
title: createRecordRes.message || "创建问卷记录失败",
|
||||||
});
|
icon: "none",
|
||||||
|
});
|
||||||
|
loading.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 延迟返回
|
const answerId = createRecordRes?.id || "";
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack();
|
// 生成发送链接
|
||||||
}, 500);
|
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",
|
||||||
|
});
|
||||||
|
// 延迟返回
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack();
|
||||||
|
}, 500);
|
||||||
|
} else {
|
||||||
|
throw new Error(result.error || "发送失败");
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("发送问卷失败:", error);
|
console.error("发送问卷失败:", error);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|||||||
@ -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 getTeamMemberAvatars(teamId) {
|
async function getTeamMemberAvatarsAndName(teamId) {
|
||||||
if (!teamId || !account.value?.corpId) return {};
|
if (!teamId || !account.value?.corpId) return {};
|
||||||
const res = await api('getTeamMemberAvatars', {
|
const res = await api('getTeamMemberAvatarsAndName', {
|
||||||
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 } 的映射对象
|
return res.data; // 返回 { userId: { avatar: "url", name: "医生名称" } } 的映射对象
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return { teams, chargeTeams, getTeam, getTeams, getTeamMemberAvatars }
|
return { teams, chargeTeams, getTeam, getTeams, getTeamMemberAvatarsAndName }
|
||||||
})
|
})
|
||||||
@ -26,7 +26,7 @@ const urlsConfig = {
|
|||||||
removeTeammate: "removeTeammate",
|
removeTeammate: "removeTeammate",
|
||||||
toggleTeamLeaderRole: "toggleTeamLeaderRole",
|
toggleTeamLeaderRole: "toggleTeamLeaderRole",
|
||||||
joinTheInvitedTeam: 'joinTheInvitedTeam',
|
joinTheInvitedTeam: 'joinTheInvitedTeam',
|
||||||
getTeamMemberAvatars: 'getTeamMemberAvatars'
|
getTeamMemberAvatarsAndName: 'getTeamMemberAvatarsAndName'
|
||||||
},
|
},
|
||||||
|
|
||||||
knowledgeBase: {
|
knowledgeBase: {
|
||||||
@ -123,7 +123,7 @@ const urlsConfig = {
|
|||||||
customerTransferRecord: 'customerTransferRecord',
|
customerTransferRecord: 'customerTransferRecord',
|
||||||
// sendConsultRejectedMessage: "sendConsultRejectedMessage"
|
// sendConsultRejectedMessage: "sendConsultRejectedMessage"
|
||||||
getTeamTodos: 'getTeamTodos',
|
getTeamTodos: 'getTeamTodos',
|
||||||
updateTaskTodo:'updateTaskTodo'
|
updateTaskTodo: 'updateTaskTodo'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2371,7 +2371,7 @@ class TimChatManager {
|
|||||||
type: 'TIMCustomElem',
|
type: 'TIMCustomElem',
|
||||||
payload: {
|
payload: {
|
||||||
data: JSON.stringify(messageData),
|
data: JSON.stringify(messageData),
|
||||||
description: messageData.content || '自定义消息',
|
description: messageData.content || '自定义消息1',
|
||||||
extension: messageData.messageType || 'custom'
|
extension: messageData.messageType || 'custom'
|
||||||
},
|
},
|
||||||
lastTime: Date.now(),
|
lastTime: Date.now(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user