tianyi 1 month ago
parent
commit
118d4fc6b1
  1. 175
      components/worker/delivery.vue

175
components/worker/delivery.vue

@ -31,7 +31,7 @@
<!-- <view class="tabs1" @tap="checkTab1('zhuandan')" <!-- <view class="tabs1" @tap="checkTab1('zhuandan')"
:style="{'color':tab1Checked == 'zhuandan'?'#000':'#777','font-size':tab1Checked== 'zhuandan'?'36rpx':'30rpx'}"> :style="{'color':tab1Checked == 'zhuandan'?'#000':'#777','font-size':tab1Checked== 'zhuandan'?'36rpx':'30rpx'}">
转单<text>()</text> 转单<text>()</text>
<img v-if="tab1Checked == 'zhuandan'" <image v-if="tab1Checked == 'zhuandan'"
src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4bb5fc7725cb4a7a84d1d3a15f05b39c.png" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4bb5fc7725cb4a7a84d1d3a15f05b39c.png"
alt="" alt=""
style="width: 80rpx;height: 14rpx;position: absolute;bottom: 4rpx;left: 32rpx;" /> style="width: 80rpx;height: 14rpx;position: absolute;bottom: 4rpx;left: 32rpx;" />
@ -77,7 +77,7 @@
</view> </view>
<view class="delivery-status-desc">{{deliveryStatusText}}</view> <view class="delivery-status-desc">{{deliveryStatusText}}</view>
<view class="delivery-status-meta"> <view class="delivery-status-meta">
<text :class="{'delivery-status-meta--warn': !zhipaiCheck}">{{zhipaiCheck ? '自动派单已开启' : '自动派单未开启'}}</text> <text :class="{'delivery-status-meta--warn': !zhipaiCheck}">{{zhipaiCheck ? '已开启指派接单' : '指派接单未开启'}}</text>
<text>覆盖 {{totalRuleCount}} 条路线</text> <text>覆盖 {{totalRuleCount}} 条路线</text>
<text v-if="minRuleFeeText">最低 {{minRuleFeeText}} </text> <text v-if="minRuleFeeText">最低 {{minRuleFeeText}} </text>
</view> </view>
@ -99,7 +99,6 @@
<view class="delivery-empty-desc">设置接单路线用户下单时即可直接指派给你</view> <view class="delivery-empty-desc">设置接单路线用户下单时即可直接指派给你</view>
<view class="delivery-empty-btn" @tap="goRuleSetting">去设置接单范围</view> <view class="delivery-empty-btn" @tap="goRuleSetting">去设置接单范围</view>
</view> </view>
<view class="box1" v-for="(item,index) in pageData" :key="index"> <view class="box1" v-for="(item,index) in pageData" :key="index">
<view class="maotou" v-if="item.deliveryType == 1"> <view class="maotou" v-if="item.deliveryType == 1">
<text>{{item.numberCode.length>14 ?'多订单':item.numberCode | delPlus}}</text> <text>{{item.numberCode.length>14 ?'多订单':item.numberCode | delPlus}}</text>
@ -124,8 +123,7 @@
{{item.mustFinishTime != null ? item.mustFinishTime : '' | formatHourMinute }}前送达 {{item.mustFinishTime != null ? item.mustFinishTime : '' | formatHourMinute }}前送达
</view> </view>
</view> </view>
<view class="" v-if="item.remark != '' && item.remark != null" <view class="delivery-remark" v-if="item.remark != '' && item.remark != null">
style="background: rgba(247, 248, 248, 0.6);height: 80rpx;line-height: 80rpx;font-weight: 500;padding: 0 20rpx;border-radius: 20rpx;">
备注{{item.remark}} 备注{{item.remark}}
</view> </view>
<view class="express-info-card" v-if="item.deliveryType == 3 || item.deliveryType == 2"> <view class="express-info-card" v-if="item.deliveryType == 3 || item.deliveryType == 2">
@ -145,8 +143,12 @@
</view> </view>
<view class="express-picture-list" v-if="getPickupPictures(item).length > 0"> <view class="express-picture-list" v-if="getPickupPictures(item).length > 0">
<view class="express-picture-title">取件码截图</view> <view class="express-picture-title">取件码截图</view>
<image class="express-picture" v-for="(pic,picIndex) in getPickupPictures(item)" :key="picIndex" <scroll-view scroll-x class="express-picture-scroll">
:src="pic" mode="aspectFill" @tap.stop="largeImg(pic)"></image> <view class="express-picture-track">
<image class="express-picture" v-for="(pic,picIndex) in getPickupPictures(item)" :key="picIndex"
:src="pic" mode="aspectFill" @tap.stop="previewPickupPicture(item, picIndex)"></image>
</view>
</scroll-view>
</view> </view>
<!-- <view style="display: flex;padding: 10px 0;"> <!-- <view style="display: flex;padding: 10px 0;">
<view class="code-box" style="margin-right:10px;"> <view class="code-box" style="margin-right:10px;">
@ -266,7 +268,7 @@
<uni-popup ref="carPopup" class="dispatch-popup" type="bottom" background-color="transparent" @change="handleDispatchPopupChange"> <uni-popup ref="carPopup" class="dispatch-popup" type="bottom" background-color="transparent" @change="handleDispatchPopupChange">
<view class="guize-list"> <view class="guize-list">
<view class="dispatch-popup-title"> <view class="dispatch-popup-title">
选择参与自动派单的接单范围 选择参与指派接单的接单范围
</view> </view>
<view class="dispatch-popup-desc"> <view class="dispatch-popup-desc">
开启后系统只会把符合你设置区域和最低佣金的订单派给你未勾选路线不会参与指派 开启后系统只会把符合你设置区域和最低佣金的订单派给你未勾选路线不会参与指派
@ -283,7 +285,7 @@
</view> </view>
<view class="dispatch-empty" v-if="totalRuleCount == 0"> <view class="dispatch-empty" v-if="totalRuleCount == 0">
<view class="dispatch-empty-title">你还没有接单范围</view> <view class="dispatch-empty-title">你还没有接单范围</view>
<view class="dispatch-empty-desc">先去划定想送的楼栋和最低配送费设置后才能开启自动派</view> <view class="dispatch-empty-desc">先去划定想送的楼栋和最低配送费设置后才能开启指派接</view>
</view> </view>
<scroll-view scroll-y="true" class="dispatch-rule-scroll"> <scroll-view scroll-y="true" class="dispatch-rule-scroll">
<view style="height: 50rpx;line-height: 50rpx;font-weight: 700;display: flex;"> <view style="height: 50rpx;line-height: 50rpx;font-weight: 700;display: flex;">
@ -370,7 +372,7 @@
</scroll-view> </scroll-view>
<view class="dispatch-actions"> <view class="dispatch-actions">
<view class="dispatch-action-btn dispatch-action-btn--secondary" @tap="buchong"> <view class="dispatch-action-btn dispatch-action-btn--secondary" @tap="buchong">
补充范围 去设置接单规则
</view> </view>
<view class="dispatch-action-btn dispatch-action-btn--primary" @tap="selectRule"> <view class="dispatch-action-btn dispatch-action-btn--primary" @tap="selectRule">
确认并保存 确认并保存
@ -492,6 +494,8 @@
refreshLoading: false, refreshLoading: false,
refreshLoadingStartTime: 0, refreshLoadingStartTime: 0,
refreshLoadingTimer: null, refreshLoadingTimer: null,
deliveryRequestId: 0,
loadStatus: 'more',
pickupCode: '', pickupCode: '',
pickupCodeContext: null, pickupCodeContext: null,
pickupCodeSubmitting: false, pickupCodeSubmitting: false,
@ -562,7 +566,7 @@
return '已设置范围,但当前离线,系统不会派单' return '已设置范围,但当前离线,系统不会派单'
} }
if (!this.zhipaiCheck) { if (!this.zhipaiCheck) {
return '已上线,未开启自动派单,系统不会派单' return '已上线,未开启指派接单,系统不会派单'
} }
if (this.activeRuleCount == 0) { if (this.activeRuleCount == 0) {
return '已上线,但还没有勾选参与派单的路线' return '已上线,但还没有勾选参与派单的路线'
@ -613,6 +617,15 @@
} }
}, },
methods: { methods: {
getCurrentRegionId() {
try {
const area = uni.getStorageSync('area')
if (!area) return ''
return (typeof area == 'string' ? JSON.parse(area) : area).regionId || ''
} catch (e) {
return ''
}
},
getPickupPictures(item) { getPickupPictures(item) {
const pictures = item && item.getPictures const pictures = item && item.getPictures
if (!pictures) return [] if (!pictures) return []
@ -642,11 +655,12 @@
} }
uni.setStorageSync('deliveryStatusCounts', this.deliveryStatusCounts) uni.setStorageSync('deliveryStatusCounts', this.deliveryStatusCounts)
}, },
syncDeliveryStatusCountFromPage(total) { syncDeliveryStatusCountFromPage(total, status) {
const count = Number(total) || 0 const count = Number(total) || 0
if (this.searchForm.status == 1) { const currentStatus = status || this.searchForm.status
if (currentStatus == 1) {
this.deliveryStatusCounts.daiqu = count this.deliveryStatusCounts.daiqu = count
} else if (this.searchForm.status == 2) { } else if (currentStatus == 2) {
this.deliveryStatusCounts.daisong = count this.deliveryStatusCounts.daisong = count
} }
uni.setStorageSync('deliveryStatusCounts', this.deliveryStatusCounts) uni.setStorageSync('deliveryStatusCounts', this.deliveryStatusCounts)
@ -681,6 +695,14 @@
urls: [url] urls: [url]
}); });
}, },
previewPickupPicture(item, index) {
const urls = this.getPickupPictures(item);
if (urls.length === 0) return;
uni.previewImage({
current: urls[index] || urls[0],
urls: urls
});
},
ensureLogin() { ensureLogin() {
const token = uni.getStorageSync('hiver_token') const token = uni.getStorageSync('hiver_token')
if (token && typeof token === 'string' && token.trim() && token !== 'null' && token !== 'undefined') { if (token && typeof token === 'string' && token.trim() && token !== 'null' && token !== 'undefined') {
@ -720,11 +742,12 @@
this.isOnLine = uni.getStorageSync('worker').isOnLine this.isOnLine = uni.getStorageSync('worker').isOnLine
this.zhipaiCheck = uni.getStorageSync('worker').getPushOrder == 1 ? true : false this.zhipaiCheck = uni.getStorageSync('worker').getPushOrder == 1 ? true : false
if (uni.getStorageSync('area')) { if (uni.getStorageSync('area')) {
this.searchForm.regionId = JSON.parse(uni.getStorageSync('area')).regionId; this.searchForm.regionId = this.getCurrentRegionId();
} }
if (uni.getStorageSync('worker')) { if (uni.getStorageSync('worker')) {
this.searchForm.workerId = uni.getStorageSync('worker').workerId this.searchForm.workerId = uni.getStorageSync('worker').workerId
} }
this.searchForm.pageNum = 1
this.$forceUpdate() this.$forceUpdate()
this.loadWorkerRules() this.loadWorkerRules()
this.getDelivery() this.getDelivery()
@ -761,11 +784,11 @@
return return
} }
const area = uni.getStorageSync('area') ? JSON.parse(uni.getStorageSync('area')) : {} const area = uni.getStorageSync('area') ? JSON.parse(uni.getStorageSync('area')) : {}
this.NB.sendRequest("/worker/admin/add", { this.NB.sendRequest("/auth/getShopByUser", {
userId: uni.getStorageSync('id'), userId: uni.getStorageSync('id'),
isChangeArea: 1, isChangeArea: 1,
region: area.regionId region: area.regionId
}, false, 'POST', 'application/x-www-form-urlencoded').then((res) => { }, false, 'post', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) { if (res.code == 200) {
if (res.result != null) { if (res.result != null) {
uni.setStorageSync('worker', res.result) uni.setStorageSync('worker', res.result)
@ -779,6 +802,7 @@
title: res.message, title: res.message,
icon: 'none' icon: 'none'
}) })
} }
uni.hideLoading() uni.hideLoading()
}) })
@ -793,8 +817,9 @@
loadWorkerRules(openAfterLoad) { loadWorkerRules(openAfterLoad) {
const worker = uni.getStorageSync('worker') const worker = uni.getStorageSync('worker')
if (!worker || !worker.workerId) return if (!worker || !worker.workerId) return
const regionId = this.getCurrentRegionId()
let that = this let that = this
this.NB.sendRequest("/app/workerRelaPrice/getByWorkerId?workerId=" + worker.workerId, {}, false, 'GET', 'application/x-www-form-urlencoded').then((res) => { this.NB.sendRequest("/app/workerRelaPrice/getByWorkerId?workerId=" + worker.workerId + "&regionId=" + regionId, {}, false, 'get', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) { if (res.code == 200) {
let list = res.result && res.result.workerRelaPriceList ? res.result.workerRelaPriceList : [] let list = res.result && res.result.workerRelaPriceList ? res.result.workerRelaPriceList : []
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
@ -826,10 +851,10 @@
success: (res) => { success: (res) => {
that.latitude = res.latitude; that.latitude = res.latitude;
that.longitude = res.longitude; that.longitude = res.longitude;
this.NB.sendRequest("/worker/admin/editLocation", { this.NB.sendRequest('/worker/admin/editLocation', {
workerId: item.workerId, workerId: item.workerId,
geolocation: that.latitude + ',' + that.longitude geolocation: that.latitude + ',' + that.longitude
}, false, 'POST', 'application/x-www-form-urlencoded').then((res) => {}) }, false, 'post', 'application/x-www-form-urlencoded').then((res) => {})
} }
}); });
@ -902,31 +927,40 @@
getDelivery() { getDelivery() {
if (!this.ensureLogin()) return if (!this.ensureLogin()) return
let that = this let that = this
const requestId = ++that.deliveryRequestId
const requestForm = Object.assign({}, that.searchForm)
const requestStatus = requestForm.status
const requestPageNum = Number(requestForm.pageNum) || 1
that.isLoadingPage = true; that.isLoadingPage = true;
this.NB.sendRequest("/mall/delivery/pagebyworker", this.searchForm, false, 'POST', 'application/json').then((res) => { that.loadStatus = 'loading';
this.NB.sendRequest("/mall/delivery/pagebyworker", requestForm, false, 'post', 'application/json').then((res) => {
if (requestId != that.deliveryRequestId) return
that.isLoadingPage = false; that.isLoadingPage = false;
that.loadStatus = 'nomore';
if (res.code == 200) { if (res.code == 200) {
that.syncDeliveryStatusCountFromPage(res.result && res.result.total) const result = res.result || {}
if (this.searchForm.status == 1) { const records = Array.isArray(result.records) ? result.records : []
if (that.searchForm.pageNum == 1) { that.syncDeliveryStatusCountFromPage(result.total, requestStatus)
that.deliveryItem1 = res.result.records; if (requestStatus == 1) {
if (requestPageNum == 1) {
that.deliveryItem1 = records;
} else { } else {
that.deliveryItem1 = [...that.deliveryItem1, ...res.result.records] that.deliveryItem1 = [...that.deliveryItem1, ...records]
} }
that.pageData = that.deliveryItem1 that.pageData = that.deliveryItem1
} else { } else {
if (that.searchForm.pageNum == 1) { if (requestPageNum == 1) {
that.deliveryItem = res.result.records; that.deliveryItem = records;
} else { } else {
that.deliveryItem = [...that.deliveryItem, ...res.result.records] that.deliveryItem = [...that.deliveryItem, ...records]
} }
that.pageData = that.deliveryItem that.pageData = that.deliveryItem
} }
that.totalPages = res.result.pages; // pages = that.totalPages = Number(result.pages) || 1; // pages =
that.loadStatus = requestPageNum >= that.totalPages ? 'nomore' : 'more';
that.$forceUpdate(); that.$forceUpdate();
} else { } else {
that.loadStatus = 'more';
uni.showToast({ uni.showToast({
title: res.message, title: res.message,
icon: 'none' icon: 'none'
@ -938,11 +972,14 @@
uni.hideLoading(); uni.hideLoading();
} }
}).catch((res) => { }).catch((res) => {
if (requestId != that.deliveryRequestId) return
that.isLoadingPage = false; that.isLoadingPage = false;
that.loadStatus = 'more';
if (that.refreshLoading) { if (that.refreshLoading) {
that.finishRefreshLoading() that.finishRefreshLoading()
} }
}); });
}, },
// //
largeImg(img) { largeImg(img) {
@ -963,7 +1000,9 @@
productDetail(item) { productDetail(item) {
const goodsList = item.goodsList || item.mallOrderGoodsList || item.orderGoodsList || []; const goodsList = item.goodsList || item.mallOrderGoodsList || item.orderGoodsList || [];
this.productData = goodsList; this.productData = goodsList;
this.$refs.productPopup.open() if(item.deliveryType != undefined && item.deliveryType == 1){
this.$refs.productPopup.open()
}
}, },
buchong() { buchong() {
this.$refs.carPopup.close() this.$refs.carPopup.close()
@ -1012,12 +1051,13 @@
} }
let submitData = { let submitData = {
userId: uni.getStorageSync('id'), userId: uni.getStorageSync('id'),
regionId: this.getCurrentRegionId(),
workerRelaPriceList: this.selectRuleList, workerRelaPriceList: this.selectRuleList,
getPushOrder: this.zhipaiCheck ? 1 : 0 getPushOrder: this.zhipaiCheck ? 1 : 0
}; };
if (!this.ensureLogin()) return if (!this.ensureLogin()) return
let that = this; let that = this;
this.NB.sendRequest("/app/workerRelaPrice/batchUpdate", submitData, false, 'post', 'application/x-www-form-urlencoded').then((res) => { this.NB.sendRequest("/app/workerRelaPrice/batchUpdate", submitData, false, 'post', 'application/json').then((res) => {
uni.hideLoading(); uni.hideLoading();
if (res.code == 200) { if (res.code == 200) {
let worker = uni.getStorageSync('worker') || {}; // let worker = uni.getStorageSync('worker') || {}; //
@ -1067,10 +1107,10 @@
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '您编辑了接单规则,开启后才会接到路线订单,需要现在开启吗?', content: '您编辑了接单规则,开启后才会接到路线订单,需要现在开启吗?',
confirmText: '取消', confirmText: '确认',
cancelText: '确认', cancelText: '取消',
success: (res) => { success: (res) => {
if (res.cancel) { if (res.confirm) {
this.openPopup() this.openPopup()
} }
} }
@ -1149,7 +1189,7 @@
deliveryId: context.item.id, deliveryId: context.item.id,
workerId: context.item.workerId, workerId: context.item.workerId,
pickupCode: this.pickupCode pickupCode: this.pickupCode
}, false, 'POST', 'application/x-www-form-urlencoded').then((res) => { }, false, 'post', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) { if (res.code == 200) {
this.pageData.splice(context.index, 1) this.pageData.splice(context.index, 1)
this.decreaseDeliveryStatusCount(2) this.decreaseDeliveryStatusCount(2)
@ -1173,6 +1213,7 @@
}).catch(() => { }).catch(() => {
this.pickupCodeSubmitting = false this.pickupCodeSubmitting = false
}) })
}, },
changeStatus(index, item, status) { changeStatus(index, item, status) {
if (!this.ensureLogin()) return if (!this.ensureLogin()) return
@ -1207,7 +1248,7 @@
regionId: regionId, regionId: regionId,
deliveryId: item.id, deliveryId: item.id,
workerId: item.workerId workerId: item.workerId
}, false, 'POST', 'application/x-www-form-urlencoded').then((res) => { }, false, 'post', 'application/x-www-form-urlencoded').then((res) => {
if (status == 3) { if (status == 3) {
that.$delete(that.completingDeliveryIds, item.id) that.$delete(that.completingDeliveryIds, item.id)
} }
@ -1238,6 +1279,7 @@
that.$delete(that.completingDeliveryIds, item.id) that.$delete(that.completingDeliveryIds, item.id)
} }
}); });
}, },
checkTab1(type) { checkTab1(type) {
if (!this.ensureWorkerRegistered()) return if (!this.ensureWorkerRegistered()) return
@ -1313,7 +1355,7 @@
} }
this.NB.sendRequest(url, { this.NB.sendRequest(url, {
id: worker.workerId id: worker.workerId
}, false, 'POST', 'application/x-www-form-urlencoded').then((res) => { }, false, 'post', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) { if (res.code == 200) {
let worker = uni.getStorageSync('worker') || {}; // let worker = uni.getStorageSync('worker') || {}; //
worker.isOnLine = value; worker.isOnLine = value;
@ -1332,23 +1374,6 @@
}) })
this.isArea = !this.isArea this.isArea = !this.isArea
this.$forceUpdate() this.$forceUpdate()
},
ceshi(e) {
if (e.detail.code) {
// code
this.NB.sendRequest("/social/wechat/getPhone", {
code: e.detail.code
}, false, 'POST', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) {
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
}
} }
} }
} }
@ -1695,7 +1720,7 @@
} }
.box1 { .box1 {
width: 95%; width: 100%;
margin: 20rpx auto 20rpx; margin: 20rpx auto 20rpx;
background: #fff; background: #fff;
border-radius: 20rpx; border-radius: 20rpx;
@ -1764,6 +1789,19 @@
white-space: normal; white-space: normal;
} }
.delivery-remark {
margin-top: 12rpx;
padding: 18rpx 20rpx;
border-radius: 20rpx;
background: rgba(247, 248, 248, 0.72);
color: #33433f;
font-size: 26rpx;
font-weight: 600;
line-height: 40rpx;
word-break: break-all;
overflow-wrap: break-word;
}
.express-info-card { .express-info-card {
margin-top: 16rpx; margin-top: 16rpx;
padding: 16rpx 18rpx; padding: 16rpx 18rpx;
@ -1816,10 +1854,6 @@
.express-picture-list { .express-picture-list {
margin-top: 14rpx; margin-top: 14rpx;
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12rpx;
} }
.express-picture-title { .express-picture-title {
@ -1833,9 +1867,24 @@
font-weight: 800; font-weight: 800;
} }
.express-picture-scroll {
width: 100%;
margin-top: 12rpx;
white-space: nowrap;
}
.express-picture-track {
display: inline-flex;
align-items: center;
gap: 14rpx;
padding-right: 8rpx;
}
.express-picture { .express-picture {
width: 112rpx; width: 156rpx;
height: 112rpx; height: 156rpx;
flex-shrink: 0;
margin-right: 14rpx;
border-radius: 14rpx; border-radius: 14rpx;
background: #eef4f1; background: #eef4f1;
border: 1px solid rgba(0, 35, 28, 0.08); border: 1px solid rgba(0, 35, 28, 0.08);

Loading…
Cancel
Save