Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
xysBooking
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2024-01-20 10:51:10 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3efb1eaee964e02d4c2933bb6317fddfa4531d2a
3efb1eae
1 parent
a36eb432
业务逻辑优化
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
28 deletions
src/views/auth.vue
src/views/booking.vue
src/views/index.vue
src/views/auth.vue
View file @
3efb1ea
<!--
* @Date: 2022-08-29 13:55:31
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-01-20 09:
25:06
* @LastEditTime: 2024-01-20 09:
33:07
* @FilePath: /xysBooking/src/views/auth.vue
* @Description: 授权模块
-->
...
...
@@ -28,13 +28,13 @@ onMounted(() => {
window.history.pushState(null, '', '/'); // 将授权页面替换为根路径或其他合适的路径
// 在返回按钮被点击时,检测历史记录的变化并进行处理
window.addEventListener('popstate', function(event) {
// 检查当前页面的 URL
if (window.location.pathname === '/auth') {
// 如果当前页面是授权页面,使用 replaceState() 方法将其替换为其他页面
window.history.replaceState(null, '', raw_url); // 替换为其他合适的路径
}
});
//
window.addEventListener('popstate', function(event) {
//
// 检查当前页面的 URL
//
if (window.location.pathname === '/auth') {
//
// 如果当前页面是授权页面,使用 replaceState() 方法将其替换为其他页面
//
window.history.replaceState(null, '', raw_url); // 替换为其他合适的路径
//
}
//
});
// TAG: 开发环境测试数据
const short_url = `/srv/?a=openid&res=${raw_url}`;
...
...
src/views/booking.vue
View file @
3efb1ea
<!--
* @Date: 2024-01-15 13:35:51
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-01-
18 13:47:50
* @LastEditTime: 2024-01-
20 10:50:39
* @FilePath: /xysBooking/src/views/booking.vue
* @Description: 预约页面
* @Version: 1.0.0
-->
<template>
<div class="booking-page">
...
...
@@ -101,8 +100,8 @@ useTitle($route.meta.title);
const go = useGo();
const dates_list = ref([]);
const dates = ref([]);
const dates_list = ref([]);
// 当月日期
列表信息
const dates = ref([]);
// 当
月日期集合
onMounted(async () => {
const raw_date = new Date();
...
...
@@ -120,6 +119,11 @@ onMounted(async () => {
}
})
/**
* @description: 根据日期获取信息
* @param {string} date
* @return {object} {text: 日期, date: 日期, price: 价格, reserve_full: 是否可约}
*/
const findDatesInfo = (date) => {
const result = dates_list.value.find((item) => item.month_date === date);
const currentDate = new Date(date);
...
...
@@ -133,6 +137,10 @@ const findDatesInfo = (date) => {
const daysOfWeek = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"];
/**
* @description: 每周日期列表
* @return {array} [array]
*/
const weeks = computed(() => {
const result = [];
let currentWeek = [];
...
...
@@ -170,28 +178,26 @@ const weeks = computed(() => {
});
const checked_day = ref('');
const checked_day_price = ref(0);
const checked_time = ref(-1);
const timePeriod = ref([]);
const timePeriod = ref([]);
// 当前时间
段信息
const chooseTime = (item, index) => { // 选择时间段回调
if (item.rest_qty > 0 || item.rest_qty === -1) {
if (item.rest_qty > 0 || item.rest_qty === -1) {
// 余量等于-
1为不限制数量
checked_time.value = index;
}
};
const checked_day_price = ref(0);
const chooseDay = async (date) => { // 点击日期回调
if (!findDatesInfo(date).reserve_full) { // 有余数可约
checked_day.value = date;
checked_day_price.value = findDatesInfo(date).price;
if (!findDatesInfo(date).reserve_full) { // 日
期
可约状态
checked_day.value = date;
// 当
前日期
checked_day_price.value = findDatesInfo(date).price;
// 当前
价格
// 选择日期后,查询时间段信息
const { code, data } = await canReserveTimeListAPI({ month_date: checked_day.value});
if (code) {
// rest_qty >0表示有余量,可约;=0表示没有余量,不可约;<0表示不限,可约;
timePeriod.value = data;
checked_time.value = -1;
checked_time.value = -1;
// 重置已选
择的时间段
}
}
};
...
...
@@ -204,8 +210,8 @@ const chooseDate = () => {
const raw_date = new Date();
const currentDate = ref([raw_date.getFullYear(), raw_date.getMonth()]);
const columnsType = ['year', 'month'];
const minDate = new Date(
2024, 0, 1
);
const maxDate = new Date(20
3
0, 11, 1);
const minDate = new Date();
const maxDate = new Date(20
5
0, 11, 1);
const currentDateText = ref((raw_date.getMonth() + 1).toString().padStart(2, '0'));
const onConfirm = async ({ selectedValues, selectedOptions }) => { // 选择日期回调
...
...
@@ -228,6 +234,7 @@ const onConfirm = async ({ selectedValues, selectedOptions }) => { //
dates.value = dates_list.value.map(item => item.month_date);
}
}
const onCancel = () => {
showPicker.value = false;
}
...
...
src/views/index.vue
View file @
3efb1ea
<!--
* @Date: 2023-06-21 10:23:09
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-01-
19 15:45:54
* @LastEditTime: 2024-01-
20 10:26:46
* @FilePath: /xysBooking/src/views/index.vue
* @Description: 预约页首页
-->
...
...
@@ -60,7 +60,7 @@ import icon_2 from '@/assets/images/预约记录@2x.png'
import icon_3 from '@/assets/images/首页02@2x.png'
import icon_4 from '@/assets/images/二维码icon.png'
import icon_5 from '@/assets/images/我的01@2x.png'
import { canReserveDateListAPI } from '@/api/index'
import { useClickAway } from '@vant/use';
const $route = useRoute();
const $router = useRouter();
...
...
@@ -82,9 +82,6 @@ const toMy = () => { // 跳转到我的
}
onMounted(async () => {
// TODO: 获取接口模拟授权,在首页的时候重定向
const raw_date = new Date();
const { code, data } = await canReserveDateListAPI({ month: `${raw_date.getFullYear()}-${raw_date.getMonth() + 1}` });
});
const root = ref();
...
...
Please
register
or
login
to post a comment