167 lines
3.4 KiB
JavaScript
167 lines
3.4 KiB
JavaScript
import userApi from '../../../api/user';
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
orderId:'',
|
|
orderDetail:{},
|
|
orderStatusKV:userApi.order.statusKV,
|
|
orderStatus:userApi.order.status,
|
|
|
|
orderDeliverStatusKV:userApi.order.orderDeliverStatusKV,
|
|
|
|
scrollViewHeight:0,
|
|
|
|
refresherTriggered:true,
|
|
genderKV:userApi.genderKV,
|
|
cancelling:false,
|
|
isShowCancelView:false,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
const windowInfo = wx.getWindowInfo();
|
|
this.setData({
|
|
orderId:options.id,
|
|
scrollViewHeight:windowInfo.windowHeight - 94
|
|
});
|
|
this.getOrderDetail();
|
|
},
|
|
getOrderDetail(){
|
|
wx.showNavigationBarLoading();
|
|
userApi.order.detail(this.data.orderId).then((data)=>{
|
|
wx.hideNavigationBarLoading();
|
|
// let totalPackage = 0;
|
|
// data.totalPackage = totalPackage;
|
|
this.setData({
|
|
orderDetail:data,
|
|
refresherTriggered:false
|
|
})
|
|
// return userApi.order.markup.get(this.data.orderId);
|
|
})
|
|
// .then((data)=>{
|
|
// const show = data.result==userApi.order.markup.status.pending&&
|
|
// this.data.orderDetail.status==this.data.orderStatus.received
|
|
// this.setData({
|
|
// isShowMarkupView:show
|
|
// })
|
|
// })
|
|
},
|
|
showCancelModal(){
|
|
this.setData({
|
|
isShowCancelView:true
|
|
})
|
|
},
|
|
cancelOrder(){
|
|
this.setData({
|
|
cancelling:true
|
|
})
|
|
userApi.order.cancel(this.data.orderDetail.orderid).then(()=>{
|
|
wx.showToast({
|
|
title: '取消成功',
|
|
})
|
|
this.setData({
|
|
cancelling:false
|
|
});
|
|
this.getOrderDetail();
|
|
const pages = getCurrentPages();
|
|
const prePage = pages[pages.length-2];
|
|
prePage.refreshList();
|
|
});
|
|
},
|
|
pay(){
|
|
const merchantPay = this.selectComponent('#merchantOrderComponent');
|
|
merchantPay.createPayment(this.data.orderDetail.orderid,true);
|
|
},
|
|
paySuccess(){
|
|
this.getOrderDetail();
|
|
app.globalData.needRefreshOrderList = true;
|
|
},
|
|
copyOrderId(){
|
|
wx.setClipboardData({
|
|
data: this.data.orderDetail.orderid,
|
|
})
|
|
},
|
|
handleContact(e){
|
|
console.log('handleContact');
|
|
console.log(e.detail.path)
|
|
console.log(e.detail.query)
|
|
},
|
|
makePhoneCall(){
|
|
wx.makePhoneCall({
|
|
phoneNumber: this.data.orderDetail.deliveryman_phone,
|
|
})
|
|
},
|
|
preview(event){
|
|
const current = event.currentTarget.dataset.url;
|
|
wx.previewImage({
|
|
current:current,
|
|
urls: this.data.orderDetail.complete_images,
|
|
})
|
|
},
|
|
orderAgain(){
|
|
wx.switchTab({
|
|
url: '/pages/help/index/index',
|
|
})
|
|
},
|
|
viewPackageImg(event){
|
|
const img = event.currentTarget.dataset.item;
|
|
wx.previewImage({
|
|
urls: this.data.orderDetail.pickup_images,
|
|
current:img
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |