发布前校验是否实名认证

This commit is contained in:
yml
2026-05-23 00:01:03 +08:00
parent 94edda9710
commit efb3b94286
5 changed files with 62 additions and 5 deletions
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { onMounted, reactive, ref } from "vue";
import { useRouter } from "vue-router";
import { useRoute, useRouter } from "vue-router";
import { showToast, showDialog } from "vant";
import {
getRealnameStatus,
@@ -11,6 +11,7 @@ import { useSessionStore } from "@/stores/session";
const session = useSessionStore();
const router = useRouter();
const route = useRoute();
const loading = ref(false);
const status = ref<RealnameStatus | null>(null);
const form = reactive({
@@ -20,10 +21,22 @@ const form = reactive({
onMounted(loadStatus);
function redirectAfterVerified() {
const redirect =
typeof route.query.redirect === "string" ? route.query.redirect : "";
if (redirect) {
router.replace(redirect);
}
}
async function loadStatus() {
if (!session.token) return;
try {
status.value = await getRealnameStatus();
if (status.value.status === "verified") {
await session.loadMe();
redirectAfterVerified();
}
} catch {
status.value = null;
}
@@ -46,6 +59,8 @@ async function handleSubmit() {
title: "认证成功",
message: "实名认证已通过",
confirmButtonText: "好的",
}).then(() => {
redirectAfterVerified();
});
} catch (error: unknown) {
const msg =