diff --git a/package1/buyFood/buyFood.vue b/package1/buyFood/buyFood.vue index 0729b71..66d980a 100644 --- a/package1/buyFood/buyFood.vue +++ b/package1/buyFood/buyFood.vue @@ -107,17 +107,17 @@ - + 配送方式 - 送到宿舍由中转配送完成,送到大门由商家自配送完成 + {{socialTransferDeliveryEnabled ? '送到宿舍由中转配送完成,送到大门由商家自配送完成' : '当前仅支持送到大门,由商家自配送完成'}} - + @@ -141,6 +141,17 @@ {{socialGateDeliveryText}} + + 请选择送达地点 + 商家暂未设置送达地点 + + + + + + {{item.locationName}} + + @@ -712,7 +723,14 @@ deliverySwitchChecked: false, deliverySwitchLoading: false, areaKind: 1, - socialDeliveryDestination: 'dorm' + socialDeliveryDestination: 'dorm', + transferDeliveryEnabled: 1, + transferDeliverySwitchChecked: false, + gateLocations: [], + gateLocationLoaded: false, + gateLocationShopId: '', + selectedGateLocationId: '', + selectedGateLocationName: '' } }, components: { @@ -776,6 +794,9 @@ useSocialDeliveryChoice() { return this.isPaotui && this.isTargetSocialDeliveryRegion && !this.isStoreGroupOrder; }, + socialTransferDeliveryEnabled() { + return Number(this.transferDeliveryEnabled) !== 0; + }, goodsAmountCalc() { if (this.isGroupBuy && this.groupItem) { if(this.groupItem.item.moreBuyData){ @@ -975,6 +996,7 @@ this.updateImmediateTimeStr(); this.fetchBaseDeliveryFee(); this.fetchDeliverySwitch(); + this.fetchTransferDeliverySwitch(); let pendingWorker = uni.getStorageSync('pendingAssignWorker'); if (pendingWorker) { uni.removeStorageSync('pendingAssignWorker'); @@ -1251,6 +1273,96 @@ } return false; }, + fetchTransferDeliverySwitch() { + if (!this.isTargetSocialDeliveryRegion) return Promise.resolve(true); + const regionId = this.getCurrentRegionId(); + if (!regionId) { + this.transferDeliveryEnabled = 1; + this.transferDeliverySwitchChecked = true; + return Promise.resolve(true); + } + return this.tui.request('/app/shopArea/transferDeliverySwitch/get', 'GET', { + regionId: regionId + }, false, true).then((res) => { + if (res.code == 200 || res.success) { + this.transferDeliveryEnabled = res.result == null ? 1 : Number(res.result); + } else { + this.transferDeliveryEnabled = 1; + } + this.transferDeliverySwitchChecked = true; + this.syncSocialDestinationByTransferSwitch(); + return true; + }).catch(() => { + this.transferDeliveryEnabled = 1; + this.transferDeliverySwitchChecked = true; + this.syncSocialDestinationByTransferSwitch(); + return true; + }); + }, + syncSocialDestinationByTransferSwitch() { + if (!this.isTargetSocialDeliveryRegion || this.socialTransferDeliveryEnabled) { + if (this.useSocialDeliveryChoice && this.socialDeliveryDestination === 'gate') { + this.fetchGateLocations(); + } + return; + } + if (this.socialDeliveryDestination !== 'gate') { + this.socialDeliveryDestination = 'gate'; + this.assignedWorker = null; + if (this.useSocialDeliveryChoice) { + this.applySocialDeliveryDefaults(); + this.refreshDeliveryTimeByModeChange(); + } + } + if (this.useSocialDeliveryChoice) { + this.fetchGateLocations(); + } + }, + fetchGateLocations() { + if (!this.useSocialDeliveryChoice) return Promise.resolve([]); + const shopId = this.shopItem.id || this.shopItem.shopId; + if (!shopId) return Promise.resolve([]); + if (this.gateLocationLoaded && this.gateLocationShopId === String(shopId)) { + return Promise.resolve(this.gateLocations); + } + return this.tui.request('/app/shop/gateLocation/list', 'GET', { + shopId: shopId + }, false, true).then((res) => { + const list = (res.code == 200 || res.success) && Array.isArray(res.result) ? res.result : []; + this.gateLocations = list; + this.gateLocationShopId = String(shopId); + this.gateLocationLoaded = true; + if (this.selectedGateLocationId && !list.some(item => String(item.id) === String(this.selectedGateLocationId))) { + this.selectedGateLocationId = ''; + this.selectedGateLocationName = ''; + } + return list; + }).catch(() => { + this.gateLocationLoaded = false; + return []; + }); + }, + isGateLocationSelected(item) { + return !!item && String(this.selectedGateLocationId) === String(item.id); + }, + selectGateLocation(item) { + if (!item) return; + this.selectedGateLocationId = item.id; + this.selectedGateLocationName = item.locationName || ''; + }, + async ensureGateLocationSelected() { + if (!(this.useSocialDeliveryChoice && this.socialDeliveryDestination === 'gate')) return true; + await this.fetchGateLocations(); + if (!this.gateLocations.length) { + this.tui.toast('商家暂未设置送达地点'); + return false; + } + if (!this.selectedGateLocationName) { + this.tui.toast('请选择送达地点'); + return false; + } + return true; + }, fetchDeliverySwitch() { if (!this.shouldCheckDeliverySwitch()) return Promise.resolve(true); const regionId = this.getCurrentRegionId(); @@ -1319,7 +1431,13 @@ return; } this.isPaotui = true; + if (this.isTargetSocialDeliveryRegion && this.transferDeliverySwitchChecked && !this.socialTransferDeliveryEnabled) { + this.socialDeliveryDestination = 'gate'; + } this.applySocialDeliveryDefaults(); + if (this.useSocialDeliveryChoice && this.socialDeliveryDestination === 'gate') { + this.fetchGateLocations(); + } this.fetchCoupons(); }, switchToStoreMode() { @@ -1536,11 +1654,21 @@ return; } + if (this.isTargetSocialDeliveryRegion && this.transferDeliverySwitchChecked && !this.socialTransferDeliveryEnabled) { + this.socialDeliveryDestination = 'gate'; + } if (this.isSocialArea && this.isPaotui) { this.applySocialDeliveryDefaults(); } if (this.useSocialDeliveryChoice && !isJoiningFaceToFace) { + if (!this.transferDeliverySwitchChecked) { + await this.fetchTransferDeliverySwitch(); + } + if (!this.socialTransferDeliveryEnabled && this.socialDeliveryDestination !== 'gate') { + this.socialDeliveryDestination = 'gate'; + this.applySocialDeliveryDefaults(); + } if (this.socialDeliveryDestination === 'dorm' && this.shopItem.supportTransferDelivery != 1) { this.tui.toast('中转配送配置不完整,请联系商家'); return; @@ -1549,6 +1677,9 @@ this.tui.toast('商家自配送配置不完整,请联系商家'); return; } + if (this.socialDeliveryDestination === 'gate' && !(await this.ensureGateLocationSelected())) { + return; + } } if (this.isPaotui && this.selected === 'buzhiding' && !isJoiningFaceToFace) { @@ -1673,12 +1804,17 @@ this.refreshDeliveryTimeByModeChange(); }, checkSocialDeliveryDestination(type) { - if (type === this.socialDeliveryDestination) return; + if (!this.socialTransferDeliveryEnabled && type === 'dorm') return; + if (type === this.socialDeliveryDestination) { + if (type === 'gate') this.fetchGateLocations(); + return; + } this.socialDeliveryDestination = type; this.assignedWorker = null; this.applySocialDeliveryDefaults(); this.refreshDeliveryTimeByModeChange(); this.fetchCoupons(); + if (type === 'gate') this.fetchGateLocations(); }, wxPayment() { let that = this; @@ -1819,6 +1955,13 @@ } return name; }, + buildSubmitRemark() { + const remark = this.remark || ''; + if (this.useSocialDeliveryChoice && this.socialDeliveryDestination === 'gate' && this.selectedGateLocationName) { + return remark ? remark + '-' + this.selectedGateLocationName : this.selectedGateLocationName; + } + return remark; + }, submitOrderToBackend() { if (this.isCreatingOrder) return; this.isCreatingOrder = true; @@ -1865,7 +2008,7 @@ deliveryType: deliveryType, isPack: this.isStoreGroupOrder ? 0 : (this.isPaotui ? 1 : this.isPack), packageFee: this.packageFee, - remark: this.remark, + remark: this.buildSubmitRemark(), items: items, receiverName: this.formData.address ? this.formData.address.receiverName : '', receiverPhone: this.formData.address ? this.formData.address.phone : '', @@ -2749,6 +2892,39 @@ box-shadow: 0 12rpx 26rpx rgba(11, 155, 115, 0.2); } + .gate-location-panel { + margin-top: 18rpx; + padding-top: 18rpx; + border-top: 1rpx solid #f0f3f2; + } + + .gate-location-title { + margin-bottom: 12rpx; + color: #66716d; + font-size: 24rpx; + font-weight: 700; + line-height: 36rpx; + } + + .gate-location-empty { + color: #ff5722; + font-size: 24rpx; + line-height: 40rpx; + } + + .gate-location-item { + display: flex; + align-items: center; + min-height: 64rpx; + font-size: 28rpx; + font-weight: 700; + line-height: 40rpx; + } + + .gate-location-item + .gate-location-item { + margin-top: 8rpx; + } + .worker-entry { width: 50%; color: $muted;