fix(ai): 展示服务端错误帧并更新快捷问题
此前只处理 ai/system 帧,权限不足与频控拒绝时用户只看到一直输入中;补充 error 与 end 帧处理,并按陪诊员视角更新快捷问题,请求体补 ts 避免历史出现 undefined。
This commit is contained in:
+13
-6
@@ -8,10 +8,10 @@ Page({
|
|||||||
scrollToMessage: '',
|
scrollToMessage: '',
|
||||||
expandedIds: {},
|
expandedIds: {},
|
||||||
quickQuestions: [
|
quickQuestions: [
|
||||||
'今日待处理订单有哪些?',
|
'今天有哪些待处理订单?',
|
||||||
'最近客户反馈统计',
|
'下一单的服务时间和医院',
|
||||||
'如何修改服务价格?',
|
'这家医院的科室位置和挂号流程',
|
||||||
'陪诊员排班情况'
|
'陪诊需要带哪些材料?'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -45,9 +45,15 @@ Page({
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.socket.onMessage((data) => {
|
this.socket.onMessage((data) => {
|
||||||
if (data && data.type === 'ai') {
|
if (!data || !data.type) return
|
||||||
|
if (data.type === 'ai') {
|
||||||
this.handleAIReply(data)
|
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)
|
console.log('[AIChat] System:', data.content)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -204,6 +210,7 @@ Page({
|
|||||||
this.socket.send({
|
this.socket.send({
|
||||||
type: type,
|
type: type,
|
||||||
content: content,
|
content: content,
|
||||||
|
ts: new Date().toISOString(),
|
||||||
userId: user ? user._id : '',
|
userId: user ? user._id : '',
|
||||||
token: user ? user.security.token : '',
|
token: user ? user.security.token : '',
|
||||||
appId: app.globalData.appId || '',
|
appId: app.globalData.appId || '',
|
||||||
|
|||||||
Reference in New Issue
Block a user