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.
156 lines
4.8 KiB
156 lines
4.8 KiB
// pages/agent/detail/index.js
|
|
const request = require('../../../utils/request') //导入模块
|
|
const util = require('../../../utils/util')
|
|
const event = require('../../../utils/event.js')
|
|
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 })
|
|
// /proxy-sell/get/proxy-order/{orderId}客户查看订单详情
|
|
request.get('/recycle-service/proxy-sell/get/proxy-order/' + 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){
|
|
this.data.cancel = false
|
|
break
|
|
}
|
|
}
|
|
this.setData({orderInfo: result.data, safeBottom: app.globalData.safeBottom, cancel: this.data.cancel })
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
util.showToast(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 })
|
|
request.post('/recycle-service/proxy-sell/cancel/order/' + 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 })
|
|
request.post('/recycle-service/proxy-sell/cancel/reservation/' + 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 })
|
|
request.post('/recycle-service/proxy-sell/cancel/order-item/' + 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 })
|
|
}
|
|
}
|
|
|
|
})
|