diff --git a/package2/group/groupBuySingle.vue b/package2/group/groupBuySingle.vue index 75e6d33..e53d2ce 100644 --- a/package2/group/groupBuySingle.vue +++ b/package2/group/groupBuySingle.vue @@ -672,7 +672,7 @@ 立即出餐 - {{nowMake === false ? '选择用餐时间,系统会在用餐前30分钟通知商家并打印小票' : '拼团成功后立即出餐'}} + {{nowMake === true ? '请选择到店用餐时间' : (nowMake === false ? '可到店后再安排出餐' : '请选择是否现在备餐')}} @@ -688,7 +688,7 @@ 否 - + 用餐时间 {{pickupTime || '选择时间 >'}} @@ -725,7 +725,7 @@ - 确认付款{{nowMake === true && groupdeliveryType == 2 && !isStoreGroupOrder ? '-即刻出餐' : ''}} + 确认付款 @@ -738,7 +738,7 @@ 是否立即出餐 请选择是否需要商家在成团后立即出餐。 - 选择“否”后需要预约用餐时间,系统会在用餐前30分钟通知商家并打印小票 + 选择“是”后请选择到店用餐时间,成团后商家会按这个时间为你备餐。选择“否”可到店后再安排出餐 否 @@ -746,6 +746,19 @@ + + + 确认用餐时间 + {{pendingPickupTime}} + + 确认后,成团后商家会按这个时间为你备餐 + + + 取消 + 确认 + + + @@ -927,6 +940,7 @@ productId: '', nowMake: null, pickupTime: '', + pendingPickupTime: '', pickupTimeContent: [], isPack: 0, productItem: [], @@ -1525,8 +1539,10 @@ checkNowMake(value) { this.nowMake = value; if (value === false) { - this.openPickupTimePicker(); + this.pickupTime = ''; + return; } + this.openPickupTimePicker(); }, openNowMakePopup() { this.$refs.nowMakePopup.open('center'); @@ -1535,30 +1551,44 @@ this.nowMake = value; this.$refs.nowMakePopup.close(); this.$nextTick(() => { - if (value === false) { + if (value === true) { this.openPickupTimePicker(); return; } + this.pickupTime = ''; this.wxPayment(); }); }, needsPickupAppointment() { - return this.groupdeliveryType == 2 && !this.isStoreGroupOrder && this.nowMake === false; + return this.groupdeliveryType == 2 && !this.isStoreGroupOrder && this.nowMake === true; }, openPickupTimePicker() { this.generatePickupTimes(); this.$refs.pickupTimeModel.open(); }, pickupTimeCallback(val) { - this.pickupTime = val.timestr; + this.pendingPickupTime = val.timestr; this.$refs.pickupTimeModel.close(); + this.$nextTick(() => { + this.$refs.pickupTimeConfirmPopup.open('center'); + }); + }, + cancelPickupTimeConfirm() { + this.pendingPickupTime = ''; + this.$refs.pickupTimeConfirmPopup.close(); + }, + confirmPickupTime() { + if (!this.pendingPickupTime) return; + this.pickupTime = this.pendingPickupTime; + this.pendingPickupTime = ''; + this.$refs.pickupTimeConfirmPopup.close(); }, getPickupLeadMinutes() { const cookingTime = Number(this.shopItem.shopTakeaway && this.shopItem.shopTakeaway.cookingTime ? this.shopItem.shopTakeaway.cookingTime : 0); return !isNaN(cookingTime) && cookingTime > 0 ? cookingTime : 30; }, getNextPickupSlot(date) { - const interval = 20; + const interval = 10; const slot = new Date(date); slot.setSeconds(0, 0); const remainder = slot.getMinutes() % interval; @@ -1591,7 +1621,7 @@ return fallbackEndTime; } endTime.setHours(parts[0], parts[1], 0, 0); - endTime.setMinutes(endTime.getMinutes() + 20); + endTime.setMinutes(endTime.getMinutes() + 10); return endTime > fallbackEndTime ? fallbackEndTime : endTime; }, generatePickupTimes() { @@ -1602,11 +1632,15 @@ earliestTime.setMinutes(earliestTime.getMinutes() + this.getPickupLeadMinutes()); const todayStartTime = this.getNextPickupSlot(earliestTime); const todayEndTime = this.getPickupAppointmentEndTime(today); + const currentTime = this.formatClockTime(now); const timelist = []; const cursor = new Date(todayStartTime); while (cursor <= todayEndTime) { timelist.push({ timestr: this.formatClockTime(cursor) }); - cursor.setMinutes(cursor.getMinutes() + 20); + cursor.setMinutes(cursor.getMinutes() + 10); + } + if (!timelist.length || timelist[0].timestr !== currentTime) { + timelist.unshift({ timestr: currentTime }); } this.pickupTimeContent = [{ id: 'today', @@ -1619,12 +1653,11 @@ let [h, m] = this.pickupTime.split(':'); let targetHour = parseInt(h); let targetMinute = parseInt(m); - let d = new Date(); - if (targetHour < d.getHours() || (targetHour === d.getHours() && targetMinute <= d.getMinutes())) { - d.setDate(d.getDate() + 1); - } - d.setHours(targetHour, targetMinute, 0, 0); - return this.formatDateTimeValue(d); + if (isNaN(targetHour) || isNaN(targetMinute)) return null; + const now = new Date(); + const target = new Date(); + target.setHours(targetHour, targetMinute, 0, 0); + return this.formatDateTimeValue(target.getTime() <= now.getTime() ? now : target); }, toNumber(value) { let amount = parseFloat(value); @@ -2404,7 +2437,6 @@ payload.isPack = this.isPack; if (this.nowMake === true) { payload.userRequireMake = 1; - } else if (this.nowMake === false) { payload.userRequireMakeTime = this.getPickupMakeTime(); } } @@ -2845,6 +2877,11 @@ this.openNowMakePopup(); return; } + if (this.needsPickupAppointment() && !this.pickupTime) { + this.tui.toast('请选择用餐时间'); + this.openPickupTimePicker(); + return; + } if (!this.currentOrderId || !this.backendTotalAmount) { if (this.pendingPaySpecChoices) { this.createFTFJoinOrder(this.pendingPaySpecChoices, true); @@ -3418,6 +3455,15 @@ text-align: center; } + .now-make-popup-time { + margin-top: 18rpx; + color: #00231C; + font-size: 48rpx; + font-weight: 900; + line-height: 64rpx; + text-align: center; + } + .now-make-popup-desc { margin-top: 12rpx; color: #6f7f79;