diff --git a/package1/buyFood/buyFood.vue b/package1/buyFood/buyFood.vue index 9655003..a488f07 100644 --- a/package1/buyFood/buyFood.vue +++ b/package1/buyFood/buyFood.vue @@ -688,6 +688,10 @@ }else{ return this.goodsAmountCalc; } + }, + deliveryDurationMinutes() { + const value = Number(this.shopItem.groupDeliveryTime); + return isNaN(value) || value < 25 ? 30 : value; } }, watch: {}, @@ -695,16 +699,7 @@ this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.initAddress() //this.fetchCoupons(); - const now = new Date(); - const startTime = new Date(now); - const endTime = new Date(now); - startTime.setMinutes(startTime.getMinutes() + 20); - endTime.setMinutes(endTime.getMinutes() + 35); - const startStr = - `${startTime.getHours().toString().padStart(2, '0')}:${startTime.getMinutes().toString().padStart(2, '0')}`; - const endStr = - `${endTime.getHours().toString().padStart(2, '0')}:${endTime.getMinutes().toString().padStart(2, '0')}`; - this.immediateTimeStr = `${startStr}-${endStr}`; + this.updateImmediateTimeStr(); uni.$on('updateDeliveryWorker', (worker) => { this.assignedWorker = worker; @@ -797,6 +792,26 @@ normalizeCustomCommission() { this.customCommission = this.formatCommissionValue(this.customCommission); }, + updateImmediateTimeStr() { + const now = new Date(); + const startTime = new Date(now); + const endTime = new Date(now); + startTime.setMinutes(startTime.getMinutes() + 25); + endTime.setMinutes(endTime.getMinutes() + this.deliveryDurationMinutes); + this.immediateTimeStr = `${this.formatClockTime(startTime)}-${this.formatClockTime(endTime)}`; + }, + formatClockTime(date) { + return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`; + }, + formatDateTimeValue(date) { + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + const hours = String(date.getHours()).padStart(2, '0'); + const minutes = String(date.getMinutes()).padStart(2, '0'); + const seconds = String(date.getSeconds()).padStart(2, '0'); + return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`; + }, initAddress() { let cachedAddress = uni.getStorageSync('selectedAddress'); if (cachedAddress) { @@ -1037,14 +1052,8 @@ if (!this.formData.deliveryTime || this.formData.deliveryTime === '自动送达' || this.formData.deliveryTime === '尽快送达'){ const now = new Date(); - now.setMinutes(now.getMinutes() + 35); - const year = now.getFullYear(); - const month = String(now.getMonth() + 1).padStart(2, '0'); - const day = String(now.getDate()).padStart(2, '0'); - const hours = String(now.getHours()).padStart(2, '0'); - const minutes = String(now.getMinutes()).padStart(2, '0'); - const seconds = String(now.getSeconds()).padStart(2, '0'); - return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`; + now.setMinutes(now.getMinutes() + this.deliveryDurationMinutes); + return this.formatDateTimeValue(now); }else{ let timeStr = this.formData.deliveryTime; if (timeStr.length === 5) { @@ -1236,15 +1245,14 @@ timestr: '自动送达' }]; - const currentHour = now.getHours(); - const currentMinute = now.getMinutes(); + const earliestTime = new Date(now); + earliestTime.setMinutes(earliestTime.getMinutes() + this.deliveryDurationMinutes); - // 计算下一个半小时点 - let nextHour = currentHour; - let nextMinute = 30; - if (currentMinute >= 30) { - nextHour = currentHour + 1; - nextMinute = 0; + // 预约配送从预计最晚送达时间后的下一个半小时点开始 + let nextHour = earliestTime.getHours(); + let nextMinute = earliestTime.getMinutes() <= 30 ? 30 : 0; + if (earliestTime.getMinutes() > 30) { + nextHour += 1; } // 从下一个半小时点开始,直到 23:30 diff --git a/package1/ieBrowser/index.vue b/package1/ieBrowser/index.vue index 0d559f5..39ac3f8 100644 --- a/package1/ieBrowser/index.vue +++ b/package1/ieBrowser/index.vue @@ -191,7 +191,7 @@ × - {{ savingCompanionIntent ? '保存中...' : '发布一句' }} diff --git a/package1/planet/pkHall.vue b/package1/planet/pkHall.vue index 05e4472..126e031 100644 --- a/package1/planet/pkHall.vue +++ b/package1/planet/pkHall.vue @@ -79,7 +79,7 @@ 创建星球擂台 - +