This commit is contained in:
lik
2026-09-03 11:35:21 +08:00
parent f8f7afceb8
commit b4c8bf0add
45 changed files with 2989 additions and 426 deletions
+102 -28
View File
@@ -4,16 +4,39 @@ const API = require('../../utils/api.js')
Page({
data: {
today: '',
todayCount: 0,
pendingCount: 0,
completedCount: 0,
menuList: [
{ icon: '/images/icon_order.png', name: '订单管理', url: '/pages/order/index' },
{ icon: '/images/icon_patient.png', name: '患者管理', url: '/pages/patient/index' },
{ icon: '/images/icon_escort.png', name: '陪诊员管理', url: '/pages/escort/index' },
{ icon: '/images/icon_schedule.png', name: '排班管理', url: '/pages/schedule/index' }
recentOrders: [],
// 快捷入口:前3个为快捷操作(橙色系),后4个为功能入口(绿色系)
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' }
],
todayOrders: [],
online: true,
profile: {
name: '王姐陪诊师',
level: '初级陪诊师',
avatar: ''
},
todayIncome: 168,
todayOrderCount: 0,
pendingOrder: {
count: 1,
hospital: '中医院',
time: '10:00',
price: 88
},
ongoingOrder: {
count: 1,
hospital: '康复医院',
time: '15:30',
price: 128
},
statusMap: {
pending: '待确认',
confirmed: '已确认',
@@ -37,56 +60,107 @@ Page({
},
onLoad(options) {
this.loadUser()
const now = new Date();
const today = now.toISOString().substring(0, 10);
this.setData({ today });
this.getTodayOrders();
this.getRecentOrders();
this.getStats();
},
onShow() {
this.getTodayOrders();
this.loadUser()
this.getRecentOrders();
this.getStats();
},
loadUser() {
const app = getApp()
const user = app.globalData && app.globalData.user
if (user) {
this.setData({
'profile.name': user.nickname || this.data.profile.name,
'profile.level': user.level || this.data.profile.level,
'profile.avatar': user.avatar || ''
})
}
},
toggleOnline() {
this.setData({
online: !this.data.online
})
},
onOrderCardTap(e) {
const { type } = e.currentTarget.dataset
const title = type === 'pending' ? '待接单' : '进行中'
wx.showToast({
title: `${title} 订单列表`,
icon: 'none'
})
},
async getStats() {
const today = new Date().toISOString().substring(0, 10);
const [todayRes, pendingRes, completedRes] = await Promise.all([
API.escort.getMyRecords({ appointmentDate: today }),
API.escort.getMyRecords({ status: ['pending', 'confirmed'] }),
API.escort.getMyRecords({ status: ['completed'] })
API.escort.getAllRecords({ appointmentDate: today }),
API.escort.getAllRecords({ status: 'pending,confirmed' }),
API.escort.getAllRecords({ status: 'completed' })
]);
this.setData({
todayCount: todayRes.code === 0 ? (todayRes.data.records || []).length : 0,
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,
});
},
async getTodayOrders() {
const res = await API.escort.getMyRecords({
appointmentDate: new Date().toISOString().substring(0, 10),
});
if (res.code == 0) {
const records = (res.data.records || []).map(item => {
if (item.schedule && item.schedule.date) {
const d = new Date(item.schedule.date);
item.schedule.date = d.toISOString().substring(0, 10) + ' ' + d.toTimeString().substring(0, 5);
}
/**
* 加载近7日订单(含6天前至今及未来订单,按预约时间倒序,最多10条)
*/
async getRecentOrders() {
const res = await API.escort.getAllRecords({ page: 1, pageSize: 50 });
if (res.code !== 0) return;
const start = new Date();
start.setDate(start.getDate() - 6);
start.setHours(0, 0, 0, 0);
const pad = (n) => String(n).padStart(2, '0');
const records = (res.data.records || [])
.filter(item => item.schedule && item.schedule.date && new Date(item.schedule.date) >= start)
.slice(0, 10)
.map(item => {
const d = new Date(item.schedule.date);
item.schedule.date = `${d.getMonth() + 1}${d.getDate()}${pad(d.getHours())}:${pad(d.getMinutes())}`;
return item;
});
this.setData({ todayOrders: records });
}
this.setData({ recentOrders: records });
},
navigateTo(e) {
const url = e.currentTarget.dataset.url
wx.navigateTo({ url })
onEntryTap(e) {
const { index } = e.currentTarget.dataset
const item = this.data.quickEntries[index]
if (item.isTab) {
wx.switchTab({ url: item.url })
} else {
wx.navigateTo({ url: item.url })
}
},
viewAllOrders() {
wx.navigateTo({
url: '/pages/order/index'
})
},
/**
* 点击近7日订单卡片,进入订单详情
*/
onOrderTap(e) {
const id = e.currentTarget.dataset.id
if (!id) return
wx.navigateTo({
url: `/pages/order/orderDetail?id=${id}`
})
}
})
+4 -1
View File
@@ -1,4 +1,7 @@
{
"navigationBarTitleText": "暖橙陪诊",
"usingComponents": {}
"usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon",
"order-stats": "../../components/order-stats/index"
}
}
+68 -72
View File
@@ -1,97 +1,93 @@
<!--pages/home/index.wxml-->
<view class="page">
<!-- 顶部问候 -->
<view class="header">
<view class="greeting">
<text class="greeting-text">您好,管理员</text>
<text class="greeting-sub">今天是 {{today}}</text>
</view>
</view>
<!-- 数据统计 -->
<view class="stats-container">
<view class="stats-grid">
<view class="stat-card">
<view class="stat-value">{{todayCount}}</view>
<view class="stat-label">新增用户</view>
</view>
<view class="stat-card">
<view class="stat-value">{{todayCount}}</view>
<view class="stat-label">新增预约</view>
</view>
<view class="stat-card">
<view class="stat-value">{{pendingCount}}</view>
<view class="stat-label">待处理</view>
</view>
<view class="stat-card">
<view class="stat-value">{{completedCount}}</view>
<view class="stat-label">已完成</view>
</view>
</view>
</view>
<!-- 功能入口 -->
<view class="section">
<view class="section-header">
<text class="section-title">快捷入口</text>
</view>
<view class="menu-grid">
<view class="menu-card" wx:for="{{menuList}}" wx:key="index" bindtap="navigateTo" data-url="{{item.url}}">
<view class="menu-icon-wrap">
<text class="menu-icon-text">{{item.name[0]}}</text>
<!-- 头部信息卡 -->
<view class="header-card">
<view class="profile-row">
<view class="profile-left">
<view class="avatar">
<image wx:if="{{profile.avatar}}" class="avatar-img" src="{{profile.avatar}}" mode="aspectFill" />
<text wx:else class="avatar-text">{{profile.name[0]}}</text>
</view>
<view class="profile-info">
<view class="name-row">
<text class="name">{{profile.name}}</text>
<view class="level-tag">
<text class="level-text">{{profile.level}}</text>
</view>
</view>
</view>
</view>
<view class="online-switch" bindtap="toggleOnline">
<text class="switch-text">{{online ? '接单中' : '休息中'}}</text>
<view class="switch-track {{online ? 'on' : 'off'}}">
<view class="switch-thumb"></view>
</view>
</view>
</view>
<view class="stats-row">
<view class="stat">
<text class="stat-label">今日收益</text>
<view class="stat-value">
<text class="stat-unit">¥</text>
<text class="stat-num">{{todayIncome}}</text>
</view>
</view>
<view class="stat stat-right">
<text class="stat-label">今日接单</text>
<view class="stat-value">
<text class="stat-num">{{todayOrderCount}}</text>
<text class="stat-unit">单</text>
</view>
<text class="menu-name">{{item.name}}</text>
</view>
</view>
</view>
<!-- 今日订单 -->
<!-- 快捷入口 -->
<view class="section">
<text class="section-title">快捷入口</text>
<view class="quick-grid card">
<view class="quick-item" wx:for="{{quickEntries}}" wx:key="name" 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>
<!-- 订单统计 -->
<order-stats />
<!-- 近7日订单 -->
<view class="section">
<view class="section-header">
<text class="section-title">日订单</text>
<text class="section-title">近7日订单</text>
<view class="view-all" bindtap="viewAllOrders">
<text>全部</text>
<text class="arrow">→</text>
</view>
</view>
<view class="order-list" wx:if="{{todayOrders.length > 0}}">
<view class="order-card" wx:for="{{todayOrders}}" wx:key="_id">
<view class="order-top">
<text class="order-no">#{{item._id}}</text>
<view class="order-list" wx:if="{{recentOrders.length > 0}}">
<view class="order-card" wx:for="{{recentOrders}}" wx:key="_id" data-id="{{item._id}}" bindtap="onOrderTap">
<view class="order-line1">
<text class="order-patient">{{item.patient.name}}</text>
<text class="order-service">{{item.escort.serviceName}}</text>
<view class="status-tag status-{{item.status}}">
<text>{{statusMap[item.status] || item.status}}</text>
</view>
</view>
<view class="order-body">
<view class="order-row">
<text class="row-label">患者</text>
<text class="row-value">{{item.patient.name}}</text>
</view>
<view class="order-row">
<text class="row-label">医院</text>
<text class="row-value">{{item.hospital.name}} · {{item.hospital.department}}</text>
</view>
<view class="order-row">
<text class="row-label">时间</text>
<text class="row-value">{{item.schedule.date}}</text>
</view>
<view class="order-row">
<text class="row-label">服务</text>
<text class="row-value">{{item.escort.serviceName}}</text>
</view>
</view>
<view class="order-footer">
<text class="fee-label">服务费用</text>
<text class="fee-value">¥{{item.payment.totalFee}}</text>
<view class="order-line2">
<text class="order-hospital">{{item.hospital.name}} · {{item.hospital.department}}</text>
<text class="order-time">{{item.schedule.date}}</text>
</view>
</view>
</view>
<view class="empty-state" wx:else>
<text class="empty-text">暂无日订单</text>
<text class="empty-text">暂无近7日订单</text>
</view>
</view>
</view>
+264 -158
View File
@@ -1,120 +1,226 @@
/* pages/home/index.wxss */
page {
background: linear-gradient(180deg, #e8f8f2 0%, #f5f6fa 360rpx);
color: #1a1a2e;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.page {
min-height: 100vh;
background: #f7f8fc;
padding-bottom: 40rpx;
box-sizing: border-box;
padding: 24rpx 24rpx 64rpx;
}
/* === 顶部问候 === */
.header {
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
padding: 60rpx 40rpx 80rpx;
/* === 头部信息卡 === */
.header-card {
position: relative;
overflow: hidden;
}
.header::after {
content: '';
position: absolute;
top: -60rpx;
right: -40rpx;
width: 280rpx;
height: 280rpx;
border-radius: 50%;
background: rgba(255, 255, 255, 0.03);
}
.header::before {
content: '';
position: absolute;
bottom: -100rpx;
right: 80rpx;
width: 200rpx;
height: 200rpx;
border-radius: 50%;
background: rgba(255, 255, 255, 0.02);
}
.greeting {
position: relative;
z-index: 1;
}
.greeting-text {
display: block;
font-size: 44rpx;
font-weight: 700;
background: linear-gradient(135deg, #2dd36f, #17c3a5);
border-radius: 28rpx;
padding: 36rpx 32rpx;
color: #ffffff;
letter-spacing: 2rpx;
margin-bottom: 12rpx;
box-shadow: 0 12rpx 32rpx rgba(23, 195, 165, 0.28);
}
.greeting-sub {
display: block;
font-size: 26rpx;
color: rgba(255, 255, 255, 0.5);
font-weight: 300;
letter-spacing: 1rpx;
/* 装饰光斑,增加层次 */
.header-card::before,
.header-card::after {
content: '';
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, 0.12);
pointer-events: none;
}
/* === 数据统计 === */
.stats-container {
margin: -40rpx 30rpx 0;
.header-card::before {
width: 260rpx;
height: 260rpx;
top: -120rpx;
right: -60rpx;
}
.header-card::after {
width: 160rpx;
height: 160rpx;
bottom: -80rpx;
left: -40rpx;
background: rgba(255, 255, 255, 0.08);
}
.profile-row {
position: relative;
z-index: 2;
}
.stats-grid {
display: flex;
gap: 16rpx;
justify-content: space-between;
align-items: center;
}
.stat-card {
flex: 1;
background: #ffffff;
border-radius: 20rpx;
padding: 28rpx 16rpx;
text-align: center;
box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.06);
transition: transform 0.2s;
.profile-left {
display: flex;
align-items: center;
}
.stat-value {
display: block;
font-size: 48rpx;
.avatar {
width: 96rpx;
height: 96rpx;
border-radius: 50%;
background-color: rgba(255, 255, 255, 0.25);
border: 2rpx solid rgba(255, 255, 255, 0.4);
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
flex-shrink: 0;
}
.avatar-img {
width: 100%;
height: 100%;
}
.avatar-text {
font-size: 40rpx;
font-weight: 600;
color: #ffffff;
}
.profile-info {
margin-left: 20rpx;
}
.name-row {
display: flex;
align-items: center;
}
.name {
font-size: 36rpx;
font-weight: 700;
color: #1a1a2e;
line-height: 1.2;
margin-bottom: 8rpx;
font-family: 'DIN Alternate', 'Helvetica Neue', sans-serif;
}
.level-tag {
margin-left: 12rpx;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 16rpx;
padding: 4rpx 14rpx;
}
.level-text {
font-size: 20rpx;
color: #ffffff;
}
.online-switch {
display: flex;
align-items: center;
background-color: rgba(255, 255, 255, 0.25);
border-radius: 28rpx;
padding: 6rpx 6rpx 6rpx 18rpx;
}
.switch-text {
font-size: 24rpx;
margin-right: 10rpx;
}
.switch-track {
width: 56rpx;
height: 32rpx;
border-radius: 16rpx;
background-color: rgba(0, 0, 0, 0.15);
position: relative;
transition: background-color 0.2s ease;
}
.switch-track.on {
background-color: #ffffff;
}
.switch-thumb {
width: 28rpx;
height: 28rpx;
border-radius: 50%;
background-color: #ffffff;
position: absolute;
top: 2rpx;
left: 2rpx;
transition: left 0.2s ease, background-color 0.2s ease;
}
.switch-track.on .switch-thumb {
left: 26rpx;
background-color: #17c3a5;
}
.stats-row {
display: flex;
justify-content: space-between;
margin-top: 36rpx;
}
.stat {
display: flex;
flex-direction: column;
}
.stat-right {
align-items: flex-end;
}
.stat-label {
display: block;
font-size: 22rpx;
color: #a0a3bd;
font-weight: 400;
letter-spacing: 1rpx;
font-size: 24rpx;
opacity: 0.9;
}
.stat-value {
display: flex;
align-items: baseline;
margin-top: 8rpx;
font-weight: 600;
}
.stat-unit {
font-size: 26rpx;
margin-right: 4rpx;
}
.stat-num {
font-size: 44rpx;
font-weight: 700;
line-height: 1;
}
/* === 通用 Section === */
.section {
margin: 32rpx 30rpx 0;
margin-top: 44rpx;
}
.section-title {
position: relative;
font-size: 30rpx;
font-weight: 600;
color: #1a1a1a;
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);
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
}
.section-title {
font-size: 32rpx;
font-weight: 700;
color: #1a1a2e;
letter-spacing: 1rpx;
margin-bottom: 16rpx;
}
.view-all {
@@ -130,44 +236,50 @@
color: #a0a3bd;
}
/* === 功能菜单 === */
.menu-grid {
display: flex;
gap: 16rpx;
/* === 快捷功能入口 === */
.card {
background-color: #ffffff;
border-radius: 24rpx;
border: 1rpx solid rgba(31, 61, 56, 0.06);
box-shadow: 0 6rpx 20rpx rgba(31, 61, 56, 0.07);
}
.menu-card {
flex: 1;
background: #ffffff;
border-radius: 20rpx;
padding: 32rpx 0;
.quick-grid {
margin-top: 16rpx;
padding: 32rpx 8rpx 8rpx;
display: flex;
flex-wrap: wrap;
}
.quick-item {
width: 25%;
display: flex;
flex-direction: column;
align-items: center;
gap: 16rpx;
box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.04);
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);
}
.menu-icon-wrap {
width: 80rpx;
height: 80rpx;
border-radius: 20rpx;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
.quick-item:active {
opacity: 0.85;
transform: scale(0.92);
}
.quick-icon {
width: 88rpx;
height: 88rpx;
background-color: #e6f9f3;
border-radius: 26rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 14rpx;
box-shadow: inset 0 2rpx 4rpx rgba(255, 255, 255, 0.8), 0 4rpx 10rpx rgba(31, 61, 56, 0.06);
}
.menu-icon-text {
font-size: 32rpx;
font-weight: 700;
color: #ffffff;
}
.menu-name {
.quick-label {
font-size: 24rpx;
color: #5a5d7a;
font-weight: 500;
color: #3a3f4d;
}
/* === 订单列表 === */
@@ -179,24 +291,38 @@
.order-card {
background: #ffffff;
border-radius: 20rpx;
border-radius: 24rpx;
border: 1rpx solid rgba(31, 61, 56, 0.06);
padding: 28rpx 32rpx;
box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.04);
box-shadow: 0 6rpx 20rpx rgba(31, 61, 56, 0.07);
transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), box-shadow 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.order-top {
.order-card:active {
transform: scale(0.98);
box-shadow: 0 4rpx 12rpx rgba(31, 61, 56, 0.08);
}
.order-line1 {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f0f1f5;
}
.order-no {
font-size: 24rpx;
color: #a0a3bd;
.order-patient {
font-size: 30rpx;
font-weight: 600;
color: #1a1a1a;
margin-right: 16rpx;
}
.order-service {
font-size: 26rpx;
font-weight: 500;
font-family: 'DIN Alternate', 'Helvetica Neue', monospace;
color: #1abc9c;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.status-tag {
@@ -204,6 +330,7 @@
padding: 6rpx 20rpx;
border-radius: 30rpx;
font-weight: 500;
flex-shrink: 0;
}
.status-pending {
@@ -231,58 +358,37 @@
color: #b0b0b0;
}
.order-body {
padding: 20rpx 0;
.order-line2 {
display: flex;
flex-direction: column;
gap: 14rpx;
}
.order-row {
display: flex;
align-items: baseline;
}
.row-label {
font-size: 24rpx;
color: #a0a3bd;
width: 72rpx;
flex-shrink: 0;
}
.row-value {
font-size: 26rpx;
color: #3a3d5c;
flex: 1;
}
.order-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 20rpx;
border-top: 1rpx solid #f0f1f5;
justify-content: space-between;
margin-top: 12rpx;
}
.fee-label {
.order-hospital {
font-size: 24rpx;
color: #888888;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 16rpx;
}
.order-time {
font-size: 24rpx;
color: #a0a3bd;
}
.fee-value {
font-size: 34rpx;
font-weight: 700;
color: #1a1a2e;
font-family: 'DIN Alternate', 'Helvetica Neue', sans-serif;
flex-shrink: 0;
}
/* === 空状态 === */
.empty-state {
background: #ffffff;
border-radius: 20rpx;
border-radius: 24rpx;
border: 1rpx solid rgba(31, 61, 56, 0.06);
padding: 80rpx 0;
text-align: center;
box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.04);
box-shadow: 0 6rpx 20rpx rgba(31, 61, 56, 0.07);
}
.empty-text {