You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.8 KiB
77 lines
1.8 KiB
// pages/order/detail/index.js
|
|
const API = require('../../../utils/api.js');
|
|
|
|
Page({
|
|
// 分享给朋友/群聊
|
|
onShareAppMessage() {
|
|
return {
|
|
title: '鸡蛋贸易平台 - 订单详情',
|
|
path: '/pages/order/detail/index',
|
|
imageUrl: '/images/你有好蛋.png'
|
|
}
|
|
},
|
|
|
|
// 分享到朋友圈
|
|
onShareTimeline() {
|
|
return {
|
|
title: '鸡蛋贸易平台 - 订单详情',
|
|
query: '',
|
|
imageUrl: '/images/你有好蛋.png'
|
|
}
|
|
},
|
|
|
|
data: {
|
|
orderId: '',
|
|
orderDetail: null,
|
|
loading: false,
|
|
error: ''
|
|
},
|
|
|
|
onLoad(options) {
|
|
if (options.orderId) {
|
|
this.setData({ orderId: options.orderId });
|
|
this.loadOrderDetail();
|
|
}
|
|
},
|
|
|
|
// 加载订单详情
|
|
loadOrderDetail() {
|
|
const orderId = this.data.orderId;
|
|
if (!orderId) {
|
|
this.setData({ error: '订单ID不能为空' });
|
|
return;
|
|
}
|
|
|
|
this.setData({ loading: true, error: '' });
|
|
|
|
API.request(`/api/orders/detail/${orderId}`, 'GET', {})
|
|
.then(res => {
|
|
console.log('获取订单详情成功:', res);
|
|
console.log('订单详情数据结构:', JSON.stringify(res.data, null, 2));
|
|
console.log('是否包含QR_code字段:', 'QR_code' in (res.data || {}));
|
|
if (res.success) {
|
|
this.setData({
|
|
orderDetail: res.data,
|
|
loading: false
|
|
});
|
|
} else {
|
|
this.setData({
|
|
error: res.message || '获取订单详情失败',
|
|
loading: false
|
|
});
|
|
}
|
|
})
|
|
.catch(err => {
|
|
console.error('获取订单详情失败:', err);
|
|
this.setData({
|
|
error: err.message || '网络请求失败,请稍后重试',
|
|
loading: false
|
|
});
|
|
});
|
|
},
|
|
|
|
// 返回上一页
|
|
goBack() {
|
|
wx.navigateBack();
|
|
}
|
|
})
|