69 lines
1.2 KiB
TypeScript
69 lines
1.2 KiB
TypeScript
import { queryOrderDetail } from "../../service/shop-api";
|
|
import message from "../../utils/message";
|
|
|
|
// pages/order/detail.ts
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
statusEnums: {
|
|
1: '待确认',
|
|
2: '已确认',
|
|
3: '已取消',
|
|
4: '已完成',
|
|
0: '已删除'
|
|
},
|
|
id: '',
|
|
order: {}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(opts: { id?: string }) {
|
|
if (!opts.id) {
|
|
message.alert('订单数据错误').then(() => wx.navigateBack());
|
|
return;
|
|
}
|
|
this.setData({
|
|
id: opts.id
|
|
})
|
|
this.loadOrderDetail(opts.id)
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
onPullDownRefresh(){
|
|
this.loadOrderDetail()
|
|
},
|
|
async loadOrderDetail(id?: string) {
|
|
message.showLoading()
|
|
try{
|
|
const order = await queryOrderDetail((id || this.data.id));
|
|
this.setData({ order })
|
|
wx.stopPullDownRefresh()
|
|
}finally{
|
|
message.hideLoading()
|
|
}
|
|
}
|
|
}) |