Compare commits
4
Commits
3bca677f30
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6da802cff9 | ||
|
|
8e508d6934 | ||
|
|
b200d0a1ab | ||
|
|
1d8af0cb26 |
@@ -2,6 +2,8 @@
|
|||||||
import config from './config';
|
import config from './config';
|
||||||
import createBus from './utils/eventBus';
|
import createBus from './utils/eventBus';
|
||||||
const API = require('./utils/api.js');
|
const API = require('./utils/api.js');
|
||||||
|
const request = require('./utils/request.js');
|
||||||
|
const AIChatSocket = require('./utils/chatmsg.js');
|
||||||
const role = require('./utils/role.js');
|
const role = require('./utils/role.js');
|
||||||
|
|
||||||
// ==================== 全局页面守卫 ====================
|
// ==================== 全局页面守卫 ====================
|
||||||
@@ -44,6 +46,9 @@ Page = function (options = {}) {
|
|||||||
|
|
||||||
App({
|
App({
|
||||||
onLaunch() {
|
onLaunch() {
|
||||||
|
// 接口层遇到 code 401(token 已失效)时静默重登并自动重试原请求
|
||||||
|
request.setUnauthorizedHandler(() => this.silentSignin());
|
||||||
|
|
||||||
const updateManager = wx.getUpdateManager();
|
const updateManager = wx.getUpdateManager();
|
||||||
|
|
||||||
updateManager.onCheckForUpdate((res) => {
|
updateManager.onCheckForUpdate((res) => {
|
||||||
@@ -73,12 +78,17 @@ App({
|
|||||||
|
|
||||||
/** 执行登录,返回可复用的 Promise(避免页面请求早于登录完成的竞态) */
|
/** 执行登录,返回可复用的 Promise(避免页面请求早于登录完成的竞态) */
|
||||||
signin() {
|
signin() {
|
||||||
|
// 已登录或登录在飞都复用同一个 Promise:每次回前台都重签会轮换 token,
|
||||||
|
// 让在飞请求拿着旧 token 收到 401;token 真失效时由 silentSignin 主动重登
|
||||||
if (this._loginPromise) return this._loginPromise;
|
if (this._loginPromise) return this._loginPromise;
|
||||||
|
|
||||||
|
this._loginPending = true;
|
||||||
|
const finish = () => { this._loginPending = false };
|
||||||
this._loginPromise = new Promise((resolve, reject) => {
|
this._loginPromise = new Promise((resolve, reject) => {
|
||||||
wx.login({
|
wx.login({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (!res.code) {
|
if (!res.code) {
|
||||||
|
finish();
|
||||||
this._loginPromise = null;
|
this._loginPromise = null;
|
||||||
return reject(new Error('wx.login 未返回 code'));
|
return reject(new Error('wx.login 未返回 code'));
|
||||||
}
|
}
|
||||||
@@ -88,21 +98,25 @@ App({
|
|||||||
console.info('[app] 静默登录成功', data.data.user && data.data.user.profile && data.data.user.profile.mobile)
|
console.info('[app] 静默登录成功', data.data.user && data.data.user.profile && data.data.user.profile.mobile)
|
||||||
this.globalData.user = data.data.user;
|
this.globalData.user = data.data.user;
|
||||||
this.eventBus.emit('user-login', data.data.user);
|
this.eventBus.emit('user-login', data.data.user);
|
||||||
|
finish();
|
||||||
resolve(data.data.user);
|
resolve(data.data.user);
|
||||||
} else {
|
} else {
|
||||||
console.warn('[app] 静默登录被拒:', data.msg)
|
console.warn('[app] 静默登录被拒:', data.msg)
|
||||||
|
finish();
|
||||||
this._loginPromise = null;
|
this._loginPromise = null;
|
||||||
reject(new Error(data.msg || '登录失败'));
|
reject(new Error(data.msg || '登录失败'));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.warn('[app] 静默登录请求异常:', err && err.message)
|
console.warn('[app] 静默登录请求异常:', err && err.message)
|
||||||
|
finish();
|
||||||
this._loginPromise = null;
|
this._loginPromise = null;
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.warn('[app] wx.login 失败:', err && err.errMsg)
|
console.warn('[app] wx.login 失败:', err && err.errMsg)
|
||||||
|
finish();
|
||||||
this._loginPromise = null;
|
this._loginPromise = null;
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
@@ -118,6 +132,34 @@ App({
|
|||||||
return this.signin();
|
return this.signin();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** AI 页发送前的登录等待:返回是否已拿到可用用户 */
|
||||||
|
waitForAuth() {
|
||||||
|
return this.ensureLogin()
|
||||||
|
.then(() => !!this.globalData.user?._id)
|
||||||
|
.catch(() => false);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 静默重登:服务端已作废本地 token 时重新走一次 wx.login 换新 token */
|
||||||
|
silentSignin() {
|
||||||
|
// 已有登录在飞时先等它落定,避免并发换 token 造成 token 互相覆盖
|
||||||
|
if (this._loginPending && this._loginPromise) {
|
||||||
|
return this._loginPromise
|
||||||
|
.then(() => !!this.globalData.user?.security?.token)
|
||||||
|
.catch(() => false);
|
||||||
|
}
|
||||||
|
this._loginPromise = null;
|
||||||
|
return this.signin()
|
||||||
|
.then(() => !!this.globalData.user?.security?.token)
|
||||||
|
.catch(() => false);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** AI 聊天 WebSocket 懒创建:语音分片与聊天共用同一条连接 */
|
||||||
|
initChatSocket() {
|
||||||
|
if (this.globalData.chatSocket) return this.globalData.chatSocket;
|
||||||
|
this.globalData.chatSocket = new AIChatSocket();
|
||||||
|
return this.globalData.chatSocket;
|
||||||
|
},
|
||||||
|
|
||||||
/** 全局事件总线 */
|
/** 全局事件总线 */
|
||||||
eventBus: createBus(),
|
eventBus: createBus(),
|
||||||
|
|
||||||
@@ -146,5 +188,6 @@ App({
|
|||||||
user: null,
|
user: null,
|
||||||
unreadNum: 0, // 未读消息数量
|
unreadNum: 0, // 未读消息数量
|
||||||
socket: null, // SocketTask 对象
|
socket: null, // SocketTask 对象
|
||||||
|
chatSocket: null, // AI 聊天 / 语音识别 WebSocket
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
/**app.wxss**/
|
/**app.wxss**/
|
||||||
page {
|
page {
|
||||||
background-color: #FAF6F1;
|
background-color: #FAF6F1;
|
||||||
|
/* 统一全局基础字号:正文主字号 28rpx */
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #2A211B;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
|
|||||||
@@ -85,13 +85,13 @@
|
|||||||
|
|
||||||
.os-label {
|
.os-label {
|
||||||
margin-top: 12rpx;
|
margin-top: 12rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
}
|
}
|
||||||
|
|
||||||
.os-fee {
|
.os-fee {
|
||||||
margin-top: 10rpx;
|
margin-top: 10rpx;
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #2A211B;
|
color: #2A211B;
|
||||||
padding: 4rpx 16rpx;
|
padding: 4rpx 16rpx;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.pi-sex {
|
.pi-sex {
|
||||||
font-size: 20rpx;
|
font-size: 22rpx;
|
||||||
padding: 2rpx 12rpx;
|
padding: 2rpx 12rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -71,19 +71,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.pi-mobile {
|
.pi-mobile {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pi-call {
|
.pi-call {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #C26A2E;
|
color: #C26A2E;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin-left: 8rpx;
|
margin-left: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pi-extra {
|
.pi-extra {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
+1426
-162
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
"navigationBarTitleText": "AI助手",
|
"navigationBarTitleText": "AI助手",
|
||||||
"navigationBarBackgroundColor": "#ffffff",
|
"navigationBarBackgroundColor": "#FAF6F1",
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"backgroundColor": "#ffffff",
|
"backgroundColor": "#FAF6F1",
|
||||||
|
"disableScroll": true,
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
|
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||||
"t-chat-markdown": "tdesign-miniprogram/chat-markdown/chat-markdown"
|
"t-chat-markdown": "tdesign-miniprogram/chat-markdown/chat-markdown"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+188
-46
@@ -1,75 +1,217 @@
|
|||||||
<view class="chat-container">
|
<view class="chat-container">
|
||||||
<scroll-view class="message-list" scroll-y scroll-into-view="{{scrollToMessage}}" scroll-with-animation>
|
<!-- 消息列表区域:页面唯一滚动容器 -->
|
||||||
<view class="quick-questions" wx:if="{{messages.length === 0}}">
|
<scroll-view
|
||||||
<view class="welcome-text">您好,我是您的AI助手,有什么可以帮您?</view>
|
class="message-list"
|
||||||
<view class="quick-list">
|
scroll-y
|
||||||
<view class="quick-item" wx:for="{{quickQuestions}}" wx:key="*this" data-question="{{item}}" bindtap="onQuickQuestionTap">
|
scroll-into-view="{{scrollToMessage}}"
|
||||||
{{item}}
|
enhanced
|
||||||
|
show-scrollbar="{{false}}"
|
||||||
|
scroll-with-animation
|
||||||
|
>
|
||||||
|
<!-- 欢迎区:空会话时的落点 -->
|
||||||
|
<view class="welcome-area" wx:if="{{messages.length === 0}}">
|
||||||
|
<text class="welcome-title">陪诊助手</text>
|
||||||
|
<view class="question-heading"><text>您可以这样问</text><text class="question-heading-sub">点选即发送</text></view>
|
||||||
|
<view class="question-list">
|
||||||
|
<view
|
||||||
|
class="quick-item"
|
||||||
|
wx:for="{{quickQuestions}}"
|
||||||
|
wx:key="id"
|
||||||
|
bindtap="onQuickQuestionTap"
|
||||||
|
data-question="{{item.text}}"
|
||||||
|
hover-class="question-hover"
|
||||||
|
aria-role="button"
|
||||||
|
aria-label="{{item.text}}"
|
||||||
|
>
|
||||||
|
<view class="question-mark" aria-hidden="true">?</view>
|
||||||
|
<text>{{item.text}}</text>
|
||||||
|
<t-icon name="chevron-right" size="26rpx" color="#A8551F" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<text class="welcome-note">AI 生成内容仅供参考,请以系统实际数据为准。</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="message-item {{item.type}}" wx:for="{{messages}}" wx:key="id" id="msg-{{item.id}}">
|
<!-- 消息:头像在上、气泡在下,时间紧跟头像右侧;用户消息整条靠右 -->
|
||||||
<view class="avatar {{item.type}}-avatar">
|
<view
|
||||||
<text class="avatar-text">{{item.type === 'user' ? '我' : 'AI'}}</text>
|
class="message-item {{item.type}}"
|
||||||
|
wx:for="{{messages}}"
|
||||||
|
wx:key="id"
|
||||||
|
id="msg-{{item.id}}"
|
||||||
|
>
|
||||||
|
<!-- 连接或服务错误是系统状态,不使用头像 -->
|
||||||
|
<view wx:if="{{item.type === 'system'}}" class="system-message">
|
||||||
|
<text>{{item.content}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<block wx:else>
|
||||||
|
<view class="message-head">
|
||||||
|
<!-- AI:品牌线稿标记;用户:人像图标,身份只由图形区分 -->
|
||||||
|
<view wx:if="{{item.type === 'ai'}}" class="avatar">
|
||||||
|
<image class="avatar-img" src="/images/ai-ink.png" mode="aspectFit" />
|
||||||
|
</view>
|
||||||
|
<view wx:else class="avatar">
|
||||||
|
<t-icon name="user" size="30rpx" color="#6F655C" />
|
||||||
|
</view>
|
||||||
|
<text class="message-author">{{item.type === 'ai' ? 'AI助手' : '我'}}</text>
|
||||||
|
<text class="message-time" wx:if="{{item.showTime}}">{{item.time}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="message-content">
|
<view class="message-content">
|
||||||
<view class="message-bubble {{item.type}}-bubble">
|
<view class="message-bubble" wx:if="{{item.contentType !== 'questions'}}">
|
||||||
<!-- subagent 消息:引用卡片样式,默认折叠 -->
|
|
||||||
<block wx:if="{{item.source === 'subagent'}}">
|
|
||||||
<view class="subagent-header" data-id="{{item.id}}" bindtap="toggleSubagent">
|
|
||||||
<text class="subagent-label">思考中...</text>
|
|
||||||
<text class="subagent-arrow {{expandedIds[item.id] ? 'expanded' : ''}}">▸</text>
|
|
||||||
</view>
|
|
||||||
<view class="subagent-body" wx:if="{{expandedIds[item.id]}}">
|
|
||||||
<t-chat-markdown class="message-markdown" content="{{item.content}}" />
|
|
||||||
</view>
|
|
||||||
</block>
|
|
||||||
<t-chat-markdown
|
<t-chat-markdown
|
||||||
wx:elif="{{item.contentType === 'text' && item.type === 'ai'}}"
|
wx:if="{{item.type === 'ai' && item.contentType === 'text'}}"
|
||||||
class="message-markdown"
|
class="message-markdown"
|
||||||
content="{{item.content}}"
|
content="{{item.content}}"
|
||||||
/>
|
/>
|
||||||
<text class="message-text" wx:elif="{{item.contentType === 'text'}}">{{item.content}}</text>
|
<text wx:elif="{{item.contentType === 'text'}}" class="message-text" user-select>{{item.content}}</text>
|
||||||
|
<image
|
||||||
|
wx:if="{{item.contentType === 'image' && item.content}}"
|
||||||
|
class="message-image"
|
||||||
|
src="{{item.content}}"
|
||||||
|
mode="widthFix"
|
||||||
|
bindtap="previewImage"
|
||||||
|
data-src="{{item.content}}"
|
||||||
|
/>
|
||||||
|
<!-- 历史里的图片不存临时路径(重启即失效),退化成一行占位 -->
|
||||||
|
<text wx:elif="{{item.contentType === 'image'}}" class="message-image-placeholder">[图片]</text>
|
||||||
|
</view>
|
||||||
|
<!-- 常见问题:把问题清单直接铺进会话流里,点一下即发送 -->
|
||||||
|
<view wx:else class="question-list">
|
||||||
|
<view
|
||||||
|
class="quick-item"
|
||||||
|
wx:for="{{item.content}}"
|
||||||
|
wx:for-item="question"
|
||||||
|
wx:key="id"
|
||||||
|
bindtap="onQuickQuestionTap"
|
||||||
|
data-question="{{question.text}}"
|
||||||
|
hover-class="question-hover"
|
||||||
|
aria-role="button"
|
||||||
|
aria-label="{{question.text}}"
|
||||||
|
>
|
||||||
|
<text>{{question.text}}</text>
|
||||||
|
<t-icon name="chevron-right" size="26rpx" color="#A8551F" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- AI 声明:本地问题清单和系统错误均不展示 -->
|
||||||
|
<text
|
||||||
|
wx:if="{{item.type === 'ai' && item.contentType !== 'questions'}}"
|
||||||
|
class="message-note"
|
||||||
|
>AI 生成,仅供参考</text>
|
||||||
|
<text
|
||||||
|
wx:if="{{item.type === 'user' && item.status === 'failed'}}"
|
||||||
|
class="message-retry"
|
||||||
|
bindtap="onRetryMessage"
|
||||||
|
data-id="{{item.id}}"
|
||||||
|
>发送失败,点击重试</text>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- AI 正在输入:图片/语音识别期间也用它作为等待态 -->
|
||||||
|
<view class="message-item ai" wx:if="{{isTyping}}" id="msg-typing">
|
||||||
|
<view class="message-head">
|
||||||
|
<view class="avatar">
|
||||||
|
<image class="avatar-img" src="/images/ai-ink.png" mode="aspectFit" />
|
||||||
|
</view>
|
||||||
|
<text class="message-author">AI助手</text>
|
||||||
|
</view>
|
||||||
|
<view class="message-content">
|
||||||
|
<view class="message-bubble typing-bubble">
|
||||||
|
<view class="typing-lines">
|
||||||
|
<text class="typing-text">{{isRecognizing ? '正在识别,请稍候' : '正在处理...' + processingSeconds + '秒'}}</text>
|
||||||
|
<!-- 后台进度:工具/子代理有动作时这行会变化,避免只剩一个计时器 -->
|
||||||
|
<text
|
||||||
|
class="typing-progress"
|
||||||
|
wx:if="{{!isRecognizing && progressLabel}}"
|
||||||
|
>{{progressLabel}}{{progressStep ? ' · 已完成 ' + progressStep + ' 步' : ''}}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="message-time" wx:if="{{item.time}}">{{item.time}}</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="typing-indicator" wx:if="{{isTyping}}">
|
<!-- 底部留白,确保最新消息可见 -->
|
||||||
<view class="avatar ai-avatar">
|
<view style="height: 40rpx;"></view>
|
||||||
<text class="avatar-text">AI</text>
|
|
||||||
</view>
|
|
||||||
<view class="typing-bubble">
|
|
||||||
<view class="dot"></view>
|
|
||||||
<view class="dot"></view>
|
|
||||||
<view class="dot"></view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<view class="chat-footer">
|
<!-- 语音状态:只在录音阶段显示,紧贴输入区上方 -->
|
||||||
<view class="chat-toolbar" wx:if="{{messages.length > 0}}">
|
<view class="voice-status" wx:if="{{recording}}">
|
||||||
<view class="chat-toolbar-action" bindtap="clearChat">
|
<view class="voice-dot recording"></view>
|
||||||
<text>清空记录</text>
|
<view class="voice-status-main">
|
||||||
|
<text class="voice-status-text">正在录音 {{recordTime}}</text>
|
||||||
|
<text class="voice-status-sub">{{voiceRealtimeOff ? '结束后整段转写' : '点麦克风或发送键发出'}}</text>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
class="voice-cancel"
|
||||||
|
bindtap="onCancelVoiceTap"
|
||||||
|
aria-role="button"
|
||||||
|
aria-label="取消语音输入"
|
||||||
|
>
|
||||||
|
<t-icon name="close" size="24rpx" color="#A8551F" />
|
||||||
|
<text>取消</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 输入面板:上方文字,下方输入方式与发送 -->
|
||||||
|
<view class="composer">
|
||||||
<view class="input-area">
|
<view class="input-area">
|
||||||
<input
|
<textarea
|
||||||
class="chat-input"
|
class="message-input {{recording || isRecognizing ? 'is-readonly' : ''}}"
|
||||||
type="text"
|
|
||||||
placeholder="请输入您的问题..."
|
|
||||||
value="{{inputValue}}"
|
value="{{inputValue}}"
|
||||||
bindinput="onInputChange"
|
placeholder="说说您的问题或需要…"
|
||||||
|
placeholder-class="input-placeholder"
|
||||||
|
auto-height
|
||||||
|
maxlength="-1"
|
||||||
|
cursor-spacing="24"
|
||||||
confirm-type="send"
|
confirm-type="send"
|
||||||
bindconfirm="sendMessage"
|
disabled="{{recording || isRecognizing}}"
|
||||||
adjust-position="{{true}}"
|
adjust-position="{{true}}"
|
||||||
cursor-spacing="20"
|
|
||||||
hold-keyboard="{{true}}"
|
hold-keyboard="{{true}}"
|
||||||
|
bindinput="onInputChange"
|
||||||
|
bindconfirm="sendMessage"
|
||||||
|
focus="{{inputFocus}}"
|
||||||
/>
|
/>
|
||||||
<view class="send-btn {{canSend ? 'active' : ''}}" bindtap="sendMessage">
|
</view>
|
||||||
<text class="send-text">发送</text>
|
<view class="composer-actions">
|
||||||
|
<view class="input-tools">
|
||||||
|
<view class="input-tool {{recording ? 'is-recording' : ''}}" bindtap="onMicTap" aria-role="button" aria-label="{{recording ? '结束并发送语音' : '语音输入'}}">
|
||||||
|
<t-icon name="microphone" size="34rpx" color="{{recording ? '#A8551F' : '#6F655C'}}" />
|
||||||
|
<text>{{recording ? '结束' : '语音'}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="input-tool" bindtap="onImageTap" aria-role="button" aria-label="拍照或选择图片">
|
||||||
|
<t-icon name="image" size="34rpx" color="#6F655C" />
|
||||||
|
<text>图片</text>
|
||||||
|
</view>
|
||||||
|
<view class="input-tool {{showMoreMenu ? 'is-open' : ''}}" bindtap="toggleMoreMenu" aria-role="button" aria-label="更多功能" aria-expanded="{{showMoreMenu}}">
|
||||||
|
<view class="more-dots" aria-hidden="true">
|
||||||
|
<view class="more-dot"></view>
|
||||||
|
<view class="more-dot"></view>
|
||||||
|
<view class="more-dot"></view>
|
||||||
|
</view>
|
||||||
|
<text>更多</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
class="send-btn {{inputValue && !isRecognizing ? 'active' : ''}}"
|
||||||
|
bindtap="sendMessage"
|
||||||
|
aria-role="button"
|
||||||
|
aria-label="发送消息"
|
||||||
|
aria-disabled="{{!inputValue || isRecognizing}}"
|
||||||
|
>
|
||||||
|
<text>发送</text>
|
||||||
|
<t-icon name="chevron-right" size="30rpx" color="{{inputValue && !isRecognizing ? '#FFFFFF' : '#6F655C'}}" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 更多菜单:向上展开,点遮罩关闭;清空仍走二次确认 -->
|
||||||
|
<view class="more-mask" wx:if="{{showMoreMenu}}" bindtap="onCloseMoreMenu" aria-hidden="true"></view>
|
||||||
|
<view class="more-menu" wx:if="{{showMoreMenu}}" aria-role="menu">
|
||||||
|
<view class="more-item" bindtap="onMoreQuickQuestions" aria-role="menuitem">
|
||||||
|
<t-icon name="help-circle" size="30rpx" color="#6F655C" />
|
||||||
|
<text class="more-item-text">常见问题</text>
|
||||||
|
</view>
|
||||||
|
<view class="more-divider" wx:if="{{messages.length}}"></view>
|
||||||
|
<view class="more-item more-item-muted" wx:if="{{messages.length}}" bindtap="onMoreClearChat" aria-role="menuitem">
|
||||||
|
<t-icon name="delete" size="30rpx" color="#6F655C" />
|
||||||
|
<text class="more-item-text">清空聊天记录</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
+125
-375
@@ -1,6 +1,25 @@
|
|||||||
|
/* 与就诊人端 AI 页同源:暖白纸面、清晰左基线、克制的暖橙强调。
|
||||||
|
页面不滚动,唯一滚动容器是消息区;颜色令牌取自本项目 TDesign 主题色阶。 */
|
||||||
page {
|
page {
|
||||||
background-color: #FAF6F1;
|
--brand-strong: #C26A2E;
|
||||||
color: #2A211B;
|
--brand-soft: #FCF3E9;
|
||||||
|
--brand-line: #EFCAA6;
|
||||||
|
--brand-ink: #A8551F;
|
||||||
|
--ink: #2A211B;
|
||||||
|
--ink-2: #4A4038;
|
||||||
|
--muted: #6F655C;
|
||||||
|
--line: #EAE1D6;
|
||||||
|
--paper: #FAF6F1;
|
||||||
|
--white: #FFFFFF;
|
||||||
|
--fs-24: 24rpx;
|
||||||
|
--fs-26: 26rpx;
|
||||||
|
--fs-28: 28rpx;
|
||||||
|
--fs-30: 30rpx;
|
||||||
|
--shadow-card: 0 2rpx 10rpx rgba(63, 43, 25, 0.07);
|
||||||
|
|
||||||
|
background-color: var(--paper);
|
||||||
|
color: var(--ink);
|
||||||
|
font-size: var(--fs-28);
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8,389 +27,120 @@ page {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: #FAF6F1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
height: 88rpx;
|
|
||||||
padding: 0 24rpx;
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-bottom: 1rpx solid #EAE1D6;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-header-title {
|
|
||||||
font-size: 30rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #2A211B;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-list {
|
|
||||||
flex: 1;
|
|
||||||
padding: 20rpx;
|
|
||||||
padding-bottom: 200rpx;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
background: var(--paper);
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-questions {
|
.message-list { flex: 1; height: 0; min-height: 0; box-sizing: border-box; }
|
||||||
display: flex;
|
.welcome-area { padding: 32rpx 32rpx 24rpx; }
|
||||||
flex-direction: column;
|
.welcome-title { display: block; color: var(--ink); font-size: 44rpx; font-weight: 600; line-height: 1.45; }
|
||||||
align-items: center;
|
.question-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12rpx; margin: 32rpx 0 16rpx; color: var(--ink); font-size: var(--fs-28); font-weight: 500; }
|
||||||
padding: 40rpx 20rpx;
|
.question-heading-sub { color: var(--muted); font-size: var(--fs-24); font-weight: 400; }
|
||||||
}
|
.question-list { display: flex; flex-direction: column; gap: 12rpx; width: 100%; box-sizing: border-box; }
|
||||||
|
.quick-item { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; min-height: 96rpx; box-sizing: border-box; padding: 20rpx; border: 2rpx solid var(--line); border-radius: 20rpx; background: var(--white); color: var(--ink-2); font-size: var(--fs-28); line-height: 1.6; }
|
||||||
|
.quick-item > text { flex: 1; min-width: 0; word-break: break-all; }
|
||||||
|
.question-mark { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 40rpx; height: 40rpx; border-radius: 12rpx; background: var(--paper); color: var(--brand-ink); font-size: var(--fs-26); }
|
||||||
|
.quick-item.question-hover, .quick-item:active { background: var(--brand-soft); border-color: var(--brand-line); }
|
||||||
|
.welcome-note { display: block; margin-top: 20rpx; color: var(--muted); font-size: var(--fs-24); line-height: 1.7; }
|
||||||
|
|
||||||
.welcome-text {
|
/* 对话正文占据主要宽度,避免头像左右分栏挤压长回答和报告表格 */
|
||||||
font-size: 32rpx;
|
.message-item { display: flex; flex-direction: column; padding: 20rpx 32rpx; }
|
||||||
color: #2A211B;
|
.message-item.user { align-items: flex-end; }
|
||||||
margin-bottom: 40rpx;
|
.message-head { display: flex; align-items: center; gap: 10rpx; margin-bottom: 12rpx; }
|
||||||
text-align: center;
|
.message-item.user .message-head { flex-direction: row-reverse; }
|
||||||
font-weight: 500;
|
.avatar { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44rpx; height: 44rpx; border-radius: 14rpx; background: var(--white); border: 2rpx solid var(--line); }
|
||||||
}
|
.avatar-img { width: 30rpx; height: 30rpx; }
|
||||||
|
.message-item.user .avatar { background: transparent; border-color: transparent; }
|
||||||
.quick-list {
|
.message-author { color: var(--ink-2); font-size: var(--fs-24); font-weight: 500; }
|
||||||
display: flex;
|
.message-time { color: var(--muted); font-size: var(--fs-24); margin: 0 6rpx; }
|
||||||
flex-direction: column;
|
.message-content { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: 100%; }
|
||||||
width: 100%;
|
.message-item.ai .message-content { width: 100%; }
|
||||||
gap: 20rpx;
|
.message-item.user .message-content { align-items: flex-end; max-width: 90%; }
|
||||||
}
|
.message-bubble { box-sizing: border-box; min-width: 0; max-width: 100%; padding: 24rpx; border-radius: 24rpx; word-wrap: break-word; word-break: break-word; }
|
||||||
|
.message-item.ai .message-bubble { width: 100%; border: 2rpx solid var(--line); border-top-left-radius: 8rpx; background: var(--white); }
|
||||||
.quick-item {
|
.message-item.user .message-bubble { border: 2rpx solid var(--brand-line); border-top-right-radius: 8rpx; background: var(--brand-soft); }
|
||||||
background-color: #ffffff;
|
.message-text { font-size: var(--fs-30); line-height: 1.75; white-space: pre-wrap; color: var(--ink-2); word-break: break-word; }
|
||||||
border-radius: 24rpx;
|
.message-item.user .message-text { color: var(--brand-ink); }
|
||||||
padding: 24rpx 32rpx;
|
.message-image { display: block; width: 400rpx; max-width: 100%; border-radius: 16rpx; }
|
||||||
font-size: 28rpx;
|
.message-image-placeholder { font-size: var(--fs-28); color: var(--muted); line-height: 1.6; }
|
||||||
color: #C26A2E;
|
.message-note { margin-top: 10rpx; color: var(--muted); font-size: var(--fs-24); line-height: 1.6; }
|
||||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
.message-retry { display: flex; align-items: center; min-height: 88rpx; color: var(--brand-ink); font-size: var(--fs-26); }
|
||||||
text-align: center;
|
.message-item.system { align-items: center; }
|
||||||
border: 1rpx solid #EAE1D6;
|
.system-message { max-width: 100%; padding: 8rpx 16rpx; color: var(--muted); font-size: var(--fs-26); line-height: 1.7; text-align: center; }
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quick-item:active {
|
|
||||||
transform: scale(0.98);
|
|
||||||
background-color: rgba(194, 106, 46, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-item {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
margin-bottom: 32rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-item.ai {
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-item.user {
|
|
||||||
align-items: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-time {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #A3988B;
|
|
||||||
margin-top: 8rpx;
|
|
||||||
padding: 0 4rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-item.ai .message-time {
|
|
||||||
text-align: left;
|
|
||||||
align-self: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-item.user .message-time {
|
|
||||||
text-align: right;
|
|
||||||
align-self: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 64rpx;
|
|
||||||
height: 64rpx;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
flex-shrink: 0;
|
|
||||||
margin-bottom: 12rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-avatar {
|
|
||||||
background: #C26A2E;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(180, 85, 42, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-avatar {
|
|
||||||
background: #B4552A;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(217, 134, 52, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-text {
|
|
||||||
color: #fff;
|
|
||||||
font-size: 26rpx;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
max-width: 95%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-item.user .message-content {
|
|
||||||
align-items: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-item.ai .message-content {
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-bubble {
|
|
||||||
padding: 20rpx 24rpx;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
line-height: 1.6;
|
|
||||||
word-break: break-word;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-bubble {
|
|
||||||
background: #C26A2E;
|
|
||||||
color: #fff;
|
|
||||||
border-bottom-right-radius: 4rpx;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(180, 85, 42, 0.2);
|
|
||||||
margin-right: 4rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-bubble {
|
|
||||||
background-color: #ffffff;
|
|
||||||
color: #2A211B;
|
|
||||||
border-bottom-left-radius: 4rpx;
|
|
||||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
|
||||||
border: 1rpx solid #EAE1D6;
|
|
||||||
margin-left: 4rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Markdown 渲染区域 */
|
|
||||||
.message-markdown {
|
.message-markdown {
|
||||||
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-size: 28rpx;
|
min-width: 0;
|
||||||
color: #2A211B;
|
font-size: var(--fs-30);
|
||||||
line-height: 1.6;
|
line-height: 1.75;
|
||||||
|
color: var(--ink-2);
|
||||||
|
/* 组件内的色彩通过实际消费的 TDesign 变量传入,不依赖跨组件选择器 */
|
||||||
|
--td-text-color-primary: var(--ink-2);
|
||||||
|
--td-bg-color-component: var(--brand-soft);
|
||||||
|
--td-bg-color-page: var(--paper);
|
||||||
|
--td-bg-color-secondarycontainer: var(--paper);
|
||||||
|
--td-component-border: var(--line);
|
||||||
}
|
}
|
||||||
|
.message-markdown .t-chat-markdown-table { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 2rpx solid var(--line); border-radius: 12rpx; }
|
||||||
/* 表格样式覆盖(防止过宽) */
|
.message-markdown .t-chat-markdown-table__container { display: table; min-width: 100%; border-collapse: collapse; }
|
||||||
.message-markdown .t-chat-markdown-table {
|
.message-markdown .t-chat-markdown-table__container-th,
|
||||||
width: 100%;
|
.message-markdown .t-chat-markdown-table__container-td { padding: 12rpx; font-size: var(--fs-26); line-height: 1.6; word-break: break-word; }
|
||||||
max-width: 100%;
|
.message-markdown .t-chat-markdown-table__container-th { background: var(--brand-soft); color: var(--ink); }
|
||||||
overflow-x: auto;
|
.message-markdown .t-chat-markdown-table__container-tr:nth-child(2n) { background: var(--paper); }
|
||||||
-webkit-overflow-scrolling: touch;
|
/* 兼容表格子组件的另一套类名 */
|
||||||
border: 1rpx solid #EAE1D6;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-markdown .t-chat-markdown-table__container {
|
|
||||||
display: table;
|
|
||||||
min-width: 100%;
|
|
||||||
max-width: max-content;
|
|
||||||
border-collapse: collapse;
|
|
||||||
white-space: normal;
|
|
||||||
table-layout: fixed;
|
|
||||||
word-break: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-markdown .t-chat-markdown-table__th,
|
.message-markdown .t-chat-markdown-table__th,
|
||||||
.message-markdown .t-chat-markdown-table__td {
|
.message-markdown .t-chat-markdown-table__td { padding: 12rpx; font-size: var(--fs-26); line-height: 1.6; white-space: normal; word-break: break-word; }
|
||||||
padding: 8rpx 12rpx;
|
.message-markdown .t-chat-markdown-table__th { background: var(--brand-soft); color: var(--ink); }
|
||||||
font-size: 24rpx;
|
.message-markdown .t-chat-markdown-table__tr:nth-child(2n) { background: var(--paper); }
|
||||||
line-height: 1.4;
|
.message-markdown .t-chat-markdown-code, .message-markdown .t-chat-markdown-codespan { font-size: var(--fs-26); word-break: break-all; }
|
||||||
white-space: normal;
|
.message-item.ai .typing-bubble { display: flex; align-items: center; width: auto; min-height: 88rpx; }
|
||||||
word-break: break-word;
|
.typing-lines { display: flex; flex-direction: column; gap: 2rpx; }
|
||||||
word-wrap: break-word;
|
.typing-text { font-size: var(--fs-26); color: var(--muted); line-height: 1.6; }
|
||||||
overflow-wrap: break-word;
|
.typing-progress { font-size: 22rpx; color: var(--muted); line-height: 1.5; opacity: 0.85; }
|
||||||
max-width: 320rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-markdown .t-chat-markdown-table__th {
|
/* 统一白色输入面板:文字在上,更多与发送在下,所有操作横向展开。
|
||||||
background-color: #FAF6F1;
|
position: relative 供「更多」菜单定位(菜单从按钮上方展开) */
|
||||||
font-weight: 600;
|
.composer { position: relative; flex-shrink: 0; margin: 12rpx 24rpx 8rpx; padding: 20rpx 20rpx 12rpx; border: 2rpx solid var(--line); border-radius: 28rpx; background: var(--white); box-shadow: var(--shadow-card); }
|
||||||
color: #2A211B;
|
.input-area { padding: 0 4rpx; }
|
||||||
}
|
.message-input { display: block; box-sizing: border-box; width: 100%; min-height: 76rpx; max-height: 180rpx; padding: 4rpx 0 12rpx; color: var(--ink); font-size: var(--fs-30); line-height: 1.6; background: transparent; }
|
||||||
|
.message-input.is-readonly { color: var(--muted); }
|
||||||
|
.input-placeholder { color: var(--muted); font-size: var(--fs-28); }
|
||||||
|
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; }
|
||||||
|
.input-tools { display: flex; align-items: center; gap: 8rpx; }
|
||||||
|
.input-tool { display: flex; align-items: center; justify-content: center; gap: 8rpx; box-sizing: border-box; min-width: 104rpx; min-height: 88rpx; padding: 12rpx; border-radius: 16rpx; color: var(--muted); font-size: var(--fs-24); }
|
||||||
|
.input-tool.is-open { color: var(--brand-ink); background: var(--brand-soft); }
|
||||||
|
.input-tool.is-recording { color: var(--brand-ink); background: var(--brand-soft); }
|
||||||
|
.input-tool:active { background: var(--paper); }
|
||||||
|
/* 三个点用 CSS 画,不依赖图标名;与文字同一条基线 */
|
||||||
|
.more-dots { display: flex; align-items: center; justify-content: center; gap: 5rpx; width: 34rpx; height: 34rpx; }
|
||||||
|
.more-dot { width: 8rpx; height: 8rpx; border-radius: 50%; background: var(--muted); }
|
||||||
|
.input-tool.is-open .more-dot { background: var(--brand-ink); }
|
||||||
|
.send-btn { display: flex; align-items: center; justify-content: center; flex-shrink: 0; gap: 10rpx; box-sizing: border-box; min-width: 136rpx; min-height: 88rpx; padding: 16rpx 20rpx; border-radius: 20rpx; background: var(--paper); color: var(--muted); font-size: var(--fs-28); font-weight: 500; }
|
||||||
|
.send-btn.active { background: var(--brand-strong); color: var(--white); }
|
||||||
|
.send-btn.active:active { background: var(--brand-ink); }
|
||||||
|
|
||||||
.message-markdown .t-chat-markdown-table__tr:nth-child(2n) {
|
/* ===== 「更多」菜单 =====
|
||||||
background-color: #FCFAF7;
|
透明遮罩负责点外部关闭;菜单锚在输入面板上方左侧,向上展开 */
|
||||||
}
|
.more-mask { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 120; background: transparent; }
|
||||||
|
.more-menu { position: absolute; left: 20rpx; bottom: calc(100% + 8rpx); z-index: 121; box-sizing: border-box; min-width: 320rpx; padding: 8rpx 0; border: 2rpx solid var(--line); border-radius: 20rpx; background: var(--white); box-shadow: var(--shadow-card); animation: more-menu-in 0.16s ease-out; }
|
||||||
|
@keyframes more-menu-in { from { opacity: 0; transform: translateY(8rpx); } to { opacity: 1; transform: translateY(0); } }
|
||||||
|
.more-item { display: flex; align-items: center; gap: 14rpx; box-sizing: border-box; min-height: 88rpx; padding: 0 24rpx; color: var(--ink-2); font-size: var(--fs-28); line-height: 1.4; }
|
||||||
|
.more-item:active { background: var(--brand-soft); }
|
||||||
|
.more-item-muted { color: var(--muted); }
|
||||||
|
.more-divider { height: 2rpx; margin: 0 20rpx; background: var(--line); }
|
||||||
|
|
||||||
/* 代码块样式覆盖 */
|
/* 语音状态条:只在录音阶段显示,紧贴输入区上方 */
|
||||||
.message-markdown .t-chat-markdown-codespan,
|
.voice-status { display: flex; align-items: center; flex-shrink: 0; gap: 16rpx; margin: 8rpx 24rpx 0; padding: 8rpx 16rpx; border: 2rpx solid var(--brand-line); border-radius: 20rpx; background: var(--brand-soft); }
|
||||||
.message-markdown .t-chat-markdown-code {
|
.voice-dot { flex-shrink: 0; width: 12rpx; height: 12rpx; border-radius: 50%; background: var(--brand-strong); }
|
||||||
font-size: 24rpx;
|
.voice-dot.recording { animation: record-pulse 1.2s infinite ease-in-out; }
|
||||||
word-break: break-all;
|
.voice-status-main { display: flex; flex: 1; flex-direction: column; gap: 4rpx; min-width: 0; }
|
||||||
}
|
.voice-status-text { font-size: var(--fs-26); font-weight: 500; color: var(--ink-2); line-height: 1.5; }
|
||||||
|
.voice-status-sub { font-size: var(--fs-24); color: var(--muted); line-height: 1.5; }
|
||||||
/* subagent 引用卡片(默认折叠) */
|
.voice-cancel { display: flex; align-items: center; justify-content: center; flex-shrink: 0; gap: 8rpx; min-width: 88rpx; min-height: 88rpx; padding: 0 8rpx; color: var(--brand-ink); font-size: var(--fs-26); }
|
||||||
.subagent-header {
|
@keyframes record-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
|
||||||
display: flex;
|
@media (prefers-reduced-motion: reduce) { .voice-dot.recording, .more-menu { animation: none; transition: none; } }
|
||||||
align-items: center;
|
@media (max-width: 340px) {
|
||||||
justify-content: space-between;
|
.input-tool { min-width: 88rpx; padding: 8rpx; }
|
||||||
padding: 4rpx 0;
|
.composer-actions { gap: 8rpx; }
|
||||||
}
|
|
||||||
|
|
||||||
.subagent-label {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #6F655C;
|
|
||||||
}
|
|
||||||
|
|
||||||
.subagent-arrow {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #A3988B;
|
|
||||||
transition: transform 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.subagent-arrow.expanded {
|
|
||||||
transform: rotate(90deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.subagent-body {
|
|
||||||
margin-top: 12rpx;
|
|
||||||
padding-top: 12rpx;
|
|
||||||
border-top: 1rpx solid #EAE1D6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.typing-indicator {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
margin-bottom: 32rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.typing-bubble {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12rpx;
|
|
||||||
background-color: #ffffff;
|
|
||||||
padding: 24rpx 32rpx;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
border-bottom-left-radius: 4rpx;
|
|
||||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
|
||||||
border: 1rpx solid #EAE1D6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dot {
|
|
||||||
width: 16rpx;
|
|
||||||
height: 16rpx;
|
|
||||||
background-color: #A3988B;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: bounce 1.4s infinite ease-in-out both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dot:nth-child(1) {
|
|
||||||
animation-delay: -0.32s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dot:nth-child(2) {
|
|
||||||
animation-delay: -0.16s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes bounce {
|
|
||||||
0%, 80%, 100% {
|
|
||||||
transform: scale(0.6);
|
|
||||||
}
|
|
||||||
40% {
|
|
||||||
transform: scale(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-area {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 20rpx 24rpx;
|
|
||||||
background-color: #ffffff;
|
|
||||||
gap: 16rpx;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-footer {
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
z-index: 10;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-toolbar {
|
|
||||||
display: flex;
|
|
||||||
align-items: right;
|
|
||||||
justify-content: right;
|
|
||||||
padding: 12rpx 24rpx;
|
|
||||||
background-color: #FAF6F1;
|
|
||||||
border-top: 1rpx solid #EAE1D6;
|
|
||||||
border-bottom: 1rpx solid #EAE1D6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-toolbar-action {
|
|
||||||
display: flex;
|
|
||||||
align-items: right;
|
|
||||||
justify-content: right;
|
|
||||||
padding: 6rpx 24rpx;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
background-color: #ffffff;
|
|
||||||
border: 1rpx solid #EAE1D6;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-toolbar-action:active {
|
|
||||||
transform: scale(0.96);
|
|
||||||
background-color: rgba(194, 106, 46, 0.08);
|
|
||||||
border-color: #C26A2E;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-toolbar-action text {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #6F655C;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-input {
|
|
||||||
flex: 1;
|
|
||||||
height: 72rpx;
|
|
||||||
background-color: #FAF6F1;
|
|
||||||
border-radius: 36rpx;
|
|
||||||
padding: 0 28rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #2A211B;
|
|
||||||
border: 1rpx solid #EAE1D6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-input::placeholder {
|
|
||||||
color: #A3988B;
|
|
||||||
}
|
|
||||||
|
|
||||||
.send-btn {
|
|
||||||
width: 120rpx;
|
|
||||||
height: 72rpx;
|
|
||||||
background-color: #EAE1D6;
|
|
||||||
border-radius: 36rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.send-btn.active {
|
|
||||||
background: #C26A2E;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(180, 85, 42, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
.send-text {
|
|
||||||
color: #A3988B;
|
|
||||||
font-size: 28rpx;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: color 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.send-btn.active .send-text {
|
|
||||||
color: #FFFFFF;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+60
-3
@@ -13,6 +13,8 @@ const SEX_OPTIONS = [
|
|||||||
]
|
]
|
||||||
const SEX_LABELS = SEX_OPTIONS.map((item) => item.label)
|
const SEX_LABELS = SEX_OPTIONS.map((item) => item.label)
|
||||||
const MOBILE_REGEX = /^1[3-9]\d{9}$/
|
const MOBILE_REGEX = /^1[3-9]\d{9}$/
|
||||||
|
// 待审核期间的轮询间隔:后台审核通过后本页自动刷新角色并跳转首页
|
||||||
|
const PENDING_POLL_INTERVAL = 10 * 1000
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
@@ -41,6 +43,55 @@ Page({
|
|||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
this.refresh()
|
this.refresh()
|
||||||
|
this.startPolling()
|
||||||
|
},
|
||||||
|
|
||||||
|
onHide() {
|
||||||
|
this.stopPolling()
|
||||||
|
},
|
||||||
|
|
||||||
|
onUnload() {
|
||||||
|
this.stopPolling()
|
||||||
|
},
|
||||||
|
|
||||||
|
startPolling() {
|
||||||
|
this.stopPolling()
|
||||||
|
this._pollTimer = setInterval(() => this.pollApproval(), PENDING_POLL_INTERVAL)
|
||||||
|
},
|
||||||
|
|
||||||
|
stopPolling() {
|
||||||
|
if (this._pollTimer) {
|
||||||
|
clearInterval(this._pollTimer)
|
||||||
|
this._pollTimer = null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待审核轮询:后台审核通过后员工档案生效,角色解析为 attendant,
|
||||||
|
* 这里直接跳首页,无需用户手动重进
|
||||||
|
*/
|
||||||
|
pollApproval() {
|
||||||
|
// 只在待审核/已通过待同步时轮询;加载、提交、修改资料期间跳过
|
||||||
|
if (this.data.loading || this.data.submitting || this.data.editing) return
|
||||||
|
if (this.data.view !== 'pending' && this.data.view !== 'approved') return
|
||||||
|
if (this._polling) return
|
||||||
|
this._polling = true
|
||||||
|
|
||||||
|
role
|
||||||
|
.ensureRoleSafe(true)
|
||||||
|
.then((detail) => {
|
||||||
|
if (detail.ok && detail.role !== 'none') {
|
||||||
|
this.stopPolling()
|
||||||
|
wx.switchTab({ url: '/pages/home/index' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 角色未变(或解析失败):静默刷新申请单,驳回等状态变化也能及时反映
|
||||||
|
return this.loadApplication(true)
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.then(() => {
|
||||||
|
this._polling = false
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +106,7 @@ Page({
|
|||||||
.ensureRoleSafe(true)
|
.ensureRoleSafe(true)
|
||||||
.then((detail) => {
|
.then((detail) => {
|
||||||
if (detail.ok && detail.role !== 'none') {
|
if (detail.ok && detail.role !== 'none') {
|
||||||
|
this.stopPolling()
|
||||||
wx.switchTab({ url: '/pages/home/index' })
|
wx.switchTab({ url: '/pages/home/index' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -63,7 +115,10 @@ Page({
|
|||||||
.catch(() => this.loadApplication())
|
.catch(() => this.loadApplication())
|
||||||
},
|
},
|
||||||
|
|
||||||
loadApplication() {
|
/**
|
||||||
|
* @param {boolean} [silent] 轮询静默刷新:不弹错误提示,不切换 loading
|
||||||
|
*/
|
||||||
|
loadApplication(silent) {
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
const user = app && app.globalData ? app.globalData.user : null
|
const user = app && app.globalData ? app.globalData.user : null
|
||||||
const accountName = user && user.profile && user.profile.name ? user.profile.name : '微信用户'
|
const accountName = user && user.profile && user.profile.name ? user.profile.name : '微信用户'
|
||||||
@@ -74,7 +129,9 @@ Page({
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.code !== 0) {
|
if (res.code !== 0) {
|
||||||
// 未登录(新用户走到这里时还没有账号)不弹错误,直接展示登录入口
|
// 未登录(新用户走到这里时还没有账号)不弹错误,直接展示登录入口
|
||||||
if (res.code !== 401) {
|
if (silent) {
|
||||||
|
console.info('[apply] 轮询刷新未拿到申请单:', res.code, res.msg)
|
||||||
|
} else if (res.code !== 401) {
|
||||||
wx.showToast({ title: res.msg || '加载失败', icon: 'none' })
|
wx.showToast({ title: res.msg || '加载失败', icon: 'none' })
|
||||||
} else {
|
} else {
|
||||||
console.info('[apply] 未登录,展示登录入口')
|
console.info('[apply] 未登录,展示登录入口')
|
||||||
@@ -138,7 +195,7 @@ Page({
|
|||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.setData({ loading: false, accountName, loggedIn })
|
this.setData({ loading: false, accountName, loggedIn })
|
||||||
wx.showToast({ title: '网络错误,请重试', icon: 'none' })
|
if (!silent) wx.showToast({ title: '网络错误,请重试', icon: 'none' })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.loading-text {
|
.loading-text {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
.hero-desc {
|
.hero-desc {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 12rpx;
|
margin-top: 12rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
.card-title {
|
.card-title {
|
||||||
display: block;
|
display: block;
|
||||||
padding: 24rpx 0 8rpx;
|
padding: 24rpx 0 8rpx;
|
||||||
font-size: 28rpx;
|
font-size: 30rpx;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #2A211B;
|
color: #2A211B;
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
.card-tip {
|
.card-tip {
|
||||||
display: block;
|
display: block;
|
||||||
padding-bottom: 8rpx;
|
padding-bottom: 8rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #9C9188;
|
color: #9C9188;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@
|
|||||||
|
|
||||||
.upload-tip {
|
.upload-tip {
|
||||||
margin-top: 8rpx;
|
margin-top: 8rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@
|
|||||||
.reject-text {
|
.reject-text {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 8rpx;
|
margin-top: 8rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: #9E443A;
|
color: #9E443A;
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@
|
|||||||
.reject-hint {
|
.reject-hint {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 8rpx;
|
margin-top: 8rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #C0564A;
|
color: #C0564A;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@
|
|||||||
.foot-note {
|
.foot-note {
|
||||||
padding: 0 16rpx;
|
padding: 0 16rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ page {
|
|||||||
padding: 16rpx 28rpx;
|
padding: 16rpx 28rpx;
|
||||||
background: @accent-primary;
|
background: @accent-primary;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-radius: 32rpx;
|
border-radius: 32rpx;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@@ -121,7 +121,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.stats-label {
|
.stats-label {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @text-secondary;
|
color: @text-secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ page {
|
|||||||
|
|
||||||
.loading-text {
|
.loading-text {
|
||||||
color: @text-secondary !important;
|
color: @text-secondary !important;
|
||||||
font-size: 26rpx !important;
|
font-size: 28rpx !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-text {
|
.empty-text {
|
||||||
@@ -257,7 +257,7 @@ page {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 4rpx 14rpx;
|
padding: 4rpx 14rpx;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|
||||||
&.male {
|
&.male {
|
||||||
@@ -272,18 +272,18 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-date {
|
.customer-date {
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
color: @text-muted;
|
color: @text-muted;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.customer-phone {
|
.customer-phone {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: @text-secondary;
|
color: @text-secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
.customer-location {
|
.customer-location {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @text-muted;
|
color: @text-muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,6 +321,6 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.no-more {
|
.no-more {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @text-muted;
|
color: @text-muted;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.stat-label {
|
.stat-label {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.stat-unit {
|
.stat-unit {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
margin-left: 8rpx;
|
margin-left: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ page {
|
|||||||
|
|
||||||
.section-title {
|
.section-title {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 32rpx;
|
font-size: 30rpx;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #2A211B;
|
color: #2A211B;
|
||||||
margin-left: 8rpx;
|
margin-left: 8rpx;
|
||||||
@@ -110,7 +110,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.quick-label {
|
.quick-label {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #3A322B;
|
color: #3A322B;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-service {
|
.order-service {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #C26A2E;
|
color: #C26A2E;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@@ -124,7 +124,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.status-tag {
|
.status-tag {
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
padding: 6rpx 20rpx;
|
padding: 6rpx 20rpx;
|
||||||
border-radius: 30rpx;
|
border-radius: 30rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -169,7 +169,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-hospital {
|
.order-hospital {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -179,7 +179,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-time {
|
.order-time {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ page {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
text {
|
text {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #C0B7AC;
|
color: #C0B7AC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -10,22 +10,22 @@ function resolveDisplayStatus(order) {
|
|||||||
return order?.status || 'pending'
|
return order?.status || 'pending'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 快捷入口:type=quick 为快捷操作(琥珀浅色系),type=function 为功能入口(暖铜主色系),分行显示。
|
// 快捷入口:琥珀浅色系为快捷操作,暖铜主色系为功能入口,统一在一行内展示。
|
||||||
// 管理员与陪诊员共用同一套入口配置,但陪诊员不展示档案/客户等管理员能力
|
// 管理员与陪诊员共用同一套入口配置,但陪诊员不展示档案/客户等管理员能力
|
||||||
const ADMIN_ENTRIES = [
|
const ADMIN_ENTRIES = [
|
||||||
{ type: 'quick', icon: 'add-circle', name: '增加预约', url: '/pages/order/orderEdit', color: '#E8A96B' },
|
{ icon: 'add-circle', name: '增加预约', url: '/pages/order/orderEdit', color: '#E8A96B' },
|
||||||
{ type: 'quick', icon: 'file-add', name: '增加档案', url: '/pages/healthprofile/profileInfo', color: '#E8A96B' },
|
{ icon: 'file-add', name: '增加档案', url: '/pages/healthprofile/profileInfo', color: '#E8A96B' },
|
||||||
{ type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' },
|
{ icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' },
|
||||||
{ type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', isTab: true, color: '#C26A2E' },
|
{ icon: 'bill', name: '预约订单', url: '/pages/order/index', isTab: true, color: '#C26A2E' },
|
||||||
{ type: 'function', icon: 'heart', name: '健康档案', url: '/pages/healthprofile/index', color: '#C26A2E' },
|
{ icon: 'heart', name: '健康档案', url: '/pages/healthprofile/index', color: '#C26A2E' },
|
||||||
{ type: 'function', icon: 'user', name: '注册用户', url: '/pages/customer/index', color: '#C26A2E' },
|
{ icon: 'user', name: '注册用户', url: '/pages/customer/index', color: '#C26A2E' },
|
||||||
{ type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' }
|
{ icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' }
|
||||||
]
|
]
|
||||||
|
|
||||||
const ATTENDANT_ENTRIES = [
|
const ATTENDANT_ENTRIES = [
|
||||||
{ type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' },
|
{ icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' },
|
||||||
{ type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', isTab: true, color: '#C26A2E' },
|
{ icon: 'bill', name: '预约订单', url: '/pages/order/index', isTab: true, color: '#C26A2E' },
|
||||||
{ type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' }
|
{ icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' }
|
||||||
]
|
]
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|||||||
+2
-12
@@ -55,23 +55,13 @@
|
|||||||
<view class="section">
|
<view class="section">
|
||||||
<text class="section-title">快捷入口</text>
|
<text class="section-title">快捷入口</text>
|
||||||
<view class="quick-grid card">
|
<view class="quick-grid card">
|
||||||
<view class="quick-row">
|
<view class="quick-item" wx:for="{{quickEntries}}" wx:key="name" bindtap="onEntryTap" data-index="{{index}}">
|
||||||
<view class="quick-item" wx:for="{{quickEntries}}" wx:key="name" wx:if="{{item.type === 'quick'}}" bindtap="onEntryTap" data-index="{{index}}">
|
|
||||||
<view class="quick-icon" style="background-color: {{item.color}}1a;">
|
<view class="quick-icon" style="background-color: {{item.color}}1a;">
|
||||||
<t-icon name="{{item.icon}}" size="40rpx" color="{{item.color}}" />
|
<t-icon name="{{item.icon}}" size="36rpx" color="{{item.color}}" />
|
||||||
</view>
|
</view>
|
||||||
<text class="quick-label">{{item.name}}</text>
|
<text class="quick-label">{{item.name}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="quick-row">
|
|
||||||
<view class="quick-item" wx:for="{{quickEntries}}" wx:key="name" wx:if="{{item.type === 'function'}}" bindtap="onEntryTap" data-index="{{index}}">
|
|
||||||
<view class="quick-icon" style="background-color: {{item.color}}1a;">
|
|
||||||
<t-icon name="{{item.icon}}" size="40rpx" color="{{item.color}}" />
|
|
||||||
</view>
|
|
||||||
<text class="quick-label">{{item.name}}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 订单统计 -->
|
<!-- 订单统计 -->
|
||||||
|
|||||||
+22
-26
@@ -107,14 +107,14 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.level-text {
|
.level-text {
|
||||||
font-size: 20rpx;
|
font-size: 22rpx;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.greeting {
|
.greeting {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 8rpx;
|
margin-top: 8rpx;
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
color: rgba(255, 255, 255, 0.65);
|
color: rgba(255, 255, 255, 0.65);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ page {
|
|||||||
|
|
||||||
.intern-tip-text {
|
.intern-tip-text {
|
||||||
margin-left: 12rpx;
|
margin-left: 12rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
color: #8A5A32;
|
color: #8A5A32;
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.switch-text {
|
.switch-text {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
margin-right: 10rpx;
|
margin-right: 10rpx;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.stat-label {
|
.stat-label {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: rgba(255, 255, 255, 0.75);
|
color: rgba(255, 255, 255, 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.stat-unit {
|
.stat-unit {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
margin-right: 4rpx;
|
margin-right: 4rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ page {
|
|||||||
.view-all {
|
.view-all {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,22 +274,17 @@ page {
|
|||||||
|
|
||||||
.quick-grid {
|
.quick-grid {
|
||||||
margin-top: 16rpx;
|
margin-top: 16rpx;
|
||||||
padding: 32rpx 8rpx 8rpx;
|
padding: 32rpx 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: nowrap;
|
||||||
}
|
|
||||||
|
|
||||||
.quick-row {
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-item {
|
.quick-item {
|
||||||
width: 25%;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 32rpx;
|
|
||||||
transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1);
|
transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,19 +294,20 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.quick-icon {
|
.quick-icon {
|
||||||
width: 88rpx;
|
width: 72rpx;
|
||||||
height: 88rpx;
|
height: 72rpx;
|
||||||
border-radius: 26rpx;
|
border-radius: 22rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-bottom: 14rpx;
|
margin-bottom: 12rpx;
|
||||||
box-shadow: inset 0 2rpx 4rpx rgba(255, 255, 255, 0.8), 0 4rpx 10rpx rgba(90, 62, 42, 0.06);
|
box-shadow: inset 0 2rpx 4rpx rgba(255, 255, 255, 0.8), 0 4rpx 10rpx rgba(90, 62, 42, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-label {
|
.quick-label {
|
||||||
font-size: 26rpx;
|
font-size: 24rpx;
|
||||||
color: #5C5044;
|
color: #5C5044;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* === 订单列表 === */
|
/* === 订单列表 === */
|
||||||
@@ -348,7 +344,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-service {
|
.order-service {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #C26A2E;
|
color: #C26A2E;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@@ -358,7 +354,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.status-tag {
|
.status-tag {
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
padding: 6rpx 20rpx;
|
padding: 6rpx 20rpx;
|
||||||
border-radius: 30rpx;
|
border-radius: 30rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -403,7 +399,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-hospital {
|
.order-hospital {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -413,7 +409,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-time {
|
.order-time {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
@@ -432,6 +428,6 @@ page {
|
|||||||
|
|
||||||
.empty-text {
|
.empty-text {
|
||||||
margin-top: 16rpx;
|
margin-top: 16rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #C7BDB2;
|
color: #C7BDB2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,19 +26,19 @@ page {
|
|||||||
|
|
||||||
.launch-sub {
|
.launch-sub {
|
||||||
margin-top: 12rpx;
|
margin-top: 12rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #9C9188;
|
color: #9C9188;
|
||||||
}
|
}
|
||||||
|
|
||||||
.launch-tip {
|
.launch-tip {
|
||||||
margin-top: 48rpx;
|
margin-top: 48rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #B5AAA0;
|
color: #B5AAA0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.launch-error {
|
.launch-error {
|
||||||
margin-top: 48rpx;
|
margin-top: 48rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #C26A2E;
|
color: #C26A2E;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.loading-text {
|
.loading-text {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #9C9188;
|
color: #9C9188;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ page {
|
|||||||
.hero-desc {
|
.hero-desc {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 12rpx;
|
margin-top: 12rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ page {
|
|||||||
.empty-desc {
|
.empty-desc {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 16rpx;
|
margin-top: 16rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ page {
|
|||||||
.status-desc {
|
.status-desc {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 8rpx;
|
margin-top: 8rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ page {
|
|||||||
|
|
||||||
.upload-tip {
|
.upload-tip {
|
||||||
margin-top: 8rpx;
|
margin-top: 8rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #9C9188;
|
color: #9C9188;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+150
-2
@@ -16,7 +16,25 @@ Page({
|
|||||||
isAttendant: false,
|
isAttendant: false,
|
||||||
serviceAreaLabels: CITY_LABELS,
|
serviceAreaLabels: CITY_LABELS,
|
||||||
serviceAreaIndex: 0,
|
serviceAreaIndex: 0,
|
||||||
serviceAreaText: ''
|
serviceAreaText: '',
|
||||||
|
// 个人信息编辑态:只开放后端支持自助修改的字段(姓名/性别/生日/地区)
|
||||||
|
editing: false,
|
||||||
|
saving: false,
|
||||||
|
today: '',
|
||||||
|
form: {
|
||||||
|
name: '',
|
||||||
|
sex: '',
|
||||||
|
birth: '',
|
||||||
|
province: '',
|
||||||
|
city: '',
|
||||||
|
district: '',
|
||||||
|
regionText: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
this.rawUser = null
|
||||||
|
this.setData({ today: this.formatDate(new Date()) })
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
@@ -98,6 +116,129 @@ Page({
|
|||||||
wx.navigateTo({ url: '/pages/materials/index' })
|
wx.navigateTo({ url: '/pages/materials/index' })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用当前用户数据构建编辑表单
|
||||||
|
*/
|
||||||
|
buildForm(user) {
|
||||||
|
const profile = (user && user.profile) || {}
|
||||||
|
const location = (user && user.location) || {}
|
||||||
|
const province = location.province || ''
|
||||||
|
const city = location.city || ''
|
||||||
|
const district = location.district || ''
|
||||||
|
return {
|
||||||
|
name: profile.name || '',
|
||||||
|
sex: profile.sex || 'male',
|
||||||
|
birth: this.formatDate(profile.birth),
|
||||||
|
province,
|
||||||
|
city,
|
||||||
|
district,
|
||||||
|
regionText: [province, city, district].filter(Boolean).join(' ')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进入/退出编辑态:退出时不保存,直接丢弃未提交的修改
|
||||||
|
*/
|
||||||
|
onToggleEdit() {
|
||||||
|
if (this.data.saving) return
|
||||||
|
if (this.data.editing) {
|
||||||
|
this.setData({ editing: false, form: this.buildForm(this.rawUser) })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.setData({ editing: true, form: this.buildForm(this.rawUser) })
|
||||||
|
},
|
||||||
|
|
||||||
|
onFormInput(e) {
|
||||||
|
this.setData({ [`form.${e.currentTarget.dataset.field}`]: e.detail.value })
|
||||||
|
},
|
||||||
|
|
||||||
|
onSelectSex(e) {
|
||||||
|
this.setData({ 'form.sex': e.currentTarget.dataset.sex })
|
||||||
|
},
|
||||||
|
|
||||||
|
onBirthChange(e) {
|
||||||
|
this.setData({ 'form.birth': e.detail.value })
|
||||||
|
},
|
||||||
|
|
||||||
|
onRegionChange(e) {
|
||||||
|
const region = e.detail.value || []
|
||||||
|
const province = region[0] || ''
|
||||||
|
const city = region[1] || ''
|
||||||
|
const district = region[2] || ''
|
||||||
|
this.setData({
|
||||||
|
'form.province': province,
|
||||||
|
'form.city': city,
|
||||||
|
'form.district': district,
|
||||||
|
'form.regionText': [province, city, district].filter(Boolean).join(' ')
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存个人信息:/user/update 只接受姓名、性别、生日、手机号与地区,这里提交可自助修改的字段
|
||||||
|
*/
|
||||||
|
onSaveProfile() {
|
||||||
|
if (this.data.saving) return
|
||||||
|
|
||||||
|
const form = this.data.form
|
||||||
|
const name = (form.name || '').trim()
|
||||||
|
if (!name) {
|
||||||
|
wx.showToast({ title: '请输入姓名', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!form.sex) {
|
||||||
|
wx.showToast({ title: '请选择性别', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const app = getApp()
|
||||||
|
if (!app.globalData.user) {
|
||||||
|
wx.showToast({ title: '请先登录', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setData({ saving: true })
|
||||||
|
wx.showLoading({ title: '保存中...' })
|
||||||
|
|
||||||
|
API.user
|
||||||
|
.update({
|
||||||
|
profile: {
|
||||||
|
name,
|
||||||
|
sex: form.sex,
|
||||||
|
birth: form.birth || ''
|
||||||
|
},
|
||||||
|
location: {
|
||||||
|
province: form.province,
|
||||||
|
city: form.city,
|
||||||
|
district: form.district
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
wx.hideLoading()
|
||||||
|
this.setData({ saving: false })
|
||||||
|
if (!res || res.code !== 0) {
|
||||||
|
wx.showToast({ title: (res && res.msg) || '保存失败', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 回写全局用户:响应是脱敏用户(不含本机 token),需保留本地 security
|
||||||
|
const prev = app.globalData.user || {}
|
||||||
|
const updated = {
|
||||||
|
...prev,
|
||||||
|
...((res.data && res.data.user) || {}),
|
||||||
|
security: prev.security || {}
|
||||||
|
}
|
||||||
|
app.globalData.user = updated
|
||||||
|
this.rawUser = updated
|
||||||
|
this.setData({ editing: false })
|
||||||
|
this.setUser(updated)
|
||||||
|
wx.showToast({ title: '保存成功', icon: 'success' })
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
wx.hideLoading()
|
||||||
|
this.setData({ saving: false })
|
||||||
|
wx.showToast({ title: (err && err.message) || '网络错误,请重试', icon: 'none' })
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载当前登录用户信息
|
* 加载当前登录用户信息
|
||||||
*/
|
*/
|
||||||
@@ -117,6 +258,7 @@ Page({
|
|||||||
*/
|
*/
|
||||||
setUser(user) {
|
setUser(user) {
|
||||||
if (!user) return
|
if (!user) return
|
||||||
|
this.rawUser = user
|
||||||
const profile = user.profile || {}
|
const profile = user.profile || {}
|
||||||
const location = user.location || {}
|
const location = user.location || {}
|
||||||
const meta = user.meta || {}
|
const meta = user.meta || {}
|
||||||
@@ -139,6 +281,11 @@ Page({
|
|||||||
createText: this.formatDate(meta.createtime)
|
createText: this.formatDate(meta.createtime)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 编辑中不覆盖用户正在填写的表单
|
||||||
|
if (!this.data.editing) {
|
||||||
|
this.setData({ form: this.buildForm(user) })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +294,8 @@ Page({
|
|||||||
formatDate(dateStr) {
|
formatDate(dateStr) {
|
||||||
if (!dateStr) return ''
|
if (!dateStr) return ''
|
||||||
const date = new Date(dateStr)
|
const date = new Date(dateStr)
|
||||||
if (isNaN(date.getTime())) return ''
|
// birth 默认值是 0(1970-01-01),视为未填写
|
||||||
|
if (isNaN(date.getTime()) || date.getTime() <= 0) return ''
|
||||||
const pad = (n) => String(n).padStart(2, '0')
|
const pad = (n) => String(n).padStart(2, '0')
|
||||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
||||||
},
|
},
|
||||||
|
|||||||
+79
-1
@@ -51,6 +51,8 @@ page {
|
|||||||
margin-left: 28rpx;
|
margin-left: 28rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-name {
|
.user-name {
|
||||||
@@ -60,10 +62,26 @@ page {
|
|||||||
|
|
||||||
.user-mobile {
|
.user-mobile {
|
||||||
margin-top: 10rpx;
|
margin-top: 10rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* === 编辑入口 === */
|
||||||
|
.edit-entry {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-left: 16rpx;
|
||||||
|
padding: 10rpx 24rpx;
|
||||||
|
border-radius: 28rpx;
|
||||||
|
background-color: rgba(255, 255, 255, 0.16);
|
||||||
|
border: 1rpx solid rgba(255, 255, 255, 0.4);
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background-color: rgba(255, 255, 255, 0.28);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* === 详细信息卡 === */
|
/* === 详细信息卡 === */
|
||||||
.info-card {
|
.info-card {
|
||||||
margin-top: 24rpx;
|
margin-top: 24rpx;
|
||||||
@@ -117,3 +135,63 @@ page {
|
|||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: #C9BFB5;
|
color: #C9BFB5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* === 编辑态表单 === */
|
||||||
|
.edit-input {
|
||||||
|
flex: 1;
|
||||||
|
height: 48rpx;
|
||||||
|
min-height: 48rpx;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-placeholder {
|
||||||
|
color: #C7BDB2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sex-edit {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sex-chip {
|
||||||
|
padding: 6rpx 32rpx;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
background-color: #F4EFE9;
|
||||||
|
border: 1rpx solid transparent;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #6F655C;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: rgba(194, 106, 46, 0.1);
|
||||||
|
border-color: #C26A2E;
|
||||||
|
color: #C26A2E;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* === 保存按钮 === */
|
||||||
|
.save-bar {
|
||||||
|
margin-top: 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-btn {
|
||||||
|
height: 96rpx;
|
||||||
|
line-height: 96rpx;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 48rpx;
|
||||||
|
background-color: #C26A2E;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
box-shadow: 0 8rpx 24rpx rgba(180, 85, 42, 0.25);
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+70
-3
@@ -10,10 +10,32 @@
|
|||||||
<text class="user-name">{{user.name}}</text>
|
<text class="user-name">{{user.name}}</text>
|
||||||
<text class="user-mobile">{{user.mobile || '暂未绑定手机号'}}</text>
|
<text class="user-mobile">{{user.mobile || '暂未绑定手机号'}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="edit-entry {{editing ? 'active' : ''}}" bindtap="onToggleEdit">
|
||||||
|
<text>{{editing ? '取消' : '编辑'}}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 详细信息 -->
|
<!-- 详细信息 -->
|
||||||
<view class="info-card">
|
<view class="info-card">
|
||||||
|
<!-- 姓名 -->
|
||||||
|
<view class="info-item">
|
||||||
|
<view class="info-left">
|
||||||
|
<t-icon name="user-circle" size="36rpx" color="#C26A2E" />
|
||||||
|
<text class="info-label">姓名</text>
|
||||||
|
</view>
|
||||||
|
<input
|
||||||
|
wx:if="{{editing}}"
|
||||||
|
class="info-value edit-input"
|
||||||
|
value="{{form.name}}"
|
||||||
|
maxlength="20"
|
||||||
|
placeholder="请输入姓名"
|
||||||
|
placeholder-class="edit-placeholder"
|
||||||
|
bindinput="onFormInput"
|
||||||
|
data-field="name"
|
||||||
|
/>
|
||||||
|
<text wx:else class="info-value">{{user.name}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="info-item" wx:if="{{identityText}}">
|
<view class="info-item" wx:if="{{identityText}}">
|
||||||
<view class="info-left">
|
<view class="info-left">
|
||||||
<t-icon name="award" size="36rpx" color="#C26A2E" />
|
<t-icon name="award" size="36rpx" color="#C26A2E" />
|
||||||
@@ -21,20 +43,46 @@
|
|||||||
</view>
|
</view>
|
||||||
<text class="info-value">{{identityText}}</text>
|
<text class="info-value">{{identityText}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 性别 -->
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<view class="info-left">
|
<view class="info-left">
|
||||||
<t-icon name="user" size="36rpx" color="#C26A2E" />
|
<t-icon name="user" size="36rpx" color="#C26A2E" />
|
||||||
<text class="info-label">性别</text>
|
<text class="info-label">性别</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="info-value">{{user.sexLabel}}</text>
|
<view class="sex-edit" wx:if="{{editing}}">
|
||||||
|
<view class="sex-chip {{form.sex === 'male' ? 'active' : ''}}" bindtap="onSelectSex" data-sex="male">
|
||||||
|
<text>男</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="sex-chip {{form.sex === 'female' ? 'active' : ''}}" bindtap="onSelectSex" data-sex="female">
|
||||||
|
<text>女</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text wx:else class="info-value">{{user.sexLabel}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 出生日期 -->
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<view class="info-left">
|
<view class="info-left">
|
||||||
<t-icon name="calendar" size="36rpx" color="#C26A2E" />
|
<t-icon name="calendar" size="36rpx" color="#C26A2E" />
|
||||||
<text class="info-label">出生日期</text>
|
<text class="info-label">出生日期</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="info-value">{{user.birthText || '未填写'}}</text>
|
<picker
|
||||||
|
wx:if="{{editing}}"
|
||||||
|
mode="date"
|
||||||
|
value="{{form.birth || today}}"
|
||||||
|
start="1930-01-01"
|
||||||
|
end="{{today}}"
|
||||||
|
bindchange="onBirthChange"
|
||||||
|
>
|
||||||
|
<view class="info-value picker-value">
|
||||||
|
{{form.birth || '请选择'}}
|
||||||
|
<text class="arrow">›</text>
|
||||||
</view>
|
</view>
|
||||||
|
</picker>
|
||||||
|
<text wx:else class="info-value">{{user.birthText || '未填写'}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<view class="info-left">
|
<view class="info-left">
|
||||||
<t-icon name="mail" size="36rpx" color="#C26A2E" />
|
<t-icon name="mail" size="36rpx" color="#C26A2E" />
|
||||||
@@ -49,13 +97,27 @@
|
|||||||
</view>
|
</view>
|
||||||
<text class="info-value">{{user.idnumber || '未填写'}}</text>
|
<text class="info-value">{{user.idnumber || '未填写'}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 所在地区 -->
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<view class="info-left">
|
<view class="info-left">
|
||||||
<t-icon name="location" size="36rpx" color="#C26A2E" />
|
<t-icon name="location" size="36rpx" color="#C26A2E" />
|
||||||
<text class="info-label">所在地区</text>
|
<text class="info-label">所在地区</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="info-value">{{user.locationText || '未填写'}}</text>
|
<picker
|
||||||
|
wx:if="{{editing}}"
|
||||||
|
mode="region"
|
||||||
|
value="{{[form.province, form.city, form.district]}}"
|
||||||
|
bindchange="onRegionChange"
|
||||||
|
>
|
||||||
|
<view class="info-value picker-value">
|
||||||
|
{{form.regionText || '请选择'}}
|
||||||
|
<text class="arrow">›</text>
|
||||||
</view>
|
</view>
|
||||||
|
</picker>
|
||||||
|
<text wx:else class="info-value">{{user.locationText || '未填写'}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="info-item" wx:if="{{isAttendant}}">
|
<view class="info-item" wx:if="{{isAttendant}}">
|
||||||
<view class="info-left">
|
<view class="info-left">
|
||||||
<t-icon name="location" size="36rpx" color="#C26A2E" />
|
<t-icon name="location" size="36rpx" color="#C26A2E" />
|
||||||
@@ -91,4 +153,9 @@
|
|||||||
<text class="info-value">{{user.createText || '未知'}}</text>
|
<text class="info-value">{{user.createText || '未知'}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 编辑态保存 -->
|
||||||
|
<view class="save-bar" wx:if="{{editing}}">
|
||||||
|
<button class="save-btn" loading="{{saving}}" bindtap="onSaveProfile">保存</button>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
+18
-18
@@ -74,7 +74,7 @@ page {
|
|||||||
|
|
||||||
.header-sub {
|
.header-sub {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
color: rgba(255, 255, 255, 0.65);
|
color: rgba(255, 255, 255, 0.65);
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
letter-spacing: 1rpx;
|
letter-spacing: 1rpx;
|
||||||
@@ -85,7 +85,7 @@ page {
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
padding: 16rpx 28rpx;
|
padding: 16rpx 28rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background: rgba(255, 255, 255, 0.18);
|
background: rgba(255, 255, 255, 0.18);
|
||||||
border: 1rpx solid rgba(255, 255, 255, 0.4);
|
border: 1rpx solid rgba(255, 255, 255, 0.4);
|
||||||
@@ -109,7 +109,7 @@ page {
|
|||||||
padding: 16rpx 0;
|
padding: 16rpx 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-radius: 26rpx;
|
border-radius: 26rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: @muted;
|
color: @muted;
|
||||||
transition: all 0.25s;
|
transition: all 0.25s;
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.filter-label {
|
.filter-label {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @muted;
|
color: @muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ page {
|
|||||||
padding: 12rpx 24rpx;
|
padding: 12rpx 24rpx;
|
||||||
background: @card;
|
background: @card;
|
||||||
border-radius: 28rpx;
|
border-radius: 28rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @text;
|
color: @text;
|
||||||
border: 1rpx solid rgba(90, 62, 42, 0.06);
|
border: 1rpx solid rgba(90, 62, 42, 0.06);
|
||||||
box-shadow: 0 4rpx 12rpx rgba(90, 62, 42, 0.05);
|
box-shadow: 0 4rpx 12rpx rgba(90, 62, 42, 0.05);
|
||||||
@@ -178,7 +178,7 @@ page {
|
|||||||
|
|
||||||
.loading-text {
|
.loading-text {
|
||||||
color: @muted !important;
|
color: @muted !important;
|
||||||
font-size: 26rpx !important;
|
font-size: 28rpx !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-text {
|
.empty-text {
|
||||||
@@ -191,7 +191,7 @@ page {
|
|||||||
padding: 14rpx 48rpx;
|
padding: 14rpx 48rpx;
|
||||||
background: @accent;
|
background: @accent;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
border-radius: 28rpx;
|
border-radius: 28rpx;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-tag {
|
.order-tag {
|
||||||
font-size: 20rpx;
|
font-size: 22rpx;
|
||||||
padding: 4rpx 14rpx;
|
padding: 4rpx 14rpx;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -248,14 +248,14 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-no {
|
.order-no {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @muted;
|
color: @muted;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-family: 'DIN Alternate', 'Helvetica Neue', monospace;
|
font-family: 'DIN Alternate', 'Helvetica Neue', monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-badge {
|
.status-badge {
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
padding: 6rpx 20rpx;
|
padding: 6rpx 20rpx;
|
||||||
border-radius: 30rpx;
|
border-radius: 30rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -338,7 +338,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.patient-sex {
|
.patient-sex {
|
||||||
font-size: 20rpx;
|
font-size: 22rpx;
|
||||||
padding: 2rpx 10rpx;
|
padding: 2rpx 10rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -355,12 +355,12 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.patient-age {
|
.patient-age {
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
color: @muted;
|
color: @muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
.patient-phone {
|
.patient-phone {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @muted;
|
color: @muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,14 +377,14 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.line-label {
|
.line-label {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @muted;
|
color: @muted;
|
||||||
width: 64rpx;
|
width: 64rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.line-value {
|
.line-value {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: @text;
|
color: @text;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
@@ -406,7 +406,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.fee-label {
|
.fee-label {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @muted;
|
color: @muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,7 +425,7 @@ page {
|
|||||||
.action-btn {
|
.action-btn {
|
||||||
padding: 14rpx 32rpx;
|
padding: 14rpx 32rpx;
|
||||||
border-radius: 24rpx;
|
border-radius: 24rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
|
||||||
@@ -455,6 +455,6 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.no-more {
|
.no-more {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: @muted;
|
color: @muted;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ page {
|
|||||||
|
|
||||||
.status-desc {
|
.status-desc {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: rgba(255, 255, 255, 0.7);
|
color: rgba(255, 255, 255, 0.7);
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.patient-sex {
|
.patient-sex {
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
padding: 4rpx 12rpx;
|
padding: 4rpx 12rpx;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -168,12 +168,12 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.patient-age {
|
.patient-age {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|
||||||
.patient-phone {
|
.patient-phone {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.attendant-phone {
|
.attendant-phone {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.note-label {
|
.note-label {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
width: 140rpx;
|
width: 140rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@@ -258,7 +258,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.note-content {
|
.note-content {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #5C5044;
|
color: #5C5044;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@@ -314,7 +314,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-tag {
|
.order-tag {
|
||||||
font-size: 20rpx;
|
font-size: 22rpx;
|
||||||
padding: 4rpx 14rpx;
|
padding: 4rpx 14rpx;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -336,7 +336,7 @@ page {
|
|||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
background: #FBF0DC;
|
background: #FBF0DC;
|
||||||
color: #A97712;
|
color: #A97712;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +377,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.share-close {
|
.share-close {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +399,7 @@ page {
|
|||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
border: 2rpx solid #D9CFC3;
|
border: 2rpx solid #D9CFC3;
|
||||||
margin-right: 24rpx;
|
margin-right: 24rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
line-height: 40rpx;
|
line-height: 40rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
@@ -422,7 +422,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.share-stage {
|
.share-stage {
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
margin-top: 6rpx;
|
margin-top: 6rpx;
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,7 @@ page {
|
|||||||
.share-empty {
|
.share-empty {
|
||||||
padding: 60rpx 0;
|
padding: 60rpx 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.brief-tag {
|
.brief-tag {
|
||||||
font-size: 22rpx;
|
font-size: 24rpx;
|
||||||
background-color: rgba(194, 106, 46, 0.1);
|
background-color: rgba(194, 106, 46, 0.1);
|
||||||
color: #C26A2E;
|
color: #C26A2E;
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
@@ -44,7 +44,7 @@ page {
|
|||||||
.brief-remark {
|
.brief-remark {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 16rpx;
|
margin-top: 16rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ page {
|
|||||||
|
|
||||||
.profile-empty-sub {
|
.profile-empty-sub {
|
||||||
margin-top: 6rpx;
|
margin-top: 6rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #8A8078;
|
color: #8A8078;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ page {
|
|||||||
border-radius: 40rpx;
|
border-radius: 40rpx;
|
||||||
background-color: rgba(194, 106, 46, 0.1);
|
background-color: rgba(194, 106, 46, 0.1);
|
||||||
color: #C26A2E;
|
color: #C26A2E;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,14 +188,14 @@ page {
|
|||||||
|
|
||||||
.picker-item-sub {
|
.picker-item-sub {
|
||||||
margin-left: 12rpx;
|
margin-left: 12rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #9A9087;
|
color: #9A9087;
|
||||||
}
|
}
|
||||||
|
|
||||||
.picker-item-mobile {
|
.picker-item-mobile {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 4rpx;
|
margin-top: 4rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #9A9087;
|
color: #9A9087;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ page {
|
|||||||
.picker-empty {
|
.picker-empty {
|
||||||
padding: 60rpx 0;
|
padding: 60rpx 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #9A9087;
|
color: #9A9087;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ page {
|
|||||||
|
|
||||||
.switch-label {
|
.switch-label {
|
||||||
margin-right: 16rpx;
|
margin-right: 16rpx;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
|
|
||||||
&.paid {
|
&.paid {
|
||||||
color: #C26A2E;
|
color: #C26A2E;
|
||||||
@@ -326,7 +326,7 @@ page {
|
|||||||
.field-tip {
|
.field-tip {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 8rpx;
|
margin-top: 8rpx;
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #D98E04;
|
color: #D98E04;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.level-text {
|
.level-text {
|
||||||
font-size: 20rpx;
|
font-size: 22rpx;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.login-desc {
|
.login-desc {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: rgba(255, 255, 255, 0.65);
|
color: rgba(255, 255, 255, 0.65);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.login-btn-text {
|
.login-btn-text {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #C26A2E;
|
color: #C26A2E;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.version-text {
|
.version-text {
|
||||||
font-size: 24rpx;
|
font-size: 26rpx;
|
||||||
color: #A3988B;
|
color: #A3988B;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ page {
|
|||||||
|
|
||||||
.form-label {
|
.form-label {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #6F655C;
|
color: #6F655C;
|
||||||
margin-bottom: 12rpx;
|
margin-bottom: 12rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
const request = require('./request.js')
|
const request = require('./request.js')
|
||||||
|
|
||||||
|
// 语音 / 图片识别链路最长可到 60s,单独放宽超时,避免网络稍慢就整单失败
|
||||||
|
const AI_MEDIA_TIMEOUT = 90000
|
||||||
|
|
||||||
const API = {
|
const API = {
|
||||||
user: {
|
user: {
|
||||||
wxGetPhoneNumber: (data) => request.post('https://api.huashengtec.com/user/wxgetphonenumber', data),
|
wxGetPhoneNumber: (data) => request.post('https://api.huashengtec.com/user/wxgetphonenumber', data),
|
||||||
@@ -74,6 +77,10 @@ const API = {
|
|||||||
|
|
||||||
ai: {
|
ai: {
|
||||||
chat: (data) => request.post('/ai/chat', data),
|
chat: (data) => request.post('/ai/chat', data),
|
||||||
|
// 语音 / 图片识别:语音优先走 /chat 的实时分片链路,整段接口用于兜底;
|
||||||
|
// 识别链路最长可到 60s,单独放宽超时
|
||||||
|
asr: (data) => request.post('/health/ai/asr', data, { timeout: AI_MEDIA_TIMEOUT }),
|
||||||
|
ocr: (data) => request.post('/health/ai/ocr', data, { timeout: AI_MEDIA_TIMEOUT }),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+75
-93
@@ -1,22 +1,26 @@
|
|||||||
|
// AI 聊天 / 语音识别 WebSocket(与 health 服务同域)
|
||||||
const WS_BASE_URL = 'wss://api.huashengtec.com/health-ws'
|
const WS_BASE_URL = 'wss://api.huashengtec.com/health-ws'
|
||||||
//const WS_BASE_URL = 'ws://127.0.0.1:9005'
|
//const WS_BASE_URL = 'ws://127.0.0.1:9005'
|
||||||
|
|
||||||
|
const WS_HEARTBEAT_INTERVAL = 30000
|
||||||
|
const WS_MAX_RECONNECT_ATTEMPTS = 3
|
||||||
|
const WS_RECONNECT_DELAY = 3000
|
||||||
|
|
||||||
class AIChatSocket {
|
class AIChatSocket {
|
||||||
constructor(url = `${WS_BASE_URL}/chat`, options = {}) {
|
constructor(url = `${WS_BASE_URL}/chat`, options = {}) {
|
||||||
this.url = url
|
this.url = url
|
||||||
this.options = {
|
this.options = {
|
||||||
timeout: 10000,
|
heartbeatInterval: WS_HEARTBEAT_INTERVAL,
|
||||||
heartbeatInterval: 30000,
|
|
||||||
autoReconnect: true,
|
autoReconnect: true,
|
||||||
maxReconnectAttempts: 3,
|
maxReconnectAttempts: WS_MAX_RECONNECT_ATTEMPTS,
|
||||||
reconnectDelay: 3000,
|
reconnectDelay: WS_RECONNECT_DELAY,
|
||||||
...options
|
...options
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socketTask = null
|
this.socketTask = null
|
||||||
this.isConnected = false
|
this.isConnected = false
|
||||||
this.isConnecting = false
|
this.isConnecting = false
|
||||||
this.messageQueue = []
|
this.connectPromise = null
|
||||||
this.reconnectAttempts = 0
|
this.reconnectAttempts = 0
|
||||||
|
|
||||||
this._openCallback = null
|
this._openCallback = null
|
||||||
@@ -26,15 +30,30 @@ class AIChatSocket {
|
|||||||
this._heartbeatTimer = null
|
this._heartbeatTimer = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 连接 Promise 单飞:调用方必须 await 成功后再发送,避免断线后的首条消息竞态
|
||||||
connect() {
|
connect() {
|
||||||
if (this.isConnected || this.isConnecting) {
|
if (this.isConnected) return Promise.resolve()
|
||||||
console.log('[AIChatSocket] Already connected or connecting')
|
if (this.connectPromise) return this.connectPromise
|
||||||
return Promise.resolve()
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isConnecting = true
|
this.isConnecting = true
|
||||||
|
this.connectPromise = new Promise((resolve, reject) => {
|
||||||
|
let settled = false
|
||||||
|
const succeed = () => {
|
||||||
|
if (settled) return
|
||||||
|
settled = true
|
||||||
|
this.isConnecting = false
|
||||||
|
this.connectPromise = null
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
const fail = (err) => {
|
||||||
|
if (settled) return
|
||||||
|
settled = true
|
||||||
|
this.isConnecting = false
|
||||||
|
this.connectPromise = null
|
||||||
|
reject(err instanceof Error ? err : new Error('WebSocket 连接失败'))
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
this.socketTask = wx.connectSocket({
|
this.socketTask = wx.connectSocket({
|
||||||
url: this.url,
|
url: this.url,
|
||||||
header: {
|
header: {
|
||||||
@@ -42,120 +61,94 @@ class AIChatSocket {
|
|||||||
...this.options.header
|
...this.options.header
|
||||||
},
|
},
|
||||||
protocols: this.options.protocols || [],
|
protocols: this.options.protocols || [],
|
||||||
success: () => {
|
fail
|
||||||
console.log('[AIChatSocket] WebSocket connecting...')
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
this.isConnecting = false
|
|
||||||
console.error('[AIChatSocket] Connect failed:', err)
|
|
||||||
reject(err)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
} catch (err) {
|
||||||
|
fail(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.socketTask) {
|
if (!this.socketTask) {
|
||||||
this.isConnecting = false
|
fail(new Error('SocketTask creation failed'))
|
||||||
reject(new Error('SocketTask creation failed'))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socketTask.onOpen(() => {
|
this.socketTask.onOpen(() => {
|
||||||
console.log('[AIChatSocket] Connection opened')
|
|
||||||
this.isConnected = true
|
this.isConnected = true
|
||||||
this.isConnecting = false
|
|
||||||
this.reconnectAttempts = 0
|
this.reconnectAttempts = 0
|
||||||
this._startHeartbeat()
|
this._startHeartbeat()
|
||||||
|
if (this._openCallback) this._openCallback()
|
||||||
this._flushMessageQueue()
|
succeed()
|
||||||
|
|
||||||
if (this._openCallback) {
|
|
||||||
this._openCallback()
|
|
||||||
}
|
|
||||||
resolve()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.socketTask.onClose((res) => {
|
this.socketTask.onClose((res) => {
|
||||||
console.log('[AIChatSocket] Connection closed:', res)
|
|
||||||
this.isConnected = false
|
this.isConnected = false
|
||||||
this.isConnecting = false
|
|
||||||
this._stopHeartbeat()
|
this._stopHeartbeat()
|
||||||
|
fail(new Error(`WebSocket 已关闭:${res.code || 'unknown'}`))
|
||||||
if (this._closeCallback) {
|
if (this._closeCallback) this._closeCallback(res)
|
||||||
this._closeCallback(res)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.options.autoReconnect && this.reconnectAttempts < this.options.maxReconnectAttempts) {
|
if (this.options.autoReconnect && this.reconnectAttempts < this.options.maxReconnectAttempts) {
|
||||||
this._reconnect()
|
this._reconnect()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
this.socketTask.onError((err) => {
|
this.socketTask.onError((err) => {
|
||||||
console.error('[AIChatSocket] WebSocket error:', err)
|
if (this._errorCallback) this._errorCallback(err)
|
||||||
this.isConnected = false
|
fail(new Error(err?.errMsg || 'WebSocket 连接错误'))
|
||||||
this.isConnecting = false
|
|
||||||
|
|
||||||
if (this._errorCallback) {
|
|
||||||
this._errorCallback(err)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.socketTask.onMessage((res) => {
|
this.socketTask.onMessage((res) => {
|
||||||
|
if (!this._messageCallback) return
|
||||||
try {
|
try {
|
||||||
const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
|
const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
|
||||||
if (this._messageCallback) {
|
|
||||||
this._messageCallback(data)
|
this._messageCallback(data)
|
||||||
}
|
} catch (err) {
|
||||||
} catch (e) {
|
this._messageCallback({
|
||||||
if (this._messageCallback) {
|
source: 'system',
|
||||||
this._messageCallback(res.data)
|
type: 'error',
|
||||||
}
|
content: '收到无法解析的服务消息',
|
||||||
|
id: ''
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return this.connectPromise
|
||||||
}
|
}
|
||||||
|
|
||||||
send(data) {
|
send(data) {
|
||||||
const message = typeof data === 'string' ? data : JSON.stringify(data)
|
const message = typeof data === 'string' ? data : JSON.stringify(data)
|
||||||
|
|
||||||
if (!this.isConnected || !this.socketTask) {
|
if (!this.isConnected || !this.socketTask) {
|
||||||
console.log('[AIChatSocket] Not connected, queueing message')
|
return Promise.reject(new Error('WebSocket 尚未连接'))
|
||||||
this.messageQueue.push(message)
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
this.socketTask.send({
|
this.socketTask.send({
|
||||||
data: message,
|
data: message,
|
||||||
fail: (err) => {
|
success: resolve,
|
||||||
console.error('[AIChatSocket] Send failed:', err)
|
fail: (err) => reject(new Error(err?.errMsg || '消息发送失败'))
|
||||||
this.messageQueue.push(message)
|
})
|
||||||
|
} catch (err) {
|
||||||
|
reject(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return true
|
|
||||||
} catch (err) {
|
|
||||||
console.error('[AIChatSocket] Send error:', err)
|
|
||||||
this.messageQueue.push(message)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this._stopHeartbeat()
|
this._stopHeartbeat()
|
||||||
this.options.autoReconnect = false
|
this.options.autoReconnect = false
|
||||||
|
const task = this.socketTask
|
||||||
if (this.socketTask) {
|
|
||||||
this.socketTask.close({
|
|
||||||
code: 1000,
|
|
||||||
reason: 'User closed',
|
|
||||||
fail: (err) => {
|
|
||||||
console.error('[AIChatSocket] Close failed:', err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this.socketTask = null
|
this.socketTask = null
|
||||||
}
|
|
||||||
|
|
||||||
this.isConnected = false
|
this.isConnected = false
|
||||||
this.isConnecting = false
|
this.isConnecting = false
|
||||||
this.messageQueue = []
|
this.connectPromise = null
|
||||||
|
if (task) {
|
||||||
|
task.close({
|
||||||
|
code: 1000,
|
||||||
|
reason: 'User closed',
|
||||||
|
fail: (err) => console.error('[AIChatSocket] Close failed:', err)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpen(callback) {
|
onOpen(callback) {
|
||||||
@@ -174,21 +167,10 @@ class AIChatSocket {
|
|||||||
this._messageCallback = callback
|
this._messageCallback = callback
|
||||||
}
|
}
|
||||||
|
|
||||||
_flushMessageQueue() {
|
|
||||||
if (this.messageQueue.length === 0) return
|
|
||||||
|
|
||||||
console.log(`[AIChatSocket] Flushing ${this.messageQueue.length} queued messages`)
|
|
||||||
while (this.messageQueue.length > 0) {
|
|
||||||
const message = this.messageQueue.shift()
|
|
||||||
this.send(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_reconnect() {
|
_reconnect() {
|
||||||
this.reconnectAttempts++
|
this.reconnectAttempts++
|
||||||
console.log(`[AIChatSocket] Reconnecting... Attempt ${this.reconnectAttempts}/${this.options.maxReconnectAttempts}`)
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (!this.options.autoReconnect || this.isConnected) return
|
||||||
this.connect().catch((err) => {
|
this.connect().catch((err) => {
|
||||||
console.error('[AIChatSocket] Reconnect failed:', err)
|
console.error('[AIChatSocket] Reconnect failed:', err)
|
||||||
})
|
})
|
||||||
@@ -197,17 +179,17 @@ class AIChatSocket {
|
|||||||
|
|
||||||
_startHeartbeat() {
|
_startHeartbeat() {
|
||||||
this._stopHeartbeat()
|
this._stopHeartbeat()
|
||||||
|
|
||||||
this._heartbeatTimer = setInterval(() => {
|
this._heartbeatTimer = setInterval(() => {
|
||||||
if (this.isConnected && this.socketTask) {
|
if (!this.isConnected || !this.socketTask) return
|
||||||
this.socketTask.send({
|
this.send({
|
||||||
data: JSON.stringify({ type: 'ping' }),
|
source: 'client',
|
||||||
fail: (err) => {
|
type: 'ping',
|
||||||
|
content: '',
|
||||||
|
id: `heartbeat_${Date.now()}`
|
||||||
|
}).catch((err) => {
|
||||||
console.error('[AIChatSocket] Heartbeat failed:', err)
|
console.error('[AIChatSocket] Heartbeat failed:', err)
|
||||||
this._stopHeartbeat()
|
this._stopHeartbeat()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}, this.options.heartbeatInterval)
|
}, this.options.heartbeatInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+26
-2
@@ -3,10 +3,34 @@ class Request {
|
|||||||
constructor(baseURL = 'https://api.huashengtec.com') {
|
constructor(baseURL = 'https://api.huashengtec.com') {
|
||||||
//constructor(baseURL = 'http://127.0.0.1:9004') {
|
//constructor(baseURL = 'http://127.0.0.1:9004') {
|
||||||
this.baseURL = baseURL
|
this.baseURL = baseURL
|
||||||
|
// 401 兜底回调由 app.js 注入(静默重登),避免各页面自己处理登录
|
||||||
|
this.onUnauthorized = null
|
||||||
}
|
}
|
||||||
|
|
||||||
async request(options) {
|
setUnauthorizedHandler(handler) {
|
||||||
const { url, method = 'GET', data = {}, header = {}, skipAuthWait = false, ...rest } = options
|
this.onUnauthorized = handler
|
||||||
|
}
|
||||||
|
|
||||||
|
request(options) {
|
||||||
|
return this.send(options).then((body) => this.recoverUnauthorized(body, options))
|
||||||
|
}
|
||||||
|
|
||||||
|
// token 失效时后端返回 HTTP 200 + code 401:静默重登一次再重试原请求。
|
||||||
|
// 登录请求自身(skipAuthWait)不再触发重登,避免递归
|
||||||
|
recoverUnauthorized(body, options) {
|
||||||
|
if (!body || body.code !== 401 || options._retried || options.skipAuthWait || !this.onUnauthorized) {
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
const notLoggedIn = { code: 401, msg: '请先登录', data: null }
|
||||||
|
return Promise.resolve()
|
||||||
|
.then(() => this.onUnauthorized())
|
||||||
|
.then((ok) => (ok ? this.request({ ...options, _retried: true }) : notLoggedIn))
|
||||||
|
.catch(() => notLoggedIn)
|
||||||
|
}
|
||||||
|
|
||||||
|
async send(options) {
|
||||||
|
const { url, method = 'GET', data = {}, header = {}, skipAuthWait = false, _retried, ...rest } = options
|
||||||
|
|
||||||
// 等待登录完成后再携带 token,避免页面请求早于 app.js 登录的竞态
|
// 等待登录完成后再携带 token,避免页面请求早于 app.js 登录的竞态
|
||||||
// skipAuthWait: 登录请求自身使用,否则会等待自己导致死锁
|
// skipAuthWait: 登录请求自身使用,否则会等待自己导致死锁
|
||||||
|
|||||||
Reference in New Issue
Block a user