This commit is contained in:
lik
2026-06-08 12:01:40 +08:00
parent 010cf160a0
commit 894a9881d7
51 changed files with 2667 additions and 740 deletions

View File

@@ -1,4 +1,5 @@
// pages/order/index.js
const API = require('../../utils/api.js')
// 状态映射配置
const STATUS_MAP = {
@@ -19,322 +20,6 @@ const STATUS_FILTERS = [
{ label: '已取消', value: 'cancelled', count: 0 }
];
// Mock 数据 - 基于 escort_record.js 的数据结构
const MOCK_ORDERS = [
{
_id: 'ORD20240530001',
orderNo: '20240530001',
userId: 'user001',
patient: {
name: '张三',
mobile: '138****1234',
sex: 'male',
age: 65,
idnumber: '310***********1234'
},
escort: {
serviceId: 1,
serviceName: '全程陪诊服务'
},
hospital: {
province: '上海',
name: '复旦大学附属中山医院',
address: '上海市徐汇区枫林路180号',
department: '心内科',
doctor: '李医生',
medicalRecordNo: 'MR202405001'
},
schedule: {
date: '2024-06-01T09:00:00.000Z',
dateText: '06月01日',
startTime: '09:00',
endTime: '12:00',
duration: 180
},
attendant: {
id: 'att001',
name: '王陪诊',
sex: 'female'
},
payment: {
totalFee: 298,
paidFee: 298,
status: 'paid'
},
notes: {
patientNote: '患者行动不便,需要轮椅',
escortNote: '',
medicalSummary: ''
},
status: 'pending',
statusText: '待确认',
meta: {
createtime: '2024-05-30T10:00:00.000Z',
updatetime: '2024-05-30T10:00:00.000Z'
}
},
{
_id: 'ORD20240529002',
orderNo: '20240529002',
userId: 'user002',
patient: {
name: '李四',
mobile: '139****5678',
sex: 'female',
age: 42,
idnumber: '310***********5678'
},
escort: {
serviceId: 2,
serviceName: '挂号陪诊服务'
},
hospital: {
province: '上海',
name: '上海交通大学医学院附属瑞金医院',
address: '上海市黄浦区瑞金二路197号',
department: '内分泌科',
doctor: '张医生',
medicalRecordNo: 'MR202405002'
},
schedule: {
date: '2024-05-31T14:00:00.000Z',
dateText: '05月31日',
startTime: '14:00',
endTime: '16:00',
duration: 120
},
attendant: {
id: 'att002',
name: '赵陪诊',
sex: 'male'
},
payment: {
totalFee: 198,
paidFee: 198,
status: 'paid'
},
notes: {
patientNote: '需要帮忙取药',
escortNote: '',
medicalSummary: ''
},
status: 'confirmed',
statusText: '已确认',
meta: {
createtime: '2024-05-29T08:30:00.000Z',
updatetime: '2024-05-29T15:00:00.000Z'
}
},
{
_id: 'ORD20240528003',
orderNo: '20240528003',
userId: 'user003',
patient: {
name: '王五',
mobile: '137****9012',
sex: 'male',
age: 78,
idnumber: '310***********9012'
},
escort: {
serviceId: 1,
serviceName: '全程陪诊服务'
},
hospital: {
province: '上海',
name: '上海市第六人民医院',
address: '上海市徐汇区宜山路600号',
department: '骨科',
doctor: '刘医生',
medicalRecordNo: 'MR202405003'
},
schedule: {
date: '2024-05-30T08:30:00.000Z',
dateText: '05月30日',
startTime: '08:30',
endTime: '11:30',
duration: 180
},
attendant: {
id: 'att003',
name: '陈陪诊',
sex: 'female'
},
payment: {
totalFee: 398,
paidFee: 200,
status: 'partial'
},
notes: {
patientNote: '听力不好,请大声说话',
escortNote: '已接到患者,正在前往医院',
medicalSummary: ''
},
status: 'in_progress',
statusText: '进行中',
meta: {
createtime: '2024-05-28T16:00:00.000Z',
updatetime: '2024-05-30T08:35:00.000Z'
}
},
{
_id: 'ORD20240525004',
orderNo: '20240525004',
userId: 'user004',
patient: {
name: '赵六',
mobile: '136****3456',
sex: 'female',
age: 55,
idnumber: '310***********3456'
},
escort: {
serviceId: 3,
serviceName: '检查陪诊服务'
},
hospital: {
province: '上海',
name: '华东医院',
address: '上海市静安区延安西路221号',
department: '体检中心',
doctor: '',
medicalRecordNo: 'MR202405004'
},
schedule: {
date: '2024-05-28T07:30:00.000Z',
dateText: '05月28日',
startTime: '07:30',
endTime: '11:00',
duration: 210
},
attendant: {
id: 'att004',
name: '孙陪诊',
sex: 'male'
},
payment: {
totalFee: 258,
paidFee: 258,
status: 'paid'
},
notes: {
patientNote: '需要空腹检查',
escortNote: '服务完成,患者已安全送回家',
medicalSummary: '完成全身检查,各项指标正常'
},
status: 'completed',
statusText: '已完成',
meta: {
createtime: '2024-05-25T09:00:00.000Z',
updatetime: '2024-05-28T11:30:00.000Z'
}
},
{
_id: 'ORD20240524005',
orderNo: '20240524005',
userId: 'user005',
patient: {
name: '钱七',
mobile: '135****7890',
sex: 'male',
age: 33,
idnumber: '310***********7890'
},
escort: {
serviceId: 2,
serviceName: '挂号陪诊服务'
},
hospital: {
province: '上海',
name: '上海市第一人民医院',
address: '上海市虹口区武进路85号',
department: '眼科',
doctor: '周医生',
medicalRecordNo: 'MR202405005'
},
schedule: {
date: '2024-05-27T10:00:00.000Z',
dateText: '05月27日',
startTime: '10:00',
endTime: '11:00',
duration: 60
},
attendant: {
id: '',
name: '',
sex: 'none'
},
payment: {
totalFee: 128,
paidFee: 0,
status: 'unpaid'
},
notes: {
patientNote: '临时有事,需要取消',
escortNote: '',
medicalSummary: ''
},
status: 'cancelled',
statusText: '已取消',
meta: {
createtime: '2024-05-24T14:00:00.000Z',
updatetime: '2024-05-26T09:00:00.000Z'
}
},
{
_id: 'ORD20240523006',
orderNo: '20240523006',
userId: 'user006',
patient: {
name: '孙八',
mobile: '134****2468',
sex: 'female',
age: 60,
idnumber: '310***********2468'
},
escort: {
serviceId: 1,
serviceName: '全程陪诊服务'
},
hospital: {
province: '上海',
name: '上海中医药大学附属龙华医院',
address: '上海市徐汇区宛平南路725号',
department: '中医内科',
doctor: '吴医生',
medicalRecordNo: 'MR202405006'
},
schedule: {
date: '2024-06-02T08:00:00.000Z',
dateText: '06月02日',
startTime: '08:00',
endTime: '11:00',
duration: 180
},
attendant: {
id: 'att005',
name: '周陪诊',
sex: 'female'
},
payment: {
totalFee: 328,
paidFee: 328,
status: 'paid'
},
notes: {
patientNote: ' prefer 女陪诊员',
escortNote: '',
medicalSummary: ''
},
status: 'pending',
statusText: '待确认',
meta: {
createtime: '2024-05-23T11:00:00.000Z',
updatetime: '2024-05-23T11:00:00.000Z'
}
}
];
Page({
/**
@@ -376,7 +61,6 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
// 页面显示时刷新数据
if (this.data.orderList.length > 0) {
this.refreshData();
}
@@ -468,7 +152,10 @@ Page({
return orders.map(order => ({
...order,
statusText: STATUS_MAP[order.status]?.text || order.status,
'schedule.dateText': this.formatDate(order.schedule.date)
schedule: {
...order.schedule,
dateText: this.formatDate(order.schedule?.date)
}
}));
},
@@ -482,40 +169,53 @@ Page({
this.setData({ isLoading: !isRefresh, isLoadingMore: isRefresh && page > 1 });
// 模拟 API 请求延迟
setTimeout(() => {
// 筛选数据
let filteredOrders = MOCK_ORDERS;
if (currentStatus) {
filteredOrders = MOCK_ORDERS.filter(order => order.status === currentStatus);
}
const params = {
page,
pageSize,
status: 'pending,confirmed,in_progress,completed,cancelled'
};
// 分页
const start = (page - 1) * pageSize;
const end = start + pageSize;
const pageData = filteredOrders.slice(start, end);
API.escort.getMyRecords(params)
.then(res => {
if (res.code !== 0) {
wx.showToast({ title: res.message || '获取订单失败', icon: 'none' });
this.setData({ isLoading: false, isLoadingMore: false, isRefreshing: false });
return;
}
// 处理数据
const processedOrders = this.processOrders(pageData);
const data = res.data || {};
const list = data.records || [];
let total = list.length || 0;
// 计算统计
const stats = this.calculateStats(MOCK_ORDERS);
this.updateFilterCounts(stats);
const processedOrders = this.processOrders(list);
// 更新列表
const orderList = isRefresh && page > 1
? [...this.data.orderList, ...processedOrders]
: processedOrders;
const allOrders = isRefresh && page > 1
? [...this.data.orderList, ...processedOrders]
: processedOrders;
this.setData({
orderList,
stats,
isLoading: false,
isLoadingMore: false,
isRefreshing: false,
hasMore: end < filteredOrders.length
const stats = this.calculateStats(allOrders);
this.updateFilterCounts(stats);
const { currentStatus } = this.data;
const orderList = currentStatus
? allOrders.filter(order => order.status === currentStatus)
: allOrders;
total = orderList.length;
this.setData({
orderList,
stats,
isLoading: false,
isLoadingMore: false,
isRefreshing: false,
hasMore: orderList.length < total
});
})
.catch(err => {
console.error('获取订单列表失败', err);
wx.showToast({ title: '网络错误,请重试', icon: 'none' });
this.setData({ isLoading: false, isLoadingMore: false, isRefreshing: false });
});
}, 600);
},
/**
@@ -562,9 +262,6 @@ Page({
const order = this.data.orderList.find(item => item._id === id);
if (!order) return;
// 阻止冒泡,防止触发卡片点击
e.stopPropagation();
const actionMap = {
confirm: { title: '确认订单', content: '确认接受此订单?', nextStatus: 'confirmed' },
cancel: { title: '取消订单', content: '确定要取消此订单?', nextStatus: 'cancelled' },
@@ -589,7 +286,6 @@ Page({
confirmColor: '#4c6ef5',
success: (res) => {
if (res.confirm) {
// 更新订单状态
this.updateOrderStatus(id, actionConfig.nextStatus);
}
}
@@ -602,34 +298,38 @@ Page({
updateOrderStatus(id, newStatus) {
wx.showLoading({ title: '处理中...' });
// 模拟 API 请求
setTimeout(() => {
const orderList = this.data.orderList.map(order => {
if (order._id === id) {
return {
...order,
status: newStatus,
statusText: STATUS_MAP[newStatus]?.text || newStatus,
'meta.updatetime': new Date().toISOString()
};
API.escort.updateStatus(id, { status: newStatus })
.then(res => {
if (res.code !== 0) {
wx.showToast({ title: res.message || '操作失败', icon: 'none' });
wx.hideLoading();
return;
}
return order;
});
// 重新计算统计
const allOrders = MOCK_ORDERS.map(order => {
if (order._id === id) {
return { ...order, status: newStatus };
}
return order;
});
const stats = this.calculateStats(allOrders);
this.updateFilterCounts(stats);
const orderList = this.data.orderList.map(order => {
if (order._id === id) {
return {
...order,
status: newStatus,
statusText: STATUS_MAP[newStatus]?.text || newStatus,
'meta.updatetime': new Date().toISOString()
};
}
return order;
});
this.setData({ orderList, stats });
wx.hideLoading();
wx.showToast({ title: '操作成功', icon: 'success' });
}, 500);
const stats = this.calculateStats(orderList);
this.updateFilterCounts(stats);
this.setData({ orderList, stats });
wx.hideLoading();
wx.showToast({ title: '操作成功', icon: 'success' });
})
.catch(err => {
console.error('更新订单状态失败', err);
wx.showToast({ title: '网络错误,请重试', icon: 'none' });
wx.hideLoading();
});
},
/**

View File

@@ -1,8 +1,8 @@
{
"navigationBarTitleText": "订单管理",
"navigationBarBackgroundColor": "#1a1f3c",
"navigationBarTextStyle": "white",
"backgroundColor": "#0f1535",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"backgroundColor": "#ffffff",
"usingComponents": {
"t-tabs": "tdesign-miniprogram/tabs/tabs",
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",

View File

@@ -1,24 +1,23 @@
/* pages/order/index.less */
// 颜色变量
@bg-primary: #0f1535;
@bg-secondary: #1a1f3c;
@bg-card: #1e2548;
@bg-card-hover: #252d5a;
// 颜色变量 - 参考图浅色社交风格
@bg-primary: #f5f6fa;
@bg-secondary: #ffffff;
@bg-card: #ffffff;
@accent-primary: #4c6ef5;
@accent-secondary: #6b7aff;
@accent-gradient-start: #4c6ef5;
@accent-gradient-end: #748ffc;
@text-primary: #ffffff;
@text-secondary: #a0a8d0;
@text-muted: #6b7298;
@border-color: #2a3366;
@text-primary: #1a1a2e;
@text-secondary: #6b7280;
@text-muted: #9ca3af;
@border-color: #e5e7eb;
@status-pending: #f59f00;
@status-confirmed: #4c6ef5;
@status-in-progress: #20c997;
@status-completed: #51cf66;
@status-cancelled: #ff6b6b;
@divider-color: #2a3366;
@divider-color: #f3f4f6;
page {
background-color: @bg-primary;
@@ -33,79 +32,11 @@ page {
background-color: @bg-primary;
}
// ========== 顶部统计区域 ==========
.header-section {
position: relative;
padding: 30rpx 30rpx 40rpx;
overflow: hidden;
.header-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(135deg, @accent-gradient-start 0%, @accent-gradient-end 100%);
border-radius: 0 0 40rpx 40rpx;
opacity: 0.15;
}
&::before {
content: '';
position: absolute;
top: -100rpx;
right: -100rpx;
width: 300rpx;
height: 300rpx;
background: radial-gradient(circle, rgba(76, 110, 245, 0.2) 0%, transparent 70%);
border-radius: 50%;
}
}
.stats-container {
position: relative;
display: flex;
align-items: center;
justify-content: space-around;
background: rgba(30, 37, 72, 0.8);
backdrop-filter: blur(20rpx);
border-radius: 24rpx;
padding: 30rpx 20rpx;
border: 1rpx solid rgba(107, 122, 255, 0.1);
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.2);
}
.stat-item {
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
}
.stat-value {
font-size: 40rpx;
font-weight: 700;
color: @text-primary;
line-height: 1.2;
margin-bottom: 8rpx;
}
.stat-label {
font-size: 24rpx;
color: @text-secondary;
line-height: 1.4;
}
.stat-divider {
width: 1rpx;
height: 60rpx;
background: linear-gradient(to bottom, transparent, @divider-color, transparent);
}
// ========== 筛选区域 ==========
.filter-section {
padding: 20rpx 0;
background-color: @bg-primary;
background-color: @bg-secondary;
border-bottom: 1rpx solid @border-color;
}
.filter-scroll {
@@ -114,28 +45,33 @@ page {
.filter-list {
display: inline-flex;
padding: 0 20rpx;
gap: 16rpx;
padding: 0 24rpx;
gap: 20rpx;
}
.filter-item {
display: inline-flex;
align-items: center;
padding: 16rpx 28rpx;
background-color: @bg-card;
padding: 16rpx 32rpx;
background-color: @bg-primary;
border-radius: 32rpx;
border: 1rpx solid transparent;
border: 1rpx solid @border-color;
transition: all 0.3s ease;
&.active {
background: linear-gradient(135deg, @accent-gradient-start, @accent-gradient-end);
border-color: transparent;
box-shadow: 0 4rpx 16rpx rgba(76, 110, 245, 0.3);
box-shadow: 0 4rpx 16rpx rgba(76, 110, 245, 0.25);
.filter-text {
color: @text-primary;
color: #ffffff;
font-weight: 600;
}
.filter-badge {
background-color: #ffffff;
color: @accent-primary;
}
}
}
@@ -156,7 +92,7 @@ page {
background-color: @status-cancelled;
border-radius: 16rpx;
font-size: 20rpx;
color: @text-primary;
color: #ffffff;
font-weight: 600;
}
@@ -168,7 +104,7 @@ page {
.order-scroll {
height: 100%;
padding: 0 20rpx;
padding: 0 24rpx;
}
.loading-container,
@@ -193,7 +129,7 @@ page {
margin-top: 30rpx;
padding: 16rpx 48rpx;
background: linear-gradient(135deg, @accent-gradient-start, @accent-gradient-end);
color: @text-primary;
color: #ffffff;
font-size: 28rpx;
border-radius: 32rpx;
display: inline-block;
@@ -201,7 +137,7 @@ page {
// ========== 订单卡片 ==========
.order-cards {
padding-bottom: 40rpx;
padding: 24rpx 0 40rpx;
}
.order-card {
@@ -209,34 +145,13 @@ page {
background-color: @bg-card;
border-radius: 24rpx;
border: 1rpx solid @border-color;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
overflow: hidden;
transition: transform 0.2s ease, box-shadow 0.2s ease;
&:active {
transform: scale(0.98);
background-color: @bg-card-hover;
}
// 状态左边框
&.pending {
border-left: 4rpx solid @status-pending;
}
&.confirmed {
border-left: 4rpx solid @status-confirmed;
}
&.in_progress {
border-left: 4rpx solid @status-in-progress;
}
&.completed {
border-left: 4rpx solid @status-completed;
}
&.cancelled {
border-left: 4rpx solid @status-cancelled;
opacity: 0.85;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
}
}
@@ -244,7 +159,7 @@ page {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 28rpx 16rpx;
padding: 28rpx 28rpx 20rpx;
}
.order-id {
@@ -256,38 +171,39 @@ page {
.order-id-text {
font-size: 24rpx;
color: @text-muted;
font-weight: 500;
}
.status-tag {
display: inline-flex;
align-items: center;
padding: 6rpx 16rpx;
border-radius: 8rpx;
padding: 8rpx 18rpx;
border-radius: 20rpx;
font-size: 22rpx;
font-weight: 600;
&.pending {
background-color: rgba(245, 159, 0, 0.15);
background-color: rgba(245, 159, 0, 0.1);
color: @status-pending;
}
&.confirmed {
background-color: rgba(76, 110, 245, 0.15);
color: @accent-secondary;
background-color: rgba(76, 110, 245, 0.1);
color: @accent-primary;
}
&.in_progress {
background-color: rgba(32, 201, 151, 0.15);
background-color: rgba(32, 201, 151, 0.1);
color: @status-in-progress;
}
&.completed {
background-color: rgba(81, 207, 102, 0.15);
background-color: rgba(81, 207, 102, 0.1);
color: @status-completed;
}
&.cancelled {
background-color: rgba(255, 107, 107, 0.15);
background-color: rgba(255, 107, 107, 0.1);
color: @status-cancelled;
}
}
@@ -298,72 +214,75 @@ page {
}
.patient-row {
margin-bottom: 16rpx;
margin-bottom: 20rpx;
}
.patient-info {
display: flex;
align-items: center;
gap: 20rpx;
gap: 24rpx;
}
.patient-avatar {
width: 72rpx;
height: 72rpx;
width: 80rpx;
height: 80rpx;
background: linear-gradient(135deg, @accent-gradient-start, @accent-gradient-end);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
box-shadow: 0 4rpx 12rpx rgba(76, 110, 245, 0.25);
}
.avatar-text {
font-size: 28rpx;
font-size: 30rpx;
font-weight: 600;
color: @text-primary;
color: #ffffff;
}
.patient-detail {
flex: 1;
display: flex;
flex-direction: column;
gap: 6rpx;
gap: 8rpx;
}
.patient-name-row {
display: flex;
align-items: center;
gap: 12rpx;
gap: 14rpx;
}
.patient-name {
font-size: 30rpx;
font-size: 32rpx;
font-weight: 600;
color: @text-primary;
}
.patient-gender {
font-size: 22rpx;
padding: 2rpx 10rpx;
border-radius: 6rpx;
background-color: rgba(107, 122, 255, 0.15);
color: @accent-secondary;
padding: 4rpx 12rpx;
border-radius: 10rpx;
background-color: rgba(76, 110, 245, 0.1);
color: @accent-primary;
font-weight: 500;
&.male {
background-color: rgba(76, 110, 245, 0.15);
background-color: rgba(76, 110, 245, 0.1);
color: @accent-primary;
}
&.female {
background-color: rgba(255, 107, 107, 0.15);
background-color: rgba(255, 107, 107, 0.1);
color: @status-cancelled;
}
}
.patient-age {
font-size: 22rpx;
font-size: 24rpx;
color: @text-secondary;
font-weight: 500;
}
.patient-phone {
@@ -373,25 +292,25 @@ page {
.info-divider {
height: 1rpx;
background: linear-gradient(to right, transparent, @divider-color, transparent);
margin: 16rpx 0;
background-color: @divider-color;
margin: 20rpx 0;
}
.info-item {
display: flex;
align-items: flex-start;
gap: 12rpx;
margin-bottom: 12rpx;
gap: 14rpx;
margin-bottom: 14rpx;
}
.info-content {
display: flex;
flex-direction: column;
gap: 4rpx;
gap: 6rpx;
}
.hospital-name {
font-size: 26rpx;
font-size: 28rpx;
color: @text-primary;
font-weight: 500;
}
@@ -404,16 +323,19 @@ page {
.service-name {
font-size: 26rpx;
color: @text-secondary;
font-weight: 500;
}
.time-text {
font-size: 26rpx;
color: @text-secondary;
font-weight: 500;
}
.attendant-name {
font-size: 26rpx;
color: @text-secondary;
font-weight: 500;
}
// ========== 卡片底部 ==========
@@ -421,9 +343,9 @@ page {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 28rpx 24rpx;
margin-top: 8rpx;
border-top: 1rpx solid rgba(42, 51, 102, 0.5);
padding: 24rpx 28rpx 28rpx;
margin-top: 12rpx;
border-top: 1rpx solid @divider-color;
}
.fee-section {
@@ -438,7 +360,7 @@ page {
}
.fee-value {
font-size: 36rpx;
font-size: 38rpx;
font-weight: 700;
color: @status-pending;
}
@@ -452,7 +374,7 @@ page {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 14rpx 32rpx;
padding: 16rpx 36rpx;
border-radius: 28rpx;
font-size: 26rpx;
font-weight: 500;
@@ -466,17 +388,17 @@ page {
.btn-primary {
background: linear-gradient(135deg, @accent-gradient-start, @accent-gradient-end);
color: @text-primary;
box-shadow: 0 4rpx 16rpx rgba(76, 110, 245, 0.3);
color: #ffffff;
box-shadow: 0 4rpx 16rpx rgba(76, 110, 245, 0.25);
}
.btn-secondary {
background-color: transparent;
background-color: @bg-primary;
color: @text-secondary;
border: 1rpx solid @border-color;
&:active {
background-color: rgba(107, 122, 255, 0.1);
background-color: rgba(76, 110, 245, 0.05);
}
}