fix: 问题修复

This commit is contained in:
huxuejian 2026-04-30 17:55:34 +08:00
parent e47d5b4dd8
commit 6d97ecfb43
4 changed files with 125 additions and 163 deletions

View File

@ -51,6 +51,9 @@
</view> </view>
</template> </template>
</view> </view>
<template #footer>
<button-footer :showCancel="false" confirmText="返回首页" @confirm="backHome" />
</template>
</full-page> </full-page>
</template> </template>
<script setup> <script setup>
@ -62,6 +65,7 @@ import useAccount from '@/store/account';
import api from '@/utils/api'; import api from '@/utils/api';
import FullPage from '@/components/full-page.vue'; import FullPage from '@/components/full-page.vue';
import buttonFooter from '@/components/button-footer.vue';
const team = ref(null); const team = ref(null);
const { useLoad } = useGuard(); const { useLoad } = useGuard();
@ -104,6 +108,10 @@ async function getTeam(corpId, teamId) {
} }
} }
function backHome() {
uni.switchTab({ url: '/pages/home/home' })
}
useLoad(options => { useLoad(options => {
corpId.value = options.corpId; corpId.value = options.corpId;
if (options.teamId && options.corpId) { if (options.teamId && options.corpId) {

View File

@ -15,6 +15,8 @@ import useAccountStore from "@/store/account";
const env = __VITE_ENV__; const env = __VITE_ENV__;
const appid = env.MP_WX_APP_ID; const appid = env.MP_WX_APP_ID;
const { account } = storeToRefs(useAccountStore()); const { account } = storeToRefs(useAccountStore());
const { login } = useAccountStore();
const loading = ref(false); const loading = ref(false);
@ -38,6 +40,7 @@ async function changeTeam({ teamId, corpId, corpUserId }) {
teamId: team.value.teamId, teamId: team.value.teamId,
corpUserId: corpUserId || '' corpUserId: corpUserId || ''
}); });
await login()
if (account.value) { if (account.value) {
bindTeam(corpUserId) bindTeam(corpUserId)
} else { } else {

View File

@ -1,30 +1,18 @@
<template> <template>
<page-meta <page-meta :page-style="'overflow:' + (keyboardHeight > 0 ? 'hidden' : 'visible')"></page-meta>
:page-style="'overflow:' + (keyboardHeight > 0 ? 'hidden' : 'visible')"
></page-meta>
<view class="chat-page" :style="{ paddingBottom: keyboardHeight + 'px' }"> <view class="chat-page" :style="{ paddingBottom: keyboardHeight + 'px' }">
<!-- 患者信息栏 --> <!-- 患者信息栏 -->
<view class="patient-info-bar" v-if="patientInfo.name"> <view class="patient-info-bar" v-if="patientInfo.name">
<view class="patient-info-content"> <view class="patient-info-content">
<view class="patient-basic-info"> <view class="patient-basic-info">
<text class="patient-name">{{ patientInfo.name }}</text> <text class="patient-name">{{ patientInfo.name }}</text>
<text class="patient-detail" <text class="patient-detail">{{ patientInfo.sex }} · {{ patientInfo.age }}</text>
>{{ patientInfo.sex }} · {{ patientInfo.age }}</text
>
</view> </view>
<view class="header-actions"> <view class="header-actions">
<view <view class="status-badge" :class="chatStatusInfo.badgeClass" v-if="chatStatusInfo.badgeText">
class="status-badge"
:class="chatStatusInfo.badgeClass"
v-if="chatStatusInfo.badgeText"
>
<text class="badge-text">{{ chatStatusInfo.badgeText }}</text> <text class="badge-text">{{ chatStatusInfo.badgeText }}</text>
</view> </view>
<view <view v-if="showSubscribeEntry" class="remind-btn" @click="handleSubscribeReminder">
v-if="showSubscribeEntry"
class="remind-btn"
@click="handleSubscribeReminder"
>
<text class="remind-btn-text">接收提醒</text> <text class="remind-btn-text">接收提醒</text>
</view> </view>
</view> </view>
@ -32,19 +20,10 @@
</view> </view>
<!-- 聊天消息区域 --> <!-- 聊天消息区域 -->
<scroll-view <scroll-view class="chat-content" :style="{
class="chat-content"
:style="{
bottom: (keyboardHeight > 0 ? keyboardHeight + 60 : 60) + 'px', bottom: (keyboardHeight > 0 ? keyboardHeight + 60 : 60) + 'px',
}" }" scroll-y="true" enhanced="true" bounces="false" :scroll-into-view="scrollIntoView" @scroll="onScroll"
scroll-y="true" @scrolltoupper="handleScrollToUpper" ref="chatScrollView">
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="load-more-tip" v-if="messageList.length >= 15">
<view class="loading" v-if="isLoadingMore"> <view class="loading" v-if="isLoadingMore">
@ -60,21 +39,13 @@
<!-- 聊天消息列表 --> <!-- 聊天消息列表 -->
<view class="message-list" @click="closeMorePanel"> <view class="message-list" @click="closeMorePanel">
<view <view v-for="(message, index) in messageList" :key="message.ID" :id="`msg-${message.ID}`" class="message-item"
v-for="(message, index) in messageList"
:key="message.ID"
:id="`msg-${message.ID}`"
class="message-item"
:class="{ :class="{
'message-right': message.flow === 'out', 'message-right': message.flow === 'out',
'message-left': message.flow === 'in', 'message-left': message.flow === 'in',
}" }">
>
<!-- 时间分割线 --> <!-- 时间分割线 -->
<view <view v-if="shouldShowTime(message, index, messageList)" class="time-divider">
v-if="shouldShowTime(message, index, messageList)"
class="time-divider"
>
<text class="time-text">{{ formatTime(message.lastTime) }}</text> <text class="time-text">{{ formatTime(message.lastTime) }}</text>
</view> </view>
@ -85,31 +56,20 @@
<!-- 消息内容 --> <!-- 消息内容 -->
<view v-else class="message-content"> <view v-else class="message-content">
<!-- 发送者头像统一处理 --> <!-- 发送者头像统一处理 -->
<image <image v-if="message.flow === 'in'" class="doctor-msg-avatar" :src="getUserAvatar(message.from)"
v-if="message.flow === 'in'" mode="aspectFill" />
class="doctor-msg-avatar"
:src="getUserAvatar(message.from)"
mode="aspectFill"
/>
<!-- 发送者头像统一处理 --> <!-- 发送者头像统一处理 -->
<image <image v-if="message.flow === 'out'" class="user-msg-avatar" :src="getUserAvatar(message.from)"
v-if="message.flow === 'out'" mode="aspectFill" />
class="user-msg-avatar"
:src="getUserAvatar(message.from)"
mode="aspectFill"
/>
<!-- 消息内容区域 --> <!-- 消息内容区域 -->
<view class="message-bubble-container"> <view class="message-bubble-container">
<!-- 用户名显示 --> <!-- 用户名显示 -->
<view <view class="username-label" :class="{
class="username-label"
:class="{
left: message.flow === 'in', left: message.flow === 'in',
right: message.flow === 'out', right: message.flow === 'out',
}" }">
>
<text class="username-text">{{ <text class="username-text">{{
chatMember[message.from]?.name chatMember[message.from]?.name
}}</text> }}</text>
@ -117,25 +77,15 @@
<view class="message-bubble" :class="getBubbleClass(message)"> <view class="message-bubble" :class="getBubbleClass(message)">
<!-- 消息内容 --> <!-- 消息内容 -->
<MessageTypes <MessageTypes :corpId="corpId" :message="message" :formatTime="formatTime"
:corpId="corpId" :playingVoiceId="playingVoiceId" @playVoice="playVoice" @previewImage="previewImage"
:message="message" @viewDetail="(message) => handleViewDetail(message)" />
:formatTime="formatTime"
:playingVoiceId="playingVoiceId"
@playVoice="playVoice"
@previewImage="previewImage"
@viewDetail="(message) => handleViewDetail(message)"
/>
</view> </view>
</view> </view>
<!-- 发送状态 --> <!-- 发送状态 -->
<view v-if="message.flow === 'out'" class="message-status"> <view v-if="message.flow === 'out'" class="message-status">
<text <text v-if="message.status === 'failed'" class="status-text failed">发送失败</text>
v-if="message.status === 'failed'"
class="status-text failed"
>发送失败</text
>
</view> </view>
</view> </view>
</view> </view>
@ -149,22 +99,12 @@
<ConsultApply v-if="showConsultApply" @apply="handleApplyConsult" /> <ConsultApply v-if="showConsultApply" @apply="handleApplyConsult" />
<!-- 聊天输入组件 --> <!-- 聊天输入组件 -->
<ChatInput <ChatInput v-if="!isEvaluationPopupOpen && !showConsultCancel && !showConsultApply" ref="chatInputRef"
v-if="!isEvaluationPopupOpen && !showConsultCancel && !showConsultApply" :timChatManager="timChatManager" :formatTime="formatTime" :groupId="chatInfo.conversationID
ref="chatInputRef"
:timChatManager="timChatManager"
:formatTime="formatTime"
:groupId="
chatInfo.conversationID
? chatInfo.conversationID.replace('GROUP', '') ? chatInfo.conversationID.replace('GROUP', '')
: '' : ''
" " :userId="openid" :corpId="corpId.value" :keyboardHeight="keyboardHeight"
:userId="openid" @scrollToBottom="() => scrollToBottom(true)" @messageSent="() => scrollToBottom(true)" />
:corpId="corpId.value"
:keyboardHeight="keyboardHeight"
@scrollToBottom="() => scrollToBottom(true)"
@messageSent="() => scrollToBottom(true)"
/>
</view> </view>
</template> </template>
@ -216,10 +156,11 @@ const showSubscribeEntry = ref(false);
// //
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore()); const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
const { initIMAfterLogin } = useAccountStore(); const { initIMAfterLogin, login } = useAccountStore();
// //
const chatInputRef = ref(null); const chatInputRef = ref(null);
const loginPromise = ref(null);
const groupId = ref(""); const groupId = ref("");
const { chatMember, getGroupInfo, getUserAvatar } = useGroupChat(groupId); const { chatMember, getGroupInfo, getUserAvatar } = useGroupChat(groupId);
@ -463,7 +404,10 @@ function getBubbleClass(message) {
// //
onLoad(async (options) => { onLoad(async (options) => {
groupId.value = options.groupID || ""; loginPromise.value = login();
await loginPromise.value;
loginPromise.value = null;
groupId.value = decodeURIComponent(options.groupID) || "";
messageList.value = []; messageList.value = [];
isLoading.value = false; isLoading.value = false;
if (options.conversationID) { if (options.conversationID) {
@ -535,7 +479,7 @@ const initTIMCallbacks = async () => {
loadMessageList(); loadMessageList();
} }
}); });
timChatManager.setCallback("onSDKNotReady", () => {}); timChatManager.setCallback("onSDKNotReady", () => { });
timChatManager.setCallback("onMessageReceived", (message) => { timChatManager.setCallback("onMessageReceived", (message) => {
console.log("页面收到消息:", { console.log("页面收到消息:", {
@ -874,7 +818,11 @@ const handleScrollToUpper = async () => {
}; };
// //
onShow(() => { onShow(async () => {
if (loginPromise.value) {
await loginPromise.value;
}
loadSubscribeEntryState(); loadSubscribeEntryState();
if (!account.value || !openid.value) { if (!account.value || !openid.value) {
uni.redirectTo({ uni.redirectTo({

View File

@ -25,6 +25,9 @@ export default defineStore("accountStore", () => {
async function login(phoneCode = '') { async function login(phoneCode = '') {
if (loading.value) return; if (loading.value) return;
if (account.value && account.value.mobile) {
return account.value
}
loading.value = true; loading.value = true;
try { try {
const { code } = await uni.login({ const { code } = await uni.login({