diff --git a/components.d.ts b/components.d.ts index 6b2082f..61bef71 100644 --- a/components.d.ts +++ b/components.d.ts @@ -37,6 +37,7 @@ declare module 'vue' { ElUpload: typeof import('element-plus/es')['ElUpload'] FloatingMenu: typeof import('./src/components/floatingMenu.vue')['default'] Login: typeof import('./src/components/login.vue')['default'] + PageNotFound: typeof import('./src/components/PageNotFound.vue')['default'] Register: typeof import('./src/components/register.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] diff --git a/src/components/PageNotFound.vue b/src/components/PageNotFound.vue new file mode 100644 index 0000000..eda2a45 --- /dev/null +++ b/src/components/PageNotFound.vue @@ -0,0 +1,33 @@ + + + + + \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index 2854c0f..5503591 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -45,6 +45,14 @@ const routes=[ isFullpage: true } }, + { + path:'/:pathMatch(.*)*', + name:'NotFound', + component:()=>import('@/components/PageNotFound.vue'), + meta:{ + isFullpage: true + } + }, ]; const router = createRouter({ history:createWebHistory(), diff --git a/src/views/HeadMenu.vue b/src/views/HeadMenu.vue index e4607c4..2f115ed 100644 --- a/src/views/HeadMenu.vue +++ b/src/views/HeadMenu.vue @@ -20,7 +20,7 @@
{{ - approval_status == 4 || !isLoggedIn ? "立即入驻" : "查看审核状态" + approval_status == -1 || approval_status == 4 || !isLoggedIn ? "立即入驻" : "查看审核状态" }}
@@ -38,7 +38,7 @@ {{ mobile }} @@ -101,7 +101,7 @@ const userStore = useUserStore(); // 从 userStore 中获取登录状态 const isLoggedIn = ref(userStore.isLoggedIn); const mobile = ref(""); -const approval_status = ref(0); +const approval_status = ref(-1); // 每次页面加载时检查 token onMounted(() => { @@ -144,15 +144,15 @@ const handleOpenStartPage = () => { return; } - if (approval_status.value == 4) { + if (approval_status.value == -1 || approval_status.value == 4) { router.push({ name: "start" }); } else { - router.push({ name: "check" }); // 已登录跳转到 check 页面 + router.push({ name: "check" }); } }; const handleUserInfoClick = () => { - if (approval_status.value == 4) { + if (approval_status.value == -1 || approval_status.value == 4) { router.push({ name: "start" }); } else { router.push({ name: "check" }); diff --git a/src/views/index/slider.vue b/src/views/index/slider.vue index d83dfc2..8f2930d 100644 --- a/src/views/index/slider.vue +++ b/src/views/index/slider.vue @@ -84,7 +84,16 @@ import { useTransition } from "@vueuse/core"; import { ref, onMounted, defineEmits } from "vue"; import { Promotion, Download } from "@element-plus/icons-vue"; import { ElMessage } from 'element-plus' +import { getApproval_status } from "@/api/login"; +import { useRouter } from "vue-router"; +import { useUserStore } from "@/stores/userStore"; + +const router = useRouter(); +const userStore = useUserStore(); + +const isLoggedIn = ref(userStore.isLoggedIn); +const approval_status = ref(-1); const businessman = ref(0); const product = ref(0); const member = ref(0); @@ -93,8 +102,16 @@ const order = ref(0); const emits = defineEmits(["open-register-form"]); const openRegisterForm = () => { - console.log(1111); - emits("open-register-form"); + if (!isLoggedIn.value) { + emits("open-register-form"); + return; + } + + if (approval_status.value == -1 || approval_status.value == 4) { + router.push({ name: "start" }); + } else { + router.push({ name: "check" }); // 已登录跳转到 check 页面 + } }; const downAndroid = ()=>{ @@ -125,6 +142,15 @@ const formatter = (value: number) => { const formatter2 = (value: number) => { return `${Math.round(value)}k+`; }; + +onMounted(()=>{ + getApproval_status().then((res) => { + if (res.code === 0 && res.status === 200) { + approval_status.value = res.data.approval_status; + console.log("res.data.approval_status", res.data.approval_status); + } + }); +})