纸通宝小程序
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.
 

216 lines
6.1 KiB

// pages/agent/detail/index.js
import {
getProxyOrderInfo,
cancelProxyOrder,
cancelReservation,
cancelProxyOrderItem
} from "../../api/ztb"
const util = require('../../../utils/util')
const math = require('../../../utils/math')
const event = require('../../../utils/event')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
safeBottom: app.globalData.safeBottom,
id: null,
cancel: true,
orderInfo: null,
orderInfoStepLs:null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options.id) {
this.data.id = options.id
this.fetchOrderInfo()
}
},
fetchOrderInfo: function () {
wx.showLoading({
title: '加载中',
mask: true
})
getProxyOrderInfo(this.data.id).then(result => {
this.data.cancel = true
for (let index = 0; index < result.data.orderItems.length; index++) {
const element = result.data.orderItems[index]
if (element.weightnoteInfo && element.weightnoteInfo.id) {
// 全额
if (util.isEmpty(element.activityOrderAuditPassNum)) {
element.sumAmount = math.times(element.weightnoteInfo.settleUtiPrice, element.weightnoteInfo.settleWeight)
if (element.unitSurcharge!=null&element.surcharge !=null&&element.surcharge == math.times(element.weightnoteInfo.netWeight, element.unitSurcharge)) {
//按照净重,计算代卖费
element.orderType = 0
} else {
//按照结算重量计算代卖费
element.orderType = 1
}
} else {
if (element.weightnoteInfo.netWeight) {
element.proxyAmount = math.times(element.weightnoteInfo.netWeight, element.unitSurcharge)
}
}
this.data.cancel = false
}
if (element.activityOrderAuditPassNum == 2) {
element.finalSettlePrice = math.plus(element.finalPayMoney, element.preSettleMoney)
}
}
this.setData({
orderInfo: result.data,
safeBottom: app.globalData.safeBottom,
cancel: this.data.cancel
})
var orderInfoStepLs = result.data.orderItems
result.data.orderItems.forEach((element1, index1) => {
for (let i = 0; i <element1.orderItemTimeList.length; i++) {
orderInfoStepLs[index1].orderItemTimeList[i] = element1.orderItemTimeList[i]
}
});
this.setData({
orderInfoStep: orderInfoStepLs
})
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
util.showToast(err)
console.log(err)
})
},
getStr: function (index) {
switch (index) {
case 0:
return "订单已提交,待预约";
case 1:
return "预约成功,待送货";
case 2:
return "已收货,待审核";
case 3:
return "已审核,结算中";
case 4:
return "已结算,订单完成";
}
},
cancelOrder: function () {
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
var that = this
this.wuxDialog.open({
resetOnClose: true,
title: '温馨提示',
content: '确定取消该订单?',
buttons: [{
text: '取消'
}, {
text: '确定',
type: 'primary',
onTap(e) {
wx.showLoading({
title: '处理中',
mask: true
})
cancelProxyOrder(that.data.orderInfo.orderId).then(result => {
//成功回调
wx.hideLoading()
that.setData({
['orderInfo.status']: 55
})
event.emit('ProxyMessage', {
what: 400,
desc: 'ProxyChange'
})
util.showToast('订单已经取消')
}).catch(err => {
//异常回调
wx.hideLoading()
util.showToast(err)
})
}
}]
})
},
refuseOrder: function () {
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
var that = this
this.wuxDialog.open({
resetOnClose: true,
title: '温馨提示',
content: '确定预约的日期无法送货,需要销售重新到纸厂进程预约?',
buttons: [{
text: '取消'
}, {
text: '确定',
type: 'primary',
onTap(e) {
wx.showLoading({
title: '处理中',
mask: true
})
cancelReservation(that.data.orderInfo.orderId).then(result => {
wx.hideLoading()
that.setData({
['orderInfo.status']: 50
})
event.emit('ProxyMessage', {
what: 400,
desc: 'ProxyChange'
})
util.showToast('订单预约已经取消')
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
}]
})
},
cancelOrderItem: function (event) {
var orderItem = this.data.orderInfo.orderItems[event.currentTarget.dataset.index]
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
var that = this
this.wuxDialog.open({
resetOnClose: true,
title: '温馨提示',
content: '该车辆无法送货,确定取消?',
buttons: [{
text: '取消'
}, {
text: '确定',
type: 'primary',
onTap(e) {
wx.showLoading({
title: '处理中',
mask: true
})
cancelProxyOrderItem(orderItem.id).then(result => {
wx.hideLoading()
// 如果全部都关闭了,那么订单也就关闭了
util.showToast('送货已经取消')
that.fetchOrderInfo()
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
}]
})
},
editOrder: function () {
wx.navigateTo({
url: '/pages/agent/edit/index?orderId=' + this.data.orderInfo.orderId
})
},
clipboard: function () {
wx.setClipboardData({
data: this.data.orderInfo.millDeliveryOrderId,
success: function (res) {
util.showToast('复制成功')
}
})
}
})