diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 28c2e5b..8ac3a1b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,8 +52,8 @@ catalogs: specifier: 8.0.0 version: 8.0.0 '@capp/eden': - specifier: http://192.168.1.2:9538/api/capp-eden-0.0.11.tgz - version: 0.0.11 + specifier: http://192.168.1.2:9538/api/capp-eden-0.0.12.tgz + version: 0.0.12 '@cloudflare/workers-types': specifier: ^4.20260113.0 version: 4.20260116.0 @@ -298,7 +298,7 @@ importers: version: 8.0.0(@capacitor/core@8.0.0) '@capp/eden': specifier: 'catalog:' - version: http://192.168.1.2:9538/api/capp-eden-0.0.11.tgz(@elysiajs/eden@1.4.6(elysia@1.4.22(@sinclair/typebox@0.34.47)(exact-mirror@0.2.6(@sinclair/typebox@0.34.47))(file-type@21.3.0)(openapi-types@12.1.3)(typescript@5.9.3))) + version: http://192.168.1.2:9538/api/capp-eden-0.0.12.tgz(@elysiajs/eden@1.4.6(elysia@1.4.22(@sinclair/typebox@0.34.47)(exact-mirror@0.2.6(@sinclair/typebox@0.34.47))(file-type@21.3.0)(openapi-types@12.1.3)(typescript@5.9.3))) '@elysiajs/eden': specifier: 'catalog:' version: 1.4.6(elysia@1.4.22(@sinclair/typebox@0.34.47)(exact-mirror@0.2.6(@sinclair/typebox@0.34.47))(file-type@21.3.0)(openapi-types@12.1.3)(typescript@5.9.3)) @@ -1182,9 +1182,9 @@ packages: '@capacitor/synapse@1.0.4': resolution: {integrity: sha512-/C1FUo8/OkKuAT4nCIu/34ny9siNHr9qtFezu4kxm6GY1wNFxrCFWjfYx5C1tUhVGz3fxBABegupkpjXvjCHrw==} - '@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.11.tgz': - resolution: {tarball: http://192.168.1.2:9538/api/capp-eden-0.0.11.tgz} - version: 0.0.11 + '@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.12.tgz': + resolution: {tarball: http://192.168.1.2:9538/api/capp-eden-0.0.12.tgz} + version: 0.0.12 peerDependencies: '@elysiajs/eden': ^1.4.6 @@ -6903,7 +6903,7 @@ snapshots: '@capacitor/synapse@1.0.4': {} - '@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.11.tgz(@elysiajs/eden@1.4.6(elysia@1.4.22(@sinclair/typebox@0.34.47)(exact-mirror@0.2.6(@sinclair/typebox@0.34.47))(file-type@21.3.0)(openapi-types@12.1.3)(typescript@5.9.3)))': + '@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.12.tgz(@elysiajs/eden@1.4.6(elysia@1.4.22(@sinclair/typebox@0.34.47)(exact-mirror@0.2.6(@sinclair/typebox@0.34.47))(file-type@21.3.0)(openapi-types@12.1.3)(typescript@5.9.3)))': dependencies: '@elysiajs/eden': 1.4.6(elysia@1.4.22(@sinclair/typebox@0.34.47)(exact-mirror@0.2.6(@sinclair/typebox@0.34.47))(file-type@21.3.0)(openapi-types@12.1.3)(typescript@5.9.3)) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 1b878b3..bf6b851 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -18,7 +18,7 @@ catalog: '@capacitor/keyboard': 8.0.0 '@capacitor/share': ^8.0.0 '@capacitor/status-bar': 8.0.0 - '@capp/eden': http://192.168.1.2:9538/api/capp-eden-0.0.11.tgz + '@capp/eden': http://192.168.1.2:9538/api/capp-eden-0.0.12.tgz '@cloudflare/workers-types': ^4.20260113.0 '@elysiajs/eden': ^1.4.6 '@faker-js/faker': ^10.2.0 diff --git a/src/views/real_name/index.vue b/src/views/real_name/index.vue index 3ca2a96..c992637 100644 --- a/src/views/real_name/index.vue +++ b/src/views/real_name/index.vue @@ -3,19 +3,49 @@ import { Camera, CameraResultType, CameraSource } from "@capacitor/camera"; import { actionSheetController, toastController } from "@ionic/vue"; import { cameraOutline, cardOutline, checkmarkCircleOutline, imageOutline, personOutline } from "ionicons/icons"; import zod from "zod"; -import { client } from "@/api"; +import { client, safeClient } from "@/api"; const router = useRouter(); -const formData = ref({ +interface RealNameFormData { + kycMethod: "id_card"; + documentName: string; + documentNumber: string; + fileId1: string; + fileId2: string; +} + +const formData = ref({ kycMethod: "id_card", documentName: "", documentNumber: "", fileId1: "", fileId2: "", }); +const image1 = ref(""); +const image2 = ref(""); const isSubmitting = ref(false); +const status = ref<"unverified" | "pending" | "approved" | "rejected">("unverified"); + +// 计算属性:是否可以编辑 +const canEdit = computed(() => { + return status.value === "unverified" || status.value === "rejected"; +}); + +// 计算属性:状态文本和颜色 +const statusInfo = computed(() => { + switch (status.value) { + case "pending": + return { text: "审核中", color: "#faad14", bg: "#fff7e6" }; + case "approved": + return { text: "已通过", color: "#52c41a", bg: "#f6ffed" }; + case "rejected": + return { text: "已拒绝", color: "#f5222d", bg: "#fff1f0" }; + default: + return { text: "未认证", color: "#999", bg: "#f7f8fa" }; + } +}); // 表单验证 Schema const RealNameSchema = zod.object({ @@ -104,9 +134,11 @@ async function selectFromGallery(type: "front" | "back") { if (image.dataUrl) { if (type === "front") { formData.value.fileId1 = fileId; + image1.value = image.dataUrl; } else { formData.value.fileId2 = fileId; + image2.value = image.dataUrl; } } } @@ -149,11 +181,9 @@ async function handleSubmit() { isSubmitting.value = true; try { - // TODO: 调用实名认证 API - // const { data } = await safeClient(client.api.realname.post(formData.value)); - - // 模拟 API 调用 - await new Promise(resolve => setTimeout(resolve, 1500)); + await safeClient(client.api.kyc({ kycMethod: "id_card" }).post({ + ...formData.value, + })); await showToast("实名认证提交成功,等待审核", "success"); router.back(); @@ -165,6 +195,22 @@ async function handleSubmit() { isSubmitting.value = false; } } + +onMounted(async () => { + const { data } = await safeClient(client.api.kyc({ kycMethod: "id_card" }).get()); + if (data.value) { + formData.value.documentName = data.value.documentName || ""; + formData.value.documentNumber = data.value.documentNumber || ""; + formData.value.fileId1 = data.value.fileId1 || ""; + formData.value.fileId2 = data.value.fileId2 || ""; + status.value = data.value?.status || "unverified"; + } + const { data: urls } = await safeClient(client.api.file_storage.access_urls.post({ + fileIds: [formData.value.fileId1, formData.value.fileId2], + })); + image1.value = urls.value?.[0].url || ""; + image2.value = urls.value?.[1].url || ""; +});