|
|
|
@ -111,6 +111,18 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="delivery-options"> |
|
|
|
<view class="delivery-option" v-if="supportShopDelivery"> |
|
|
|
<view class="delivery-choice"> |
|
|
|
<view class="radio-check" v-if="selected === 'shopDelivery'"> |
|
|
|
<uni-icons type="checkmarkempty" size="12"></uni-icons> |
|
|
|
</view> |
|
|
|
<view class="radio-no-check" @tap="checkVoucher('shopDelivery')" v-else></view> |
|
|
|
商家自配送 |
|
|
|
</view> |
|
|
|
<view class="worker-entry" @tap.stop> |
|
|
|
{{shopDeliveryText}} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="delivery-option"> |
|
|
|
<view class="delivery-choice"> |
|
|
|
<view class="radio-check" v-if="selected === 'buzhiding'"> |
|
|
|
@ -321,9 +333,9 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<!-- 地址簿弹出层 --> |
|
|
|
<uni-popup ref="bookPopup" background-color="#fff"> |
|
|
|
<uni-popup ref="bookPopup" background-color="#fff" @change="onAddressPopupChange"> |
|
|
|
<view class="book-popup-content"> |
|
|
|
<address-list @selectAddress="handleSelectAddress" @syncAddress="handleSyncAddress" |
|
|
|
<address-list v-if="addressBookVisible" @selectAddress="handleSelectAddress" @syncAddress="handleSyncAddress" |
|
|
|
@close="closeAddressBook"></address-list> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
@ -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) |
|
|
|
}; |
|
|
|
|