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.
159 lines
5.0 KiB
159 lines
5.0 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,
|
|
visiable1: false,
|
|
visiable2: false,
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
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(element.weightnoteInfo.netWeight){
|
|
element.proxyAmount = math.times(element.weightnoteInfo.netWeight, element.unitSurcharge)
|
|
}
|
|
if(util.isEmpty(element.activityOrderAuditPassNum)){
|
|
element.sumAmount = math.times(element.weightnoteInfo.settleUtiPrice, element.weightnoteInfo.settleWeight)
|
|
}
|
|
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 })
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
console.log(err)
|
|
})
|
|
},
|
|
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('复制成功')
|
|
}
|
|
})
|
|
},
|
|
hideLayout: function(e){
|
|
if(e.currentTarget.id == 'info2'){
|
|
this.setData({ visiable2: !this.data.visiable2 })
|
|
} else {
|
|
this.setData({ visiable1: !this.data.visiable1 })
|
|
}
|
|
}
|
|
|
|
})
|