Showing
1 changed file
with
28 additions
and
17 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-01-15 13:35:51 | 2 | * @Date: 2024-01-15 13:35:51 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-01-22 10:24:44 | 4 | + * @LastEditTime: 2024-01-22 15:35:03 |
| 5 | * @FilePath: /xysBooking/src/views/booking.vue | 5 | * @FilePath: /xysBooking/src/views/booking.vue |
| 6 | * @Description: 预约页面 | 6 | * @Description: 预约页面 |
| 7 | --> | 7 | --> |
| ... | @@ -19,18 +19,19 @@ | ... | @@ -19,18 +19,19 @@ |
| 19 | <div v-for="(week, index) in weeks" :key="week" class="weeks"> | 19 | <div v-for="(week, index) in weeks" :key="week" class="weeks"> |
| 20 | <div v-for="date in week" :key="date" | 20 | <div v-for="date in week" :key="date" |
| 21 | @click="chooseDay(date)" | 21 | @click="chooseDay(date)" |
| 22 | - :class="['item', checked_day === findDatesInfo(date).date ? 'checked' : '', findDatesInfo(date).reserve_full ? 'disabled' : '']" | 22 | + :class="['item', checked_day === findDatesInfo(date).date ? 'checked' : '', findDatesInfo(date).reserve_full === 0 ? 'disabled' : '']" |
| 23 | > | 23 | > |
| 24 | <div v-if="findDatesInfo(date).date"> | 24 | <div v-if="findDatesInfo(date).date"> |
| 25 | <p class="day-text">{{ findDatesInfo(date).text }}</p> | 25 | <p class="day-text">{{ findDatesInfo(date).text }}</p> |
| 26 | - <p v-if="!findDatesInfo(date).reserve_full" class="day-price">¥{{ findDatesInfo(date).price }}</p> | 26 | + <p v-if="findDatesInfo(date).reserve_full === 1" class="day-price">¥{{ findDatesInfo(date).price }}</p> |
| 27 | - <!-- <p v-else class="day-no-booking">已约满</p> --> | 27 | + <p v-else-if="findDatesInfo(date).reserve_full === -1" class="day-price"></p> |
| 28 | - <p v-else class="day-no-booking">¥{{ findDatesInfo(date).price }}</p> | 28 | + <p v-else-if="findDatesInfo(date).reserve_full === 0" class="day-no-booking">约满</p> |
| 29 | + <!-- <p v-else class="day-no-booking">¥{{ findDatesInfo(date).price }}</p> --> | ||
| 29 | </div> | 30 | </div> |
| 30 | </div> | 31 | </div> |
| 31 | </div> | 32 | </div> |
| 32 | </div> | 33 | </div> |
| 33 | - <div v-if="checked_day" class="choose-time"> | 34 | + <div v-if="checked_day && checked_day_reserve_full === 1" class="choose-time"> |
| 34 | <div class="title"> | 35 | <div class="title"> |
| 35 | <div class="text">选择参访时间段</div> | 36 | <div class="text">选择参访时间段</div> |
| 36 | </div> | 37 | </div> |
| ... | @@ -54,9 +55,14 @@ | ... | @@ -54,9 +55,14 @@ |
| 54 | </div> | 55 | </div> |
| 55 | </div> | 56 | </div> |
| 56 | </div> | 57 | </div> |
| 58 | + <div v-if="checked_day_reserve_full === -1" class="choose-time"> | ||
| 59 | + <div class="title"> | ||
| 60 | + <div class="text">无需预约</div> | ||
| 61 | + </div> | ||
| 62 | + </div> | ||
| 57 | </div> | 63 | </div> |
| 58 | <div style="height: 5rem;"></div> | 64 | <div style="height: 5rem;"></div> |
| 59 | - <div class="next"> | 65 | + <div v-if="checked_day && checked_day_reserve_full === 1" class="next"> |
| 60 | <div @click="nextBtn" class="button" style="background-color: #A67939;">下一步</div> | 66 | <div @click="nextBtn" class="button" style="background-color: #A67939;">下一步</div> |
| 61 | </div> | 67 | </div> |
| 62 | 68 | ||
| ... | @@ -113,7 +119,7 @@ onMounted(async () => { | ... | @@ -113,7 +119,7 @@ onMounted(async () => { |
| 113 | // 今日之前都不可约 | 119 | // 今日之前都不可约 |
| 114 | dates_list.value.forEach((date) => { | 120 | dates_list.value.forEach((date) => { |
| 115 | if (dayjs(date.month_date).isBefore(dayjs())) { | 121 | if (dayjs(date.month_date).isBefore(dayjs())) { |
| 116 | - date.reserve_full = 1; | 122 | + date.reserve_full = 0; |
| 117 | } | 123 | } |
| 118 | }); | 124 | }); |
| 119 | dates.value = dates_list.value.map(item => item.month_date); | 125 | dates.value = dates_list.value.map(item => item.month_date); |
| ... | @@ -123,7 +129,7 @@ onMounted(async () => { | ... | @@ -123,7 +129,7 @@ onMounted(async () => { |
| 123 | /** | 129 | /** |
| 124 | * @description: 根据日期获取信息 | 130 | * @description: 根据日期获取信息 |
| 125 | * @param {string} date | 131 | * @param {string} date |
| 126 | - * @return {object} {text: 日期, date: 日期, price: 价格, reserve_full: 是否可约} | 132 | + * @return {object} {text: 日期, date: 日期, price: 价格, reserve_full: 是否可约 1=可约,0=约满,-1=无需预约 } |
| 127 | */ | 133 | */ |
| 128 | const findDatesInfo = (date) => { | 134 | const findDatesInfo = (date) => { |
| 129 | const result = dates_list.value.find((item) => item.month_date === date); | 135 | const result = dates_list.value.find((item) => item.month_date === date); |
| ... | @@ -180,6 +186,7 @@ const weeks = computed(() => { | ... | @@ -180,6 +186,7 @@ const weeks = computed(() => { |
| 180 | 186 | ||
| 181 | const checked_day = ref(''); | 187 | const checked_day = ref(''); |
| 182 | const checked_day_price = ref(0); | 188 | const checked_day_price = ref(0); |
| 189 | +const checked_day_reserve_full = ref(null); | ||
| 183 | const checked_time = ref(-1); | 190 | const checked_time = ref(-1); |
| 184 | const timePeriod = ref([]); // 当前时间段信息 | 191 | const timePeriod = ref([]); // 当前时间段信息 |
| 185 | 192 | ||
| ... | @@ -190,15 +197,18 @@ const chooseTime = (item, index) => { // 畾萄 | ... | @@ -190,15 +197,18 @@ const chooseTime = (item, index) => { // 畾萄 |
| 190 | }; | 197 | }; |
| 191 | 198 | ||
| 192 | const chooseDay = async (date) => { // 点击日期回调 | 199 | const chooseDay = async (date) => { // 点击日期回调 |
| 193 | - if (!findDatesInfo(date).reserve_full) { // 日期可约状态 | 200 | + if (findDatesInfo(date).reserve_full !== 0) { // 状态 1可约 || -1不限制 |
| 194 | checked_day.value = date; // 当前日期 | 201 | checked_day.value = date; // 当前日期 |
| 195 | checked_day_price.value = findDatesInfo(date).price; // 当前价格 | 202 | checked_day_price.value = findDatesInfo(date).price; // 当前价格 |
| 196 | - // 选择日期后,查询时间段信息 | 203 | + checked_day_reserve_full.value = findDatesInfo(date).reserve_full; // 当前状态 |
| 197 | - const { code, data } = await canReserveTimeListAPI({ month_date: checked_day.value}); | 204 | + if (findDatesInfo(date).reserve_full === 1) { |
| 198 | - if (code) { | 205 | + // 选择日期后,查询时间段信息 |
| 199 | - // rest_qty >0表示有余量,可约;=0表示没有余量,不可约;<0表示不限,可约; | 206 | + const { code, data } = await canReserveTimeListAPI({ month_date: checked_day.value}); |
| 200 | - timePeriod.value = data; | 207 | + if (code) { |
| 201 | - checked_time.value = -1; // 重置已选择的时间段 | 208 | + // rest_qty >0表示有余量,可约;=0表示没有余量,不可约;<0表示不限,可约; |
| 209 | + timePeriod.value = data; | ||
| 210 | + checked_time.value = -1; // 重置已选择的时间段 | ||
| 211 | + } | ||
| 202 | } | 212 | } |
| 203 | } | 213 | } |
| 204 | }; | 214 | }; |
| ... | @@ -221,6 +231,7 @@ const onConfirm = async ({ selectedValues, selectedOptions }) => { // | ... | @@ -221,6 +231,7 @@ const onConfirm = async ({ selectedValues, selectedOptions }) => { // |
| 221 | // 清空选择 | 231 | // 清空选择 |
| 222 | checked_day.value = ''; | 232 | checked_day.value = ''; |
| 223 | checked_time.value = -1; | 233 | checked_time.value = -1; |
| 234 | + checked_day_reserve_full.value = null; | ||
| 224 | // 选择日期后,查询月份信息 | 235 | // 选择日期后,查询月份信息 |
| 225 | const { code, data } = await canReserveDateListAPI({ month: `${selectedValues[0]}-${selectedValues[1]}` }); | 236 | const { code, data } = await canReserveDateListAPI({ month: `${selectedValues[0]}-${selectedValues[1]}` }); |
| 226 | if (code) { | 237 | if (code) { |
| ... | @@ -229,7 +240,7 @@ const onConfirm = async ({ selectedValues, selectedOptions }) => { // | ... | @@ -229,7 +240,7 @@ const onConfirm = async ({ selectedValues, selectedOptions }) => { // |
| 229 | // 今日之前都不可约 | 240 | // 今日之前都不可约 |
| 230 | dates_list.value.forEach((date) => { | 241 | dates_list.value.forEach((date) => { |
| 231 | if (dayjs(date.month_date).isBefore(dayjs())) { | 242 | if (dayjs(date.month_date).isBefore(dayjs())) { |
| 232 | - date.reserve_full = 1; | 243 | + date.reserve_full = 0; |
| 233 | } | 244 | } |
| 234 | }); | 245 | }); |
| 235 | dates.value = dates_list.value.map(item => item.month_date); | 246 | dates.value = dates_list.value.map(item => item.month_date); | ... | ... |
-
Please register or login to post a comment