|
@@ -1,47 +1,43 @@
|
|
-<script setup lang='ts'>
|
|
|
|
-import { sceneBookingApi } from '@/api/api/sceneBooking';
|
|
|
|
-import router from '@/router';
|
|
|
|
-import { useStore } from '@/stores';
|
|
|
|
-import { showToast } from 'vant';
|
|
|
|
|
|
+<script setup lang="ts">
|
|
|
|
+import { sceneBookingApi } from '@/api/api/sceneBooking'
|
|
|
|
+import router from '@/router'
|
|
|
|
+import { useStore } from '@/stores'
|
|
|
|
+import { showToast } from 'vant'
|
|
|
|
|
|
const dateArray = ref([] as any)
|
|
const dateArray = ref([] as any)
|
|
const store = useStore()
|
|
const store = useStore()
|
|
|
|
|
|
const getFutureDates = (numDays: number) => {
|
|
const getFutureDates = (numDays: number) => {
|
|
- const datesArray = [];
|
|
|
|
- const today = new Date();
|
|
|
|
- const dateFormat = 'yyyy-MM-dd 星期X'; // 新增星期格式
|
|
|
|
|
|
+ const datesArray = []
|
|
|
|
+ const today = new Date()
|
|
|
|
+ const dateFormat = 'yyyy-MM-dd 星期X' // 新增星期格式
|
|
|
|
|
|
for (let i = 0; i <= numDays; i++) {
|
|
for (let i = 0; i <= numDays; i++) {
|
|
- const futureDate = new Date(today.getTime());
|
|
|
|
- futureDate.setDate(today.getDate() + i);
|
|
|
|
- const formattedDate = formatDate(futureDate, dateFormat);
|
|
|
|
|
|
+ const futureDate = new Date(today.getTime())
|
|
|
|
+ futureDate.setDate(today.getDate() + i)
|
|
|
|
+ const formattedDate = formatDate(futureDate, dateFormat)
|
|
datesArray.push({
|
|
datesArray.push({
|
|
date: formattedDate,
|
|
date: formattedDate,
|
|
isDisabled: false
|
|
isDisabled: false
|
|
- });
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- return datesArray;
|
|
|
|
|
|
+ return datesArray
|
|
}
|
|
}
|
|
|
|
|
|
const formatDate = (date: any, format: any) => {
|
|
const formatDate = (date: any, format: any) => {
|
|
- const year = date.getFullYear();
|
|
|
|
- const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
|
- const day = String(date.getDate()).padStart(2, '0');
|
|
|
|
- const weekDay = getWeekDay(date);
|
|
|
|
-
|
|
|
|
- return format.replace('yyyy', year)
|
|
|
|
- .replace('MM', month)
|
|
|
|
- .replace('dd', day)
|
|
|
|
- .replace('X', weekDay);
|
|
|
|
|
|
+ const year = date.getFullYear()
|
|
|
|
+ const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
|
|
+ const day = String(date.getDate()).padStart(2, '0')
|
|
|
|
+ const weekDay = getWeekDay(date)
|
|
|
|
+
|
|
|
|
+ return format.replace('yyyy', year).replace('MM', month).replace('dd', day).replace('X', weekDay)
|
|
}
|
|
}
|
|
|
|
|
|
const getWeekDay = (date: any) => {
|
|
const getWeekDay = (date: any) => {
|
|
- const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六'];
|
|
|
|
- return daysOfWeek[date.getDay()];
|
|
|
|
|
|
+ const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六']
|
|
|
|
+ return daysOfWeek[date.getDay()]
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
const selectDate = ref('' as string)
|
|
const selectDate = ref('' as string)
|
|
const selectTime = ref('' as string)
|
|
const selectTime = ref('' as string)
|
|
const selectId = ref('' as string)
|
|
const selectId = ref('' as string)
|
|
@@ -51,12 +47,14 @@ const disableTimeList = ref([] as any)
|
|
|
|
|
|
const noticeText = ref('' as any)
|
|
const noticeText = ref('' as any)
|
|
|
|
|
|
-
|
|
|
|
// 获得可预约时间段
|
|
// 获得可预约时间段
|
|
const getBookingTime = async () => {
|
|
const getBookingTime = async () => {
|
|
const res: any = await sceneBookingApi.getBookingTimeAPI(selectDate.value.slice(0, 10))
|
|
const res: any = await sceneBookingApi.getBookingTimeAPI(selectDate.value.slice(0, 10))
|
|
if (res.code == 0) {
|
|
if (res.code == 0) {
|
|
- bookingTimeList.value = res.data.time
|
|
|
|
|
|
+ bookingTimeList.value = res.data.time.map(v=>({
|
|
|
|
+ ...v,
|
|
|
|
+ lastTime:v.time.split('-')[1]
|
|
|
|
+ }))
|
|
disableTimeList.value = res.data.stopDate
|
|
disableTimeList.value = res.data.stopDate
|
|
noticeText.value = res.data.notice
|
|
noticeText.value = res.data.notice
|
|
|
|
|
|
@@ -71,23 +69,26 @@ watch(selectDate, () => {
|
|
getBookingTime()
|
|
getBookingTime()
|
|
})
|
|
})
|
|
|
|
|
|
-watch(disableTimeList, (newVal: any) => {
|
|
|
|
- dateArray.value = dateArray.value.map((item: any) => {
|
|
|
|
- return {
|
|
|
|
- ...item,
|
|
|
|
- isDisabled: disableTimeList.value.includes(item.date.slice(0, 10))
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- let today = selectDate.value.slice(0, 10)
|
|
|
|
- if (newVal.includes(today)) {
|
|
|
|
- const newDate = dateArray.value.find((item: any) => {
|
|
|
|
- return item.isDisabled == false
|
|
|
|
|
|
+watch(
|
|
|
|
+ disableTimeList,
|
|
|
|
+ (newVal: any) => {
|
|
|
|
+ dateArray.value = dateArray.value.map((item: any) => {
|
|
|
|
+ return {
|
|
|
|
+ ...item,
|
|
|
|
+ isDisabled: disableTimeList.value.includes(item.date.slice(0, 10))
|
|
|
|
+ }
|
|
})
|
|
})
|
|
- selectDate.value = newDate.date
|
|
|
|
- console.log(selectDate.value)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-}, { immediate: true })
|
|
|
|
|
|
+ let today = selectDate.value.slice(0, 10)
|
|
|
|
+ if (newVal.includes(today)) {
|
|
|
|
+ const newDate = dateArray.value.find((item: any) => {
|
|
|
|
+ return item.isDisabled == false
|
|
|
|
+ })
|
|
|
|
+ selectDate.value = newDate.date
|
|
|
|
+ console.log(selectDate.value)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ { immediate: true }
|
|
|
|
+)
|
|
|
|
|
|
const selectDateFu = (item: any) => {
|
|
const selectDateFu = (item: any) => {
|
|
if (item.isDisabled) {
|
|
if (item.isDisabled) {
|
|
@@ -95,17 +96,17 @@ const selectDateFu = (item: any) => {
|
|
} else {
|
|
} else {
|
|
selectDate.value = item.date
|
|
selectDate.value = item.date
|
|
selectTime.value = ''
|
|
selectTime.value = ''
|
|
- selectId.value=''
|
|
|
|
|
|
+ selectId.value = ''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
const selectTimeFu = (item: any) => {
|
|
const selectTimeFu = (item: any) => {
|
|
// router.go(0)
|
|
// router.go(0)
|
|
- if (item.pcs === 0) {
|
|
|
|
|
|
+ if (item.pcs <= 0) {
|
|
showToast('该时段预约已满,请选择其他时段进行预约')
|
|
showToast('该时段预约已满,请选择其他时段进行预约')
|
|
} else {
|
|
} else {
|
|
selectTime.value = item.time
|
|
selectTime.value = item.time
|
|
- selectId.value=item.id
|
|
|
|
|
|
+ selectId.value = item.id
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -119,14 +120,13 @@ const goInpitInfo = async () => {
|
|
store.selectDate = selectDate.value
|
|
store.selectDate = selectDate.value
|
|
store.selectTime = selectTime.value
|
|
store.selectTime = selectTime.value
|
|
store.selectId = selectId.value
|
|
store.selectId = selectId.value
|
|
- router.push({ name: 'bookInputInfo' });
|
|
|
|
|
|
+ router.push({ name: 'bookInputInfo' })
|
|
} else {
|
|
} else {
|
|
router.go(0)
|
|
router.go(0)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
showToast(res.msg)
|
|
showToast(res.msg)
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
@@ -138,38 +138,65 @@ onMounted(() => {
|
|
selectDate.value = dateArray.value[0].date
|
|
selectDate.value = dateArray.value[0].date
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// 获取当前时间小时,比较时间
|
|
|
|
+const nowTime =(lastTime:string)=>{
|
|
|
|
+ let d = new Date();
|
|
|
|
+ let t =d.getHours()
|
|
|
|
+
|
|
|
|
+ let aa =Number(lastTime.split(':')[0])
|
|
|
|
+ return t<aa
|
|
|
|
+
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
- <div class='time-box'>
|
|
|
|
|
|
+ <div class="time-box">
|
|
<div class="date-select-box">
|
|
<div class="date-select-box">
|
|
- <div class="date-select-item" v-for="(item, index) in dateArray" :key="index"
|
|
|
|
- :class="{ active: item.date === selectDate, disAble: item.isDisabled }" @click="selectDateFu(item)">
|
|
|
|
- {{
|
|
|
|
- item.date.slice(5) }}</div>
|
|
|
|
|
|
+ <div
|
|
|
|
+ class="date-select-item"
|
|
|
|
+ v-for="(item, index) in dateArray"
|
|
|
|
+ :key="index"
|
|
|
|
+ :class="{ active: item.date === selectDate, disAble: item.isDisabled }"
|
|
|
|
+ @click="selectDateFu(item)"
|
|
|
|
+ >
|
|
|
|
+ {{ item.date.slice(5) }}
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
<div class="time-select-box">
|
|
<div class="time-select-box">
|
|
- <div class="time-select-item" v-for="(item, index) in bookingTimeList" :key="index"
|
|
|
|
- :class="{ active: item.time === selectTime }" :style="{ color: item.pcs == 0 ? '#9D4F0B' : '' }"
|
|
|
|
- @click="() => { selectTimeFu(item) }">
|
|
|
|
|
|
+ <div
|
|
|
|
+ class="time-select-item"
|
|
|
|
+ v-for="(item, index) in bookingTimeList"
|
|
|
|
+ :key="index"
|
|
|
|
+ :class="{ active: item.time === selectTime,noAc:!nowTime(item.lastTime) }"
|
|
|
|
+ :style="{ color: item.pcs <= 0 ? '#9D4F0B' : '' }"
|
|
|
|
+ @click="
|
|
|
|
+ () => {
|
|
|
|
+ selectTimeFu(item)
|
|
|
|
+ }
|
|
|
|
+ "
|
|
|
|
+ >
|
|
<div>{{ item.time }}</div>
|
|
<div>{{ item.time }}</div>
|
|
- <div>{{ item.pcs == 0 ? `预约已满` : `剩余${item.pcs}` }}</div>
|
|
|
|
|
|
+ <div>{{nowTime(item.lastTime)?item.pcs <= 0 ? `预约已满` : `剩余${item.pcs}`:'超过预约时间' }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="notice-box" v-html="noticeText"></div>
|
|
<div class="notice-box" v-html="noticeText"></div>
|
|
</div>
|
|
</div>
|
|
- <div class="online-box" v-if="selectDate != '' && selectTime != ''" @click="goInpitInfo()">发起预约</div>
|
|
|
|
|
|
+ <div class="online-box" v-if="selectDate != '' && selectTime != ''" @click="goInpitInfo()">
|
|
|
|
+ 发起预约
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
-<style lang='less' scoped>
|
|
|
|
|
|
+<style lang="less" scoped>
|
|
.time-box {
|
|
.time-box {
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
height: 100%;
|
|
display: flex;
|
|
display: flex;
|
|
justify-content: start;
|
|
justify-content: start;
|
|
align-items: center;
|
|
align-items: center;
|
|
- background: #F1E9D4;
|
|
|
|
|
|
+ background: #f1e9d4;
|
|
margin: 0;
|
|
margin: 0;
|
|
box-sizing: border-box;
|
|
box-sizing: border-box;
|
|
font-family: 'SourceHanSansCN-Regular';
|
|
font-family: 'SourceHanSansCN-Regular';
|
|
@@ -177,31 +204,30 @@ onMounted(() => {
|
|
position: relative;
|
|
position: relative;
|
|
overflow: auto;
|
|
overflow: auto;
|
|
|
|
|
|
-
|
|
|
|
.date-select-box {
|
|
.date-select-box {
|
|
width: 35%;
|
|
width: 35%;
|
|
height: 100%;
|
|
height: 100%;
|
|
overflow: auto;
|
|
overflow: auto;
|
|
|
|
|
|
-
|
|
|
|
.date-select-item {
|
|
.date-select-item {
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 80px;
|
|
height: 80px;
|
|
display: flex;
|
|
display: flex;
|
|
justify-content: center;
|
|
justify-content: center;
|
|
align-items: center;
|
|
align-items: center;
|
|
- color: #88866F;
|
|
|
|
|
|
+ color: #88866f;
|
|
margin-bottom: 3px;
|
|
margin-bottom: 3px;
|
|
- background: #F7F3E8;
|
|
|
|
|
|
+ background: #f7f3e8;
|
|
}
|
|
}
|
|
|
|
|
|
.active {
|
|
.active {
|
|
- background: #E4DCC5;
|
|
|
|
|
|
+ background: #e4dcc5;
|
|
color: #333333;
|
|
color: #333333;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
.disAble {
|
|
.disAble {
|
|
- background: #E4DCC5;
|
|
|
|
|
|
+ background: #e4dcc5;
|
|
color: rgba(51, 51, 51, 0.2);
|
|
color: rgba(51, 51, 51, 0.2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -216,9 +242,9 @@ onMounted(() => {
|
|
.time-select-item {
|
|
.time-select-item {
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 50px;
|
|
height: 50px;
|
|
- background: #F7F3E8;
|
|
|
|
|
|
+ background: #f7f3e8;
|
|
border-radius: 5px;
|
|
border-radius: 5px;
|
|
- color: #88866F;
|
|
|
|
|
|
+ color: #88866f;
|
|
display: flex;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
align-items: center;
|
|
@@ -228,11 +254,14 @@ onMounted(() => {
|
|
}
|
|
}
|
|
|
|
|
|
.active {
|
|
.active {
|
|
- background: #E4DCC5;
|
|
|
|
|
|
+ background: #e4dcc5;
|
|
color: #333333;
|
|
color: #333333;
|
|
}
|
|
}
|
|
-
|
|
|
|
- .notice-box{
|
|
|
|
|
|
+ .noAc{
|
|
|
|
+ opacity: .5;
|
|
|
|
+ pointer-events: none;
|
|
|
|
+ }
|
|
|
|
+ .notice-box {
|
|
width: 100%;
|
|
width: 100%;
|
|
white-space: pre-wrap;
|
|
white-space: pre-wrap;
|
|
color: #88866fad;
|
|
color: #88866fad;
|
|
@@ -247,7 +276,7 @@ onMounted(() => {
|
|
border-radius: 50px;
|
|
border-radius: 50px;
|
|
background: url(@/assets/images/onlineBg.png);
|
|
background: url(@/assets/images/onlineBg.png);
|
|
background-size: 100% 100%;
|
|
background-size: 100% 100%;
|
|
- color: #F1E9D4;
|
|
|
|
|
|
+ color: #f1e9d4;
|
|
position: fixed;
|
|
position: fixed;
|
|
left: 50%;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
transform: translateX(-50%);
|
|
@@ -259,4 +288,4 @@ onMounted(() => {
|
|
font-weight: bold;
|
|
font-weight: bold;
|
|
z-index: 2;
|
|
z-index: 2;
|
|
}
|
|
}
|
|
-</style>
|
|
|
|
|
|
+</style>
|