刘洋 1 ano atrás
pai
commit
1f1b38e51f

+ 1 - 1
index.html

@@ -2,7 +2,7 @@
 <html lang="zh-CN">
   <head>
     <meta charset="UTF-8" />
-    <link rel="icon" href="/favicon.ico" />
+    <!-- <link rel="icon" href="/favicon.ico" /> -->
     <meta
       name="viewport"
       content="width=device-width, initial-scale=1.0, user-scalable=0, viewport-fit=cover"

BIN
public/favicon.ico


+ 1 - 2
src/api/apiConfig/index.js

@@ -80,8 +80,7 @@ axiosInstance.interceptors.response.use(
           break;
         case 401:
           error.message = "请重新登录(401)";
-          //todo
-          // router.replace({ name: "Login" });
+          router.replace({ name: "Login" });
           break;
         case 403:
           error.message = "拒绝访问(403)";

+ 24 - 2
src/api/user.js

@@ -28,10 +28,11 @@ export function getProperties() {
 }
 
 //获取考生当前进行中的预约列表(首页)
-export function getMyList() {
+export function getIndexList() {
   return request({
     url: "/api/student/apply/list/for/current",
     method: "post",
+    loading: true,
   });
 }
 
@@ -41,14 +42,35 @@ export function getReservationList(data) {
     url: "/api/student/apply/time/period/list",
     method: "post",
     data,
+    loading: true,
+  });
+}
+//保存考生预约结果
+export function reservationSave(data) {
+  return request({
+    url: "/api/student/apply/save",
+    method: "post",
+    data,
+  });
+}
+//取消考生预约结果
+export function reservationCancel(data) {
+  return request({
+    url: "/api/student/apply/cancel",
+    method: "post",
+    data,
   });
 }
 
 //获取数据分类列表
