Showing
9 changed files
with
70 additions
and
107 deletions
| ... | @@ -2,13 +2,13 @@ | ... | @@ -2,13 +2,13 @@ |
| 2 | VITE_PORT = 8208 | 2 | VITE_PORT = 8208 |
| 3 | 3 | ||
| 4 | # 反向代理服务器地址 | 4 | # 反向代理服务器地址 |
| 5 | -VITE_PROXY_TARGET = https://oa.onwall.cn | 5 | +VITE_PROXY_TARGET = https://oa-dev.onwall.cn |
| 6 | 6 | ||
| 7 | # API请求前缀 | 7 | # API请求前缀 |
| 8 | VITE_PROXY_PREFIX = /srv/ | 8 | VITE_PROXY_PREFIX = /srv/ |
| 9 | 9 | ||
| 10 | # 打包输出文件夹名称 | 10 | # 打包输出文件夹名称 |
| 11 | -VITE_OUTDIR = xysBooking | 11 | +VITE_OUTDIR = reserve |
| 12 | 12 | ||
| 13 | # 是否开启调试 | 13 | # 是否开启调试 |
| 14 | VITE_CONSOLE = 0 | 14 | VITE_CONSOLE = 0 | ... | ... |
| 1 | { | 1 | { |
| 2 | - "name": "xysBooking", | 2 | + "name": "reserve", |
| 3 | "version": "1.0.0", | 3 | "version": "1.0.0", |
| 4 | "lockfileVersion": 2, | 4 | "lockfileVersion": 2, |
| 5 | "requires": true, | 5 | "requires": true, |
| 6 | "packages": { | 6 | "packages": { |
| 7 | "": { | 7 | "": { |
| 8 | - "name": "xysBooking", | 8 | + "name": "reserve", |
| 9 | "version": "1.0.0", | 9 | "version": "1.0.0", |
| 10 | "dependencies": { | 10 | "dependencies": { |
| 11 | "@vant/area-data": "^1.3.1", | 11 | "@vant/area-data": "^1.3.1", | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2023-08-24 09:42:27 | 2 | * @Date: 2023-08-24 09:42:27 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-08-24 12:52:26 | 4 | + * @LastEditTime: 2024-01-17 17:37:48 |
| 5 | - * @FilePath: /front/src/api/index.js | 5 | + * @FilePath: /xysBooking/src/api/index.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| 8 | import { fn, fetch } from '@/api/fn'; | 8 | import { fn, fetch } from '@/api/fn'; |
| 9 | 9 | ||
| 10 | const Api = { | 10 | const Api = { |
| 11 | - ORDER_REST_COUNT: '/srv/?a=order_rest_count', | 11 | + CAN_RESERVE_DATE_LIST: '/srv/?a=api&t=can_reserve_date_list', |
| 12 | - ORDER_INFO: '/srv/?a=order_info', | 12 | + CAN_RESERVE_TIME_LIST: '/srv/?a=api&t=can_reserve_time_list', |
| 13 | - ORDER_DETAIL_MY_LAST: '/srv/?a=order_detail_my_last', | ||
| 14 | - ORDER_ADD: '/srv/?a=order_add', | ||
| 15 | - ORDER_CANCEL: '/srv/?a=order_cancel', | ||
| 16 | }; | 13 | }; |
| 17 | 14 | ||
| 18 | /** | 15 | /** |
| 19 | - * @description: 剩余预约数量列表 | 16 | + * @description: 可预约日期列表 |
| 20 | - * @param {Array} dates 查询日期 | 17 | + * @param {Array} month 月份,格式yyyy-mm |
| 21 | * @returns | 18 | * @returns |
| 22 | */ | 19 | */ |
| 23 | -export const orderRestCountAPI = (params) => fn(fetch.get(Api.ORDER_REST_COUNT, params)); | 20 | +export const canReserveDateListAPI = (params) => fn(fetch.get(Api.CAN_RESERVE_DATE_LIST, params)); |
| 24 | 21 | ||
| 25 | /** | 22 | /** |
| 26 | - * @description: 查询预约信息 | 23 | + * @description: 可预约时段列表 |
| 27 | - * @param {String} id 预约订单ID | 24 | + * @param {Array} month_date 日期,格式yyyy-mm-dd |
| 28 | * @returns | 25 | * @returns |
| 29 | */ | 26 | */ |
| 30 | -export const orderInfoAPI = (params) => fn(fetch.get(Api.ORDER_INFO, params)); | 27 | +export const canReserveTimeListAPI = (params) => fn(fetch.get(Api.CAN_RESERVE_TIME_LIST, params)); |
| 31 | - | ||
| 32 | -/** | ||
| 33 | - * @description: 我的预约信息 | ||
| 34 | - * @returns | ||
| 35 | - */ | ||
| 36 | -export const orderDetailMyLastAPI = (params) => fn(fetch.get(Api.ORDER_DETAIL_MY_LAST, params)); | ||
| 37 | - | ||
| 38 | -/** | ||
| 39 | - * @description: 保存预约信息 | ||
| 40 | - * @param {Array} dates 日期列表 | ||
| 41 | - * @param {Array} details | ||
| 42 | - * @returns | ||
| 43 | - */ | ||
| 44 | -export const orderAddAPI = (params) => fn(fetch.post(Api.ORDER_ADD, params)); | ||
| 45 | 28 | ||
| 46 | /** | 29 | /** |
| 47 | * @description: 取消预约 | 30 | * @description: 取消预约 |
| 48 | * @param {String} id 预约订单的ID | 31 | * @param {String} id 预约订单的ID |
| 49 | * @returns | 32 | * @returns |
| 50 | */ | 33 | */ |
| 51 | -export const orderCancelAPI = (params) => fn(fetch.post(Api.ORDER_CANCEL, params)); | 34 | +// export const orderCancelAPI = (params) => fn(fetch.post(Api.ORDER_CANCEL, params)); | ... | ... |
| ... | @@ -2,8 +2,8 @@ | ... | @@ -2,8 +2,8 @@ |
| 2 | * @Author: hookehuyr hookehuyr@gmail.com | 2 | * @Author: hookehuyr hookehuyr@gmail.com |
| 3 | * @Date: 2022-05-28 10:17:40 | 3 | * @Date: 2022-05-28 10:17:40 |
| 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 5 | - * @LastEditTime: 2023-08-24 10:56:20 | 5 | + * @LastEditTime: 2024-01-17 15:14:04 |
| 6 | - * @FilePath: /front/src/utils/axios.js | 6 | + * @FilePath: /xysBooking/src/utils/axios.js |
| 7 | * @Description: | 7 | * @Description: |
| 8 | */ | 8 | */ |
| 9 | import axios from 'axios'; | 9 | import axios from 'axios'; |
| ... | @@ -13,7 +13,8 @@ import { strExist } from '@/utils/tools' | ... | @@ -13,7 +13,8 @@ import { strExist } from '@/utils/tools' |
| 13 | // import { parseQueryString } from '@/utils/tools' | 13 | // import { parseQueryString } from '@/utils/tools' |
| 14 | 14 | ||
| 15 | axios.defaults.params = { | 15 | axios.defaults.params = { |
| 16 | - f: 'xysBooking', | 16 | + f: 'reserve', |
| 17 | + client_name: '西园寺', | ||
| 17 | }; | 18 | }; |
| 18 | 19 | ||
| 19 | /** | 20 | /** | ... | ... |
| 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-16 17:44:34 | 4 | + * @LastEditTime: 2024-01-17 18:07:39 |
| 5 | * @FilePath: /xysBooking/src/views/booking.vue | 5 | * @FilePath: /xysBooking/src/views/booking.vue |
| 6 | * @Description: 预约页面 | 6 | * @Description: 预约页面 |
| 7 | * @Version: 1.0.0 | 7 | * @Version: 1.0.0 |
| ... | @@ -17,17 +17,19 @@ | ... | @@ -17,17 +17,19 @@ |
| 17 | <div class="days-of-week"> | 17 | <div class="days-of-week"> |
| 18 | <div v-for="day in daysOfWeek" :key="day" class="item">{{ day }}</div> | 18 | <div v-for="day in daysOfWeek" :key="day" class="item">{{ day }}</div> |
| 19 | </div> | 19 | </div> |
| 20 | - <div v-for="(week, index) in weeks" :key="index" class="weeks"> | 20 | + <div v-for="(week, index) in weeks" :key="week" class="weeks"> |
| 21 | <div v-for="date in week" :key="date" | 21 | <div v-for="date in week" :key="date" |
| 22 | @click="chooseDay(date)" | 22 | @click="chooseDay(date)" |
| 23 | - :class="['item', checked_day === findDatesInfo(date).date ? 'checked' : '', !findDatesInfo(date).num ? 'disabled' : '']" | 23 | + :class="['item', checked_day === findDatesInfo(date).date ? 'checked' : '', findDatesInfo(date).reserve_full ? 'disabled' : '']" |
| 24 | > | 24 | > |
| 25 | + <div v-if="findDatesInfo(date).date"> | ||
| 25 | <p class="day-text">{{ findDatesInfo(date).text }}</p> | 26 | <p class="day-text">{{ findDatesInfo(date).text }}</p> |
| 26 | - <p v-if="findDatesInfo(date).num" class="day-price">¥{{ findDatesInfo(date).price }}</p> | 27 | + <p v-if="!findDatesInfo(date).reserve_full" class="day-price">¥{{ findDatesInfo(date).price }}</p> |
| 27 | <p v-else class="day-no-booking">已约满</p> | 28 | <p v-else class="day-no-booking">已约满</p> |
| 28 | </div> | 29 | </div> |
| 29 | </div> | 30 | </div> |
| 30 | </div> | 31 | </div> |
| 32 | + </div> | ||
| 31 | <div v-if="checked_day" class="choose-time"> | 33 | <div v-if="checked_day" class="choose-time"> |
| 32 | <div class="title"> | 34 | <div class="title"> |
| 33 | <div class="text">选择参访时间段</div> | 35 | <div class="text">选择参访时间段</div> |
| ... | @@ -37,15 +39,16 @@ | ... | @@ -37,15 +39,16 @@ |
| 37 | @click="chooseTime(item, index)" | 39 | @click="chooseTime(item, index)" |
| 38 | v-for="(item, index) in timePeriod" | 40 | v-for="(item, index) in timePeriod" |
| 39 | :key="index" | 41 | :key="index" |
| 40 | - :class="['time', !item.num ? 'disabled' : '']" | 42 | + :class="['time', item.rest_qty === 0 ? 'disabled' : '']" |
| 41 | > | 43 | > |
| 42 | <div class="left"> | 44 | <div class="left"> |
| 43 | <van-icon v-if="checked_time !== index" :name="icon_select1" /> | 45 | <van-icon v-if="checked_time !== index" :name="icon_select1" /> |
| 44 | <van-icon v-else :name="icon_select2" /> | 46 | <van-icon v-else :name="icon_select2" /> |
| 45 | - {{ item.left }} | 47 | + {{ item.begin_time }}-{{ item.end_time }} |
| 46 | </div> | 48 | </div> |
| 47 | <div class="right"> | 49 | <div class="right"> |
| 48 | - <span v-if="item.num">余量:{{ item.right }}</span> | 50 | + <span v-if="item.rest_qty > 0">余量:{{ item.price }}</span> |
| 51 | + <span v-else-if="item.rest_qty === -1">可约</span> | ||
| 49 | <span v-else>已约满</span> | 52 | <span v-else>已约满</span> |
| 50 | </div> | 53 | </div> |
| 51 | </div> | 54 | </div> |
| ... | @@ -88,6 +91,7 @@ import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@ | ... | @@ -88,6 +91,7 @@ import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@ |
| 88 | import { useGo } from '@/hooks/useGo' | 91 | import { useGo } from '@/hooks/useGo' |
| 89 | import icon_select1 from '@/assets/images/单选01@2x.png' | 92 | import icon_select1 from '@/assets/images/单选01@2x.png' |
| 90 | import icon_select2 from '@/assets/images/单选02@2x.png' | 93 | import icon_select2 from '@/assets/images/单选02@2x.png' |
| 94 | +import { canReserveDateListAPI, canReserveTimeListAPI } from '@/api/index' | ||
| 91 | 95 | ||
| 92 | const $route = useRoute(); | 96 | const $route = useRoute(); |
| 93 | const $router = useRouter(); | 97 | const $router = useRouter(); |
| ... | @@ -95,53 +99,27 @@ useTitle($route.meta.title); | ... | @@ -95,53 +99,27 @@ useTitle($route.meta.title); |
| 95 | 99 | ||
| 96 | const go = useGo(); | 100 | const go = useGo(); |
| 97 | 101 | ||
| 98 | -const dates_list = ref([{ | 102 | +const dates_list = ref([]); |
| 99 | - date: "2024-01-01", | 103 | +const dates = ref([]); |
| 100 | - price: 5, | 104 | + |
| 101 | - num: 0, | 105 | +onMounted(async () => { |
| 102 | -}, { | 106 | + const raw_date = new Date(); |
| 103 | - date: "2024-01-02", | 107 | + const { code, data } = await canReserveDateListAPI({ month: `${raw_date.getFullYear()}-${raw_date.getMonth() + 1}` }); |
| 104 | - price: 5, | 108 | + if (code) { |
| 105 | - num: 0, | 109 | + // 日期列表 |
| 106 | -}, { | 110 | + dates_list.value = data; |
| 107 | - date: "2024-01-03", | 111 | + dates.value = dates_list.value.map(item => item.month_date); |
| 108 | - price: 5, | 112 | + } |
| 109 | - num: 1, | 113 | +}) |
| 110 | -}, { | ||
| 111 | - date: "2024-01-04", | ||
| 112 | - price: 5, | ||
| 113 | - num: 1, | ||
| 114 | -}, { | ||
| 115 | - date: "2024-01-05", | ||
| 116 | - price: 5, | ||
| 117 | - num: 1, | ||
| 118 | -}, { | ||
| 119 | - date: "2024-01-06", | ||
| 120 | - price: 5, | ||
| 121 | - num: 1, | ||
| 122 | -}, { | ||
| 123 | - date: "2024-01-07", | ||
| 124 | - price: 5, | ||
| 125 | - num: 1, | ||
| 126 | -}, { | ||
| 127 | - date: "2024-01-08", | ||
| 128 | - price: 5, | ||
| 129 | - num: 1, | ||
| 130 | -}, { | ||
| 131 | - date: "2024-01-09", | ||
| 132 | - price: 5, | ||
| 133 | - num: 1, | ||
| 134 | -}]); | ||
| 135 | -const dates = ref(dates_list.value.map(item => item.date)); | ||
| 136 | 114 | ||
| 137 | const findDatesInfo = (date) => { | 115 | const findDatesInfo = (date) => { |
| 138 | - const result = dates_list.value.find((item) => item.date === date); | 116 | + const result = dates_list.value.find((item) => item.month_date === date); |
| 139 | const currentDate = new Date(date); | 117 | const currentDate = new Date(date); |
| 140 | return { | 118 | return { |
| 141 | text: currentDate.getDate().toString().padStart(2, '0'), | 119 | text: currentDate.getDate().toString().padStart(2, '0'), |
| 142 | - date: result.date, | 120 | + date: result?.month_date, |
| 143 | - price: result.price, | 121 | + price: result?.price, |
| 144 | - num: result.num, | 122 | + reserve_full: result?.reserve_full, |
| 145 | }; | 123 | }; |
| 146 | }; | 124 | }; |
| 147 | 125 | ||
| ... | @@ -186,31 +164,27 @@ const weeks = computed(() => { | ... | @@ -186,31 +164,27 @@ const weeks = computed(() => { |
| 186 | const checked_day = ref(''); | 164 | const checked_day = ref(''); |
| 187 | 165 | ||
| 188 | const checked_time = ref(-1); | 166 | const checked_time = ref(-1); |
| 189 | -const timePeriod = ref([{ | 167 | +const timePeriod = ref([]); |
| 190 | - left: '05:00-08:00', | ||
| 191 | - right: 1098, | ||
| 192 | - num: 1, | ||
| 193 | -}, { | ||
| 194 | - left: '08:00-10:00', | ||
| 195 | - right: 98, | ||
| 196 | - num: 0, | ||
| 197 | -}]); | ||
| 198 | 168 | ||
| 199 | const chooseTime = (item, index) => { // 选择时间段回调 | 169 | const chooseTime = (item, index) => { // 选择时间段回调 |
| 200 | - if (item.num) { | 170 | + if (item.rest_qty > 0 || item.rest_qty === -1) { |
| 201 | checked_time.value = index; | 171 | checked_time.value = index; |
| 202 | } | 172 | } |
| 203 | - console.log(item, index); | ||
| 204 | }; | 173 | }; |
| 205 | 174 | ||
| 206 | const checked_day_price = ref(0); | 175 | const checked_day_price = ref(0); |
| 207 | 176 | ||
| 208 | -const chooseDay = (date) => { // 点击日期回调 | 177 | +const chooseDay = async (date) => { // 点击日期回调 |
| 209 | - if (findDatesInfo(date).num) { // 有余数可约 | 178 | + if (!findDatesInfo(date).reserve_full) { // 有余数可约 |
| 210 | checked_day.value = date; | 179 | checked_day.value = date; |
| 211 | checked_day_price.value = findDatesInfo(date).price; | 180 | checked_day_price.value = findDatesInfo(date).price; |
| 212 | - // TODO: 选择日期后,查询时间段信息 | 181 | + // 选择日期后,查询时间段信息 |
| 213 | - console.warn(checked_day.value); | 182 | + const { code, data } = await canReserveTimeListAPI({ month_date: checked_day.value}); |
| 183 | + if (code) { | ||
| 184 | + // rest_qty >0表示有余量,可约;=0表示没有余量,不可约;<0表示不限,可约; | ||
| 185 | + timePeriod.value = data; | ||
| 186 | + checked_time.value = -1; | ||
| 187 | + } | ||
| 214 | } | 188 | } |
| 215 | }; | 189 | }; |
| 216 | 190 | ||
| ... | @@ -226,14 +200,19 @@ const minDate = new Date(2024, 0, 1); | ... | @@ -226,14 +200,19 @@ const minDate = new Date(2024, 0, 1); |
| 226 | const maxDate = new Date(2030, 11, 1); | 200 | const maxDate = new Date(2030, 11, 1); |
| 227 | const currentDateText = ref((raw_date.getMonth() + 1).toString().padStart(2, '0')); | 201 | const currentDateText = ref((raw_date.getMonth() + 1).toString().padStart(2, '0')); |
| 228 | 202 | ||
| 229 | -const onConfirm = ({ selectedValues, selectedOptions }) => { // 选择日期回调 | 203 | +const onConfirm = async ({ selectedValues, selectedOptions }) => { // 选择日期回调 |
| 230 | showPicker.value = false; | 204 | showPicker.value = false; |
| 231 | currentDateText.value = selectedValues[1].toString(); | 205 | currentDateText.value = selectedValues[1].toString(); |
| 232 | // 清空选择 | 206 | // 清空选择 |
| 233 | checked_day.value = ''; | 207 | checked_day.value = ''; |
| 234 | checked_time.value = -1; | 208 | checked_time.value = -1; |
| 235 | - // TODO: 选择日期后,查询月份信息 | 209 | + // 选择日期后,查询月份信息 |
| 236 | - console.warn(selectedValues); | 210 | + const { code, data } = await canReserveDateListAPI({ month: `${selectedValues[0]}-${selectedValues[1]}` }); |
| 211 | + if (code) { | ||
| 212 | + // 日期列表 | ||
| 213 | + dates_list.value = data; | ||
| 214 | + dates.value = dates_list.value.map(item => item.month_date); | ||
| 215 | + } | ||
| 237 | } | 216 | } |
| 238 | const onCancel = () => { | 217 | const onCancel = () => { |
| 239 | showPicker.value = false; | 218 | showPicker.value = false; |
| ... | @@ -246,7 +225,7 @@ const nextBtn = () => { | ... | @@ -246,7 +225,7 @@ const nextBtn = () => { |
| 246 | show_error.value = true; | 225 | show_error.value = true; |
| 247 | error_message.value = '请选择日期和时间段'; | 226 | error_message.value = '请选择日期和时间段'; |
| 248 | } else { | 227 | } else { |
| 249 | - go('/submit', { date: checked_day.value, time: timePeriod.value[checked_time.value]['left'], price: checked_day_price.value }); | 228 | + go('/submit', { date: checked_day.value, time: `${timePeriod.value[checked_time.value]['begin_time']}-${timePeriod.value[checked_time.value]['end_time']}`, price: checked_day_price.value }); |
| 250 | } | 229 | } |
| 251 | } | 230 | } |
| 252 | </script> | 231 | </script> | ... | ... |
-
Please register or login to post a comment