From 7de8a2ae23b4cd7e615a08fb2abc2c282489a8a9 Mon Sep 17 00:00:00 2001 From: lik Date: Sun, 1 Nov 2026 12:09:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(ai):=20=E5=B1=95=E7=A4=BA=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=AB=AF=E9=94=99=E8=AF=AF=E5=B8=A7=E5=B9=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此前只处理 ai/system 帧,权限不足与频控拒绝时用户只看到一直输入中;补充 error 与 end 帧处理,并按陪诊员视角更新快捷问题,请求体补 ts 避免历史出现 undefined。 --- pages/ai/index.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pages/ai/index.js b/pages/ai/index.js index 7757658..77e5bfa 100644 --- a/pages/ai/index.js +++ b/pages/ai/index.js @@ -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 || '',