Quellcode durchsuchen

chore: 可预约日期取当天往后顺延6天

chenlei vor 2 Jahren
Ursprung
Commit
4cafe39f85

+ 3 - 0
src/views/venue-reservation/index.scss

@@ -186,6 +186,9 @@
       &:not(:last-child) {
         margin-right: 0.1625rem /* 13/80 */;
       }
+      &.disabled {
+        color: #999;
+      }
       &.active {
         color: #fff;
         background-image: url("./imgs/btn_m_active@2x.png");

+ 14 - 9
src/views/venue-reservation/index.vue

@@ -96,8 +96,9 @@
               :class="[
                 'vr-flex__item',
                 item.value === form.bookDay && 'active',
+                item.disabled && 'disabled',
               ]"
-              @click="form.bookDay = item.value"
+              @click="!item.disabled && (form.bookDay = item.value)"
             >
               {{ item.label }}
             </div>
@@ -159,7 +160,7 @@
 <script lang="ts" setup>
 import { getVenueNumApi, reservationVenueApi } from "@/api";
 import { BackBtn } from "@/components";
-import { formatDate, parseDate } from "@/utils";
+import { formatDate } from "@/utils";
 import Dialog from "./components/dialog.vue";
 import { FormInstance, FormRules } from "element-plus";
 import { computed, onActivated, onMounted, reactive, ref, watch } from "vue";
@@ -173,6 +174,8 @@ import { OpenVirtualKeyBoard } from "@/utils/open-keyboard";
 type DateType = {
   label: string;
   value: string;
+  week: number;
+  disabled: boolean;
 };
 
 let visitorId = 0;
@@ -258,7 +261,10 @@ const handleFocus = () => {
 const clear = () => {
   Object.assign(form, {
     ...DEFAULT_FORM,
-    bookDay: dateList.value[0].value,
+    bookDay:
+      dateList.value[0].week !== 1
+        ? dateList.value[0].value
+        : dateList.value[1].value,
     venues: venues.value[0],
     exhibitionName: MUSEUM_LIST[0].name,
   });
@@ -286,25 +292,24 @@ const addVisitor = () => {
 const initDate = () => {
   const stack: DateType[] = [];
   const today = new Date();
-  const endDay = parseDate("2023-08-20");
+  const endDay = new Date();
   let isTomorro = true;
+  endDay.setDate(today.getDate() + 6);
 
   if (!endDay) return;
 
   while (today.getTime() < endDay.getTime()) {
     today.setDate(today.getDate() + 1);
     const day = formatDate(today);
-    if (day === "2023-08-14") {
-      isTomorro = false;
-      continue;
-    }
+    const week = today.getDay();
     stack.push({
       value: day,
       label: `${isTomorro ? "明天" : ""}${formatDate(today, "MM月DD日")}`,
+      disabled: week === 1,
+      week,
     });
     isTomorro = false;
   }
-  form.bookDay = stack[0].value;
   dateList.value = stack;
 };
 

+ 3 - 3
src/views/ver-scroll-home/index.vue

@@ -105,9 +105,9 @@ const menuList = computed(() => [
         isOnline.value = online;
 
         const today = formatDate(new Date());
-        const curTime = parseDate(new Date())!;
-        const startTime = parseDate(`${today} 8:00`)!;
-        const endTime = parseDate(`${today} 18:00`)!;
+        const curTime = parseDate(new Date()) || new Date();
+        const startTime = parseDate(`${today} 8:00`) || new Date();
+        const endTime = parseDate(`${today} 18:00`) || new Date();
 
         if (
           curTime.getTime() < startTime.getTime() ||