-export function getCategoryList() {
+export function getCategoryList(data) {
   return request({
     url: "/api/student/category/list",
     method: "post",
+    data,
+    headers: {
+      "Content-Type": "application/x-www-form-urlencoded",
+    },
   });
 }
 

+ 1 - 2
src/assets/styles/base.css

@@ -49,9 +49,8 @@ body {
   color: var(--color-text);
   background: var(--color-background);
   transition: color 0.5s, background-color 0.5s;
-  line-height: 1.6;
   font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
-  font-size: 15px;
+  font-size: 14px;
   text-rendering: optimizeLegibility;
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;

+ 1 - 2
src/assets/styles/base.less

@@ -62,11 +62,10 @@ body {
   color: var(--color-text);
   background: var(--color-background);
   transition: color 0.5s, background-color 0.5s;
-  line-height: 1.6;
   font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
     Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue",
     sans-serif;
-  font-size: 15px;
+  font-size: 14px;
   text-rendering: optimizeLegibility;
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;

+ 1 - 0
src/assets/styles/main.css

@@ -71,6 +71,7 @@
   min-height: 100vh;
   background-color: #f9f9f9;
   font-family: PingFangSC-Regular, PingFang SC;
+  overflow: auto;
   -webkit-overflow-scrolling: touch;
   display: flex;
   flex-direction: column;

+ 1 - 0
src/assets/styles/main.less

@@ -73,6 +73,7 @@
   min-height: 100vh;
   background-color: #f9f9f9;
   font-family: PingFangSC-Regular, PingFang SC;
+  overflow: auto;
   -webkit-overflow-scrolling: touch;
   display: flex;
   flex-direction: column;

+ 3 - 16
src/pages/chooseSite.vue

@@ -13,27 +13,14 @@ import { useRoute, useRouter } from "vue-router";
 import { getSiteList } from "@/api/user";
 import bus from "@/utils/bus";
 
-const data = [
-  {
-    examSiteId: "1",
-    examSiteName: "作弊考点1",
-    examSiteAddress: "作弊考点地址",
-  },
-];
-
 const router = useRouter();
 const route = useRoute();
 const siteList = ref([]);
 const activeItem = ref();
 function getExamSiteList() {
-  getSiteList({ categoryId: route.params.id })
-    .then((res) => {
-      siteList.value = res;
-    })
-    .catch(() => {
-      //借用catch使用假数据先
-      siteList.value = data;
-    });
+  getSiteList({ categoryId: route.params.id }).then((res) => {
+    siteList.value = res;
+  });
 }
 getExamSiteList();
 

+ 28 - 7
src/pages/tab-pages/index.vue

@@ -1,21 +1,42 @@
 <template>
-  <div class="index tab-page f14">
-    首页
-
-    <van-button>111</van-button>
+  <div class="index tab-page">
+    <div class="card">
+      <div class="location-info"></div>
+      <div class="time-info"></div>
+    </div>
   </div>
 </template>
 <script name="Index" setup>
 import { ref } from "vue";
 import { useUserStore } from "@/store";
-import { getMyList } from "@/api/user";
+import { getIndexList, reservationCancel } from "@/api/user";
 const userStore = useUserStore();
 userStore.requestStuInfo();
 const resultList = ref([]);
 function getList() {
-  getMyList().then((res) => {
+  getIndexList().then((res) => {
     resultList.value = res || [];
   });
 }
+getList();
+function cancel(item) {
+  showConfirmDialog({
+    // title: '标题',
+    message: "确定取消该预约吗?",
+  }).then(() => {
+    reservationCancel({ applyId: item.applyId }).then(() => {
+      showSuccessToast("取消成功");
+      getList();
+    });
+  });
+}
 </script>
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.index {
+  padding: 15px;
+  .card {
+    background-color: #fff;
+    border-radius: 6px;
+  }
+}
+</style>

+ 55 - 82
src/pages/tab-pages/reservation.vue

@@ -79,11 +79,19 @@
       <div class="list-box">
         <div v-for="item in resultList" :key="item.timePeriodId">
           <div class="flex-h-between">
-            <div>{{ $filters.dateFormat(item.timePeriodStart, "mm:ss") }}</div>
+            <div>
+              {{ $filters.dateFormat(item.timePeriodStart, "mm:ss") }}-{{
+                $filters.dateFormat(item.timePeriodEnd, "mm:ss")
+              }}
+            </div>
             <div>剩余{{ item.availableCount }}</div>
-            <van-button type="primary" size="small">{{
-              item.status
-            }}</van-button>
+            <van-button
+              type="primary"
+              size="small"
+              :disabled="item.status != '可约'"
+              @click="reservation(item)"
+              >{{ item.status }}</van-button
+            >
           </div>
         </div>
       </div>
@@ -98,43 +106,18 @@
 <script name="Reservation" setup>
 import { ref, reactive, computed, watch } from "vue";
 import { isJson } from "@/utils";
-import { getCategoryList, getDateList, getReservationList } from "@/api/user";
+import filters from "@/filters";
+import {
+  getCategoryList,
+  getDateList,
+  getReservationList,
+  reservationSave,
+} from "@/api/user";
 import { useRouter } from "vue-router";
 import bus from "@/utils/bus";
 
 const router = useRouter();
-const data = [
-  {
-    parentId: "0",
-    id: "1",
-    name: "广州",
-    level: "1",
-    subNodes: [
-      {
-        parentId: "1",
-        id: "2",
-        name: "广州教学点A",
-        level: "2",
-        subNodes: [],
-      },
-    ],
-  },
-  {
-    parentId: "0",
-    id: "3",
-    name: "武汉",
-    level: "1",
-    subNodes: [
-      {
-        parentId: "3",
-        id: "4",
-        name: "武汉教学点A",
-        level: "2",
-        subNodes: [],
-      },
-    ],
-  },
-];
+
 const resultList = ref([]);
 const params = reactive({
   aaa: { value: "", text: "" },
@@ -142,6 +125,7 @@ const params = reactive({
   examSiteId: { value: "", text: "" },
   date: { value: "", text: "" },
 });
+const treeData = ref([]);
 const cityStates = reactive({
   show: false,
   value: [],
@@ -152,7 +136,7 @@ const cityStates = reactive({
       params.aaa = { ...option };
       teachStates.value = [];
       params.bbb = { value: "", text: "" };
-      teachStates.columns = data
+      teachStates.columns = treeData.value
         .find((item) => item.id == option.value)
         .subNodes.map((item) => ({ text: item.name, value: item.id }));
     }
@@ -191,33 +175,24 @@ const toChooseSite = () => {
 };
 
 function getLocation() {
-  getCategoryList()
-    .then((res) => {
-      cityStates.columns = res.map((item) => ({
-        text: item.name,
-        value: item.id,
-      }));
-    })
-    .catch(() => {
-      //借用catch使用假数据先
-      cityStates.columns = data.map((item) => ({
-        text: item.name,
-        value: item.id,
-      }));
-    });
+  getCategoryList().then((res) => {
+    res = res || [];
+    treeData.value = res;
+    cityStates.columns = res.map((item) => ({
+      text: item.name,
+      value: item.id,
+    }));
+  });
 }
 getLocation();
 
 function getDateOptions() {
-  getDateList()
-    .then((res) => {})
-    .catch(() => {
-      let res = ["20240403"];
-      dateStates.columns = res.map((item) => ({
-        value: item,
-        text: `${item.slice(0, 4)}-${item.slice(4, 6)}-${item.slice(6)}`,
-      }));
-    });
+  getDateList().then((res) => {
+    dateStates.columns = res.map((item) => ({
+      value: item,
+      text: `${item.slice(0, 4)}-${item.slice(4, 6)}-${item.slice(6)}`,
+    }));
+  });
 }
 getDateOptions();
 
@@ -226,27 +201,25 @@ function getResultList() {
   getReservationList({
     examSiteId: params.examSiteId.value,
     date: params.date.value,
-  })
-    .then((res) => {
-      unApplyNumber.value = res.unApplyNumber;
-      resultList.value = res.periodList || [];
-    })
-    .catch(() => {
-      let res = {
-        unApplyNumber: 1,
-        periodList: [
-          {
-            timePeriodId: "1",
-            timePeriodStart: 1712134122545,
-            timePeriodEnd: 1714435200000,
-            availableCount: 1,
-            status: "可约",
-          },
-        ],
-      };
-      unApplyNumber.value = res.unApplyNumber;
-      resultList.value = res.periodList || [];
-    });
+  }).then((res) => {
+    unApplyNumber.value = res.unApplyNumber;
+    resultList.value = res.periodList || [];
+  });
+}
+
+function reservation(item) {
+  showConfirmDialog({
+    // title: '标题',
+    message: `${params.date.text} ${filters.dateFormat(
+      item.timePeriodStart,
+      "mm:ss"
+    )}-${filters.dateFormat(item.timePeriodEnd, "mm:ss")}`,
+  }).then(() => {
+    reservationSave({
+      examSiteId: params.examSiteId.value,
+      timePeriodId: item.timePeriodId,
+    }).then(() => {});
+  });
 }
 
 watch([() => params.examSiteId, () => params.date], ([examSiteId, date]) => {

+ 1 - 1
src/router/index.js

@@ -17,7 +17,7 @@ const router = createRouter({
     behavior: "smooth",
   }),
 });
-const whiteList = ["Login", "Index", "Reservation", "Mine"];
+const whiteList = ["Login"];
 router.beforeEach(async (to, from, next) => {
   if (to.meta.jsApiList) {
     await LibForWeixin.initJSSDK(to.meta.jsApiList)