diff --git a/app.json b/app.json index 0bf51e3..c5484a0 100644 --- a/app.json +++ b/app.json @@ -25,7 +25,7 @@ }, "tabBar": { "color": "#8a8a8a", - "selectedColor": "#1296db", + "selectedColor": "#1a8a63", "backgroundColor": "#ffffff", "borderStyle": "black", "list": [ @@ -33,19 +33,19 @@ "pagePath": "pages/home/index", "text": "首页", "iconPath": "images/home.png", - "selectedIconPath": "images/home-blue.png" + "selectedIconPath": "images/home-green.png" }, { "pagePath": "pages/ai/index", "text": "AI", "iconPath": "images/chat.png", - "selectedIconPath": "images/chat-blue.png" + "selectedIconPath": "images/chat-green.png" }, { "pagePath": "pages/set/index", "text": "设置", "iconPath": "images/set.png", - "selectedIconPath": "images/set-blue.png" + "selectedIconPath": "images/set-green.png" } ] }, diff --git a/components/order-stats/index.wxss b/components/order-stats/index.wxss index 56fefdd..ffb6c84 100644 --- a/components/order-stats/index.wxss +++ b/components/order-stats/index.wxss @@ -12,13 +12,26 @@ } .os-title { + position: relative; font-size: 30rpx; - font-weight: 500; + font-weight: 600; color: #1a1a1a; - margin-left: 8rpx; + margin-left: 20rpx; letter-spacing: 1rpx; } +.os-title::before { + content: ''; + position: absolute; + left: -20rpx; + top: 50%; + transform: translateY(-50%); + width: 8rpx; + height: 28rpx; + border-radius: 4rpx; + background: linear-gradient(180deg, #2dd36f, #17c3a5); +} + .os-card { background: linear-gradient(135deg, #ffffff 0%, #f3fbf8 100%); border-radius: 24rpx; @@ -63,11 +76,11 @@ } .os-num.blue { - color: #409eff; + color: #17c3a5; } .os-num.orange { - color: #ff9f43; + color: #f5a623; } .os-label { @@ -92,13 +105,13 @@ } .os-item:nth-child(3) .os-fee { - color: #3d8fe0; - background: rgba(64, 158, 255, 0.12); + color: #14a08a; + background: rgba(23, 195, 165, 0.12); } .os-item:nth-child(5) .os-fee { - color: #e08a1e; - background: rgba(255, 159, 67, 0.14); + color: #d99a2b; + background: rgba(245, 166, 35, 0.14); } .os-divider { diff --git a/images/chat-green.png b/images/chat-green.png new file mode 100644 index 0000000..a21a4f4 Binary files /dev/null and b/images/chat-green.png differ diff --git a/images/home-green.png b/images/home-green.png new file mode 100644 index 0000000..93b65e1 Binary files /dev/null and b/images/home-green.png differ diff --git a/images/set-green.png b/images/set-green.png new file mode 100644 index 0000000..d078745 Binary files /dev/null and b/images/set-green.png differ diff --git a/pages/healthprofile/profileInfo.js b/pages/healthprofile/profileInfo.js index cf078a3..2f5ffae 100644 --- a/pages/healthprofile/profileInfo.js +++ b/pages/healthprofile/profileInfo.js @@ -8,6 +8,14 @@ const SEX_MAP = [ ] const BLOOD_TYPES = ['A', 'B', 'O', 'AB'] +const STATUS_TEXT_MAP = { + pending: '待确认', + confirmed: '已确认', + in_progress: '进行中', + completed: '已完成', + cancelled: '已取消' +} + Page({ data: { isEdit: false, @@ -27,6 +35,7 @@ Page({ }, region: [], regionLabel: '', + orderList: [], sexLabels: SEX_MAP.map(item => item.label), bloodTypes: BLOOD_TYPES }, @@ -44,6 +53,50 @@ Page({ } }, + onShow() { + // 从订单页返回后刷新关联订单列表 + if (this.data.isEdit && this.data.profileId) { + this.loadProfileOrders(this.data.profileId) + } + }, + + /** + * 加载与本档案关联的预约订单 + */ + loadProfileOrders(profileId) { + API.escort.getAllRecords({ page: 1, pageSize: 50, healthProfileId: profileId }) + .then(res => { + if (res.code !== 0) return + const pad = (n) => String(n).padStart(2, '0') + const orderList = (res.data.records || []).map(item => { + const d = item.schedule && item.schedule.date ? new Date(item.schedule.date) : null + return { + ...item, + statusText: STATUS_TEXT_MAP[item.status] || item.status, + hospitalText: [item.hospital && item.hospital.name, item.hospital && item.hospital.department] + .filter(Boolean).join('·'), + schedule: { + ...item.schedule, + dateText: d && !isNaN(d.getTime()) + ? `${d.getMonth() + 1}月${d.getDate()}日 ${pad(d.getHours())}:${pad(d.getMinutes())}` + : '' + } + } + }) + this.setData({ orderList }) + }) + .catch(() => {}) + }, + + /** + * 点击关联订单,进入订单详情 + */ + onOrderTap(e) { + const id = e.currentTarget.dataset.id + if (!id) return + wx.navigateTo({ url: `/pages/order/orderDetail?id=${id}` }) + }, + /** * 加载档案详情 */ diff --git a/pages/healthprofile/profileInfo.less b/pages/healthprofile/profileInfo.less index 4b1c076..ef80177 100644 --- a/pages/healthprofile/profileInfo.less +++ b/pages/healthprofile/profileInfo.less @@ -21,11 +21,25 @@ page { } .section-title { + position: relative; display: block; - font-size: 32rpx; - font-weight: 700; + font-size: 30rpx; + font-weight: 600; color: #1a1a1a; - margin-left: 8rpx; + margin-left: 28rpx; + letter-spacing: 1rpx; + + &::before { + content: ''; + position: absolute; + left: -20rpx; + top: 50%; + transform: translateY(-50%); + width: 8rpx; + height: 28rpx; + border-radius: 4rpx; + background: linear-gradient(180deg, #2dd36f, #17c3a5); + } } .form-card { @@ -68,6 +82,116 @@ page { background-color: #f0f0f0; } +/* 关联预约订单 */ +.order-list { + margin-top: 16rpx; + display: flex; + flex-direction: column; + gap: 20rpx; +} + +.order-card { + background-color: #ffffff; + border-radius: 24rpx; + padding: 28rpx 32rpx; + box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04); + + &:active { + opacity: 0.85; + } +} + +.order-line1 { + display: flex; + align-items: center; +} + +.order-patient { + font-size: 30rpx; + font-weight: 600; + color: #1a1a1a; + margin-right: 16rpx; +} + +.order-service { + font-size: 26rpx; + font-weight: 500; + color: #1abc9c; + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.status-tag { + font-size: 22rpx; + padding: 6rpx 20rpx; + border-radius: 30rpx; + font-weight: 500; + flex-shrink: 0; +} + +.status-pending { + background: #fdf3e0; + color: #d99a2b; +} + +.status-confirmed { + background: #e6f4ee; + color: #43a08a; +} + +.status-in_progress { + background: #e6f4ee; + color: #43a08a; +} + +.status-completed { + background: #efedf6; + color: #8a7bb5; +} + +.status-cancelled { + background: #f5f5f5; + color: #b0b0b0; +} + +.order-line2 { + display: flex; + align-items: center; + justify-content: space-between; + margin-top: 12rpx; +} + +.order-hospital { + font-size: 26rpx; + color: #888888; + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + margin-right: 16rpx; +} + +.order-time { + font-size: 26rpx; + color: #a0a3bd; + flex-shrink: 0; +} + +.empty-order { + margin-top: 16rpx; + background-color: #ffffff; + border-radius: 24rpx; + padding: 48rpx 0; + text-align: center; + + text { + font-size: 26rpx; + color: #b8b8c4; + } +} + /* 操作按钮 */ .btn-group { display: flex; diff --git a/pages/healthprofile/profileInfo.wxml b/pages/healthprofile/profileInfo.wxml index 2c0a2be..eab66e1 100644 --- a/pages/healthprofile/profileInfo.wxml +++ b/pages/healthprofile/profileInfo.wxml @@ -81,6 +81,27 @@ + + + 预约订单 + + + + {{item.patient.name}} + {{item.escort.serviceName}} + {{item.statusText}} + + + {{item.hospitalText}} + {{item.schedule.dateText}} + + + + + 暂无关联的预约订单 + + + 陪诊预约 diff --git a/pages/home/index.js b/pages/home/index.js index b53c180..5cdbad4 100644 --- a/pages/home/index.js +++ b/pages/home/index.js @@ -4,18 +4,20 @@ const API = require('../../utils/api.js') Page({ data: { today: '', + greeting: '', + todayText: '', pendingCount: 0, completedCount: 0, recentOrders: [], - // 快捷入口:前3个为快捷操作(橙色系),后4个为功能入口(绿色系) + // 快捷入口:type=quick 为快捷操作(橙色系),type=function 为功能入口(绿色系),分行显示 quickEntries: [ - { icon: 'add-circle', name: '增加预约', url: '/pages/order/orderEdit', color: '#ff8f4d' }, - { icon: 'file-add', name: '增加档案', url: '/pages/healthprofile/profileInfo', color: '#ff8f4d' }, - { icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#ff8f4d' }, - { icon: 'bill', name: '预约订单', url: '/pages/order/index', color: '#1abc9c' }, - { icon: 'heart', name: '健康档案', url: '/pages/healthprofile/index', color: '#1abc9c' }, - { icon: 'user', name: '注册用户', url: '/pages/customer/index', color: '#1abc9c' }, - { icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#1abc9c' } + { type: 'quick', icon: 'add-circle', name: '增加预约', url: '/pages/order/orderEdit', color: '#ff8f4d' }, + { type: 'quick', icon: 'file-add', name: '增加档案', url: '/pages/healthprofile/profileInfo', color: '#ff8f4d' }, + { type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#ff8f4d' }, + { type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', color: '#1abc9c' }, + { type: 'function', icon: 'heart', name: '健康档案', url: '/pages/healthprofile/index', color: '#1abc9c' }, + { type: 'function', icon: 'user', name: '注册用户', url: '/pages/customer/index', color: '#1abc9c' }, + { type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#1abc9c' } ], online: true, profile: { @@ -23,7 +25,7 @@ Page({ level: '初级陪诊师', avatar: '' }, - todayIncome: 168, + todayIncome: 0, todayOrderCount: 0, pendingOrder: { count: 1, @@ -63,7 +65,10 @@ Page({ this.loadUser() const now = new Date(); const today = now.toISOString().substring(0, 10); - this.setData({ today }); + const hour = now.getHours(); + const greeting = hour < 6 ? '夜深了' : hour < 9 ? '早上好' : hour < 12 ? '上午好' : hour < 14 ? '中午好' : hour < 18 ? '下午好' : '晚上好'; + const week = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][now.getDay()]; + this.setData({ today, greeting, todayText: `${now.getMonth() + 1}月${now.getDate()}日 ${week}` }); this.getRecentOrders(); this.getStats(); }, @@ -104,16 +109,33 @@ Page({ }, async getStats() { - const today = new Date().toISOString().substring(0, 10); - const [todayRes, pendingRes, completedRes] = await Promise.all([ - API.escort.getAllRecords({ appointmentDate: today }), - API.escort.getAllRecords({ status: 'pending,confirmed' }), + const now = new Date(); + const pad = (n) => String(n).padStart(2, '0'); + // 本地日期(toISOString 是 UTC,早晨会差一天) + const todayStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`; + const isSameDay = (d, ref) => + d.getFullYear() === ref.getFullYear() && d.getMonth() === ref.getMonth() && d.getDate() === ref.getDate(); + const feeOf = (item) => Number(item.payment && item.payment.totalFee) || 0; + + const [todayRes, completedRes] = await Promise.all([ + API.escort.getAllRecords({ appointmentDate: todayStr }), API.escort.getAllRecords({ status: 'completed' }) ]); + + // 今日收益:当日已完成订单的费用合计 + let todayIncome = 0; + if (completedRes.code === 0) { + (completedRes.data.records || []).forEach(item => { + const d = item.schedule && item.schedule.date ? new Date(item.schedule.date) : null; + if (d && !isNaN(d.getTime()) && isSameDay(d, now)) { + todayIncome += feeOf(item); + } + }); + } + this.setData({ - todayOrderCount: todayRes.code === 0 ? (todayRes.data.records || []).length : 0, - pendingCount: pendingRes.code === 0 ? (pendingRes.data.records || []).length : 0, - completedCount: completedRes.code === 0 ? (completedRes.data.records || []).length : 0, + todayIncome, + todayOrderCount: todayRes.code === 0 ? (todayRes.data.records || []).length : 0 }); }, diff --git a/pages/home/index.wxml b/pages/home/index.wxml index 388e89b..6fc272f 100644 --- a/pages/home/index.wxml +++ b/pages/home/index.wxml @@ -15,6 +15,7 @@ {{profile.level}} + {{greeting}},{{todayText}} @@ -33,6 +34,7 @@ {{todayIncome}} + 今日接单 @@ -47,11 +49,21 @@ 快捷入口 - - - + + + + + + {{item.name}} + + + + + + + + {{item.name}} - {{item.name}} @@ -65,7 +77,7 @@ 近7日订单 全部 - + @@ -86,6 +98,7 @@ + 暂无近7日订单 diff --git a/pages/home/index.wxss b/pages/home/index.wxss index 2a4a1d8..9991adc 100644 --- a/pages/home/index.wxss +++ b/pages/home/index.wxss @@ -1,7 +1,7 @@ /* pages/home/index.wxss */ page { - background: linear-gradient(180deg, #ffb97a 0%, #f5f6fa 420rpx); + background: #f5f6fa; color: #1a1a2e; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; } @@ -12,16 +12,15 @@ page { padding: 24rpx 24rpx 64rpx; } -/* === 头部信息卡(浅色玻璃) === */ +/* === 头部信息卡(翡翠绿实底) === */ .header-card { position: relative; overflow: hidden; - background: rgba(255, 255, 255, 0.62); - border: 1rpx solid rgba(255, 255, 255, 0.85); + background: linear-gradient(135deg, #29b785 0%, #1a8a63 100%); border-radius: 28rpx; padding: 36rpx 32rpx; - color: #3d2f25; - box-shadow: 0 12rpx 32rpx rgba(242, 100, 80, 0.16); + color: #ffffff; + box-shadow: 0 12rpx 32rpx rgba(26, 138, 99, 0.25); } /* 装饰光斑,增加层次 */ @@ -30,7 +29,7 @@ page { content: ''; position: absolute; border-radius: 50%; - background: rgba(255, 138, 61, 0.1); + background: rgba(255, 255, 255, 0.07); pointer-events: none; } @@ -46,7 +45,7 @@ page { height: 160rpx; bottom: -80rpx; left: -40rpx; - background: rgba(242, 100, 80, 0.08); + background: rgba(255, 255, 255, 0.05); } .profile-row { @@ -65,8 +64,8 @@ page { width: 96rpx; height: 96rpx; border-radius: 50%; - background-color: rgba(255, 138, 61, 0.15); - border: 2rpx solid rgba(255, 255, 255, 0.9); + background-color: rgba(255, 255, 255, 0.2); + border: 2rpx solid rgba(255, 255, 255, 0.45); display: flex; align-items: center; justify-content: center; @@ -82,7 +81,7 @@ page { .avatar-text { font-size: 40rpx; font-weight: 600; - color: #f2633f; + color: #ffffff; } .profile-info { @@ -101,21 +100,28 @@ page { .level-tag { margin-left: 12rpx; - background-color: rgba(242, 100, 80, 0.12); + background-color: rgba(255, 255, 255, 0.2); border-radius: 16rpx; padding: 4rpx 14rpx; } .level-text { font-size: 20rpx; - color: #e05a3a; + color: #ffffff; +} + +.greeting { + display: block; + margin-top: 8rpx; + font-size: 22rpx; + color: rgba(255, 255, 255, 0.65); } .online-switch { display: flex; align-items: center; - background-color: rgba(255, 255, 255, 0.75); - border: 1rpx solid rgba(255, 255, 255, 0.9); + background-color: rgba(255, 255, 255, 0.16); + border: 1rpx solid rgba(255, 255, 255, 0.28); border-radius: 28rpx; padding: 6rpx 6rpx 6rpx 18rpx; } @@ -123,14 +129,14 @@ page { .switch-text { font-size: 24rpx; margin-right: 10rpx; - color: #3d2f25; + color: #ffffff; } .switch-track { width: 56rpx; height: 32rpx; border-radius: 16rpx; - background-color: rgba(61, 47, 37, 0.15); + background-color: rgba(255, 255, 255, 0.35); position: relative; transition: background-color 0.2s ease; } @@ -152,7 +158,7 @@ page { .switch-track.on .switch-thumb { left: 26rpx; - background-color: #ff8f4d; + background-color: #1a8a63; } .stats-row { @@ -170,9 +176,14 @@ page { align-items: flex-end; } +.stat-divider { + width: 2rpx; + background: rgba(255, 255, 255, 0.25); +} + .stat-label { font-size: 24rpx; - color: rgba(61, 47, 37, 0.65); + color: rgba(255, 255, 255, 0.75); } .stat-value { @@ -191,7 +202,7 @@ page { font-size: 44rpx; font-weight: 700; line-height: 1; - color: #f2633f; + color: #ffffff; } /* === 通用 Section === */ @@ -230,16 +241,10 @@ page { .view-all { display: flex; align-items: center; - gap: 6rpx; font-size: 24rpx; color: #a0a3bd; } -.view-all .arrow { - font-size: 28rpx; - color: #a0a3bd; -} - /* === 快捷功能入口 === */ .card { background-color: #ffffff; @@ -255,6 +260,11 @@ page { flex-wrap: wrap; } +.quick-row { + display: flex; + width: 100%; +} + .quick-item { width: 25%; display: flex; @@ -272,7 +282,6 @@ page { .quick-icon { width: 88rpx; height: 88rpx; - background-color: #e6f9f3; border-radius: 26rpx; display: flex; align-items: center; @@ -282,7 +291,7 @@ page { } .quick-label { - font-size: 24rpx; + font-size: 26rpx; color: #3a3f4d; } @@ -338,23 +347,23 @@ page { } .status-pending { - background: #fff8e6; - color: #e6a23c; + background: #fdf3e0; + color: #d99a2b; } .status-confirmed { - background: #ecf5ff; - color: #409eff; + background: #e9f1f8; + color: #5c88a8; } .status-in_progress { - background: #f0f9eb; - color: #67c23a; + background: #e6f4ee; + color: #43a08a; } .status-completed { - background: #f4f0ff; - color: #7c5cfc; + background: #efedf6; + color: #8a7bb5; } .status-cancelled { @@ -370,7 +379,7 @@ page { } .order-hospital { - font-size: 24rpx; + font-size: 26rpx; color: #888888; flex: 1; overflow: hidden; @@ -380,7 +389,7 @@ page { } .order-time { - font-size: 24rpx; + font-size: 26rpx; color: #a0a3bd; flex-shrink: 0; } @@ -390,13 +399,15 @@ page { background: #ffffff; border-radius: 24rpx; border: 1rpx solid rgba(31, 61, 56, 0.06); - padding: 80rpx 0; - text-align: center; + padding: 64rpx 0; + display: flex; + flex-direction: column; + align-items: center; box-shadow: 0 6rpx 20rpx rgba(31, 61, 56, 0.07); } .empty-text { - font-size: 28rpx; + margin-top: 16rpx; + font-size: 26rpx; color: #c0c3d4; - font-weight: 400; } diff --git a/pages/order/orderDetail.js b/pages/order/orderDetail.js index 412cb6c..c685e9b 100644 --- a/pages/order/orderDetail.js +++ b/pages/order/orderDetail.js @@ -133,8 +133,8 @@ Page({ paymentStatusText: PAYMENT_STATUS_MAP[payment.status] || payment.status || '未支付', attendantSexText: attendant.sex === 'male' ? '男' : attendant.sex === 'female' ? '女' : '', sexRequirementText: escort.sexRequirement === 'male' ? '要求男陪诊' : escort.sexRequirement === 'female' ? '要求女陪诊' : '不限', - // 操作按钮(待确认/已确认状态下可编辑订单信息) - showEditBtn: status === 'pending' || status === 'confirmed', + // 操作按钮(任何状态下均可编辑订单信息) + showEditBtn: true, showConfirmBtn: status === 'pending', showCancelBtn: status === 'pending', showStartBtn: status === 'confirmed', @@ -153,6 +153,17 @@ Page({ wx.makePhoneCall({ phoneNumber: phone }) }, + // 点击患者信息,进入健康档案详情 + onProfileTap() { + if (!this.data.healthProfileId) { + wx.showToast({ title: '该订单未关联健康档案', icon: 'none' }) + return + } + wx.navigateTo({ + url: `/pages/healthprofile/profileInfo?id=${this.data.healthProfileId}` + }) + }, + // 编辑订单 onEdit() { wx.navigateTo({ diff --git a/pages/order/orderDetail.wxml b/pages/order/orderDetail.wxml index c56e91a..113235b 100644 --- a/pages/order/orderDetail.wxml +++ b/pages/order/orderDetail.wxml @@ -24,20 +24,8 @@ use-cache="{{false}}" dial="{{true}}" bind:call="callPhone" + bindtap="onProfileTap" /> - - - 体重 - {{order.patient.weight}}kg - - - 身高 - {{order.patient.height}}cm - - - 身份证号 - {{order.patient.idnumber}} - @@ -133,10 +121,6 @@ 服务费用 ¥{{order.payment.totalFee || 0}} - - 已支付 - ¥{{order.payment.paidFee}} - 支付状态 {{paymentStatusText}} diff --git a/pages/order/orderDetail.wxss b/pages/order/orderDetail.wxss index 039c1e0..db593d5 100644 --- a/pages/order/orderDetail.wxss +++ b/pages/order/orderDetail.wxss @@ -89,17 +89,30 @@ page { } .section-title { - font-size: 32rpx; - font-weight: 700; + position: relative; + font-size: 30rpx; + font-weight: 600; color: #1a1a1a; - margin-bottom: 16rpx; - margin-left: 8rpx; + margin-bottom: 24rpx; + margin-left: 20rpx; letter-spacing: 1rpx; } +.section-title::before { + content: ''; + position: absolute; + left: -20rpx; + top: 50%; + transform: translateY(-50%); + width: 8rpx; + height: 28rpx; + border-radius: 4rpx; + background: linear-gradient(180deg, #2dd36f, #17c3a5); +} + .info-card { background: #ffffff; - border-radius: 24rpx; + border-radius: 8rpx; padding: 28rpx; box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04); } @@ -115,14 +128,14 @@ page { } .info-label { - font-size: 24rpx; + font-size: 28rpx; color: #a0a3bd; width: 140rpx; flex-shrink: 0; } .info-value { - font-size: 26rpx; + font-size: 28rpx; color: #3a3d5c; flex: 1; } @@ -150,12 +163,12 @@ page { } .patient-age { - font-size: 24rpx; + font-size: 26rpx; color: #a0a3bd; } .patient-phone { - font-size: 24rpx; + font-size: 26rpx; color: #a0a3bd; } @@ -208,7 +221,7 @@ page { } .attendant-phone { - font-size: 24rpx; + font-size: 26rpx; color: #a0a3bd; } @@ -222,7 +235,9 @@ page { /* === 备注信息 === */ .note-block { - margin-bottom: 20rpx; + display: flex; + align-items: baseline; + margin-bottom: 16rpx; } .note-block:last-child { @@ -230,18 +245,18 @@ page { } .note-label { - display: block; - font-size: 24rpx; + font-size: 26rpx; color: #a0a3bd; - margin-bottom: 8rpx; + width: 140rpx; + flex-shrink: 0; font-weight: 500; } .note-content { - display: block; font-size: 26rpx; color: #3a3d5c; line-height: 1.6; + flex: 1; } /* === 底部操作 === */ diff --git a/pages/set/index.js b/pages/set/index.js index 08987c6..fcb4d63 100644 --- a/pages/set/index.js +++ b/pages/set/index.js @@ -3,8 +3,9 @@ const API = require('../../utils/api.js') Page({ data: { isLoggedIn: false, - userInfo: null, - phoneNumber: '', + displayName: '', + avatar: '', + levelText: '初级陪诊员', version: '1.0.0', showLoginPopup: false, loginForm: { @@ -12,7 +13,7 @@ Page({ mobile: '' }, menuList: [ - { icon: 'user', title: '个人资料', url: '' }, + { icon: 'user', title: '个人资料', url: '/pages/me/index' }, { icon: 'notification', title: '消息通知', url: '' }, { icon: 'lock-on', title: '账号安全', url: '' }, { icon: 'help-circle', title: '帮助中心', url: '' }, @@ -38,28 +39,34 @@ Page({ }, onUserLogin(user) { - this.setData({ - isLoggedIn: true, - userInfo: user, - phoneNumber: this.maskPhoneNumber(user.mobile || '') - }) + this.applyUser(user) }, checkLoginStatus() { const app = getApp() - const user = app.globalData.user - if (user && user.security && user.security.token) { - this.setData({ - isLoggedIn: true, - userInfo: user, - phoneNumber: this.maskPhoneNumber(user.mobile || '') - }) - } + this.applyUser(app.globalData.user) }, - maskPhoneNumber(phone) { - if (!phone || phone.length < 7) return phone - return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2') + /** + * 将用户对象映射为页面展示字段(真实信息) + */ + applyUser(user) { + if (!user || !user.security || !user.security.token) { + this.setData({ + isLoggedIn: false, + displayName: '', + avatar: '', + levelText: '初级陪诊员' + }) + return + } + const p = user.profile || {} + this.setData({ + isLoggedIn: true, + displayName: p.name || '管理员', + avatar: p.avatar || '', + levelText: user.level || p.level || '初级陪诊员' + }) }, getAppVersion() { @@ -112,14 +119,12 @@ Page({ if (data.code == 0) { const app = getApp() app.globalData.user = data.data.user + this.applyUser(app.globalData.user) this.setData({ - isLoggedIn: true, - userInfo: app.globalData.user, - phoneNumber: this.maskPhoneNumber(app.globalData.user.profile.mobile || ''), showLoginPopup: false, loginForm: { name: '', mobile: '' } }) - + wx.showToast({ title: '登录成功', icon: 'success' }) } else { wx.showToast({ title: '登录失败', icon: 'none' }) @@ -159,7 +164,7 @@ Page({ wx.showModal({ title: '退出登录', content: '确定要退出登录吗?', - confirmColor: '#4c6ef5', + confirmColor: '#1a8a63', success: (res) => { if (res.confirm) { wx.showLoading({ title: '退出中...' }) @@ -183,11 +188,7 @@ Page({ wx.removeStorageSync('admin_ai_session_id') wx.removeStorageSync('admin_ai_chat_history') - this.setData({ - isLoggedIn: false, - userInfo: null, - phoneNumber: '' - }) + this.applyUser(null) wx.showToast({ title: '已退出登录', icon: 'success' }) }, @@ -200,18 +201,14 @@ Page({ wx.showModal({ title: '清除缓存', content: '确定要清除所有缓存数据吗?', - confirmColor: '#4c6ef5', + confirmColor: '#1a8a63', success: (res) => { if (res.confirm) { wx.clearStorage({ success: () => { const app = getApp() app.globalData.user = null - this.setData({ - isLoggedIn: false, - userInfo: null, - phoneNumber: '' - }) + this.applyUser(null) wx.showToast({ title: '缓存已清除', icon: 'success' }) } }) diff --git a/pages/set/index.wxml b/pages/set/index.wxml index 0fcf01c..e675445 100644 --- a/pages/set/index.wxml +++ b/pages/set/index.wxml @@ -1,21 +1,23 @@ - +