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 '不可订' + } + }, /** * 处理日期点击事件