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
+38 -15
View File
@@ -1,10 +1,11 @@
// pages/order/index.js
const API = require('../../utils/api.js')
const { calcAge } = require('../../utils/format.js')
// 状态映射配置
const STATUS_MAP = {
pending: { label: '待确认', text: '待确认', color: '#f59f00' },
confirmed: { label: '已确认', text: '已确认', color: '#4c6ef5' },
confirmed: { label: '已确认', text: '已确认', color: '#1abc9c' },
in_progress: { label: '进行中', text: '进行中', color: '#20c997' },
completed: { label: '已完成', text: '已完成', color: '#51cf66' },
cancelled: { label: '已取消', text: '已取消', color: '#ff6b6b' }
@@ -37,7 +38,7 @@ Page({
},
// 状态筛选
statusFilters: STATUS_FILTERS,
currentStatus: '',
currentStatus: 'pending',
// 订单列表
orderList: [],
// 分页
@@ -149,15 +150,19 @@ Page({
* 处理订单数据
*/
processOrders(orders) {
return orders.map(order => ({
...order,
statusText: STATUS_MAP[order.status]?.text || order.status,
patientFirstChar: (order.patient?.name || '?')[0],
schedule: {
...order.schedule,
dateText: this.formatDate(order.schedule?.date)
}
}));
return orders.map(order => {
const age = calcAge(order.patient?.birth)
return {
...order,
statusText: STATUS_MAP[order.status]?.text || order.status,
patientFirstChar: (order.patient?.name || '?')[0],
patientAgeText: age ? `${age}` : '',
schedule: {
...order.schedule,
dateText: this.formatDate(order.schedule?.date)
}
};
});
},
/**
@@ -176,10 +181,10 @@ Page({
status: 'pending,confirmed,in_progress,completed,cancelled'
};
API.escort.getMyRecords(params)
API.escort.getAllRecords(params)
.then(res => {
if (res.code !== 0) {
wx.showToast({ title: res.message || '获取订单失败', icon: 'none' });
wx.showToast({ title: res.msg || '获取订单失败', icon: 'none' });
this.setData({ isLoading: false, isLoadingMore: false, isRefreshing: false });
return;
}
@@ -228,6 +233,24 @@ Page({
});
},
/**
* 跳转新增预约(页面内选择健康档案)
*/
onAddOrder() {
wx.navigateTo({
url: '/pages/order/orderEdit'
});
},
/**
* 空状态刷新
*/
onReload() {
this.setData({ page: 1, hasMore: true }, () => {
this.loadOrderList();
});
},
/**
* 状态筛选切换
*/
@@ -284,7 +307,7 @@ Page({
wx.showModal({
title: actionConfig.title,
content: actionConfig.content,
confirmColor: '#4c6ef5',
confirmColor: '#1abc9c',
success: (res) => {
if (res.confirm) {
this.updateOrderStatus(id, actionConfig.nextStatus);
@@ -302,7 +325,7 @@ Page({
API.escort.updateStatus(id, { status: newStatus })
.then(res => {
if (res.code !== 0) {
wx.showToast({ title: res.message || '操作失败', icon: 'none' });
wx.showToast({ title: res.msg || '操作失败', icon: 'none' });
wx.hideLoading();
return;
}