This commit is contained in:
2025-03-20 10:58:18 +08:00
parent 4d21314fc6
commit ce0ab24c57
24 changed files with 791 additions and 138 deletions
+80 -10
View File
@@ -2,7 +2,8 @@
<view class="container">
<uv-sticky bg-color="white">
<view class="merchant-name">{{ merchant.name }}</view>
<uv-tabs :list="next7day" :itemStyle="{height: '58px'}" :activeStyle="{ color: '#2ba91c'}" lineColor="#2ba91c"
<uv-tabs :current="activeIndex" :list="next7day" :itemStyle="{height: '58px'}" :activeStyle="{ color: '#2ba91c'}"
lineColor="#2ba91c"
:inactiveStyle="{ color: '#808080' }" @change="onDateTime"></uv-tabs>
</uv-sticky>
<template v-if="merchantId !== 37">
@@ -178,7 +179,9 @@ export default {
disabled: false,
// 购物车信息
showCarInfo: false,
timeList: []
timeList: [],
timeListOrigin: [],
activeIndex: 0
}
},
onLoad(option) {
@@ -200,7 +203,7 @@ export default {
else totalPrice += d.price
})
carStore.totalPrice = totalPrice
console.log('totalPrice: ', totalPrice);
// console.log('totalPrice: ', totalPrice);
return totalPrice;
},
carNum() {
@@ -260,7 +263,7 @@ export default {
setDateList() {
this.next7day = []
let day = 7
if (this.merchantId === 37) day = 7
if (this.merchantId === 37) day = 1
for (let i = 0; i < day; i++) {
const day = dayjs().add(i, 'day')
this.next7day.push({
@@ -275,25 +278,92 @@ export default {
},
async getTimeList() {
this.timeList = await listThinkSiteTime({sid: this.merchantId})
// console.log(this.week)
// console.log(this.dateTime)
this.timeListOrigin = JSON.parse(JSON.stringify(this.timeList))
this.timeList = this.timeList.filter(item => {
return JSON.parse(item.week).map(Number).includes(parseInt(this.week))
})
console.log(this.timeList)
this.makeTimeList()
},
makeTimeList() {
this.periodList = []
this.timeList.forEach(item => {
this.timeListOrigin.forEach(item => {
const weekList = JSON.parse(item.week)
if (parseInt(this.merchantId) === 37) {
const today = dayjs().format('YYYY-MM-DD')
if (dayjs().isBefore(dayjs(today + ' 21:00:00')) || dayjs(this.dateTime).isAfter(dayjs())) this.periodList.push(item)
if ((dayjs().isBefore(dayjs(today + ' 21:00:00')) || dayjs(this.dateTime).isAfter(dayjs())) && weekList.includes(this.week)) this.periodList.push(item)
} else {
// console.log(this.dateTime + ' ' + item.timePeriod.split(' - ')[0])
// console.log(dayjs().isBefore(dayjs(this.dateTime + ' ' + item.timePeriod.split(' - ')[0])))
if (weekList.includes(this.week) && dayjs().isBefore(dayjs(this.dateTime + ' ' + item.timePeriod.split(' - ')[0]))) this.periodList.push(item)
}
})
// console.log(this.periodList)
const month = dayjs().format('YYYY-MM')
this.periodList.map(item => {
if (item.prices && item.prices.includes('{')) {
const dataList = JSON.parse(item.prices)[month]
if (dataList) {
const price = dataList[dayjs(this.dateTime).format('D') - 1]
if (price && price !== '') {
item.price = price
}
}
}
if (item.halfPrices && item.halfPrices.includes('{')) {
const dataList = JSON.parse(item.halfPrices)[month]
if (dataList) {
const price = dataList[dayjs(this.dateTime).format('D') - 1]
if (price && price !== '') {
item.halfPrices = price
}
}
}
return item
})
},
onDisabled() {
this.disabled = !this.disabled;
},
onDateTime(e) {
this.periodList = []
if (![37, 44, 32].includes(this.merchantId)) {
const date = dayjs().format('d')
const hour = dayjs().format('H')
const clickedDate = dayjs(e.dateTime).format('d')
if ([0, 5, 6].includes(parseInt(clickedDate))) {
if ([1, 2, 3].includes(parseInt(date))) {
return uni.showModal({
showCancel: false,
title: '周末场地需要周四17点后才能预定。',
})
} else if (parseInt(date) === 4) {
if (parseInt(hour) < 17) {
return uni.showModal({
showCancel: false,
title: '周末场地需要周四17点后才能预定。',
})
}
} else if ([0, 5, 6].includes(parseInt(date))) {
const diff = dayjs(e.dateTime).diff(dayjs(), 'day')
if (diff > 2) {
return uni.showModal({
showCancel: false,
title: '周末场地需要周四17点后才能预定。',
})
}
}
}
if (hour < 8 || hour === 23) {
return uni.showModal({
showCancel: false,
title: '场地预定时间为:8:00-23:00。',
})
}
}
this.activeIndex = e.index
this.week = e.week
this.dateTime = e.dateTime
this.makeTimeList()
@@ -348,7 +418,7 @@ export default {
const checkTimePeriod = field.periodVoList.find(d => (d.period === timePeriod && d.id === item.id))
// console.log('here', field, item)
// 已被预定
if (checkTimePeriod.sold) {
if (checkTimePeriod.sold || checkTimePeriod.took) {
return
}
const app = this
@@ -420,7 +490,7 @@ export default {
const timePeriod = item.timePeriod
const checkTimePeriod = field.periodVoList.find(d => (d.period === timePeriod && d.id === item.id))
// console.log('checkTimePeriod', checkTimePeriod, timePeriod)
if (checkTimePeriod && checkTimePeriod.sold) {
if (checkTimePeriod && (checkTimePeriod.sold || checkTimePeriod.took)) {
if (item.isHalf === 1) {
return 'web-bg-warning'
}
@@ -439,7 +509,7 @@ export default {
uni.navigateTo({
url: '/package/booking/confirm',
success: (res) => {
console.log(this.selection)
// console.log(this.selection)
res.eventChannel.emit('data', this.selection)
}
})