feat(ai): 等待气泡展示后台处理进度
- AI 聊天用工具/子代理/推理帧推断等待阶段,提示已完成步数,子代理输出不再并入主回答 - 下单弹层去掉 01-04 编号分组标题 - 同步首页设计规范与 UI 测试断言,补充首页品牌图
This commit is contained in:
@@ -42,6 +42,9 @@ Page({
|
||||
// 「更多」菜单:常见问题与清空聊天收进同一个低频入口
|
||||
showMoreMenu: false,
|
||||
isTyping: false,
|
||||
// 等待气泡的第二行:用已有的工具/子代理帧推断后台在做什么
|
||||
progressLabel: '',
|
||||
progressStep: 0,
|
||||
// 登录态:先判完再渲染提示条,避免静默登录成功前闪一下「未登录」
|
||||
authChecked: false,
|
||||
isLoggedIn: false,
|
||||
@@ -83,6 +86,8 @@ Page({
|
||||
// 本轮请求现场与「已为重登重试过」的请求 id:服务端回「请先登录」时原样重发
|
||||
this.activePayload = null
|
||||
this.authRetriedRequestId = ''
|
||||
// 本轮已计入步骤的帧 id:流式分片会复用同一 id,不能重复计数
|
||||
this.progressStepIds = new Set()
|
||||
this.loadChatHistory()
|
||||
this.initSocketListeners()
|
||||
this.initRecorder()
|
||||
@@ -258,8 +263,12 @@ Page({
|
||||
break
|
||||
case 'connected':
|
||||
case 'pong':
|
||||
break
|
||||
case 'reasoning':
|
||||
this.noteProgress('reasoning', data)
|
||||
break
|
||||
case 'tool':
|
||||
this.noteProgress('tool', data)
|
||||
break
|
||||
default:
|
||||
console.warn('[AIChat] Unknown message type:', data.type)
|
||||
@@ -274,6 +283,13 @@ Page({
|
||||
handleAIReply(data) {
|
||||
if (!this.activeRequestId) return
|
||||
|
||||
// 子代理(非主 agent)的输出不并入回答,只用来更新等待气泡的进度;
|
||||
// 主 agent 没有子代理时这段不会触发,行为保持不变
|
||||
if ((data.source || 'main') !== 'main') {
|
||||
this.noteProgress('subagent', data)
|
||||
return
|
||||
}
|
||||
|
||||
const serverId = data.id || this.activeRequestId
|
||||
const messages = this.data.messages.slice()
|
||||
const lastMessage = messages[messages.length - 1]
|
||||
@@ -336,6 +352,8 @@ Page({
|
||||
this.activeRequestType = ''
|
||||
// 请求已结束,不再保留提问现场(图片原文可能很大)
|
||||
this.activePayload = null
|
||||
this.progressStepIds = new Set()
|
||||
this.setData({ progressLabel: '', progressStep: 0 })
|
||||
},
|
||||
|
||||
beginRequest(requestId, userMessageId = '', type = 'chat') {
|
||||
@@ -343,6 +361,39 @@ Page({
|
||||
this.activeUserMessageId = userMessageId
|
||||
this.activeServerId = ''
|
||||
this.activeRequestType = type
|
||||
this.resetProgress(type)
|
||||
},
|
||||
|
||||
// 等待态进度:后端没有独立的进度帧,用已有的 tool / subagent / reasoning 帧
|
||||
// 推断当前阶段;图片/语音识别有自己的文案,不在这里抢提示
|
||||
resetProgress(type = 'chat') {
|
||||
this.progressStepIds = new Set()
|
||||
this.setData({
|
||||
progressLabel: type === 'chat' ? '正在理解您的问题' : '',
|
||||
progressStep: 0
|
||||
})
|
||||
},
|
||||
|
||||
noteProgress(kind, data) {
|
||||
if (!this.activeRequestId) return
|
||||
|
||||
const labels = {
|
||||
reasoning: '正在分析…',
|
||||
tool: '正在查询资料…',
|
||||
subagent: '正在处理子任务…'
|
||||
}
|
||||
const label = labels[kind]
|
||||
if (!label) return
|
||||
|
||||
// 工具结果与子代理消息都按 id 计一步,主代理自己调工具也算
|
||||
let step = this.data.progressStep
|
||||
const id = data && data.id
|
||||
if (id && (kind === 'tool' || kind === 'subagent') && !this.progressStepIds.has(id)) {
|
||||
this.progressStepIds.add(id)
|
||||
step += 1
|
||||
}
|
||||
if (label === this.data.progressLabel && step === this.data.progressStep) return
|
||||
this.setData({ progressLabel: label, progressStep: step })
|
||||
},
|
||||
|
||||
createMessageId(prefix = 'msg') {
|
||||
|
||||
+15
-5
@@ -133,12 +133,22 @@
|
||||
</view>
|
||||
<view class="message-content">
|
||||
<view class="message-bubble typing-bubble">
|
||||
<view class="typing-indicator">
|
||||
<view class="dot"></view>
|
||||
<view class="dot"></view>
|
||||
<view class="dot"></view>
|
||||
<view class="typing-lines">
|
||||
<view class="typing-main">
|
||||
<text class="typing-text">{{isRecognizing ? '正在识别,请稍候' : '正在为您整理'}}</text>
|
||||
<!-- 动态点跟在文字后面,作为文字的省略号 -->
|
||||
<view class="typing-indicator">
|
||||
<view class="dot"></view>
|
||||
<view class="dot"></view>
|
||||
<view class="dot"></view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 后台进度:工具/子代理有动作时这行会变化,避免只剩一个等待动画 -->
|
||||
<text
|
||||
class="typing-progress"
|
||||
wx:if="{{!isRecognizing && progressLabel}}"
|
||||
>{{progressLabel}}{{progressStep ? ' · 已完成 ' + progressStep + ' 步' : ''}}</text>
|
||||
</view>
|
||||
<text class="typing-text">{{isRecognizing ? '正在识别,请稍候' : '正在为您整理'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -75,11 +75,14 @@
|
||||
.system-message { max-width: 100%; padding: 8rpx 16rpx; color: var(--muted); font-size: var(--fs-26); line-height: 1.7; text-align: center; }
|
||||
.system-login-link { display: inline-block; padding: 16rpx; color: var(--brand-ink); font-size: var(--fs-28); }
|
||||
.message-item.ai .typing-bubble { display: flex; align-items: center; gap: 20rpx; width: auto; min-height: 88rpx; }
|
||||
.typing-indicator { display: flex; align-items: center; gap: 8rpx; }
|
||||
.typing-main { display: flex; align-items: center; gap: 12rpx; }
|
||||
.typing-indicator { display: flex; align-items: center; gap: 8rpx; flex-shrink: 0; }
|
||||
.typing-lines { display: flex; flex-direction: column; gap: 2rpx; }
|
||||
.dot { width: 10rpx; height: 10rpx; border-radius: 50%; background: var(--brand-ink); animation: typing 1.4s infinite ease-in-out both; }
|
||||
.dot:nth-child(1) { animation-delay: -0.32s; }
|
||||
.dot:nth-child(2) { animation-delay: -0.16s; }
|
||||
.typing-text { font-size: var(--fs-26); color: var(--muted); line-height: 1.6; }
|
||||
.typing-progress { font-size: 22rpx; color: var(--muted); line-height: 1.5; opacity: 0.85; }
|
||||
|
||||
/* 统一白色输入面板,语音/图片/更多在左,发送在右,所有操作横向展开。
|
||||
position: relative 供「更多」菜单定位(菜单从按钮上方展开) */
|
||||
|
||||
@@ -92,12 +92,8 @@
|
||||
</view>
|
||||
|
||||
<scroll-view class="popup-body" scroll-y>
|
||||
<!-- 01 陪诊项目:服务与价格只读确认,分组口径与预约页一致 -->
|
||||
<!-- 陪诊项目:服务与价格只读确认 -->
|
||||
<view class="form-section">
|
||||
<view class="form-section-head">
|
||||
<text class="form-section-number">01</text>
|
||||
<text class="form-section-title">陪诊项目</text>
|
||||
</view>
|
||||
<view class="order-service-info">
|
||||
<view class="order-service-mark">
|
||||
<view class="assist-icon {{serviceIconClass}}"></view>
|
||||
@@ -110,12 +106,8 @@
|
||||
<text class="service-fee-note">费用仅含人工服务费,不含就医、药品及快递费用。</text>
|
||||
</view>
|
||||
|
||||
<!-- 02 就诊人信息:订单必须关联健康档案,就诊人信息全部由此带入 -->
|
||||
<!-- 就诊人信息:订单必须关联健康档案,就诊人信息全部由此带入 -->
|
||||
<view class="form-section">
|
||||
<view class="form-section-head">
|
||||
<text class="form-section-number">02</text>
|
||||
<text class="form-section-title">就诊人信息</text>
|
||||
</view>
|
||||
<view class="order-row column">
|
||||
<text class="order-label">选择就诊人</text>
|
||||
<scroll-view class="patient-scroll" scroll-x wx:if="{{profiles.length > 0}}">
|
||||
@@ -146,12 +138,8 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 03 就诊安排 -->
|
||||
<!-- 就诊安排 -->
|
||||
<view class="form-section">
|
||||
<view class="form-section-head">
|
||||
<text class="form-section-number">03</text>
|
||||
<text class="form-section-title">就诊安排</text>
|
||||
</view>
|
||||
<view class="order-row">
|
||||
<text class="order-label">就诊省份</text>
|
||||
<picker class="order-picker" mode="selector" range="{{provinces}}" value="{{provinceIndex}}" bindchange="onProvinceChange">
|
||||
@@ -208,20 +196,15 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 04 补充信息:收货地址仅对快递/跑腿服务展示,随订单保存快照 -->
|
||||
<!-- 补充信息:收货地址仅对快递/跑腿服务展示,随订单保存快照 -->
|
||||
<view class="form-section">
|
||||
<view class="form-section-head">
|
||||
<text class="form-section-number">04</text>
|
||||
<text class="form-section-title">补充信息</text>
|
||||
<text class="form-section-optional">选填</text>
|
||||
</view>
|
||||
<view class="order-row column" wx:if="{{requiresAddress}}">
|
||||
<text class="order-label">收货地址(选填)</text>
|
||||
<textarea class="order-textarea" value="{{shippingAddress}}" placeholder="请输入省市区、街道门牌等完整收货地址" maxlength="200" placeholder-class="input-placeholder" bindinput="onShippingAddressChange" />
|
||||
<text class="address-tip">收货人与联系电话使用所选就诊人信息</text>
|
||||
</view>
|
||||
|
||||
<view class="order-row column remark-row">
|
||||
<view class="order-row column">
|
||||
<text class="order-label">备注说明</text>
|
||||
<textarea class="order-textarea" value="{{remark}}" placeholder="请输入其他需求或备注信息" maxlength="200" placeholder-class="input-placeholder" bindinput="onRemarkChange" />
|
||||
<text class="textarea-count">{{remark.length}}/200</text>
|
||||
|
||||
@@ -55,9 +55,11 @@ page {
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* ===== 下单表单分组:沿用 01–04 编号,用发丝线分隔,不叠白卡 ===== */
|
||||
/* ===== 下单表单分组:用发丝线分隔,不叠白卡 =====
|
||||
去掉了 01–04 编号标题,分组间距改为仅由发丝线上下各 8rpx 贡献:
|
||||
行内相邻字段间距 48rpx,跨分组 64rpx,靠 16rpx 差形成层级,不再靠大段留白 */
|
||||
.form-section {
|
||||
padding: 24rpx 0 8rpx;
|
||||
padding: 8rpx 0;
|
||||
}
|
||||
|
||||
.form-section:first-child {
|
||||
@@ -65,36 +67,9 @@ page {
|
||||
}
|
||||
|
||||
.form-section + .form-section {
|
||||
margin-top: 8rpx;
|
||||
border-top: 2rpx solid var(--line);
|
||||
}
|
||||
|
||||
.form-section-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.form-section-number {
|
||||
color: var(--brand-ink);
|
||||
font-size: var(--fs-24);
|
||||
font-weight: 500;
|
||||
letter-spacing: 2rpx;
|
||||
}
|
||||
|
||||
.form-section-title {
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-32);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.form-section-optional {
|
||||
margin-left: auto;
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-24);
|
||||
}
|
||||
|
||||
/* ===== 头部:短横色标 + 深墨标题 ===== */
|
||||
.page-header {
|
||||
padding: 32rpx 0 0;
|
||||
@@ -644,9 +619,6 @@ page {
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.remark-row { padding-top: 12rpx; }
|
||||
.remark-row .order-textarea { margin-top: 0; }
|
||||
|
||||
/* ===== 就诊人选择 ===== */
|
||||
.patient-scroll {
|
||||
width: 100%;
|
||||
|
||||
Reference in New Issue
Block a user