Browse Source

小程序修改

featrue/v4.3
DESKTOP-A1SENDA\HUzy 5 years ago
parent
commit
5bbea9df39
2 changed files with 125 additions and 51 deletions
  1. 112
      pages/agent/detail/index.js
  2. 64
      pages/agent/detail/index.wxml

112
pages/agent/detail/index.js

@ -1,5 +1,10 @@
// pages/agent/detail/index.js
import { getProxyOrderInfo, cancelProxyOrder, cancelReservation, cancelProxyOrderItem } from "../../api/ztb"
import {
getProxyOrderInfo,
cancelProxyOrder,
cancelReservation,
cancelProxyOrderItem
} from "../../api/ztb"
const util = require('../../../utils/util')
const math = require('../../../utils/math')
const event = require('../../../utils/event')
@ -14,6 +19,7 @@ Page({
id: null,
cancel: true,
orderInfo: null,
orderInfoStep: null,
},
/**
* 生命周期函数--监听页面加载
@ -24,33 +30,62 @@ Page({
this.fetchOrderInfo()
}
},
fetchOrderInfo: function(){
wx.showLoading({ title: '加载中', mask: true })
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 && element.weightnoteInfo.id) {
// 全额
if(util.isEmpty(element.activityOrderAuditPassNum)){
if (util.isEmpty(element.activityOrderAuditPassNum)) {
element.sumAmount = math.times(element.weightnoteInfo.settleUtiPrice, element.weightnoteInfo.settleWeight)
if(element.surcharge == math.times(element.weightnoteInfo.netWeight, element.unitSurcharge)){
if (element.surcharge == math.times(element.weightnoteInfo.netWeight, element.unitSurcharge)) {
element.orderType = 0
} else {
element.orderType = 1
}
} else {
if(element.weightnoteInfo.netWeight){
if (element.weightnoteInfo.netWeight) {
element.proxyAmount = math.times(element.weightnoteInfo.netWeight, element.unitSurcharge)
}
}
this.data.cancel = false
}
if(element.activityOrderAuditPassNum == 2){
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 })
this.setData({
orderInfo: result.data,
safeBottom: app.globalData.safeBottom,
cancel: this.data.cancel
})
var orderInfoStepLs = result.data.orderItems
result.data.orderItems.forEach((element1, index1) => {
var dataLength=0;
for (let i = 0; i < 5; i++) {
if (element1.orderItemTimeList[i]) {//有数据
dataLength=i;
orderInfoStepLs[index1].orderItemTimeList[i] = element1.orderItemTimeList[i]
orderInfoStepLs[index1].orderItemTimeList[i].rank= i
} else {
orderInfoStepLs[index1].orderItemTimeList[i] = {
description: this.getStr(i),
time: "",
rank: i
}
}
}
orderInfoStepLs[index1].datalength=dataLength;
});
console.log('hhhh', orderInfoStepLs)
this.setData({
orderInfoStep: orderInfoStepLs
})
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
@ -58,6 +93,20 @@ Page({
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
@ -71,12 +120,20 @@ Page({
text: '确定',
type: 'primary',
onTap(e) {
wx.showLoading({ title: '处理中', mask: true })
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' })
that.setData({
['orderInfo.status']: 55
})
event.emit('ProxyMessage', {
what: 400,
desc: 'ProxyChange'
})
util.showToast('订单已经取消')
}).catch(err => {
//异常回调
@ -87,7 +144,7 @@ Page({
}]
})
},
refuseOrder: function(){
refuseOrder: function () {
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
var that = this
this.wuxDialog.open({
@ -100,11 +157,19 @@ Page({
text: '确定',
type: 'primary',
onTap(e) {
wx.showLoading({ title: '处理中', mask: true })
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' })
that.setData({
['orderInfo.status']: 50
})
event.emit('ProxyMessage', {
what: 400,
desc: 'ProxyChange'
})
util.showToast('订单预约已经取消')
}).catch(err => {
wx.hideLoading()
@ -114,7 +179,7 @@ Page({
}]
})
},
cancelOrderItem: function(event){
cancelOrderItem: function (event) {
var orderItem = this.data.orderInfo.orderItems[event.currentTarget.dataset.index]
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
var that = this
@ -128,7 +193,10 @@ Page({
text: '确定',
type: 'primary',
onTap(e) {
wx.showLoading({ title: '处理中', mask: true })
wx.showLoading({
title: '处理中',
mask: true
})
cancelProxyOrderItem(orderItem.id).then(result => {
wx.hideLoading()
// 如果全部都关闭了,那么订单也就关闭了
@ -142,10 +210,12 @@ Page({
}]
})
},
editOrder: function(){
wx.navigateTo({ url: '/pages/agent/edit/index?orderId=' + this.data.orderInfo.orderId })
editOrder: function () {
wx.navigateTo({
url: '/pages/agent/edit/index?orderId=' + this.data.orderInfo.orderId
})
},
clipboard: function(){
clipboard: function () {
wx.setClipboardData({
data: this.data.orderInfo.millDeliveryOrderId,
success: function (res) {

64
pages/agent/detail/index.wxml

@ -14,7 +14,7 @@
<view class="bg-white text-df text-gray" style="border-bottom:2rpx solid #f3f3f3;padding:24rpx 30rpx">
车辆信息({{orderInfo.orderItems.length}}辆车)
</view>
<view wx:for="{{orderInfo.orderItems}}" wx:key="index" style="margin-top:{{index == 0 ? 0 : 16}}rpx">
<view wx:for="{{orderInfoStep}}" wx:key="index" style="margin-top:{{index == 0 ? 0 : 16}}rpx">
<!-- <view class="bg-white flex flex-justify text-sg" style="padding: 24rpx 30rpx">
<text class="text-sg text-bold">货车车牌:{{item.logisticcsInfo.plateNumber}}</text>
<text class="text-black" style="padding: 4rpx 0rpx 4rpx 16rpx">{{agent.orderStatus(item.status)}}</text>
@ -30,7 +30,7 @@
</view>
<wux-steps direction="vertical">
<wux-step wx:for-item="timeItem" wx:for-index="oindex" wx:for="{{item.orderItemTimeList}}" wx:key="oindex"
title="{{timeItem.description}}" status="{{statusStep(oindex, item.orderItemTimeList.length, item.status)}}" content="{{timeItem.time}}"/>
title="{{timeItem.description}}" status="{{statusStep(oindex, item.orderItemTimeList.length, item.datalength)}}" content="{{timeItem.time}}"/>
</wux-steps>
</wux-accordion>
</wux-accordion-group>
@ -279,7 +279,7 @@
车辆信息({{orderInfo.orderItems.length}}辆车)
</view>
<wux-accordion-group>
<wux-accordion wx:for="{{orderInfo.orderItems}}" wx:key="index">
<wux-accordion wx:for="{{orderInfoStep}}" wx:key="index">
<view slot="header" class="flex flex-justify" style="width: 100%">
<view class="flex">
<text class="text-sg text-black text-bold">{{item.logisticcsInfo.plateNumber}}</text>
@ -289,7 +289,7 @@
</view>
<wux-steps direction="vertical">
<wux-step wx:for-item="timeItem" wx:for-index="oindex" wx:for="{{item.orderItemTimeList}}" wx:key="oindex"
title="{{timeItem.description}}" status="{{statusStep(oindex, item.orderItemTimeList.length, item.status)}}" content="{{timeItem.time}}"/>
title="{{timeItem.description}}" status="{{statusStep(oindex, item.orderItemTimeList.length,item.datalength)}}" content="{{timeItem.time}}"/>
</wux-steps>
</wux-accordion>
</wux-accordion-group>
@ -327,7 +327,7 @@
车辆信息({{orderInfo.orderItems.length}}辆车)
</view>
<wux-accordion-group>
<wux-accordion wx:for="{{orderInfo.orderItems}}" wx:key="index">
<wux-accordion wx:for="{{orderInfoStep}}" wx:key="index">
<view slot="header" class="flex flex-justify" style="width: 100%">
<view class="flex">
<text class="text-sg text-black text-bold">{{item.logisticcsInfo.plateNumber}}</text>
@ -337,7 +337,7 @@
</view>
<wux-steps direction="vertical">
<wux-step wx:for-item="timeItem" wx:for-index="oindex" wx:for="{{item.orderItemTimeList}}" wx:key="oindex"
title="{{timeItem.description}}" status="{{statusStep(oindex, item.orderItemTimeList.length, item.status)}}" content="{{timeItem.time}}"/>
title="{{timeItem.description}}" status="{{statusStep(oindex, item.orderItemTimeList.length,item.datalength)}}" content="{{timeItem.time}}"/>
</wux-steps>
</wux-accordion>
</wux-accordion-group>
@ -441,7 +441,7 @@
车辆信息({{orderInfo.orderItems.length}}辆车)
</view>
<wux-accordion-group>
<wux-accordion wx:for="{{orderInfo.orderItems}}" wx:key="index">
<wux-accordion wx:for="{{orderInfoStep}}" wx:key="index">
<view slot="header" class="flex flex-justify" style="width: 100%">
<view class="flex">
<text class="text-sg text-black text-bold">{{item.logisticcsInfo.plateNumber}}</text>
@ -451,7 +451,7 @@
</view>
<wux-steps direction="vertical">
<wux-step wx:for-item="timeItem" wx:for-index="oindex" wx:for="{{item.orderItemTimeList}}" wx:key="oindex"
title="{{timeItem.description}}" status="{{statusStep(oindex, item.orderItemTimeList.length, item.status)}}" content="{{timeItem.time}}"/>
title="{{timeItem.description}}" status="{{statusStep(oindex, item.orderItemTimeList.length, item.datalength)}}" content="{{timeItem.time}}"/>
</wux-steps>
</wux-accordion>
</wux-accordion-group>
@ -479,34 +479,38 @@
<view style="height:{{116 + safeBottom}}rpx;" wx:if="{{orderInfo && ((cancel && orderInfo.status == 51) || orderInfo.status == 50)}}"></view>
<view class="cu-bar bg-white foot flex flex-center" style="height:{{100 + safeBottom}}rpx;padding: 32rpx 32rpx {{safeBottom + 32}}rpx 32rpx;justify-content: flex-end"
wx:if="{{orderInfo && ((cancel && orderInfo.status == 51) || orderInfo.status == 50)}}">
<wux-button outline style="margin-right:24rpx" type="assertive" size="agent" bind:click="refuseOrder" wx:if="{{orderInfo.status == 51}}">更改预约</wux-button>
<!-- <wux-button outline style="margin-right:24rpx" type="assertive" size="agent" bind:click="refuseOrder" wx:if="{{orderInfo.status == 51}}">更改预约</wux-button> -->
<wux-button outline type="stable" size="agent" bind:click="cancelOrder" wx:if="{{orderInfo.status == 50 || orderInfo.status == 51}}">取消订单</wux-button>
</view>
<wux-dialog id="wux-dialog" />
<wxs module="statusStep">
function statusStep(step, size, status) {
if(status == 54 || status == 55){
return 'finish'
}
if(size == 1){
return 'wait'
} else if(size == 2){
if(step == 0){
return 'process'
} else {
return 'wait'
}
} else {
if(step == size - 2){
return 'process'
} else if(step == size - 1){
return 'wait'
} else {
return 'finish'
}
}
function statusStep(step, size, datalength) {
console.log("step=",step);
console.log("size=",size);
console.log("datalength=",datalength);
return step<datalength?"finish":(step==datalength?"process":"wait");
// if(status == 54 || status == 55){
// return 'finish'
// }
// if(size == 1){
// return 'wait'
// } else if(size == 2){
// if(step == 0){
// return 'process'
// } else {
// return 'wait'
// }
// } else {
// if(step == size - 2){
// return 'process'
// } else if(step == size - 1){
// return 'wait'
// } else {
// return 'finish'
// }
// }
}
module.exports = statusStep
</wxs>
Loading…
Cancel
Save