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 || '',