Explorar el Código

自查,优化

刘洋 hace 1 año
padre
commit
af72a08b58

+ 4 - 0
src/api/apiConfig/index.js

@@ -77,6 +77,7 @@ axiosInstance.interceptors.response.use(
 
     if (error && error.response) {
       error.response.config.toast?.close();
+      console.log("error.response", error.response);
       switch (error.response.status) {
         case 400:
           error.message = "请求参数错误(400)";
@@ -124,6 +125,9 @@ axiosInstance.interceptors.response.use(
     } else {
       error.message = "服务连接失败";
     }
+    if (error?.response?.data?.message) {
+      error.message = error?.response?.data?.message;
+    }
     showToast(error.message);
     return Promise.reject(error);
   }

+ 4 - 2
src/pages/applyResult.vue

@@ -12,9 +12,11 @@
         <template #title>
           预约{{ route.query?.status === "success" ? "成功" : "失败" }}!
         </template>
-        <span v-if="route.query?.status === 'fail'">当前时段已约满</span>
+        <span v-if="route.query?.status === 'fail'">{{
+          route.query?.message || "当前时段已约满"
+        }}</span>
       </NoData>
-      <div class="btn-box d-flex align-items-center">
+      <div class="btn-box d-flex align-items-center justify-content-center">
         <div class="cus-btn flex-h-center" @click="continueApply">继续预约</div>
         <div
           class="cus-btn default flex-h-center ml-20"

+ 13 - 3
src/pages/examNotice.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="page exam-notice">
     <div class="title">考试须知</div>
-    <div class="content" v-html="ct"></div>
+    <div class="content" v-html="cutNbsp(ct)"></div>
   </div>
 </template>
 <script name="ExamNotice" setup>
@@ -10,12 +10,22 @@ import { useRoute } from "vue-router";
 import { getExamNotice } from "@/api/user";
 
 const route = useRoute();
-const ct = ref("");
+const ct = ref(
+  `
+  <p>Peter&rsquo;s&nbsp;job&nbsp;was&nbsp;to&nbsp;examine&nbsp;cars&nbsp;when&nbsp;they&nbsp;crossed&nbsp;the&nbsp;frontier&nbsp;to&nbsp;make&nbsp;sure&nbsp;that&nbsp;they&nbsp;were&nbsp;not&nbsp;smuggling&nbsp;anything&nbsp;into&nbsp;the&nbsp;country.&nbsp;Every&nbsp;evening&nbsp;he&nbsp;would&nbsp;see&nbsp;a&nbsp;factory&nbsp;worker&nbsp;coming&nbsp;___1___the&nbsp;hill&nbsp;towards&nbsp;the&nbsp;frontier,&nbsp;___2___a&nbsp;bike&nbsp;with&nbsp;a&nbsp;pile&nbsp;of&nbsp;goods&nbsp;of&nbsp;old&nbsp;straw&nbsp;on&nbsp;it.&nbsp;When&nbsp;the&nbsp;bike___3___&nbsp;the&nbsp;frontier,&nbsp;Peter&nbsp;would&nbsp;stop&nbsp;the&nbsp;man&nbsp;and___4___him&nbsp;take&nbsp;the&nbsp;straw&nbsp;off&nbsp;and&nbsp;untie&nbsp;it.&nbsp;Then&nbsp;he&nbsp;would&nbsp;examine&nbsp;the&nbsp;straw&nbsp;very___5___&nbsp;to&nbsp;see___6___he&nbsp;could&nbsp;find&nbsp;anything,&nbsp;after&nbsp;which&nbsp;he&nbsp;would&nbsp;look&nbsp;in&nbsp;all&nbsp;the&nbsp;man&rsquo;s&nbsp;pockets___7___he&nbsp;let&nbsp;him&nbsp;tie&nbsp;the&nbsp;straw&nbsp;again.&nbsp;The&nbsp;man&nbsp;would&nbsp;then&nbsp;put&nbsp;it&nbsp;on&nbsp;his&nbsp;bike&nbsp;and&nbsp;go&nbsp;off&nbsp;down&nbsp;the&nbsp;hill&nbsp;with&nbsp;it.&nbsp;Although&nbsp;Peter&nbsp;was&nbsp;always___8___to&nbsp;find&nbsp;gold&nbsp;or&nbsp;other&nbsp;valuable&nbsp;things&nbsp;___9___in&nbsp;the&nbsp;straw,&nbsp;he&nbsp;never&nbsp;found&nbsp;___10___.&nbsp;He&nbsp;was&nbsp;sure&nbsp;the&nbsp;man&nbsp;was&nbsp;smuggling&nbsp;something,&nbsp;but&nbsp;he&nbsp;was&nbsp;not&nbsp;able&nbsp;to&nbsp;think&nbsp;out&nbsp;what&nbsp;it&nbsp;could&nbsp;be.&nbsp;</p>
+  `
+);
+function cutNbsp(ct) {
+  if (typeof ct !== "string") {
+    return ct;
+  }
+  return ct.replace(/&nbsp;/g, " ");
+}
 
 //获取考试须知
 function _getExamNotice() {
   getExamNotice({ applyTaskId: route.params?.applyId }).then((res) => {
-    ct.value = res?.content || "";
+    // ct.value = res?.content || "";
   });
 }
 _getExamNotice();

+ 35 - 9
src/pages/myHistory.vue

@@ -1,22 +1,48 @@
 <template>
   <div class="my-history page p-16">
-    <ApplyItem
-      :item="item"
-      @update="_getMyHistory"
-      v-for="item in list"
-      :key="item.applyId"
-    ></ApplyItem>
+    <template v-if="loading"></template>
+    <template v-else-if="list.length">
+      <ApplyItem
+        :item="item"
+        @update="_getMyHistory"
+        v-for="item in list"
+        :key="item.applyId"
+      ></ApplyItem>
+    </template>
+    <div class="vh-100 text-center flex-h-center" v-else>
+      <div>
+        <NoData>
+          <template #img>
+            <img src="../assets/imgs/no_data.png" />
+          </template>
+          当前无考试预约订单</NoData
+        >
+        <div class="cus-btn flex-h-center" @click="toReservation">去预约</div>
+      </div>
+    </div>
   </div>
 </template>
 <script name="MyHistory" setup>
 import { ref } from "vue";
 import { getMyHistory } from "@/api/user";
+import { useRouter } from "vue-router";
+const router = useRouter();
 const list = ref([]);
+const loading = ref(false);
 function _getMyHistory() {
-  getMyHistory().then((res) => {
-    list.value = res || [];
-  });
+  loading.value = true;
+  getMyHistory()
+    .then((res) => {
+      list.value = res || [];
+    })
+    .finally(() => {
+      loading.value = false;
+    });
 }
 _getMyHistory();
+
+function toReservation() {
+  router.push({ name: "Reservation" });
+}
 </script>
 <style lang="less" scoped></style>

+ 7 - 4
src/pages/tab-pages/reservation.vue

@@ -20,7 +20,7 @@
           label="教学点"
           placeholder=""
           input-align="right"
-          is-link
+          :is-link="!!params.aaa.value"
           readonly
           :rules="[{ required: true, message: '请选择教学点' }]"
           @click="teachStates.show = true"
@@ -32,7 +32,7 @@
           label="考点"
           placeholder=""
           input-align="right"
-          is-link
+          :is-link="!!params.bbb.value"
           readonly
           :rules="[{ required: true, message: '请选择考点' }]"
           @click="toChooseSite"
@@ -276,8 +276,11 @@ function reservationHandle(item) {
       .then(() => {
         router.push({ name: "ApplyResult", query: { status: "success" } });
       })
-      .catch(() => {
-        router.push({ name: "ApplyResult", query: { status: "fail" } });
+      .catch((err) => {
+        router.push({
+          name: "ApplyResult",
+          query: { status: "fail", message: err?.message || "" },
+        });
       });
   });
 }