diff --git a/pages/ai-consult/chat.vue b/pages/ai-consult/chat.vue index 4a318f5..ee2aeb4 100644 --- a/pages/ai-consult/chat.vue +++ b/pages/ai-consult/chat.vue @@ -16,7 +16,7 @@ {{ displayContent(item) }} - + {{ assistantDisplayName }} @@ -28,7 +28,7 @@ - {{ assistantDisplayName }} + {{ assistantDisplayName }} @@ -62,8 +62,11 @@ const waitingAi = ref(false); const bottomId = ref(''); const active = ref(false); const keyboardHeight = ref(0); +const avatarLoadFailed = ref(false); +const defaultAssistantAvatar = '/static/home/ai-consult-assistant.png'; const assistantDisplayName = computed(() => removeAiLabel(session.value?.assistantName, '咨询助理')); -const rateAssistantInfo = computed(() => ({ name: assistantDisplayName.value, title: '咨询助理', department: session.value?.teamName || '', avatar: '' })); +const assistantAvatar = computed(() => avatarLoadFailed.value ? defaultAssistantAvatar : (session.value?.assistantAvatar || defaultAssistantAvatar)); +const rateAssistantInfo = computed(() => ({ name: assistantDisplayName.value, title: '咨询助理', department: session.value?.teamName || '', avatar: assistantAvatar.value })); const patientDisplayName = computed(() => patientInfo.value?.name || session.value?.customerName || '未建档患者'); const patientDetail = computed(() => { const patient = patientInfo.value || {}; @@ -109,6 +112,9 @@ function handleKeyboardHeightChange(res) { keyboardHeight.value = Math.max(0, Number(res?.height) || 0); if (keyboardHeight.value > 0) scrollToBottom(); } +function handleAssistantAvatarError() { + avatarLoadFailed.value = true; +} function openPatientInfo() { const customerId = session.value?.archiveCustomerId; if (!customerId) return uni.showToast({ title: '暂无可查看的患者档案', icon: 'none' }); @@ -123,6 +129,7 @@ async function detail() { const res = await api('getAiConsultSessionDetail', { corpId: corpId.value, sessionId: sessionId.value, miniAppId: openid.value || uni.getStorageSync('openid') }, false); if (!res?.success) return uni.showToast({ title: removeAiLabel(res?.message, '加载失败'), icon: 'none' }); session.value = res.data.session; + avatarLoadFailed.value = false; patientInfo.value = res.data.patient || null; messages.value = res.data.messages || []; active.value = session.value.status === 'active'; diff --git a/pages/message/message.vue b/pages/message/message.vue index 5e30eba..92c6eb7 100644 --- a/pages/message/message.vue +++ b/pages/message/message.vue @@ -11,7 +11,7 @@ - + {{ @@ -101,6 +101,7 @@ const hasMore = ref(false); const refreshing = ref(false); const showSubscribeEntry = ref(false); const HOME_CURRENT_TEAM_CACHE_KEY = "home-current-team-info"; +const defaultAssistantAvatar = "/static/home/ai-consult-assistant.png"; // 群聊头像管理 const { loadGroupAvatars, getAvatarList } = useGroupAvatars(); @@ -262,6 +263,10 @@ function mergeConsultationList(imConversations) { ); } +function handleConversationAvatarError(conversation) { + conversation.assistantAvatar = defaultAssistantAvatar; +} + const loadAiConsultationList = async () => { const corpId = getCurrentTeamCorpId(); const miniAppId = openid.value || account.value?.openid || ""; @@ -281,6 +286,7 @@ const loadAiConsultationList = async () => { sessionId: item.id, corpId: item.corpId, displayName: removeAiLabel(item.assistantName, "咨询助理"), + assistantAvatar: item.assistantAvatar || defaultAssistantAvatar, teamName: item.teamName || "", patientName: item.customerName || "未命名患者", lastMessage: removeAiLabel(item.statusLabel, "咨询"),