diff --git a/package1/address/addressList.vue b/package1/address/addressList.vue index 63c69e2..4f8d3d0 100644 --- a/package1/address/addressList.vue +++ b/package1/address/addressList.vue @@ -109,6 +109,8 @@ addressList: [], areaList: [], areaTitleList: [], + areaListLoaded: false, + areaListLoading: false, areaTitleInput: '', areaSearchInput: '', addressForm: { @@ -125,7 +127,6 @@ }, created() { this.getAddressList(); - this.getAreaList(); }, computed: { filteredAreaTitleList() { @@ -166,14 +167,20 @@ } }, getAreaList() { + if (this.areaListLoaded || this.areaListLoading) return Promise.resolve(this.areaList); + this.areaListLoading = true; let that = this; - that.tui.request("/app/shopArea/getByParentId/"+JSON.parse(uni.getStorageSync('area')).id, "GET", {}, false, true).then((res) => { + return that.tui.request("/app/shopArea/getByParentId/"+JSON.parse(uni.getStorageSync('area')).id, "GET", {}, false, true).then((res) => { if (res.code == 200 && res.result) { that.$emit('shopAreaList',res.result) that.areaList = res.result; that.areaTitleList = res.result.map(item => item.title); + that.areaListLoaded = true; } - }).catch(() => {}); + return that.areaList; + }).catch(() => {}).finally(() => { + that.areaListLoading = false; + }); }, selectAddress(item) { this.$emit('selectAddress', item); @@ -191,6 +198,7 @@ }; this.areaTitleInput = ''; this.areaSearchInput = ''; + this.getAreaList(); this.$refs.addBookPopup.open('bottom'); }, openEdit(item) { @@ -204,6 +212,7 @@ receiverPhone: item.receiverPhone, isDefault: item.isDefault || 0 }; + this.getAreaList(); let match = this.areaList.find(a => a.id === item.areaId); this.areaTitleInput = match ? match.title : (item.areaName || ''); this.areaSearchInput = ''; @@ -211,6 +220,7 @@ }, openAreaPopup() { this.areaSearchInput = this.areaTitleInput; + this.getAreaList(); this.$refs.areaPopup.open(); }, closeAreaPopup() { diff --git a/package1/buyFood/buyFood.vue b/package1/buyFood/buyFood.vue index a488f07..3a6dac2 100644 --- a/package1/buyFood/buyFood.vue +++ b/package1/buyFood/buyFood.vue @@ -111,6 +111,18 @@ + + + + + + + 商家自配送 + + + {{shopDeliveryText}} + + @@ -321,9 +333,9 @@ - + - @@ -560,6 +572,7 @@ isPaymentSuccessGroupInitiate: false, availableCoupons: [], selectedCoupon: null, + addressBookVisible: false, freeOrderEffectVisible: false, freeOrderAmount: '0.00' } @@ -605,6 +618,10 @@ this.isPack = 0; this.totalPackageFee = 0; } + if (this.supportShopDelivery) { + this.selected = 'shopDelivery'; + } + this.fetchCoupons(); }, computed: { goodsAmountCalc() { @@ -626,6 +643,7 @@ return this.orderScene === 'storeGroup' || (this.groupItem && this.groupItem.orderScene === 'storeGroup') || this.shopItem.merchantType == 2; }, highFloorFeeCalc() { + if (this.selected === 'shopDelivery') return 0; if (this.selected === 'zhiding' && this.assignedWorker) { let hFee = parseFloat(this.assignedWorker.highFloorFee || 0); if (hFee > 0 && this.formData.address && parseInt(this.formData.address.floor) > 3) { @@ -655,7 +673,9 @@ if (isJoiningFaceToFace) return 0; // Front-end doesn't know exact fee, relies on backend after order creation let commission = 0; - if (this.selected === 'zhiding') { + if (this.selected === 'shopDelivery') { + commission = parseFloat(this.shopItem.orderBkge || 0); + } else if (this.selected === 'zhiding') { if (!this.assignedWorker) return 0; commission = parseFloat(this.assignedWorker.orderBkge || 3); } else { @@ -690,20 +710,36 @@ } }, deliveryDurationMinutes() { + if (this.selected === 'shopDelivery') { + const selfDeliveryDuration = Number(this.shopItem.shopDeliveryDuration); + const cookingTime = Number(this.shopItem.shopTakeaway && this.shopItem.shopTakeaway.cookingTime ? this.shopItem.shopTakeaway.cookingTime : 0); + const validCookingTime = isNaN(cookingTime) || cookingTime < 0 ? 0 : cookingTime; + return isNaN(selfDeliveryDuration) || selfDeliveryDuration <= 0 ? validCookingTime + 30 : validCookingTime + selfDeliveryDuration; + } const value = Number(this.shopItem.groupDeliveryTime); return isNaN(value) || value < 25 ? 30 : value; + }, + supportShopDelivery() { + return this.shopItem && this.shopItem.supportShopDelivery == 1 && this.shopItem.workerId; + }, + shopDeliveryText() { + const fee = parseFloat(this.shopItem.orderBkge || 0); + const feeText = fee > 0 ? `¥${fee.toFixed(1)}` : '免配送费'; + const locationText = this.shopItem.shopDeliveryLocation == 1 ? '送到宿舍' : '送到楼下'; + const workerText = this.shopItem.workerName ? ` ${this.shopItem.workerName}` : ''; + return `${feeText} ${locationText}${workerText}`; } }, watch: {}, onShow() { this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.initAddress() - //this.fetchCoupons(); this.updateImmediateTimeStr(); uni.$on('updateDeliveryWorker', (worker) => { this.assignedWorker = worker; this.selected = 'zhiding'; + this.refreshDeliveryTimeByModeChange(); }); }, onShareAppMessage(res) { @@ -800,6 +836,13 @@ endTime.setMinutes(endTime.getMinutes() + this.deliveryDurationMinutes); this.immediateTimeStr = `${this.formatClockTime(startTime)}-${this.formatClockTime(endTime)}`; }, + refreshDeliveryTimeByModeChange() { + this.updateImmediateTimeStr(); + if (this.formData.isImmediately === false) { + this.formData.deliveryTime = ''; + this.generateDeliveryTimes(); + } + }, formatClockTime(date) { return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`; }, @@ -834,12 +877,19 @@ this.formData.address = address; uni.setStorageSync('selectedAddress', address); this.$refs.bookPopup.close(); + this.addressBookVisible = false; }, handleSyncAddress(address) { this.formData.address = address; }, closeAddressBook() { this.$refs.bookPopup.close(); + this.addressBookVisible = false; + }, + onAddressPopupChange(e) { + if (!e.show) { + this.addressBookVisible = false; + } }, getSpecDisplayString(specs) { if (!specs) return ''; @@ -878,6 +928,13 @@ this.$refs.warnPopup.open(); return; } + if (this.isPaotui && this.selected === 'shopDelivery' && !this.supportShopDelivery && !isJoiningFaceToFace) { + uni.showToast({ + title: '商家自配送配置不完整', + icon: 'none' + }) + return; + } this.submitOrderToBackend(); }, goDetail() { @@ -923,7 +980,10 @@ this.$refs.couponPopup.close(); }, openAddressBook() { - this.$refs.bookPopup.open('bottom') + this.addressBookVisible = true; + this.$nextTick(() => { + this.$refs.bookPopup.open('bottom') + }); }, checkTime(type) { if (type === this.formData.isImmediately) { @@ -945,7 +1005,11 @@ if (this.selected == 'buzhiding') { this.formData.peisongyuan = ""; this.assignedWorker = null; + } else if (this.selected == 'shopDelivery') { + this.formData.peisongyuan = ""; + this.assignedWorker = null; } + this.refreshDeliveryTimeByModeChange(); }, wxPayment() { let that = this; @@ -1154,14 +1218,24 @@ payload.groupParam = { targetMembers: parseInt(this.groupItem.groupRule.groupCount), isFaceToFace: this.groupItem.isFaceToFace ? 1 : 0, - selfCommission: this.selected === 'buzhiding' ? parseFloat(this.customCommission || 0) : + selfCommission: this.selected === 'shopDelivery' ? parseFloat(this.shopItem.orderBkge || 0) : (this.selected === 'buzhiding' ? parseFloat(this.customCommission || 0) : null + ) }; } } if (this.isPaotui && !isJoiningFaceToFace) { - if (this.selected === 'zhiding' && this.assignedWorker) { + if (this.selected === 'shopDelivery') { + payload.shopDelivery = 1; + payload.workerParam = { + workerId: this.shopItem.workerId, + workerPhone: this.shopItem.workerPhone, + workerName: this.shopItem.workerName, + orderBkge: parseFloat(this.shopItem.orderBkge || 0) + }; + } else if (this.selected === 'zhiding' && this.assignedWorker) { + payload.shopDelivery = 0; payload.workerParam = { workerId: this.assignedWorker.workerId, workerPhone: this.assignedWorker.mobile, @@ -1169,6 +1243,7 @@ orderBkge: parseFloat(this.assignedWorker.orderBkge || 0) + this.highFloorFeeCalc }; } else if (this.selected === 'buzhiding') { + payload.shopDelivery = 0; payload.workerParam = { orderBkge: parseFloat(this.customCommission || 0) }; diff --git a/package1/index/deliveryPersonList.vue b/package1/index/deliveryPersonList.vue index ba02f6e..0a079a7 100644 --- a/package1/index/deliveryPersonList.vue +++ b/package1/index/deliveryPersonList.vue @@ -51,7 +51,7 @@ alt="" style="width: 140rpx;height: 32rpx;margin-top: 18rpx;" v-if="worker.rebateAmount > 0" /> - + ¥{{worker.orderBkge}} @@ -83,10 +83,13 @@ - + 备注:{{worker.remark || '无'}} - + + {{formatDeliveryLocation(worker.deliveryLocation)}} + + 查看位置 @@ -187,6 +190,9 @@ this.latitude = this.markers[0].latitude this.longitude = this.markers[0].longitude }, + formatDeliveryLocation(value) { + return value == 1 ? '送到宿舍门口' : '送上楼' + }, getShopList() { this.loadStatus = 'loading'; // Fake request to our new endpoint @@ -398,6 +404,7 @@ height: 70rpx; line-height: 70rpx; padding-right: 20rpx; + align-items: center; } .man-name { @@ -450,21 +457,61 @@ } .man-mank { - line-height: 40rpx; + line-height: 44rpx; color: #777; font-weight: 700; display: flex; + align-items: center; } - .shop-menu-purchase { - display: flex; - background: rgba(255, 57, 57, 0.1); - height: 36rpx; - line-height: 36rpx; - padding: 0 0 0 4rpx; - border-radius: 8rpx; + .worker-remark { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .delivery-location { + height: 44rpx; + line-height: 44rpx; + padding: 0 18rpx; + margin-right: 20rpx; + border-radius: 10rpx; + background: rgba(166, 255, 234, 0.22); + border: 1rpx solid rgba(166, 255, 234, 1); + color: #00231C; + font-size: 22rpx; font-weight: 700; - margin-top: 10rpx; + white-space: nowrap; + } + + .location-btn { + height: 44rpx; + line-height: 44rpx; + padding: 0 18rpx; + border-radius: 10rpx; + background: rgba(247, 248, 248, 0.9); + border: 1rpx solid #E7E7E7; color: #777; + font-size: 22rpx; + white-space: nowrap; + } + + .worker-price { + display: flex; + align-items: center; + justify-content: center; + min-width: 118rpx; + height: 58rpx; + line-height: 58rpx; + padding: 0 18rpx; + border-radius: 12rpx; + background: linear-gradient(90deg, rgba(227, 255, 150, 0.55), rgba(166, 255, 234, 0.55)); + border: 2rpx solid rgba(166, 255, 234, 1); + font-weight: 700; + font-size: 32rpx; + color: #00231C; + box-shadow: 0 4rpx 12rpx rgba(0, 35, 28, 0.08); } \ No newline at end of file diff --git a/package1/order/orderDetail.vue b/package1/order/orderDetail.vue index cfb9ced..4c12122 100644 --- a/package1/order/orderDetail.vue +++ b/package1/order/orderDetail.vue @@ -132,8 +132,8 @@ 待支付 - 等待配送员接单 - 配送员已接单 + {{orderDetail.shopDelivery == 1 ? '等待商家配送接单' : '等待配送员接单'}} + {{orderDetail.shopDelivery == 1 ? '商家配送已接单' : '配送员已接单'}} 待消费 配送员已取货 订单已完成 @@ -207,10 +207,10 @@ @tap="makeMeal" style="background: rgba(0, 35, 28, 1);color:rgba(166, 255, 234, 1);"> 立即备餐 - + 增加配送佣金 - + 改派配送员 - + @@ -387,9 +388,12 @@ commissionInputValue: '', shopArea: [], kuaidiAreaList: [], + shopAreaLoaded: false, + shopAreaLoading: false, selectedPickupArea: null, addressSelectMode: 'put', // 'put' | 'get' isBookPopupOpen: false, + addressBookVisible: false, formData: { address: null, // 收货地址 putArea pickupAddress: null, // 取货地址 getArea (跑腿模式) @@ -539,20 +543,29 @@ this.$refs.couponPopup.close(); }, getShopArea(){ + if (this.shopAreaLoaded || this.shopAreaLoading) return Promise.resolve(this.shopArea); + this.shopAreaLoading = true; let that = this let areaStorage = uni.getStorageSync('area'); - if(!areaStorage) return; - that.tui.request("/app/shopArea/getByParentId/"+JSON.parse(areaStorage).id, "GET", {}, false, true).then((res) => { + if(!areaStorage) { + this.shopAreaLoading = false; + return Promise.resolve([]); + } + return that.tui.request("/app/shopArea/getByParentId/"+JSON.parse(areaStorage).id, "GET", {}, false, true).then((res) => { if (res.code == 200) { if(res.result != null){ that.shopArea = res.result; that.kuaidiAreaList = that.shopArea.filter(item => item.isCanteen === 2); + that.shopAreaLoaded = true; } } else { that.tui.toast(res.message) return } - }).catch((res) => {}) + return that.shopArea; + }).catch((res) => {}).finally(() => { + that.shopAreaLoading = false; + }) }, initAddress() { let cachedAddress = uni.getStorageSync('selectedAddress'); @@ -576,10 +589,21 @@ openAddressBook(mode) { this.addressSelectMode = mode; this.isBookPopupOpen = true; - this.$refs.bookPopup.open('bottom'); + this.addressBookVisible = true; + this.$nextTick(() => { + this.$refs.bookPopup.open('bottom'); + }); }, onBookPopupChange(e) { this.isBookPopupOpen = !!e.show; + if (!e.show) { + this.addressBookVisible = false; + } + }, + closeAddressBook() { + this.isBookPopupOpen = false; + this.addressBookVisible = false; + this.$refs.bookPopup.close(); }, handleSelectAddress(address) { if (this.addressSelectMode === 'put') { @@ -589,6 +613,7 @@ this.formData.pickupAddress = address; } this.isBookPopupOpen = false; + this.addressBookVisible = false; this.$refs.bookPopup.close(); }, updateArea(v){ @@ -601,6 +626,7 @@ } }, openKuaidiPicker() { + this.getShopArea(); this.$refs.kuaidiPickerPopup.open(); }, selectKuaidiArea(item) {