no message

This commit is contained in:
wangdongbo 2026-08-14 10:13:46 +08:00
parent 3770881c92
commit fdf9428f36
2 changed files with 96 additions and 10 deletions

View File

@ -4,8 +4,8 @@
<view class="message-list">
<view v-for="(item, index) in messages" :key="item._id" :id="`message-${item._id}`" class="message-item" :class="`message-${item.sender}`">
<view v-if="shouldShowTime(item, index)" class="time-divider">{{ formatMessageTime(item.createTime) }}</view>
<view v-if="item.sender === 'system' && item.messageType !== 'risk_notice'" class="system-message" :class="{ warn: item.messageType === 'sensitive_notice' }">{{ displayContent(item) }}</view>
<evaluation-card v-else-if="item.messageType === 'consult_ended' && (item.rateId || session?.rateId)" class="rate-card" :extension="{ rateId: item.rateId || session.rateId }" :corp-id="corpId" :doctor-info="rateAssistantInfo" />
<evaluation-card v-if="item.messageType === 'consult_ended' && (item.rateId || session?.rateId)" class="rate-card" :extension="{ rateId: item.rateId || session.rateId }" :corp-id="corpId" :doctor-info="rateAssistantInfo" />
<view v-else-if="item.sender === 'system' && item.messageType !== 'risk_notice'" class="system-message" :class="{ warn: item.messageType === 'sensitive_notice' }">{{ displayContent(item) }}</view>
<view v-else-if="item.messageType !== 'risk_notice'" class="message-content">
<view v-if="item.sender === 'assistant'" class="avatar assistant-avatar">AI</view>
<view class="message-bubble-container">

View File

