赛事订单显示
This commit is contained in:
parent
fb23abcb6d
commit
c3ec9298f7
@ -1,28 +1,60 @@
|
||||
const auth = require('../../../utils/auth');
|
||||
const { formatTime } = require('../../../utils/format');
|
||||
|
||||
const STATUS_MAP = {
|
||||
Pending: { text: '待支付', key: 'pending' },
|
||||
Paid: { text: '交易成功', key: 'success' },
|
||||
Cancelled: { text: '已取消', key: 'cancelled' },
|
||||
Refunded: { text: '已退款', key: 'refunded' },
|
||||
Refunding: { text: '退款中', key: 'pending' }
|
||||
};
|
||||
|
||||
const PAYMENT_METHOD_MAP = {
|
||||
1: '线上支付',
|
||||
2: '线下支付',
|
||||
0: '未知'
|
||||
};
|
||||
|
||||
Page({
|
||||
data: {
|
||||
detail: {
|
||||
eventName: '2024上海市学生运动会跳绳比赛',
|
||||
statusText: '交易成功',
|
||||
statusKey: 'success',
|
||||
payMethod: '线上支付',
|
||||
actualAmount: '689',
|
||||
payTimeStr: '2025-08-05 16:26',
|
||||
refundAmount: '689',
|
||||
refundTimeStr: '2025-08-05 16:26',
|
||||
orderNo: '13123421516216512515 1',
|
||||
items: [
|
||||
{ id: 1, projectName: '30秒单摇', groupName: '少年儿童组', fee: 23 },
|
||||
{ id: 2, projectName: '交互绳', groupName: '成年组', fee: 411 },
|
||||
{ id: 3, projectName: '交互绳', groupName: '少年儿童组', fee: 32 },
|
||||
{ id: 4, projectName: '交互绳', groupName: '成年组', fee: 12 }
|
||||
]
|
||||
detail: null,
|
||||
loading: true
|
||||
},
|
||||
|
||||
async onLoad(options) {
|
||||
const id = options && options.id;
|
||||
if (!id) {
|
||||
wx.showToast({ title: '缺少订单ID', icon: 'none' });
|
||||
setTimeout(() => wx.navigateBack(), 1500);
|
||||
return;
|
||||
}
|
||||
await this.loadDetail(id);
|
||||
},
|
||||
|
||||
async loadDetail(id) {
|
||||
this.setData({ loading: true });
|
||||
try {
|
||||
const detail = await auth.fetchMyOrderDetail(id);
|
||||
const formatted = this.formatDetail(detail);
|
||||
this.setData({ detail: formatted, loading: false });
|
||||
} catch (err) {
|
||||
wx.showToast({ title: err?.message || '加载失败', icon: 'none' });
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const id = options && options.id;
|
||||
// TODO: 根据 id 调用接口获取订单详情
|
||||
// this.loadDetail(id);
|
||||
formatDetail(item) {
|
||||
const statusInfo = STATUS_MAP[item.orderStatus] || { text: item.orderStatus || '-', key: 'default' };
|
||||
return {
|
||||
...item,
|
||||
statusText: statusInfo.text,
|
||||
statusKey: statusInfo.key,
|
||||
payMethod: PAYMENT_METHOD_MAP[item.paymentMethod] || '未知',
|
||||
actualAmount: item.actualAmount != null ? item.actualAmount : '-',
|
||||
refundAmount: item.refundAmount != null && item.refundAmount > 0 ? item.refundAmount : '',
|
||||
payTimeStr: item.paymentTime ? formatTime(item.paymentTime) : '-',
|
||||
refundTimeStr: item.refundTime ? formatTime(item.refundTime) : '-'
|
||||
};
|
||||
},
|
||||
|
||||
onBack() {
|
||||
@ -34,10 +66,10 @@ Page({
|
||||
},
|
||||
|
||||
onCopyOrderNo() {
|
||||
const orderNo = this.data.detail.orderNo || '';
|
||||
const orderNo = this.data.detail?.orderNo || '';
|
||||
wx.setClipboardData({
|
||||
data: orderNo,
|
||||
success: () => wx.showToast({ title: '已复制', icon: 'success' })
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -1,6 +1,14 @@
|
||||
const auth = require('../../../utils/auth');
|
||||
const { formatDateTime } = require('../../../utils/format');
|
||||
|
||||
const STATUS_MAP = {
|
||||
0: '待支付',
|
||||
1: '已支付',
|
||||
2: '支付失败',
|
||||
3: '已退款',
|
||||
4: '已取消'
|
||||
};
|
||||
|
||||
Page({
|
||||
data: {
|
||||
registrations: [],
|
||||
@ -55,7 +63,8 @@ Page({
|
||||
const rows = (page && Array.isArray(page.rows) ? page.rows : []).map((r) => {
|
||||
return {
|
||||
...r,
|
||||
registrationTimeText: formatDateTime(r.registrationTime)
|
||||
registrationTimeText: formatDateTime(r.registrationTime),
|
||||
statusText: STATUS_MAP[r.status] || r.status
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<view class="r-title">{{item.eventName || '-'}}</view>
|
||||
<view class="r-sub" wx:if="{{item.teamName}}">团队/联系人:{{item.teamName}}</view>
|
||||
<view class="r-sub" wx:if="{{item.projectNames}}">项目:{{item.projectNames}}</view>
|
||||
<view class="r-sub">状态:{{item.status}}</view>
|
||||
<view class="r-sub">状态:{{item.statusText}}</view>
|
||||
<view class="r-sub">报名时间:{{item.registrationTimeText}}</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
@ -362,6 +362,15 @@ async function fetchMyOrders({ pageNo = 1, pageSize = 10 } = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchMyOrderDetail(id) {
|
||||
if (id == null || id === '') throw new Error('缺少订单ID');
|
||||
return request({
|
||||
path: `${API.myOrders}/${id}`,
|
||||
method: 'GET',
|
||||
needAuth: true
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchMyCertificates({ pageNo = 1, pageSize = 10, type } = {}) {
|
||||
const data = {
|
||||
PageNo: pageNo,
|
||||
@ -392,6 +401,7 @@ module.exports = {
|
||||
fetchMyTeams,
|
||||
fetchMyTeamDetail,
|
||||
fetchMyOrders,
|
||||
fetchMyOrderDetail,
|
||||
fetchMyCertificates,
|
||||
refreshAccessToken,
|
||||
uploadFile,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user