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.

79 lines
1.7 KiB

// pages/order/detail/index.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: '' });
wx.request({
url: `http://localhost:3003/api/orders/detail/${orderId}`,
method: 'GET',
header: {
'Content-Type': 'application/json'
},
success: (res) => {
console.log('获取订单详情成功:', res.data);
if (res.data.success) {
this.setData({
orderDetail: res.data.data,
loading: false
});
} else {
this.setData({
error: res.data.message || '获取订单详情失败',
loading: false
});
}
},
fail: (err) => {
console.error('获取订单详情失败:', err);
this.setData({
error: '网络请求失败,请稍后重试',
loading: false
});
}
});
},
// 返回上一页
goBack() {
wx.navigateBack();
}
})