From 8f88e1bbabd9694b5a27a92d2610d5dc7125c341 Mon Sep 17 00:00:00 2001 From: linxi <957440651@qq.com> Date: Wed, 31 Dec 2025 17:37:57 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E6=89=80=E6=9C=89=E5=9B=A2?= =?UTF-8?q?=E8=B4=AD=E8=AF=A6=E6=83=85=E9=A1=B52026=E5=B9=B41=E6=9C=88?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=E9=83=BD=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E9=A2=84=E7=BA=A6=EF=BC=8C=E4=BD=86=E6=98=AF=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=97=A5=E6=9C=9F=E9=A1=B5=E9=9D=A2=E5=8D=B4?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E9=A2=84=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg_product/views/groupBuyDetails.vue | 72 +++++++++++++++------------ 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/pkg_product/views/groupBuyDetails.vue b/pkg_product/views/groupBuyDetails.vue index 306c28a..467fcc7 100644 --- a/pkg_product/views/groupBuyDetails.vue +++ b/pkg_product/views/groupBuyDetails.vue @@ -231,7 +231,7 @@ export default { onLoad(query) { this.id = (query && query.id) || '' this.getDetail() - this.getCalendar() + // this.getCalendar() getJiaLouBookingRules(this.id).then(res => { if (res.status === 200) { this.rules = res.data || '' @@ -256,22 +256,22 @@ export default { handleDate() { this.showDatePicker = true }, - /** - * 获取产品可预约日期 - */ - getCalendar() { - const currentMonth = new Date().toISOString().slice(0, 7) - getJiaLouCalendar({ - travelGroupProductId: this.id, - month: currentMonth - }).then(res => { - if (res.status === 200) { - this.calendar = res.data || [] - // 计算当前日及后面4天 - this.currentWeek = this.computeCurrentWeekFromCalendar() - } - }) - }, + // /** + // * 获取产品可预约日期 + // */ + // getCalendar() { + // const currentMonth = new Date().toISOString().slice(0, 7) + // getJiaLouCalendar({ + // travelGroupProductId: this.id, + // month: currentMonth + // }).then(res => { + // if (res.status === 200) { + // this.calendar = res.data || [] + // // 计算当前日及后面4天 + // this.currentWeek = this.computeCurrentWeekFromCalendar() + // } + // }) + // }, /** * 根据 calendar 数据计算:今天 + 接下来4天(共5天) @@ -322,6 +322,19 @@ export default { if (res.status === 200) { this.detail = res.data this.detail.packageDetails = this.detail.packageDetails.filter(e => e.title !== '') + const inventoryList = Array.isArray(res.data.inventoryStatus) ? res.data.inventoryStatus : [] + const todayStr = this.formatYMD(new Date()) + const futureList = inventoryList.filter(item => item.date >= todayStr) + const limitedList = (futureList.length ? futureList : inventoryList).slice(0, 5) + this.currentWeek = limitedList.map((item, index) => { + const dateStr = item.date + return { + date: dateStr, + week: this.getWeekLabel(dateStr), + status: this.mapInventoryStatus(item.inventoryStatus), + monthDay: index === 0 ? '今日' : this.getMonthDay(dateStr) + } + }) } }, @@ -362,26 +375,23 @@ export default { * @returns {string} 预约状态文本:可约、已约、不可约 */ findDateStatus(dateStr) { - // 在calendar数组中查找匹配的日期 const matchedDate = this.calendar.find(item => item.date === dateStr) console.log('未找到匹配日期:', matchedDate) - // 如果找到匹配的日期,根据inventoryStatus返回对应文本 if (matchedDate) { - switch (matchedDate.inventoryStatus) { - case 0: - return '可订' - case 1: - return '不可订' - case 2: - return '不可订' - default: - return '不可订' - } + return this.mapInventoryStatus(matchedDate.inventoryStatus) } - - // 如果没有找到匹配的日期,返回不可约 return '不可订' }, + mapInventoryStatus(status) { + switch (status) { + case 0: + return '可订' + case 1: + case 2: + default: + return '不可订' + } + }, /** * 处理日期点击事件