提交
This commit is contained in:
parent
afbbb12ec7
commit
b475223370
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import { getArticle } from "@/utils/api.js";
|
import api from "@/utils/api.js";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
const env = __VITE_ENV__;
|
const env = __VITE_ENV__;
|
||||||
const corpId = env.MP_CORP_ID;
|
const corpId = env.MP_CORP_ID;
|
||||||
@ -75,7 +75,7 @@ const loadArticle = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
error.value = "";
|
error.value = "";
|
||||||
try {
|
try {
|
||||||
const res = await getArticle({ id: articleId, corpId });
|
const res = await api("getArticle", { id: articleId, corpId });
|
||||||
|
|
||||||
if (res.success && res.data) {
|
if (res.success && res.data) {
|
||||||
// 格式化日期
|
// 格式化日期
|
||||||
|
|||||||
@ -109,12 +109,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import {
|
import api from "@/utils/api.js";
|
||||||
getArticleCateList,
|
|
||||||
getArticleList,
|
|
||||||
getArticle,
|
|
||||||
sendArticleMessage,
|
|
||||||
} from "@/utils/api.js";
|
|
||||||
import useAccountStore from "@/store/account.js";
|
import useAccountStore from "@/store/account.js";
|
||||||
import EmptyData from "@/components/empty-data.vue";
|
import EmptyData from "@/components/empty-data.vue";
|
||||||
|
|
||||||
@ -154,7 +149,7 @@ const previewPopup = ref(null);
|
|||||||
// 获取分类列表
|
// 获取分类列表
|
||||||
const getCategoryList = async () => {
|
const getCategoryList = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getArticleCateList({ corpId: corpId });
|
const res = await api("getArticleCateList", { corpId: corpId });
|
||||||
if (res.success && res.list) {
|
if (res.success && res.list) {
|
||||||
const cates = res.list || [];
|
const cates = res.list || [];
|
||||||
categoryList.value = [{ _id: "", label: "全部" }, ...cates];
|
categoryList.value = [{ _id: "", label: "全部" }, ...cates];
|
||||||
@ -203,7 +198,7 @@ const loadArticleList = async () => {
|
|||||||
params.cateIds = [currentCateId.value];
|
params.cateIds = [currentCateId.value];
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await getArticleList(params);
|
const res = await api("getArticleList", params);
|
||||||
if (res.success && res.list) {
|
if (res.success && res.list) {
|
||||||
const { list = [], total: count = 0 } = res;
|
const { list = [], total: count = 0 } = res;
|
||||||
const formattedList = list.map((item) => {
|
const formattedList = list.map((item) => {
|
||||||
@ -286,7 +281,7 @@ const processRichTextContent = (html) => {
|
|||||||
const previewArticle = async (article) => {
|
const previewArticle = async (article) => {
|
||||||
try {
|
try {
|
||||||
uni.showLoading({ title: "加载中..." });
|
uni.showLoading({ title: "加载中..." });
|
||||||
const res = await getArticle({ id: article._id, corpId: corpId });
|
const res = await api("getArticle", { id: article._id, corpId: corpId });
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
||||||
if (res.success && res.data) {
|
if (res.success && res.data) {
|
||||||
@ -320,9 +315,9 @@ const closePreview = () => {
|
|||||||
const sendArticle = async (article) => {
|
const sendArticle = async (article) => {
|
||||||
try {
|
try {
|
||||||
const { doctorInfo } = useAccountStore();
|
const { doctorInfo } = useAccountStore();
|
||||||
const result = await sendArticleMessage({
|
const result = await api("sendArticleMessage", {
|
||||||
groupId: pageParams.value.groupId,
|
groupId: pageParams.value.groupId,
|
||||||
fromAccount: doctorInfo.weChatOpenId,
|
fromAccount: doctorInfo.userid,
|
||||||
articleId: article._id,
|
articleId: article._id,
|
||||||
title: article.title || "宣教文章",
|
title: article.title || "宣教文章",
|
||||||
imgUrl: article.cover || "",
|
imgUrl: article.cover || "",
|
||||||
|
|||||||
@ -85,7 +85,6 @@
|
|||||||
}}</text>
|
}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
<view class="message-bubble" :class="getBubbleClass(message)">
|
<view class="message-bubble" :class="getBubbleClass(message)">
|
||||||
<!-- 消息内容 -->
|
<!-- 消息内容 -->
|
||||||
<MessageTypes
|
<MessageTypes
|
||||||
@ -132,7 +131,11 @@
|
|||||||
ref="chatInputRef"
|
ref="chatInputRef"
|
||||||
:timChatManager="timChatManager"
|
:timChatManager="timChatManager"
|
||||||
:formatTime="formatTime"
|
:formatTime="formatTime"
|
||||||
:groupId="chatInfo.conversationID ? chatInfo.conversationID.replace('GROUP', '') : ''"
|
:groupId="
|
||||||
|
chatInfo.conversationID
|
||||||
|
? chatInfo.conversationID.replace('GROUP', '')
|
||||||
|
: ''
|
||||||
|
"
|
||||||
:userId="openid"
|
:userId="openid"
|
||||||
:corpId="corpId"
|
:corpId="corpId"
|
||||||
@scrollToBottom="() => scrollToBottom(true)"
|
@scrollToBottom="() => scrollToBottom(true)"
|
||||||
@ -165,7 +168,7 @@ import {
|
|||||||
handleViewDetail,
|
handleViewDetail,
|
||||||
checkIMConnectionStatus,
|
checkIMConnectionStatus,
|
||||||
} from "@/utils/chat-utils.js";
|
} from "@/utils/chat-utils.js";
|
||||||
import { sendConsultRejectedMessage, endConsultation, sendArticleMessage } from "@/utils/api.js";
|
import api from "@/utils/api.js";
|
||||||
import useGroupChat from "./hooks/use-group-chat";
|
import useGroupChat from "./hooks/use-group-chat";
|
||||||
import MessageTypes from "./components/message-types.vue";
|
import MessageTypes from "./components/message-types.vue";
|
||||||
import ChatInput from "./components/chat-input.vue";
|
import ChatInput from "./components/chat-input.vue";
|
||||||
@ -177,7 +180,7 @@ const timChatManager = globalTimChatManager;
|
|||||||
|
|
||||||
// 获取环境变量
|
// 获取环境变量
|
||||||
const env = __VITE_ENV__;
|
const env = __VITE_ENV__;
|
||||||
const corpId = env.MP_CORP_ID || '';
|
const corpId = env.MP_CORP_ID || "";
|
||||||
|
|
||||||
// 获取登录状态
|
// 获取登录状态
|
||||||
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
|
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
|
||||||
@ -202,21 +205,21 @@ const chatInfo = ref({
|
|||||||
userID: "",
|
userID: "",
|
||||||
avatar: "/static/home/avatar.svg",
|
avatar: "/static/home/avatar.svg",
|
||||||
});
|
});
|
||||||
|
|
||||||
// 评价弹窗状态
|
// 评价弹窗状态
|
||||||
const isEvaluationPopupOpen = ref(false);
|
const isEvaluationPopupOpen = ref(false);
|
||||||
|
|
||||||
// 接受问诊状态
|
// 订单状态
|
||||||
const showConsultAccept = ref(false);
|
const orderStatus = ref("");
|
||||||
|
|
||||||
|
// 计算弹框显示状态 - 只有 pending 状态才显示接受问诊组件
|
||||||
|
const showConsultAccept = computed(() => orderStatus.value === "pending");
|
||||||
|
|
||||||
// 拒绝原因对话框状态
|
// 拒绝原因对话框状态
|
||||||
const showRejectReasonModal = ref(false);
|
const showRejectReasonModal = ref(false);
|
||||||
|
|
||||||
// 消息列表相关状态
|
// 消息列表相关状态
|
||||||
const messageList = ref([]);
|
const messageList = ref([]);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
const scrollIntoView = ref("");
|
const scrollIntoView = ref("");
|
||||||
|
|
||||||
// 分页加载相关状态
|
// 分页加载相关状态
|
||||||
const isLoadingMore = ref(false);
|
const isLoadingMore = ref(false);
|
||||||
const isCompleted = ref(false);
|
const isCompleted = ref(false);
|
||||||
@ -258,46 +261,31 @@ function isSystemMessage(message) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否有待接诊的系统消息
|
// 获取群组订单状态
|
||||||
function checkConsultPendingStatus() {
|
const fetchGroupOrderStatus = async () => {
|
||||||
// 查找最新的系统消息
|
|
||||||
for (let i = messageList.value.length - 1; i >= 0; i--) {
|
|
||||||
const message = messageList.value[i];
|
|
||||||
|
|
||||||
if (message.type === "TIMCustomElem" && message.payload?.data) {
|
|
||||||
try {
|
try {
|
||||||
const data =
|
const result = await api("getGroupListByGroupId", {
|
||||||
typeof message.payload.data === "string"
|
groupId: groupId.value,
|
||||||
? JSON.parse(message.payload.data)
|
});
|
||||||
: message.payload.data;
|
|
||||||
|
|
||||||
// 如果是 consult_pending 类型的系统消息,显示接受组件
|
if (result.success && result.data) {
|
||||||
if (
|
orderStatus.value = result.data.orderStatus || "";
|
||||||
data.type === "system_message" &&
|
console.log("获取群组订单状态:", {
|
||||||
data.messageType === "consult_pending"
|
orderStatus: orderStatus.value,
|
||||||
) {
|
groupId: groupId.value,
|
||||||
showConsultAccept.value = true;
|
});
|
||||||
return;
|
} else {
|
||||||
}
|
console.error("获取群组订单状态失败:", result.message);
|
||||||
|
|
||||||
// 如果是其他系统消息类型(如已接诊、已结束、已拒绝等),隐藏接受组件
|
|
||||||
if (
|
|
||||||
data.type === "system_message" &&
|
|
||||||
(data.messageType === "consult_accepted" ||
|
|
||||||
data.messageType === "consult_ended" ||
|
|
||||||
data.messageType === "consult_rejected")
|
|
||||||
) {
|
|
||||||
showConsultAccept.value = false;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("解析系统消息失败:", error);
|
console.error("获取群组订单状态异常:", error);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 如果没有找到相关系统消息,隐藏接受组件
|
// 检查是否有待接诊的系统消息
|
||||||
showConsultAccept.value = false;
|
function checkConsultPendingStatus() {
|
||||||
|
// 直接获取最新的订单状态
|
||||||
|
fetchGroupOrderStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取消息气泡样式类
|
// 获取消息气泡样式类
|
||||||
@ -336,7 +324,7 @@ const checkLoginAndInitTIM = async () => {
|
|||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "连接中...",
|
title: "连接中...",
|
||||||
});
|
});
|
||||||
const success = await initIMAfterLogin(openid.value);
|
const success = await initIMAfterLogin();
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
if (!success) {
|
if (!success) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -391,8 +379,10 @@ const initTIMCallbacks = async () => {
|
|||||||
messageList.value.push(message);
|
messageList.value.push(message);
|
||||||
console.log("✓ 添加消息到列表,当前消息数量:", messageList.value.length);
|
console.log("✓ 添加消息到列表,当前消息数量:", messageList.value.length);
|
||||||
|
|
||||||
// 检查是否有待接诊的系统消息
|
// 如果是系统消息,重新获取订单状态
|
||||||
checkConsultPendingStatus();
|
if (isSystemMessage(message)) {
|
||||||
|
fetchGroupOrderStatus();
|
||||||
|
}
|
||||||
|
|
||||||
// 立即滚动到底部,不使用延迟
|
// 立即滚动到底部,不使用延迟
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@ -514,7 +504,7 @@ const initTIMCallbacks = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 加载消息列表
|
// 加载消息列表
|
||||||
const loadMessageList = () => {
|
const loadMessageList = async () => {
|
||||||
if (isLoading.value) {
|
if (isLoading.value) {
|
||||||
console.log("正在加载中,跳过重复加载");
|
console.log("正在加载中,跳过重复加载");
|
||||||
return;
|
return;
|
||||||
@ -531,6 +521,9 @@ const loadMessageList = () => {
|
|||||||
mask: false,
|
mask: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 获取群组订单状态
|
||||||
|
await fetchGroupOrderStatus();
|
||||||
|
|
||||||
timChatManager.enterConversation(chatInfo.value.conversationID || "test1");
|
timChatManager.enterConversation(chatInfo.value.conversationID || "test1");
|
||||||
|
|
||||||
// 标记会话为已读
|
// 标记会话为已读
|
||||||
@ -703,7 +696,6 @@ onHide(() => {
|
|||||||
stopIMMonitoring();
|
stopIMMonitoring();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const sendCommonPhrase = (content) => {
|
const sendCommonPhrase = (content) => {
|
||||||
if (chatInputRef.value) {
|
if (chatInputRef.value) {
|
||||||
chatInputRef.value.sendTextMessageFromPhrase(content);
|
chatInputRef.value.sendTextMessageFromPhrase(content);
|
||||||
@ -721,35 +713,27 @@ const handleAcceptConsult = async () => {
|
|||||||
title: "处理中...",
|
title: "处理中...",
|
||||||
});
|
});
|
||||||
|
|
||||||
// 发送接受问诊的系统消息
|
// 调用后端接口接受问诊
|
||||||
const customMessage = {
|
const result = await api("acceptConsultation", {
|
||||||
data: JSON.stringify({
|
groupId: groupId.value,
|
||||||
type: "system_message",
|
adminAccount: account.value?.userId || "",
|
||||||
messageType: "consult_accepted",
|
extraData: {
|
||||||
content: "医生已接诊",
|
acceptedBy: account.value?.userId || "",
|
||||||
timestamp: Date.now(),
|
acceptedByName: account.value?.name || "医生",
|
||||||
}),
|
},
|
||||||
description: "系统消息标记",
|
|
||||||
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) {
|
|
||||||
showConsultAccept.value = false;
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
// 重新获取订单状态
|
||||||
|
await fetchGroupOrderStatus();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "已接受问诊",
|
title: "已接受问诊",
|
||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new Error(sendResult.message || "发送失败");
|
throw new Error(result.message || "操作失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("接受问诊失败:", error);
|
console.error("接受问诊失败:", error);
|
||||||
@ -780,11 +764,11 @@ const handleRejectReasonConfirm = async (reason) => {
|
|||||||
const memberName = account.value?.name || "医生";
|
const memberName = account.value?.name || "医生";
|
||||||
|
|
||||||
// 获取群组ID
|
// 获取群组ID
|
||||||
const groupId = chatInfo.value.conversationID.replace("GROUP", "");
|
const currentGroupId = chatInfo.value.conversationID.replace("GROUP", "");
|
||||||
|
|
||||||
// 调用后端接口发送拒绝消息
|
// 调用后端接口发送拒绝消息
|
||||||
const result = await sendConsultRejectedMessage({
|
const result = await api("sendConsultRejectedMessage", {
|
||||||
groupId,
|
groupId: currentGroupId,
|
||||||
memberName,
|
memberName,
|
||||||
reason,
|
reason,
|
||||||
});
|
});
|
||||||
@ -792,7 +776,8 @@ const handleRejectReasonConfirm = async (reason) => {
|
|||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
showConsultAccept.value = false;
|
// 重新获取订单状态
|
||||||
|
await fetchGroupOrderStatus();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "已拒绝问诊",
|
title: "已拒绝问诊",
|
||||||
icon: "success",
|
icon: "success",
|
||||||
@ -821,7 +806,7 @@ const handleEndConsult = async () => {
|
|||||||
title: "处理中...",
|
title: "处理中...",
|
||||||
});
|
});
|
||||||
// 调用结束问诊接口,直接传入 groupId
|
// 调用结束问诊接口,直接传入 groupId
|
||||||
const result = await endConsultation({
|
const result = await api("endConsultation", {
|
||||||
groupId: groupId.value,
|
groupId: groupId.value,
|
||||||
adminAccount: account.value?.userId || "",
|
adminAccount: account.value?.userId || "",
|
||||||
extraData: {
|
extraData: {
|
||||||
@ -862,7 +847,6 @@ onUnmounted(() => {
|
|||||||
uni.$off("sendSurvey");
|
uni.$off("sendSurvey");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// 监听问卷发送事件
|
// 监听问卷发送事件
|
||||||
uni.$on("sendSurvey", async (data) => {
|
uni.$on("sendSurvey", async (data) => {
|
||||||
const { survey, corpId, userId, sendSurveyId } = data;
|
const { survey, corpId, userId, sendSurveyId } = data;
|
||||||
@ -885,8 +869,7 @@ uni.$on("sendSurvey", async (data) => {
|
|||||||
const customerName = chatInfo.value.customerName || "";
|
const customerName = chatInfo.value.customerName || "";
|
||||||
|
|
||||||
// 创建问卷记录
|
// 创建问卷记录
|
||||||
const { createSurveyRecord } = await import("@/utils/api.js");
|
const recordRes = await api("createSurveyRecord", {
|
||||||
const recordRes = await createSurveyRecord({
|
|
||||||
corpId,
|
corpId,
|
||||||
userId,
|
userId,
|
||||||
surveryId: survey._id,
|
surveryId: survey._id,
|
||||||
|
|||||||
@ -95,7 +95,7 @@ const initIM = async () => {
|
|||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "连接中...",
|
title: "连接中...",
|
||||||
});
|
});
|
||||||
const success = await initIMAfterLogin(openid.value);
|
const success = await initIMAfterLogin();
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
@ -122,7 +122,7 @@ const initIM = async () => {
|
|||||||
// 加载会话列表
|
// 加载会话列表
|
||||||
const loadConversationList = async () => {
|
const loadConversationList = async () => {
|
||||||
if (loading.value) return;
|
if (loading.value) return;
|
||||||
// loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log("开始加载群聊列表");
|
console.log("开始加载群聊列表");
|
||||||
@ -224,8 +224,10 @@ const setupConversationListener = () => {
|
|||||||
console.log("会话列表更新事件:", eventData);
|
console.log("会话列表更新事件:", eventData);
|
||||||
|
|
||||||
// 如果是新消息导致的会话更新
|
// 如果是新消息导致的会话更新
|
||||||
if (eventData.reason === "NEW_MESSAGE_RECEIVED_IN_CURRENT_CONVERSATION" ||
|
if (
|
||||||
eventData.reason === "NEW_MESSAGE_RECEIVED") {
|
eventData.reason === "NEW_MESSAGE_RECEIVED_IN_CURRENT_CONVERSATION" ||
|
||||||
|
eventData.reason === "NEW_MESSAGE_RECEIVED"
|
||||||
|
) {
|
||||||
const conversation = eventData.conversation;
|
const conversation = eventData.conversation;
|
||||||
if (!conversation) return;
|
if (!conversation) return;
|
||||||
|
|
||||||
@ -237,8 +239,10 @@ const setupConversationListener = () => {
|
|||||||
if (conversationIndex !== -1) {
|
if (conversationIndex !== -1) {
|
||||||
// 更新现有会话
|
// 更新现有会话
|
||||||
const existingConversation = conversationList.value[conversationIndex];
|
const existingConversation = conversationList.value[conversationIndex];
|
||||||
existingConversation.lastMessage = conversation.lastMessage || "暂无消息";
|
existingConversation.lastMessage =
|
||||||
existingConversation.lastMessageTime = conversation.lastMessageTime || Date.now();
|
conversation.lastMessage || "暂无消息";
|
||||||
|
existingConversation.lastMessageTime =
|
||||||
|
conversation.lastMessageTime || Date.now();
|
||||||
existingConversation.unreadCount = conversation.unreadCount || 0;
|
existingConversation.unreadCount = conversation.unreadCount || 0;
|
||||||
|
|
||||||
// 将该会话移到顶部
|
// 将该会话移到顶部
|
||||||
@ -365,36 +369,36 @@ onLoad(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 页面显示
|
// 页面显示
|
||||||
// onShow(async () => {
|
onShow(async () => {
|
||||||
// try {
|
try {
|
||||||
// // 初始化IM
|
// 初始化IM
|
||||||
// const imReady = await initIM();
|
const imReady = await initIM();
|
||||||
// if (!imReady) {
|
if (!imReady) {
|
||||||
// console.error("IM初始化失败");
|
console.error("IM初始化失败");
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // 先加载初始会话列表
|
// 先加载初始会话列表
|
||||||
// await loadConversationList();
|
await loadConversationList();
|
||||||
|
|
||||||
// // 再设置监听器,后续通过事件更新列表
|
// 再设置监听器,后续通过事件更新列表
|
||||||
// setupConversationListener();
|
setupConversationListener();
|
||||||
// } catch (error) {
|
} catch (error) {
|
||||||
// console.error("页面初始化失败:", error);
|
console.error("页面初始化失败:", error);
|
||||||
// uni.showToast({
|
uni.showToast({
|
||||||
// title: "初始化失败,请重试",
|
title: "初始化失败,请重试",
|
||||||
// icon: "none",
|
icon: "none",
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// 页面隐藏
|
// 页面隐藏
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
// 移除消息监听
|
// 移除消息监听
|
||||||
// if (globalTimChatManager) {
|
if (globalTimChatManager) {
|
||||||
// globalTimChatManager.setCallback("onConversationListUpdated", null);
|
globalTimChatManager.setCallback("onConversationListUpdated", null);
|
||||||
// globalTimChatManager.setCallback("onMessageReceived", null);
|
globalTimChatManager.setCallback("onMessageReceived", null);
|
||||||
// }
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -87,11 +87,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import {
|
import api from "@/utils/api.js";
|
||||||
getSurveyCateList,
|
|
||||||
getSurveyList,
|
|
||||||
createSurveyRecord,
|
|
||||||
} from "@/utils/api.js";
|
|
||||||
import useAccountStore from "@/store/account.js";
|
import useAccountStore from "@/store/account.js";
|
||||||
import EmptyData from "@/components/empty-data.vue";
|
import EmptyData from "@/components/empty-data.vue";
|
||||||
|
|
||||||
@ -119,7 +115,7 @@ const emptyText = ref("");
|
|||||||
// 获取分类列表
|
// 获取分类列表
|
||||||
const getCategoryList = async () => {
|
const getCategoryList = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getSurveyCateList({ corpId: corpId });
|
const res = await api("getSurveyCateList", { corpId: corpId });
|
||||||
if (res.success && res.list) {
|
if (res.success && res.list) {
|
||||||
const cates = res.list || [];
|
const cates = res.list || [];
|
||||||
categoryList.value = [{ _id: "", label: "全部" }, ...cates];
|
categoryList.value = [{ _id: "", label: "全部" }, ...cates];
|
||||||
@ -169,7 +165,7 @@ const loadSurveyList = async () => {
|
|||||||
params.cateIds = [currentCateId.value];
|
params.cateIds = [currentCateId.value];
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await getSurveyList(params);
|
const res = await api("getSurveyList", params);
|
||||||
if (res.success && res) {
|
if (res.success && res) {
|
||||||
const { list = [], total: count = 0 } = res;
|
const { list = [], total: count = 0 } = res;
|
||||||
|
|
||||||
|
|||||||
@ -52,15 +52,7 @@ export default defineStore("accountStore", () => {
|
|||||||
account.value = res.data;
|
account.value = res.data;
|
||||||
openid.value = res.data.openid;
|
openid.value = res.data.openid;
|
||||||
// 登录成功后初始化腾讯IM
|
// 登录成功后初始化腾讯IM
|
||||||
try {
|
|
||||||
console.log('开始初始化腾讯IM,userID:', res.data.openid);
|
|
||||||
await initGlobalTIM(res.data.openid);
|
|
||||||
isIMInitialized.value = true;
|
|
||||||
console.log('腾讯IM初始化成功');
|
|
||||||
} catch (imError) {
|
|
||||||
console.error('腾讯IM初始化失败:', imError);
|
|
||||||
// IM初始化失败不影响登录流程
|
|
||||||
}
|
|
||||||
await getDoctorInfo(openid.value);
|
await getDoctorInfo(openid.value);
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
@ -79,18 +71,21 @@ export default defineStore("accountStore", () => {
|
|||||||
weChatOpenId: account.value.openid,
|
weChatOpenId: account.value.openid,
|
||||||
});
|
});
|
||||||
doctorInfo.value = res?.data || null;
|
doctorInfo.value = res?.data || null;
|
||||||
|
await initIMAfterLogin();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('获取医生信息失败:', e);
|
console.error('获取医生信息失败:', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async function initIMAfterLogin() {
|
||||||
async function initIMAfterLogin(userID) {
|
|
||||||
if (isIMInitialized.value) {
|
if (isIMInitialized.value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
const userID = doctorInfo.value.userid;
|
||||||
|
console.log('开始初始化腾讯IM,userID:', userID);
|
||||||
await initGlobalTIM(userID);
|
await initGlobalTIM(userID);
|
||||||
isIMInitialized.value = true;
|
isIMInitialized.value = true;
|
||||||
|
console.log('腾讯IM初始化成功');
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('IM初始化失败:', error);
|
console.error('IM初始化失败:', error);
|
||||||
|
|||||||
77
utils/api.js
77
utils/api.js
@ -65,7 +65,9 @@ const urlsConfig = {
|
|||||||
getChatRecordsByGroupId: "getChatRecordsByGroupId",
|
getChatRecordsByGroupId: "getChatRecordsByGroupId",
|
||||||
sendConsultRejectedMessage: "sendConsultRejectedMessage",
|
sendConsultRejectedMessage: "sendConsultRejectedMessage",
|
||||||
endConsultation: "endConsultation",
|
endConsultation: "endConsultation",
|
||||||
getGroupListByGroupId: "getGroupListByGroupId"
|
getGroupListByGroupId: "getGroupListByGroupId",
|
||||||
|
acceptConsultation: "acceptConsultation",
|
||||||
|
sendArticleMessage: "sendArticleMessage"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -99,76 +101,3 @@ export default async function api(urlId, data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 宣教文章相关 API
|
|
||||||
export async function getArticleCateList(data) {
|
|
||||||
return api('getArticleCateList', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getArticleList(data) {
|
|
||||||
return api('getArticleList', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getArticle(data) {
|
|
||||||
return api('getArticle', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function addArticleSendRecord(data) {
|
|
||||||
return api('addArticleSendRecord', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 问卷相关 API
|
|
||||||
export async function getSurveyCateList(data) {
|
|
||||||
return api('getSurveyCateList', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getSurveyList(data) {
|
|
||||||
return api('getSurveyList', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createSurveyRecord(data) {
|
|
||||||
return api('createSurveyRecord', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getSurveyDetail(data) {
|
|
||||||
return api('getSurveyDetail', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// IM 系统消息相关 API
|
|
||||||
export async function sendConsultRejectedMessage(data) {
|
|
||||||
return request({
|
|
||||||
url: '/getYoucanData/im',
|
|
||||||
data: {
|
|
||||||
type: 'sendConsultRejectedMessage',
|
|
||||||
...data
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送宣教文章消息
|
|
||||||
export async function sendArticleMessage(data) {
|
|
||||||
return request({
|
|
||||||
url: '/getYoucanData/im',
|
|
||||||
data: {
|
|
||||||
type: 'sendArticleMessage',
|
|
||||||
...data
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 结束问诊接口
|
|
||||||
export async function endConsultation(data) {
|
|
||||||
return request({
|
|
||||||
url: '/getYoucanData/im',
|
|
||||||
data: {
|
|
||||||
type: 'endConsultation',
|
|
||||||
...data
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据群组ID获取群组记录
|
|
||||||
export async function getGroupListByGroupId(data) {
|
|
||||||
return api('getGroupListByGroupId', data);
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user