hookehuyr

业务逻辑优化

1 <!-- 1 <!--
2 * @Date: 2022-08-29 13:55:31 2 * @Date: 2022-08-29 13:55:31
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-01-20 09:25:06 4 + * @LastEditTime: 2024-01-20 09:33:07
5 * @FilePath: /xysBooking/src/views/auth.vue 5 * @FilePath: /xysBooking/src/views/auth.vue
6 * @Description: 授权模块 6 * @Description: 授权模块
7 --> 7 -->
...@@ -28,13 +28,13 @@ onMounted(() => { ...@@ -28,13 +28,13 @@ onMounted(() => {
28 window.history.pushState(null, '', '/'); // 将授权页面替换为根路径或其他合适的路径 28 window.history.pushState(null, '', '/'); // 将授权页面替换为根路径或其他合适的路径
29 29
30 // 在返回按钮被点击时,检测历史记录的变化并进行处理 30 // 在返回按钮被点击时,检测历史记录的变化并进行处理
31 - window.addEventListener('popstate', function(event) { 31 + // window.addEventListener('popstate', function(event) {
32 - // 检查当前页面的 URL 32 + // // 检查当前页面的 URL
33 - if (window.location.pathname === '/auth') { 33 + // if (window.location.pathname === '/auth') {
34 - // 如果当前页面是授权页面,使用 replaceState() 方法将其替换为其他页面 34 + // // 如果当前页面是授权页面,使用 replaceState() 方法将其替换为其他页面
35 - window.history.replaceState(null, '', raw_url); // 替换为其他合适的路径 35 + // window.history.replaceState(null, '', raw_url); // 替换为其他合适的路径
36 - } 36 + // }
37 - }); 37 + // });
38 38
39 // TAG: 开发环境测试数据 39 // TAG: 开发环境测试数据
40 const short_url = `/srv/?a=openid&res=${raw_url}`; 40 const short_url = `/srv/?a=openid&res=${raw_url}`;
......
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-18 13:47:50 4 + * @LastEditTime: 2024-01-20 10:50:39
5 * @FilePath: /xysBooking/src/views/booking.vue 5 * @FilePath: /xysBooking/src/views/booking.vue
6 * @Description: 预约页面 6 * @Description: 预约页面
7 - * @Version: 1.0.0
8 --> 7 -->
9 <template> 8 <template>
10 <div class="booking-page"> 9 <div class="booking-page">
...@@ -101,8 +100,8 @@ useTitle($route.meta.title); ...@@ -101,8 +100,8 @@ useTitle($route.meta.title);
101 100
102 const go = useGo(); 101 const go = useGo();
103 102
104 -const dates_list = ref([]); 103 +const dates_list = ref([]); // 当月日期列表信息
105 -const dates = ref([]); 104 +const dates = ref([]); // 当月日期集合
106 105
107 onMounted(async () => { 106 onMounted(async () => {
108 const raw_date = new Date(); 107 const raw_date = new Date();
...@@ -120,6 +119,11 @@ onMounted(async () => { ...@@ -120,6 +119,11 @@ onMounted(async () => {
120 } 119 }
121 }) 120 })
122 121
122 +/**
123 + * @description: 根据日期获取信息
124 + * @param {string} date
125 + * @return {object} {text: 日期, date: 日期, price: 价格, reserve_full: 是否可约}
126 + */
123 const findDatesInfo = (date) => { 127 const findDatesInfo = (date) => {
124 const result = dates_list.value.find((item) => item.month_date === date); 128 const result = dates_list.value.find((item) => item.month_date === date);
125 const currentDate = new Date(date); 129 const currentDate = new Date(date);
...@@ -133,6 +137,10 @@ const findDatesInfo = (date) => { ...@@ -133,6 +137,10 @@ const findDatesInfo = (date) => {
133 137
134 const daysOfWeek = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]; 138 const daysOfWeek = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"];
135 139
140 +/**
141 + * @description: 每周日期列表
142 + * @return {array} [array]
143 + */
136 const weeks = computed(() => { 144 const weeks = computed(() => {
137 const result = []; 145 const result = [];
138 let currentWeek = []; 146 let currentWeek = [];
...@@ -170,28 +178,26 @@ const weeks = computed(() => { ...@@ -170,28 +178,26 @@ const weeks = computed(() => {
170 }); 178 });
171 179
172 const checked_day = ref(''); 180 const checked_day = ref('');
173 - 181 +const checked_day_price = ref(0);
174 const checked_time = ref(-1); 182 const checked_time = ref(-1);
175 -const timePeriod = ref([]); 183 +const timePeriod = ref([]); // 当前时间段信息
176 184
177 const chooseTime = (item, index) => { // 选择时间段回调 185 const chooseTime = (item, index) => { // 选择时间段回调
178 - if (item.rest_qty > 0 || item.rest_qty === -1) { 186 + if (item.rest_qty > 0 || item.rest_qty === -1) { // 余量等于-1为不限制数量
179 checked_time.value = index; 187 checked_time.value = index;
180 } 188 }
181 }; 189 };
182 190
183 -const checked_day_price = ref(0);
184 -
185 const chooseDay = async (date) => { // 点击日期回调 191 const chooseDay = async (date) => { // 点击日期回调
186 - if (!findDatesInfo(date).reserve_full) { // 有余数可约 192 + if (!findDatesInfo(date).reserve_full) { // 日可约状态
187 - checked_day.value = date; 193 + checked_day.value = date; // 当前日期
188 - checked_day_price.value = findDatesInfo(date).price; 194 + checked_day_price.value = findDatesInfo(date).price; // 当前价格
189 // 选择日期后,查询时间段信息 195 // 选择日期后,查询时间段信息
190 const { code, data } = await canReserveTimeListAPI({ month_date: checked_day.value}); 196 const { code, data } = await canReserveTimeListAPI({ month_date: checked_day.value});
191 if (code) { 197 if (code) {
192 // rest_qty >0表示有余量,可约;=0表示没有余量,不可约;<0表示不限,可约; 198 // rest_qty >0表示有余量,可约;=0表示没有余量,不可约;<0表示不限,可约;
193 timePeriod.value = data; 199 timePeriod.value = data;
194 - checked_time.value = -1; 200 + checked_time.value = -1; // 重置已选择的时间段
195 } 201 }
196 } 202 }
197 }; 203 };
...@@ -204,8 +210,8 @@ const chooseDate = () => { ...@@ -204,8 +210,8 @@ const chooseDate = () => {
204 const raw_date = new Date(); 210 const raw_date = new Date();
205 const currentDate = ref([raw_date.getFullYear(), raw_date.getMonth()]); 211 const currentDate = ref([raw_date.getFullYear(), raw_date.getMonth()]);
206 const columnsType = ['year', 'month']; 212 const columnsType = ['year', 'month'];
207 -const minDate = new Date(2024, 0, 1); 213 +const minDate = new Date();
208 -const maxDate = new Date(2030, 11, 1); 214 +const maxDate = new Date(2050, 11, 1);
209 const currentDateText = ref((raw_date.getMonth() + 1).toString().padStart(2, '0')); 215 const currentDateText = ref((raw_date.getMonth() + 1).toString().padStart(2, '0'));
210 216
211 const onConfirm = async ({ selectedValues, selectedOptions }) => { // 选择日期回调 217 const onConfirm = async ({ selectedValues, selectedOptions }) => { // 选择日期回调
...@@ -228,6 +234,7 @@ const onConfirm = async ({ selectedValues, selectedOptions }) => { // ...@@ -228,6 +234,7 @@ const onConfirm = async ({ selectedValues, selectedOptions }) => { //
228 dates.value = dates_list.value.map(item => item.month_date); 234 dates.value = dates_list.value.map(item => item.month_date);
229 } 235 }
230 } 236 }
237 +
231 const onCancel = () => { 238 const onCancel = () => {
232 showPicker.value = false; 239 showPicker.value = false;
233 } 240 }
......
1 <!-- 1 <!--
2 * @Date: 2023-06-21 10:23:09 2 * @Date: 2023-06-21 10:23:09
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-01-19 15:45:54 4 + * @LastEditTime: 2024-01-20 10:26:46
5 * @FilePath: /xysBooking/src/views/index.vue 5 * @FilePath: /xysBooking/src/views/index.vue
6 * @Description: 预约页首页 6 * @Description: 预约页首页
7 --> 7 -->
...@@ -60,7 +60,7 @@ import icon_2 from '@/assets/images/预约记录@2x.png' ...@@ -60,7 +60,7 @@ import icon_2 from '@/assets/images/预约记录@2x.png'
60 import icon_3 from '@/assets/images/首页02@2x.png' 60 import icon_3 from '@/assets/images/首页02@2x.png'
61 import icon_4 from '@/assets/images/二维码icon.png' 61 import icon_4 from '@/assets/images/二维码icon.png'
62 import icon_5 from '@/assets/images/我的01@2x.png' 62 import icon_5 from '@/assets/images/我的01@2x.png'
63 -import { canReserveDateListAPI } from '@/api/index' 63 +
64 import { useClickAway } from '@vant/use'; 64 import { useClickAway } from '@vant/use';
65 const $route = useRoute(); 65 const $route = useRoute();
66 const $router = useRouter(); 66 const $router = useRouter();
...@@ -82,9 +82,6 @@ const toMy = () => { // 跳转到我的 ...@@ -82,9 +82,6 @@ const toMy = () => { // 跳转到我的
82 } 82 }
83 83
84 onMounted(async () => { 84 onMounted(async () => {
85 - // TODO: 获取接口模拟授权,在首页的时候重定向
86 - const raw_date = new Date();
87 - const { code, data } = await canReserveDateListAPI({ month: `${raw_date.getFullYear()}-${raw_date.getMonth() + 1}` });
88 }); 85 });
89 86
90 const root = ref(); 87 const root = ref();
......