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.
784 lines
27 KiB
784 lines
27 KiB
// pages/morder/detail/index.js
|
|
const request = require('../../../utils/request') //导入模块
|
|
const util = require('../../../utils/util')
|
|
const math = require('../../../utils/math')
|
|
const event = require('../../../utils/event.js')
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
safeBottom: app.globalData.safeBottom,
|
|
kg: app.globalData.kg,
|
|
type: 0,
|
|
orderId: null,
|
|
orderInfo: null,
|
|
vidth: math.divide(690, 5) - 16,
|
|
imgList: [
|
|
{text : '视频', must: false, status: 0, video: true }, {text : '磅单', must: true, status: 0}, {text : '装车照(前)', must: true, status: 0},
|
|
{text : '装车照(左)', must: true, status: 0}, {text : '装车照(右)', must: true, status: 0}
|
|
],
|
|
boImgList: [],
|
|
duration: 60,
|
|
taskList: [],
|
|
orderPoundBO: {
|
|
grossWeight: null,
|
|
tareWeight: null,
|
|
netWeight: 0,
|
|
},
|
|
grossWeight: null,
|
|
tareWeight: null,
|
|
amount: 0,
|
|
payment: 0,
|
|
operatBar: false,
|
|
imageHeight: math.divide(math.times(750, 9), 16),
|
|
visible: false,
|
|
videoUrl: null,
|
|
radioIndex: 1,
|
|
deductedPoint: '',
|
|
deductedAmount1: 0.00,
|
|
deductedWeight: '',
|
|
deductedAmount2: 0.00,
|
|
modalName: null,
|
|
requesting: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if (options.orderId) {
|
|
this.data.orderId = options.orderId
|
|
this.data.type = options.type ? Number(options.type) : 0
|
|
this.fetchOrderInfo(this.data.orderId)
|
|
}
|
|
event.on('EventMessage', this, this.onEvent)
|
|
},
|
|
/*******************************************************onEvent************************************************************/
|
|
onEvent: function (message) {
|
|
if (message.what == 320) {
|
|
this.fetchOrderInfo(this.data.orderId)
|
|
}
|
|
},
|
|
/*******************************************************fetchOrderInfo************************************************************/
|
|
fetchOrderInfo(orderId) {
|
|
if(this.data.requesting){
|
|
return
|
|
}
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
mask: true
|
|
})
|
|
if(this.data.type == 1){
|
|
this.data.requesting = true
|
|
request.get('/recycle-service/get/store-order-trade-details/' + orderId).then(result => {
|
|
//成功回调
|
|
this.initPoundBO(result.data)
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
this.data.requesting = false
|
|
util.showToast(err)
|
|
})
|
|
} else {
|
|
this.data.requesting = true
|
|
request.get('/recycle-service/get/user-order-trade-details/' + orderId).then(result => {
|
|
//成功回调
|
|
this.initPoundBO(result.data)
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
this.data.requesting = false
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
},
|
|
/*******************************************************set订单信息************************************************************/
|
|
initPoundBO: function(orderInfo){
|
|
var amount = orderInfo.totalOfferPrice
|
|
var netWeight = orderInfo.quantity
|
|
this.data.boImgList = []
|
|
var vurl = null
|
|
var editBO = false
|
|
this.data.operatBar = false
|
|
if(this.data.type == 0){//买家
|
|
if(orderInfo.status == 1 || orderInfo.status == 3 || orderInfo.status == 4 || orderInfo.status == 5){
|
|
this.data.operatBar = true
|
|
}
|
|
} else if(this.data.type == 1){//卖家
|
|
if(orderInfo.status == 2 || orderInfo.status == 6 || orderInfo.status == 7){
|
|
this.data.operatBar = true
|
|
editBO = true
|
|
}
|
|
}
|
|
if(!util.isEmpty(orderInfo.orderPoundBO)){
|
|
if(!util.isEmpty(orderInfo.orderPoundBO.videoUrl)){
|
|
this.videoContext = wx.createVideoContext('video')
|
|
vurl = orderInfo.orderPoundBO.videoUrl
|
|
if(editBO){
|
|
this.data.imgList[0].status = 8
|
|
this.data.imgList[0].video = true
|
|
this.data.imgList[0].path = orderInfo.orderPoundBO.videoUrl
|
|
this.data.imgList[0].url = orderInfo.orderPoundBO.videoUrl
|
|
}
|
|
this.data.boImgList.push({text : '视频', url: orderInfo.orderPoundBO.videoUrl, video: true})
|
|
}
|
|
if(!util.isEmpty(orderInfo.orderPoundBO.poundUrl)){
|
|
this.data.boImgList.push({text : '磅单', url: orderInfo.orderPoundBO.poundUrl})
|
|
if(editBO){
|
|
this.data.imgList[1].status = 8
|
|
this.data.imgList[1].path = orderInfo.orderPoundBO.poundUrl
|
|
this.data.imgList[1].url = orderInfo.orderPoundBO.poundUrl
|
|
}
|
|
}
|
|
if(!util.isEmpty(orderInfo.orderPoundBO.beforeUrl)){
|
|
this.data.boImgList.push({text : '装车照(前)', url: orderInfo.orderPoundBO.beforeUrl})
|
|
if(editBO){
|
|
this.data.imgList[2].status = 8
|
|
this.data.imgList[2].path = orderInfo.orderPoundBO.beforeUrl
|
|
this.data.imgList[2].url = orderInfo.orderPoundBO.beforeUrl
|
|
}
|
|
}
|
|
if(!util.isEmpty(orderInfo.orderPoundBO.leftUrl)){
|
|
this.data.boImgList.push({text : '装车照(左)', url: orderInfo.orderPoundBO.leftUrl})
|
|
if(editBO){
|
|
this.data.imgList[3].status = 8
|
|
this.data.imgList[3].path = orderInfo.orderPoundBO.leftUrl
|
|
this.data.imgList[3].url = orderInfo.orderPoundBO.leftUrl
|
|
}
|
|
}
|
|
if(!util.isEmpty(orderInfo.orderPoundBO.rightUrl)){
|
|
this.data.boImgList.push({text : '装车照(右)', url: orderInfo.orderPoundBO.rightUrl})
|
|
if(editBO){
|
|
this.data.imgList[4].status = 8
|
|
this.data.imgList[4].path = orderInfo.orderPoundBO.rightUrl
|
|
this.data.imgList[4].url = orderInfo.orderPoundBO.rightUrl
|
|
}
|
|
}
|
|
if(orderInfo.orderPoundBO.netWeight){
|
|
netWeight = orderInfo.orderPoundBO.netWeight
|
|
amount = math.times(orderInfo.orderPoundBO.netWeight, orderInfo.unitPrice)
|
|
}
|
|
this.data.requesting = false
|
|
}
|
|
if(!orderInfo.orderPoundBO.deductPrice && orderInfo.orderPoundBO.deductedWeight){
|
|
orderInfo.orderPoundBO.deductPrice = math.times(orderInfo.orderPoundBO.deductedWeight, orderInfo.unitPrice)
|
|
}
|
|
if(!orderInfo.orderPoundBO.currentSettlePrice && orderInfo.orderPoundBO.deductedWeight){
|
|
orderInfo.orderPoundBO.currentSettlePrice = math.minus(orderInfo.totalOfferPrice, orderInfo.orderPoundBO.deductPrice)
|
|
}
|
|
// 如果是吨为单位的,进行换算;这里指的是重量
|
|
if(!app.globalData.kg){
|
|
netWeight = math.divide(netWeight, 1000)
|
|
if(orderInfo.orderPoundBO.grossWeight){
|
|
orderInfo.orderPoundBO.grossWeight = math.divide(orderInfo.orderPoundBO.grossWeight, 1000).toFixed(2)
|
|
}
|
|
if(orderInfo.orderPoundBO.tareWeight){
|
|
orderInfo.orderPoundBO.tareWeight = math.divide(orderInfo.orderPoundBO.tareWeight, 1000).toFixed(2)
|
|
}
|
|
if(orderInfo.orderPoundBO.netWeight){
|
|
orderInfo.orderPoundBO.netWeight = math.divide(orderInfo.orderPoundBO.netWeight, 1000).toFixed(2)
|
|
}
|
|
}
|
|
this.setData({
|
|
orderInfo: orderInfo,
|
|
imgList: this.data.imgList,
|
|
videoUrl: vurl,
|
|
boImgList: this.data.boImgList,
|
|
orderPoundBO: orderInfo.orderPoundBO,
|
|
['orderPoundBO.netWeight']: netWeight,
|
|
amount: amount,
|
|
deductedAmount2: Number(math.minus(amount, orderInfo.imprestAmount)).toFixed(2),
|
|
payment: math.minus(amount, orderInfo.imprestAmount),
|
|
type: this.data.type,
|
|
operatBar: this.data.operatBar,
|
|
kg: app.globalData.kg,
|
|
safeBottom: app.globalData.safeBottom
|
|
})
|
|
},
|
|
/*******************************************************店铺信息************************************************************/
|
|
toShopInfo: function(){
|
|
if(!this.data.orderInfo){
|
|
return
|
|
}
|
|
if(!app.globalData.userInfo){
|
|
wx.navigateTo({ url: '/pages/login/index'})
|
|
return
|
|
}
|
|
wx.navigateTo({ url: '/pages/shop/detail/index?storeId=' + this.data.orderInfo.storeId })
|
|
},
|
|
bindInput: function(e){
|
|
if(e.target.id == 'grossWeight'){
|
|
// 毛重输入
|
|
this.data.orderPoundBO.grossWeight = Number(e.detail.value)
|
|
} else {
|
|
// 皮重输入
|
|
this.data.orderPoundBO.tareWeight = Number(e.detail.value)
|
|
}
|
|
},
|
|
mountWeight: function(){
|
|
if(util.isEmpty(this.data.orderPoundBO.grossWeight)){
|
|
this.data.orderPoundBO.tareWeight = null
|
|
}
|
|
if(Number(this.data.orderPoundBO.grossWeight) <= Number(this.data.orderPoundBO.tareWeight)){
|
|
this.data.orderPoundBO.tareWeight = null
|
|
}
|
|
var netWeight = math.minus(this.data.orderPoundBO.grossWeight || this.data.orderInfo.quantity, this.data.orderPoundBO.tareWeight || 0)
|
|
var amount = math.times(netWeight, this.data.orderInfo.unitPrice)
|
|
if(!app.globalData.kg){
|
|
amount = math.times(amount, 1000)
|
|
}
|
|
this.setData({
|
|
['orderPoundBO.netWeight']: netWeight,
|
|
amount: amount,
|
|
payment: math.minus(amount, this.data.orderInfo.imprestAmount)
|
|
})
|
|
},
|
|
/*******************************************************订单磅单上传************************************************************/
|
|
submitInfo: function(){
|
|
if(util.isEmpty(this.data.orderPoundBO.grossWeight) || parseInt(this.data.orderPoundBO.grossWeight) <= 0){
|
|
util.showToast('请输入毛重')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.orderPoundBO.tareWeight) || parseInt(this.data.orderPoundBO.tareWeight) <= 0){
|
|
util.showToast('请输入皮重')
|
|
return
|
|
}
|
|
var grossWeight = this.data.orderPoundBO.grossWeight
|
|
if(!app.globalData.kg){
|
|
grossWeight = math.times(this.data.orderPoundBO.grossWeight, 1000)
|
|
}
|
|
if(Number(grossWeight) < this.data.orderInfo.quantity){
|
|
util.showToast('您输入的磅单信息与订单要求不符,请检查后重新输入')
|
|
return
|
|
}
|
|
this.data.orderPoundBO.poundUrl = this.data.imgList[1].url
|
|
if(util.isEmpty(this.data.orderPoundBO.poundUrl)){
|
|
util.showToast('请上传磅单图片')
|
|
return
|
|
}
|
|
this.data.orderPoundBO.beforeUrl = this.data.imgList[2].url
|
|
if(util.isEmpty(this.data.orderPoundBO.beforeUrl)){
|
|
util.showToast('请上装车照(前)图片')
|
|
return
|
|
}
|
|
this.data.orderPoundBO.leftUrl = this.data.imgList[3].url
|
|
if(util.isEmpty(this.data.orderPoundBO.leftUrl)){
|
|
util.showToast('请上装车照(左)图片')
|
|
return
|
|
}
|
|
this.data.orderPoundBO.rightUrl = this.data.imgList[4].url
|
|
if(util.isEmpty(this.data.orderPoundBO.rightUrl)){
|
|
util.showToast('请上传装车照(右)图片')
|
|
return
|
|
}
|
|
this.data.orderPoundBO.videoUrl = this.data.imgList[0].url
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
var form = {
|
|
orderId: this.data.orderInfo.orderId,
|
|
orderPoundBO: this.data.orderPoundBO,
|
|
uniPrice: this.data.orderInfo.unitPrice
|
|
}
|
|
if(!app.globalData.kg){
|
|
form.orderPoundBO.grossWeight = math.times(this.data.orderPoundBO.grossWeight, 1000)
|
|
form.orderPoundBO.tareWeight = math.times(this.data.orderPoundBO.tareWeight, 1000)
|
|
}
|
|
request.post('/recycle-service/upload/store-order-trade', form).then(result => {
|
|
//成功回调
|
|
wx.hideLoading()
|
|
util.showToast('您已成功上传磅单信息,请等待买家确认榜单')
|
|
this.eventOrder()
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
/*******************************************************订单支付************************************************************/
|
|
paymentOffline: function(){
|
|
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
|
|
var that = this
|
|
this.wuxDialog.open({
|
|
resetOnClose: true,
|
|
title: '温馨提示',
|
|
content: '1、还没看到货,就要支付货款或定金,存在资金风险通过千鸟平台担保交易,先交纳诚意金,就可以查看货物的磅单信息和装货拍照图片,满意后才支付尾款。如果不满意,可以申请取消订单,取回已付的诚意金。\n 2、货不对板,担心买到假货、次货通过千鸟平台担保交易,买家验货时,确认没有扣点、扣重的异常问题后,平台才会结算货款给卖家。如果协商不一致,可以申请退货退款,取回已付的货款。',
|
|
buttons: [{
|
|
text: '取消'
|
|
},{
|
|
text: '坚持线下支付',
|
|
type: 'primary',
|
|
onTap(e) {
|
|
that.paymentOffOrder()
|
|
}
|
|
}]
|
|
})
|
|
},
|
|
paymentOrder: function(){
|
|
if(this.data.orderInfo.status == 1){
|
|
wx.navigateTo({ url: '/pages/payment/index?type=11&orderId=' + this.data.orderInfo.orderId })
|
|
} else if(this.data.orderInfo.status == 4){
|
|
wx.navigateTo({ url: '/pages/payment/index?type=14&orderId=' + this.data.orderInfo.orderId })
|
|
}
|
|
},
|
|
paymentOffOrder: function(){
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
request.post('/recycle-service/order-trade/pay/offline', { orderId: this.data.orderId }).then(result => {
|
|
//成功回调
|
|
wx.hideLoading()
|
|
this.eventOrder()
|
|
util.showToast('订单支付已处理')
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
/*******************************************************确认磅单************************************************************/
|
|
editPrice: function(){
|
|
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
|
|
var that = this
|
|
this.wuxDialog.prompt({
|
|
resetOnClose: true,
|
|
title: '温馨提示',
|
|
content: '请修改您的单价(元/' + (app.globalData.kg ? 'KG' : '吨') + ')',
|
|
placeholder: '请输入单价',
|
|
maxlength: 8,
|
|
onConfirm(e, response) {
|
|
that.setData({['orderInfo.unitPrice'] : app.globalData.kg ? response : math.divide(response, 1000)})
|
|
that.mountWeight()
|
|
}
|
|
})
|
|
},
|
|
offerInfo: function(e){
|
|
console.log(e)
|
|
if(e.currentTarget.id == 'refuse'){
|
|
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) {
|
|
that.confrimInfo(2)
|
|
}
|
|
}]
|
|
})
|
|
} else {
|
|
this.confrimInfo(1)
|
|
}
|
|
},
|
|
confrimInfo(type){
|
|
wx.showLoading({
|
|
title: '处理中',
|
|
mask: true
|
|
})
|
|
var form = {orderId: this.data.orderInfo.orderId, type}
|
|
request.post('/recycle-service/confirm/user-order-data', form).then(result => {
|
|
//成功回调
|
|
wx.hideLoading()
|
|
this.eventOrder()
|
|
if(type == 1){
|
|
if(!this.data.orderInfo.isPayOffline){
|
|
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) {
|
|
that.paymentOrder()
|
|
}
|
|
}]
|
|
})
|
|
} else {
|
|
util.showToast('订单信息已经处理')
|
|
}
|
|
} else {
|
|
util.showToast('订单信息已经处理')
|
|
}
|
|
}).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.get('/recycle-service/cancel/user-order-trade/'+ that.data.orderId).then(result => {
|
|
//成功回调
|
|
wx.hideLoading()
|
|
that.eventOrder()
|
|
util.showToast('订单已经取消')
|
|
// that.fetchOrderInfo(that.data.orderId)
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
}]
|
|
})
|
|
},
|
|
/*******************************************************收货处理************************************************************/
|
|
actionSheet: function(){
|
|
var that = this
|
|
wx.showActionSheet({
|
|
itemList: ['申请退货', '申请扣点扣重'],
|
|
success(res){
|
|
if (res.tapIndex === 0){
|
|
that.backGood()
|
|
}else if (res.tapIndex === 1){
|
|
that.setData({ modalName: 'bottomModal' })
|
|
}
|
|
}
|
|
})
|
|
},
|
|
hideModal: function(){
|
|
this.setData({ modalName: null })
|
|
},
|
|
stopModal: function(){
|
|
|
|
},
|
|
takeGood: function(){
|
|
wx.showLoading({
|
|
title: '处理中',
|
|
mask: true
|
|
})
|
|
var form = { orderId: this.data.orderId }
|
|
request.post('/recycle-service/confirm/user-order-trade', form).then(result => {
|
|
//成功回调
|
|
wx.hideLoading()
|
|
this.eventOrder()
|
|
util.showToast('收货成功')
|
|
// that.fetchOrderInfo(that.data.orderId)
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
backGood: 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/return/user-order-trade', { orderId:that.data.orderId }).then(result => {
|
|
//成功回调
|
|
wx.hideLoading()
|
|
that.eventOrder()
|
|
util.showToast('退货申请成功!')
|
|
// that.fetchOrderInfo(that.data.orderId)
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
}]
|
|
})
|
|
},
|
|
bind2Input: function(e){
|
|
if(this.data.radioIndex == 1){
|
|
this.data.deductedPoint = e.detail.value
|
|
this.data.deductedWeight = Number(math.divide(math.times(this.data.orderPoundBO.netWeight, this.data.deductedPoint), 100))
|
|
this.data.deductedAmount1 = Number(math.times(this.data.orderInfo.unitPrice, this.data.deductedWeight)).toFixed(2)
|
|
this.data.deductedAmount2 = Number(math.minus(this.data.orderInfo.totalOfferPrice, this.data.deductedAmount1)).toFixed(2)
|
|
if(!app.globalData.kg){
|
|
this.data.deductedWeight = math.divide(this.data.deductedWeight, 1000)
|
|
}
|
|
this.setData({
|
|
deductedWeight: this.data.deductedWeight,
|
|
deductedAmount1: this.data.deductedAmount1,
|
|
deductedAmount2: this.data.deductedAmount2
|
|
})
|
|
} else {
|
|
if(!app.globalData.kg){
|
|
this.data.deductedWeight = math.times(e.detail.value, 1000)
|
|
} else {
|
|
this.data.deductedWeight = e.detail.value
|
|
}
|
|
if(math.minus(this.data.deductedWeight, this.data.orderPoundBO.netWeight) >= 0){
|
|
this.data.deductedWeight = 0
|
|
}
|
|
this.data.deductedPoint = math.times(math.divide(this.data.deductedWeight, this.data.orderPoundBO.netWeight), 100)
|
|
this.data.deductedAmount1 = Number(math.times(this.data.orderInfo.unitPrice, this.data.deductedWeight)).toFixed(2)
|
|
this.data.deductedAmount2 = Number(math.minus(this.data.orderInfo.totalOfferPrice, this.data.deductedAmount1)).toFixed(2)
|
|
if(this.data.deductedWeight == 0){
|
|
this.setData({
|
|
deductedWeight: this.data.deductedWeight,
|
|
deductedPoint: this.data.deductedPoint,
|
|
deductedAmount1: this.data.deductedAmount1,
|
|
deductedAmount2: this.data.deductedAmount2
|
|
})
|
|
} else {
|
|
this.setData({
|
|
deductedPoint: this.data.deductedPoint,
|
|
deductedAmount1: this.data.deductedAmount1,
|
|
deductedAmount2: this.data.deductedAmount2
|
|
})
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
changRadio: function(e){
|
|
this.setData({
|
|
radioIndex: parseInt(e.currentTarget.id)
|
|
})
|
|
},
|
|
applyGood: function(){
|
|
if(util.isEmpty(this.data.deductedPoint) || Number(this.data.deductedPoint) <= 0){
|
|
util.showToast('请输入扣点扣重')
|
|
return
|
|
}
|
|
this.hideModal()
|
|
wx.showLoading({
|
|
title: '处理中',
|
|
mask: true
|
|
})
|
|
var form = { orderId: this.data.orderId }
|
|
form.deductedPoint = Number(this.data.deductedPoint)
|
|
if(!app.globalData.kg){
|
|
form.deductedWeight = math.times(this.data.deductedWeight, 1000)
|
|
} else {
|
|
form.deductedWeight = Number(this.data.deductedWeight)
|
|
}
|
|
request.post('/recycle-service/apply/user-order-trade-deduction', form).then(result => {
|
|
//成功回调
|
|
wx.hideLoading()
|
|
this.eventOrder()
|
|
util.showToast('申请扣重扣点成功')
|
|
// that.fetchOrderInfo(that.data.orderId)
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
handleDeducted: function(e){
|
|
console.log(e)
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
var form = { orderId: this.data.orderId, type: 1 }
|
|
if(e.currentTarget.id == 'crefuse'){
|
|
form.status = 0
|
|
form.type = 1
|
|
} else if(e.currentTarget.id == 'cagree'){
|
|
form.status = 1
|
|
form.type = 1
|
|
} else if(e.currentTarget.id == 'drefuse'){
|
|
form.status = 0
|
|
form.type = 2
|
|
} else if(e.currentTarget.id == 'dagree'){
|
|
form.status = 1
|
|
form.type = 2
|
|
}
|
|
request.post('/recycle-service/confirm/store-order-trade', form).then(result => {
|
|
//成功回调
|
|
wx.hideLoading()
|
|
if(form.status == 0){
|
|
util.showToast('已经拒绝')
|
|
} else {
|
|
util.showToast('已经同意')
|
|
}
|
|
this.eventOrder()
|
|
// that.fetchOrderInfo(that.data.orderId)
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
eventOrder: function(){
|
|
event.emit('EventMessage', {
|
|
what: 320,
|
|
desc: 'OrderChange'
|
|
})
|
|
},
|
|
/*******************************************************图片上传************************************************************/
|
|
chooseImage: function(e){
|
|
var index = e.currentTarget.dataset.index
|
|
if(index == 0){
|
|
wx.chooseVideo({
|
|
sourceType: ['album', 'camera'], //从相册选择
|
|
maxDuration: this.data.duration,
|
|
camera: 'back',
|
|
success: (res) => {
|
|
this.setData({
|
|
['imgList[' + index + '].status']: 1,
|
|
['imgList[' + index + '].path']: res.tempFilePath,
|
|
['imgList[' + index + '].cover']: res.thumbTempFilePath
|
|
})
|
|
this.uploadFile(index, res.tempFilePath)
|
|
}
|
|
})
|
|
} else {
|
|
wx.chooseImage({
|
|
count: 1, //默认9
|
|
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], //从相册选择
|
|
success: (res) => {
|
|
this.setData({
|
|
['imgList[' + index + '].status']: 1,
|
|
['imgList[' + index + '].path']: res.tempFilePaths[0]
|
|
})
|
|
this.uploadFile(index, res.tempFilePaths[0])
|
|
}
|
|
})
|
|
}
|
|
},
|
|
uploadFile: function (index, path) {
|
|
var _this = this
|
|
const task = wx.uploadFile({
|
|
url: app.httpUrl + '/saas-user/utils/uploadImage',
|
|
filePath: path,
|
|
name: 'image',
|
|
header: {
|
|
'Content-Type': 'multipart/form-data',
|
|
'appversion': app.version
|
|
},
|
|
success: function (result) {
|
|
var resp = null
|
|
if (!util.isEmpty(result.data)) {
|
|
resp = JSON.parse(result.data)
|
|
}
|
|
if (resp && resp.code === 0) {
|
|
_this.setData({
|
|
['imgList[' + index + '].status']: 8,
|
|
['imgList[' + index + '].url']: resp.data
|
|
})
|
|
} else {
|
|
if (index > 0) {
|
|
util.showToast('图片上传失败,请重新上传')
|
|
} else {
|
|
util.showToast('视频上传失败,请重新上传')
|
|
}
|
|
_this.setData({
|
|
['imgList[' + index + '].status']: -1
|
|
})
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
_this.setData({
|
|
['imgList[' + index + '].status']: -1
|
|
})
|
|
if (index > 0) {
|
|
util.showToast('图片上传失败,请重新上传')
|
|
} else {
|
|
util.showToast('视频上传失败,请重新上传')
|
|
}
|
|
},
|
|
complete: function (res) {
|
|
for (let i = 0; i < _this.data.taskList.length; i++) {
|
|
if (_this.data.taskList[i].path === path) {
|
|
_this.data.taskList.splice(i, 1);
|
|
break
|
|
}
|
|
}
|
|
}
|
|
})
|
|
_this.data.taskList.push({ path: path, task: task })
|
|
},
|
|
deleteImg(e) {
|
|
var index = e.currentTarget.dataset.index
|
|
// 如果是正在上传的;
|
|
if (this.data.imgList[index].status === 1) {
|
|
if (this.data.taskList[index] && this.data.taskList[index].task) {
|
|
this.data.taskList[index].task.abort() // 取消上传任务
|
|
}
|
|
this.data.taskList.splice(index, 1);
|
|
}
|
|
this.setData({
|
|
['imgList[' + index + '].status']: 0,
|
|
['imgList[' + index + '].path']: null,
|
|
['imgList[' + index + '].cover']: null,
|
|
['imgList[' + index + '].url']: null
|
|
})
|
|
},
|
|
viewImage: function(e){
|
|
if (util.isEmpty(e.currentTarget.dataset.url)) {
|
|
return
|
|
}
|
|
var urlList = []
|
|
for (var i = 0; i < this.data.imgList.length; i++) {
|
|
if (!util.isEmpty(this.data.imgList[i].path)) {
|
|
urlList.push(this.data.imgList[i].path)
|
|
}
|
|
}
|
|
wx.previewImage({ urls: urlList, current: e.currentTarget.dataset.url })
|
|
},
|
|
previewImage: function(e){
|
|
var urlList = []
|
|
for (var i = 0; i < this.data.boImgList.length; i++) {
|
|
urlList.push(this.data.boImgList[i].url)
|
|
}
|
|
wx.previewImage({ urls: urlList, current: e.currentTarget.dataset.url })
|
|
},
|
|
videoTap: function(e){
|
|
this.setData({
|
|
visible: true,
|
|
})
|
|
if (this.videoContext) {
|
|
this.videoContext.play()
|
|
}
|
|
},
|
|
onClose: function () {
|
|
this.setData({
|
|
visible: false,
|
|
})
|
|
if (this.videoContext) {
|
|
this.videoContext.pause()
|
|
}
|
|
},
|
|
bindended: function () {
|
|
this.videoContext.exitFullScreen()
|
|
this.setData({
|
|
visible: false
|
|
})
|
|
},
|
|
onUnload: function(){
|
|
event.remove('EventMessage', this)
|
|
}
|
|
})
|