fix: 问题修复
This commit is contained in:
parent
e47d5b4dd8
commit
6d97ecfb43
@ -51,6 +51,9 @@
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
<template #footer>
|
||||
<button-footer :showCancel="false" confirmText="返回首页" @confirm="backHome" />
|
||||
</template>
|
||||
</full-page>
|
||||
</template>
|
||||
<script setup>
|
||||
@ -62,6 +65,7 @@ import useAccount from '@/store/account';
|
||||
import api from '@/utils/api';
|
||||
|
||||
import FullPage from '@/components/full-page.vue';
|
||||
import buttonFooter from '@/components/button-footer.vue';
|
||||
|
||||
const team = ref(null);
|
||||
const { useLoad } = useGuard();
|
||||
@ -104,6 +108,10 @@ async function getTeam(corpId, teamId) {
|
||||
}
|
||||
}
|
||||
|
||||
function backHome() {
|
||||
uni.switchTab({ url: '/pages/home/home' })
|
||||
}
|
||||
|
||||
useLoad(options => {
|
||||
corpId.value = options.corpId;
|
||||
if (options.teamId && options.corpId) {
|
||||
|
||||
@ -15,6 +15,8 @@ import useAccountStore from "@/store/account";
|
||||
const env = __VITE_ENV__;
|
||||
const appid = env.MP_WX_APP_ID;
|
||||
const { account } = storeToRefs(useAccountStore());
|
||||
const { login } = useAccountStore();
|
||||
|
||||
|
||||
|
||||
const loading = ref(false);
|
||||
@ -38,6 +40,7 @@ async function changeTeam({ teamId, corpId, corpUserId }) {
|
||||
teamId: team.value.teamId,
|
||||
corpUserId: corpUserId || ''
|
||||
});
|
||||
await login()
|
||||
if (account.value) {
|
||||
bindTeam(corpUserId)
|
||||
} else {
|
||||
|
||||
@ -1,50 +1,29 @@
|
||||
<template>
|
||||
<page-meta
|
||||
:page-style="'overflow:' + (keyboardHeight > 0 ? 'hidden' : 'visible')"
|
||||
></page-meta>
|
||||
<page-meta :page-style="'overflow:' + (keyboardHeight > 0 ? 'hidden' : 'visible')"></page-meta>
|
||||
<view class="chat-page" :style="{ paddingBottom: keyboardHeight + 'px' }">
|
||||
<!-- 患者信息栏 -->
|
||||
<view class="patient-info-bar" v-if="patientInfo.name">
|
||||
<view class="patient-info-content">
|
||||
<view class="patient-basic-info">
|
||||
<text class="patient-name">{{ patientInfo.name }}</text>
|
||||
<text class="patient-detail"
|
||||
>{{ patientInfo.sex }} · {{ patientInfo.age }}岁</text
|
||||
>
|
||||
</view>
|
||||
<view class="header-actions">
|
||||
<view
|
||||
class="status-badge"
|
||||
:class="chatStatusInfo.badgeClass"
|
||||
v-if="chatStatusInfo.badgeText"
|
||||
>
|
||||
<text class="badge-text">{{ chatStatusInfo.badgeText }}</text>
|
||||
</view>
|
||||
<view
|
||||
v-if="showSubscribeEntry"
|
||||
class="remind-btn"
|
||||
@click="handleSubscribeReminder"
|
||||
>
|
||||
<text class="remind-btn-text">接收提醒</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="patient-basic-info">
|
||||
<text class="patient-name">{{ patientInfo.name }}</text>
|
||||
<text class="patient-detail">{{ patientInfo.sex }} · {{ patientInfo.age }}岁</text>
|
||||
</view>
|
||||
<view class="header-actions">
|
||||
<view class="status-badge" :class="chatStatusInfo.badgeClass" v-if="chatStatusInfo.badgeText">
|
||||
<text class="badge-text">{{ chatStatusInfo.badgeText }}</text>
|
||||
</view>
|
||||
<view v-if="showSubscribeEntry" class="remind-btn" @click="handleSubscribeReminder">
|
||||
<text class="remind-btn-text">接收提醒</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 聊天消息区域 -->
|
||||
<scroll-view
|
||||
class="chat-content"
|
||||
:style="{
|
||||
bottom: (keyboardHeight > 0 ? keyboardHeight + 60 : 60) + 'px',
|
||||
}"
|
||||
scroll-y="true"
|
||||
enhanced="true"
|
||||
bounces="false"
|
||||
:scroll-into-view="scrollIntoView"
|
||||
@scroll="onScroll"
|
||||
@scrolltoupper="handleScrollToUpper"
|
||||
ref="chatScrollView"
|
||||
>
|
||||
<scroll-view class="chat-content" :style="{
|
||||
bottom: (keyboardHeight > 0 ? keyboardHeight + 60 : 60) + 'px',
|
||||
}" scroll-y="true" enhanced="true" bounces="false" :scroll-into-view="scrollIntoView" @scroll="onScroll"
|
||||
@scrolltoupper="handleScrollToUpper" ref="chatScrollView">
|
||||
<!-- 加载更多提示 -->
|
||||
<view class="load-more-tip" v-if="messageList.length >= 15">
|
||||
<view class="loading" v-if="isLoadingMore">
|
||||
@ -60,21 +39,13 @@
|
||||
|
||||
<!-- 聊天消息列表 -->
|
||||
<view class="message-list" @click="closeMorePanel">
|
||||
<view
|
||||
v-for="(message, index) in messageList"
|
||||
:key="message.ID"
|
||||
:id="`msg-${message.ID}`"
|
||||
class="message-item"
|
||||
<view v-for="(message, index) in messageList" :key="message.ID" :id="`msg-${message.ID}`" class="message-item"
|
||||
:class="{
|
||||
'message-right': message.flow === 'out',
|
||||
'message-left': message.flow === 'in',
|
||||
}"
|
||||
>
|
||||
}">
|
||||
<!-- 时间分割线 -->
|
||||
<view
|
||||
v-if="shouldShowTime(message, index, messageList)"
|
||||
class="time-divider"
|
||||
>
|
||||
<view v-if="shouldShowTime(message, index, messageList)" class="time-divider">
|
||||
<text class="time-text">{{ formatTime(message.lastTime) }}</text>
|
||||
</view>
|
||||
|
||||
@ -85,31 +56,20 @@
|
||||
<!-- 消息内容 -->
|
||||
<view v-else class="message-content">
|
||||
<!-- 发送者头像(统一处理) -->
|
||||
<image
|
||||
v-if="message.flow === 'in'"
|
||||
class="doctor-msg-avatar"
|
||||
:src="getUserAvatar(message.from)"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<image v-if="message.flow === 'in'" class="doctor-msg-avatar" :src="getUserAvatar(message.from)"
|
||||
mode="aspectFill" />
|
||||
|
||||
<!-- 发送者头像(统一处理) -->
|
||||
<image
|
||||
v-if="message.flow === 'out'"
|
||||
class="user-msg-avatar"
|
||||
:src="getUserAvatar(message.from)"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<image v-if="message.flow === 'out'" class="user-msg-avatar" :src="getUserAvatar(message.from)"
|
||||
mode="aspectFill" />
|
||||
|
||||
<!-- 消息内容区域 -->
|
||||
<view class="message-bubble-container">
|
||||
<!-- 用户名显示 -->
|
||||
<view
|
||||
class="username-label"
|
||||
:class="{
|
||||
left: message.flow === 'in',
|
||||
right: message.flow === 'out',
|
||||
}"
|
||||
>
|
||||
<view class="username-label" :class="{
|
||||
left: message.flow === 'in',
|
||||
right: message.flow === 'out',
|
||||
}">
|
||||
<text class="username-text">{{
|
||||
chatMember[message.from]?.name
|
||||
}}</text>
|
||||
@ -117,25 +77,15 @@
|
||||
|
||||
<view class="message-bubble" :class="getBubbleClass(message)">
|
||||
<!-- 消息内容 -->
|
||||
<MessageTypes
|
||||
:corpId="corpId"
|
||||
:message="message"
|
||||
:formatTime="formatTime"
|
||||
:playingVoiceId="playingVoiceId"
|
||||
@playVoice="playVoice"
|
||||
@previewImage="previewImage"
|
||||
@viewDetail="(message) => handleViewDetail(message)"
|
||||
/>
|
||||
<MessageTypes :corpId="corpId" :message="message" :formatTime="formatTime"
|
||||
:playingVoiceId="playingVoiceId" @playVoice="playVoice" @previewImage="previewImage"
|
||||
@viewDetail="(message) => handleViewDetail(message)" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 发送状态 -->
|
||||
<view v-if="message.flow === 'out'" class="message-status">
|
||||
<text
|
||||
v-if="message.status === 'failed'"
|
||||
class="status-text failed"
|
||||
>发送失败</text
|
||||
>
|
||||
<text v-if="message.status === 'failed'" class="status-text failed">发送失败</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -149,22 +99,12 @@
|
||||
<ConsultApply v-if="showConsultApply" @apply="handleApplyConsult" />
|
||||
|
||||
<!-- 聊天输入组件 -->
|
||||
<ChatInput
|
||||
v-if="!isEvaluationPopupOpen && !showConsultCancel && !showConsultApply"
|
||||
ref="chatInputRef"
|
||||
:timChatManager="timChatManager"
|
||||
:formatTime="formatTime"
|
||||
:groupId="
|
||||
chatInfo.conversationID
|
||||
<ChatInput v-if="!isEvaluationPopupOpen && !showConsultCancel && !showConsultApply" ref="chatInputRef"
|
||||
:timChatManager="timChatManager" :formatTime="formatTime" :groupId="chatInfo.conversationID
|
||||
? chatInfo.conversationID.replace('GROUP', '')
|
||||
: ''
|
||||
"
|
||||
:userId="openid"
|
||||
:corpId="corpId.value"
|
||||
:keyboardHeight="keyboardHeight"
|
||||
@scrollToBottom="() => scrollToBottom(true)"
|
||||
@messageSent="() => scrollToBottom(true)"
|
||||
/>
|
||||
" :userId="openid" :corpId="corpId.value" :keyboardHeight="keyboardHeight"
|
||||
@scrollToBottom="() => scrollToBottom(true)" @messageSent="() => scrollToBottom(true)" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -194,32 +134,33 @@ import {
|
||||
} from "@/utils/chat-utils.js";
|
||||
import api from "@/utils/api.js";
|
||||
import useGroupChat from "./hooks/use-group-chat";
|
||||
import MessageTypes from "./components/message-types.vue";
|
||||
import ChatInput from "./components/chat-input.vue";
|
||||
import SystemMessage from "./components/system-message.vue";
|
||||
import ConsultCancel from "./components/consult-cancel.vue";
|
||||
import ConsultApply from "./components/consult-apply.vue";
|
||||
import {
|
||||
checkConversationSubscribeEntryVisible,
|
||||
requestConversationSubscribeMessage,
|
||||
} from "@/utils/subscribe-message";
|
||||
import {
|
||||
SUBSCRIBE_MESSAGE_ROLE,
|
||||
SUBSCRIBE_MESSAGE_SCENE,
|
||||
} from "@/utils/subscribe-message-config";
|
||||
import MessageTypes from "./components/message-types.vue";
|
||||
import ChatInput from "./components/chat-input.vue";
|
||||
import SystemMessage from "./components/system-message.vue";
|
||||
import ConsultCancel from "./components/consult-cancel.vue";
|
||||
import ConsultApply from "./components/consult-apply.vue";
|
||||
import {
|
||||
checkConversationSubscribeEntryVisible,
|
||||
requestConversationSubscribeMessage,
|
||||
} from "@/utils/subscribe-message";
|
||||
import {
|
||||
SUBSCRIBE_MESSAGE_ROLE,
|
||||
SUBSCRIBE_MESSAGE_SCENE,
|
||||
} from "@/utils/subscribe-message-config";
|
||||
|
||||
const timChatManager = globalTimChatManager;
|
||||
|
||||
// corpId 从群组信息中获取
|
||||
const corpId = ref("");
|
||||
const showSubscribeEntry = ref(false);
|
||||
// corpId 从群组信息中获取
|
||||
const corpId = ref("");
|
||||
const showSubscribeEntry = ref(false);
|
||||
|
||||
// 获取登录状态
|
||||
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
|
||||
const { initIMAfterLogin } = useAccountStore();
|
||||
const { initIMAfterLogin, login } = useAccountStore();
|
||||
|
||||
// 聊天输入组件引用
|
||||
const chatInputRef = ref(null);
|
||||
const loginPromise = ref(null);
|
||||
|
||||
const groupId = ref("");
|
||||
const { chatMember, getGroupInfo, getUserAvatar } = useGroupChat(groupId);
|
||||
@ -463,7 +404,10 @@ function getBubbleClass(message) {
|
||||
|
||||
// 页面加载
|
||||
onLoad(async (options) => {
|
||||
groupId.value = options.groupID || "";
|
||||
loginPromise.value = login();
|
||||
await loginPromise.value;
|
||||
loginPromise.value = null;
|
||||
groupId.value = decodeURIComponent(options.groupID) || "";
|
||||
messageList.value = [];
|
||||
isLoading.value = false;
|
||||
if (options.conversationID) {
|
||||
@ -535,7 +479,7 @@ const initTIMCallbacks = async () => {
|
||||
loadMessageList();
|
||||
}
|
||||
});
|
||||
timChatManager.setCallback("onSDKNotReady", () => {});
|
||||
timChatManager.setCallback("onSDKNotReady", () => { });
|
||||
|
||||
timChatManager.setCallback("onMessageReceived", (message) => {
|
||||
console.log("页面收到消息:", {
|
||||
@ -874,11 +818,15 @@ const handleScrollToUpper = async () => {
|
||||
};
|
||||
|
||||
// 页面显示
|
||||
onShow(() => {
|
||||
loadSubscribeEntryState();
|
||||
if (!account.value || !openid.value) {
|
||||
uni.redirectTo({
|
||||
url: "/pages/login/login",
|
||||
onShow(async () => {
|
||||
if (loginPromise.value) {
|
||||
await loginPromise.value;
|
||||
}
|
||||
|
||||
loadSubscribeEntryState();
|
||||
if (!account.value || !openid.value) {
|
||||
uni.redirectTo({
|
||||
url: "/pages/login/login",
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -924,16 +872,16 @@ onShow(() => {
|
||||
}
|
||||
|
||||
startIMMonitoring(30000);
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => corpId.value,
|
||||
() => {
|
||||
loadSubscribeEntryState();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => corpId.value,
|
||||
() => {
|
||||
loadSubscribeEntryState();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 页面隐藏
|
||||
onHide(() => {
|
||||
@ -1003,7 +951,7 @@ const handleCancelConsult = async () => {
|
||||
};
|
||||
|
||||
// 处理咨询申请
|
||||
const handleApplyConsult = async () => {
|
||||
const handleApplyConsult = async () => {
|
||||
try {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
@ -1087,36 +1035,36 @@ const handleApplyConsult = async () => {
|
||||
title: error.message || "操作失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubscribeReminder = async () => {
|
||||
await requestConversationSubscribeMessage({
|
||||
role: SUBSCRIBE_MESSAGE_ROLE.PATIENT,
|
||||
scene: SUBSCRIBE_MESSAGE_SCENE.CHAT,
|
||||
conversationId: chatInfo.value.conversationID || "",
|
||||
groupId: groupId.value || "",
|
||||
corpId: corpId.value || "",
|
||||
patientId: patientId.value || "",
|
||||
userId: openid.value || account.value?.openid || "",
|
||||
openid: openid.value || account.value?.openid || "",
|
||||
unionid: account.value?.unionid || "",
|
||||
extraData: {
|
||||
orderStatus: orderStatus.value || "",
|
||||
page: "pages/message/index",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const loadSubscribeEntryState = async () => {
|
||||
showSubscribeEntry.value = await checkConversationSubscribeEntryVisible(
|
||||
corpId.value || "",
|
||||
true
|
||||
);
|
||||
};
|
||||
|
||||
// 页面卸载
|
||||
onUnmounted(() => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubscribeReminder = async () => {
|
||||
await requestConversationSubscribeMessage({
|
||||
role: SUBSCRIBE_MESSAGE_ROLE.PATIENT,
|
||||
scene: SUBSCRIBE_MESSAGE_SCENE.CHAT,
|
||||
conversationId: chatInfo.value.conversationID || "",
|
||||
groupId: groupId.value || "",
|
||||
corpId: corpId.value || "",
|
||||
patientId: patientId.value || "",
|
||||
userId: openid.value || account.value?.openid || "",
|
||||
openid: openid.value || account.value?.openid || "",
|
||||
unionid: account.value?.unionid || "",
|
||||
extraData: {
|
||||
orderStatus: orderStatus.value || "",
|
||||
page: "pages/message/index",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const loadSubscribeEntryState = async () => {
|
||||
showSubscribeEntry.value = await checkConversationSubscribeEntryVisible(
|
||||
corpId.value || "",
|
||||
true
|
||||
);
|
||||
};
|
||||
|
||||
// 页面卸载
|
||||
onUnmounted(() => {
|
||||
clearMessageCache();
|
||||
|
||||
// 移除键盘监听
|
||||
|
||||
@ -25,6 +25,9 @@ export default defineStore("accountStore", () => {
|
||||
|
||||
async function login(phoneCode = '') {
|
||||
if (loading.value) return;
|
||||
if (account.value && account.value.mobile) {
|
||||
return account.value
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const { code } = await uni.login({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user