@ -1,14 +1,100 @@
<template><view class="page"><template v-if="customers.length"><view class="title">请选择本次咨询档案</view><view v-for="item in customers" :key="item._id" class="customer" @click="open(item)"><view>{{item.name || '未命名'}}</view><view class="sub">{{ item.age ? item.age + '岁' : '' }}</view></view></template><view v-else-if="loaded" class="empty">正在前往建档...</view></view></template>
<template>
<view class="page">
<template v-if="customers.length">
<view class="title">请选择本次咨询档案</view>
<view v-for="item in customers" :key="item._id" class="customer-card" @click="open(item)">
<view class="card-header">
<view class="customer-name">{{ item.name || '未命名' }}</view>
<view v-if="item.relationship" class="relationship">{{ item.relationship }}</view>
<view class="header-spacer" />
<view v-if="enableHis" :class="['his-status', item.isConnectHis ? 'connected' : 'unconnected']">
{{ item.isConnectHis ? '已关联院内档案' : '未关联院内档案' }}
</view>
</view>
<view class="card-body">
<view class="customer-info">
<text v-if="item.sex">{{ item.sex }}</text>
<text v-if="item.sex && item.age">/</text>
<text v-if="item.age">{{ item.age }}</text>
<text v-if="item.sex || item.age"></text>
<text v-if="item.mobile">{{ item.mobile }}</text>
</view>
<view class="customer-info">证件号{{ item.idCard || '--' }}</view>
</view>
<view class="card-footer">选择此档案咨询</view>
</view>
</template>
<view v-else-if="loaded" class="empty">正在前往建档...</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import api from '@/utils/api';
import useAccountStore from '@/store/account';
import { storeToRefs } from 'pinia';
const { openid } = storeToRefs(useAccountStore()); const corpId=ref(''),teamId=ref(''),assistantId=ref(''),qrid=ref(''),customers=ref([]),loaded=ref(false);
function getEntryUrl(){return `/pages/ai-consult/entry?corpId=${corpId.value}&teamId=${teamId.value}&assistantId=${assistantId.value}&qrid=${qrid.value}`;}
function toCreateArchive(){uni.redirectTo({url:`/pages/archive/edit-archive?corpId=${corpId.value}&teamId=${teamId.value}&redirectUrl=${encodeURIComponent(getEntryUrl())}`});}
async function load(){const miniAppId=openid.value||uni.getStorageSync('openid');const res=await api('getMiniAppCustomers',{corpId:corpId.value,miniAppId},false);loaded.value=true;if(!res?.success)return uni.showToast({title:res?.message||'查询档案失败',icon:'none'});customers.value=res.data||[];if(!customers.value.length)toCreateArchive();}
async function open(customer){const res=await api('openAiConsultSession',{corpId:corpId.value,teamId:teamId.value,assistantId:assistantId.value,qrid:qrid.value,customerId:customer?._id||'',miniAppId:openid.value||uni.getStorageSync('openid')});if(!res?.success)return uni.showToast({title:res?.message||'创建失败',icon:'none'});uni.redirectTo({url:`/pages/ai-consult/chat?corpId=${corpId.value}&sessionId=${res.data.session._id}`});}
onLoad(opts=>{corpId.value=opts.corpId||'';teamId.value=opts.teamId||'';assistantId.value=opts.assistantId||'';qrid.value=opts.qrid||'';load();});
</script><style scoped>.page{min-height:100vh;background:#f7f8fa;padding:28rpx}.title{font-size:34rpx;font-weight:600;margin-bottom:20rpx}.customer{background:#fff;border-radius:16rpx;padding:24rpx;margin-bottom:18rpx;font-size:30rpx}.sub,.empty{font-size:25rpx;color:#888;margin-top:8rpx}.empty{text-align:center;padding-top:100rpx}</style>
const { account, openid } = storeToRefs(useAccountStore());
const corpId = ref('');
const teamId = ref('');
const assistantId = ref('');
const qrid = ref('');
const customers = ref([]);
const enableHis = ref(false);
const loaded = ref(false);
function getEntryUrl() {
return `/pages/ai-consult/entry?corpId=${corpId.value}&teamId=${teamId.value}&assistantId=${assistantId.value}&qrid=${qrid.value}`;
}
function toLogin() {
uni.redirectTo({ url: `/pages/login/login?redirectUrl=${encodeURIComponent(getEntryUrl())}` });
}
function toCreateArchive() {
uni.redirectTo({ url: `/pages/archive/edit-archive?corpId=${corpId.value}&teamId=${teamId.value}&redirectUrl=${encodeURIComponent(getEntryUrl())}` });
}
async function load() {
const miniAppId = openid.value || uni.getStorageSync('openid');
const res = await api('getMiniAppCustomers', { corpId: corpId.value, miniAppId }, false);
loaded.value = true;
if (!res?.success) return uni.showToast({ title: res?.message || '查询档案失败', icon: 'none' });
customers.value = res.data || [];
enableHis.value = res.enableHis === true;
if (!customers.value.length) toCreateArchive();
}
async function open(customer) {
const res = await api('openAiConsultSession', { corpId: corpId.value, teamId: teamId.value, assistantId: assistantId.value, qrid: qrid.value, customerId: customer?._id || '', miniAppId: openid.value || uni.getStorageSync('openid') });
if (!res?.success) return uni.showToast({ title: res?.message || '创建失败', icon: 'none' });
uni.redirectTo({ url: `/pages/ai-consult/chat?corpId=${corpId.value}&sessionId=${res.data.session._id}` });
}
onLoad((opts) => {
corpId.value = opts.corpId || '';
teamId.value = opts.teamId || '';
assistantId.value = opts.assistantId || '';
qrid.value = opts.qrid || '';
if (!account.value?.mobile) return toLogin();
load();
});
</script>
<style scoped>
.page { min-height: 100vh; background: #f7f8fa; padding: 28rpx; }
.title { font-size: 34rpx; font-weight: 600; margin-bottom: 20rpx; }
.customer-card { overflow: hidden; margin-bottom: 20rpx; background: #fff; border-radius: 16rpx; box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1); }
.card-header { display: flex; align-items: center; padding: 24rpx 30rpx; border-bottom: 1rpx solid #eee; }
.customer-name { flex-shrink: 0; font-size: 32rpx; font-weight: 600; color: #333; }
.relationship { flex-shrink: 0; margin-left: 10rpx; padding: 2rpx 16rpx; border: 1rpx solid #1677ff; border-radius: 4rpx; color: #1677ff; font-size: 24rpx; }
.header-spacer { flex: 1; }
.his-status { padding: 8rpx 18rpx; border-radius: 6rpx; color: #fff; font-size: 24rpx; line-height: 1.3; }
.his-status.connected { background: #22a06b; }
.his-status.unconnected { background: #ff9d00; }
.card-body { padding: 20rpx 30rpx; border-bottom: 1rpx solid #eee; }
.customer-info { min-height: 38rpx; color: #333; font-size: 28rpx; line-height: 42rpx; }
.card-footer { padding: 20rpx 30rpx; color: #1677ff; font-size: 28rpx; text-align: right; }
.empty { padding-top: 100rpx; color: #888; font-size: 25rpx; text-align: center; }
</style>