"use client"; import React, { useState } from "react"; import { Toast } from "antd-mobile"; import { uploadImage } from "@/utils/upload"; import { getCookie } from "cookies-next"; import baseRequest from "@/utils/baseRequest"; import { JSEncrypt } from "jsencrypt"; import { useRouter } from "next/navigation"; import { generateSignature } from "@/utils/crypto"; import Image from "next/image"; import verification_water_mark from "@/public/images/verification_water_mark.png"; export default function Verification() { const router = useRouter(); const [idNumber, setIdNumber] = useState(""); const [realName, setRealName] = useState(""); const [idCardFront, setIdCardFront] = useState(); const [idCardBack, setIdCardBack] = useState(); const [handleIdCard, setHandleIdCard] = useState(); const [isSubmitting, setIsSubmitting] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); if ( !idNumber || !realName || !idCardFront || !idCardBack || !handleIdCard ) { Toast.show({ content: "请完善信息后提交" }); return; } if (idNumber.length !== 18) { Toast.show({ content: "身份证位数不正确" }); return; } const mid = getCookie("mid"); const token = getCookie("token"); if (!mid || !token) { Toast.show({ content: "身份验证失败,请联系客服提现" }); return; } setIsSubmitting(true); const idCardFrontSrcId = await uploadImage(idCardFront); const idCardBackSrcId = await uploadImage(idCardBack); const handleIdCardSrcId = await uploadImage(handleIdCard); //提交数据 try { const base = baseRequest(); //对手机号进行RSA加密 const encrypt = new JSEncrypt(); encrypt.setPublicKey(process.env.NEXT_PUBLIC_RSA_KEY); const encrypted_real_name = encrypt.encrypt(realName); const encrypted_ID_no = encrypt.encrypt(idNumber); const signature = generateSignature({ mid: parseInt(mid, 10), real_name: encrypted_real_name, ID_no: encrypted_ID_no, ID_card_photos: { image_ids: [idCardFrontSrcId, idCardBackSrcId] }, full_face_photo_with_ID_card_in_hand: { image_ids: [handleIdCardSrcId], }, ...base, b_mid: parseInt(mid, 10), }); const detailResponse = await fetch( `/api/realname_authentication/create?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ mid: parseInt(mid, 10), real_name: encrypted_real_name, ID_no: encrypted_ID_no, ID_card_photos: { image_ids: [idCardFrontSrcId, idCardBackSrcId] }, full_face_photo_with_ID_card_in_hand: { image_ids: [handleIdCardSrcId], }, ...base, b_mid: parseInt(mid, 10), }), } ); const detailData = await detailResponse.json(); if (detailData.ret === -1) { Toast.show({ content: detailData.msg, }); return; } Toast.show({ content: "提交成功,请耐心等待审核", }); router.back(); } catch (error) { console.error(error); } finally { setIsSubmitting(false); } }; return (

*真实姓名:

setRealName(e.target.value)} className="input input-bordered input-md input-primary w-full max-w-sm" />

*身份证号:

setIdNumber(e.target.value)} className="input input-bordered input-md input-primary w-full max-w-sm" />

*身份证照片:

身份证人像面

身份证国徽面

*本人手持身份证人像面照片:

手持身份证照片
(需清晰可见身份证号码)

重要提示:

1.所有信息仅用于审核用途,预计24小时内完成,请耐心等待,如进度缓慢,请联系客服;
2.请确认当前实名认证人与提现收款人一致,否则无法打款。

); }