fix(ai): 展示服务端错误帧并更新快捷问题

此前只处理 ai/system 帧,权限不足与频控拒绝时用户只看到一直输入中;补充 error 与 end 帧处理,并按陪诊员视角更新快捷问题,请求体补 ts 避免历史出现 undefined。
This commit is contained in:
lik
2026-11-01 12:09:27 +08:00
parent 435852a09d
commit 7de8a2ae23
+13 -6
View File
@@ -8,10 +8,10 @@ Page({
scrollToMessage: '',
expandedIds: {},
quickQuestions: [
'今日待处理订单有哪些?',
'最近客户反馈统计',
'如何修改服务价格?',
'陪诊员排班情况'
'今天有哪些待处理订单?',
'下一单的服务时间和医院',
'这家医院的科室位置和挂号流程',
'陪诊需要带哪些材料?'
]
},
@@ -45,9 +45,15 @@ Page({
})
this.socket.onMessage((data) => {
if (data && data.type === 'ai') {
if (!data || !data.type) return
if (data.type === 'ai') {
this.handleAIReply(data)
} else if (data && data.type === 'system') {
} else if (data.type === 'end') {
this.setData({ isTyping: false })
} else if (data.type === 'error') {
// 权限不足、频次限制等服务端拒绝必须展示,否则用户只看到一直输入中
this.handleAIError(data.content || '服务处理失败,请稍后重试')
} else if (data.type === 'system') {
console.log('[AIChat] System:', data.content)
}
})
@@ -204,6 +210,7 @@ Page({
this.socket.send({
type: type,
content: content,
ts: new Date().toISOString(),
userId: user ? user._id : '',
token: user ? user.security.token : '',
appId: app.globalData.appId || '',