import{d as F,D as N,r as x,H as $,c as m,a as t,w as a,a$ as I,Z as d,u as _,bd as T,be as j,K as q,L as A,bf as D,E as L,bg as S,b as f,i as z,h as p,J as H,b1 as J,B as K,a8 as M,o as l}from"./index-DqVhJ65C.js";/* empty css                *//* empty css                    *//* empty css                 *//* empty css               */const X={class:"max-w-3xl mx-auto py-8"},Z={class:"flex items-center justify-between"},G={key:0,class:"text-center py-12"},O=["src"],te=F({__name:"RealName",setup(P){const g=N(),i=x(!1),o=$({name:"",id_card:"",face_img:""}),v={name:[{required:!0,message:"请输入真实姓名",trigger:"blur"}],id_card:[{required:!0,message:"请输入身份证号码",trigger:"blur"},{pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,message:"身份证格式不正确",trigger:"blur"}]},c=x(),w=r=>{const e=new FileReader;e.readAsDataURL(r.raw),e.onload=()=>{o.face_img=e.result}},E=async()=>{c.value&&await c.value.validate(async r=>{if(r){i.value=!0;try{(await K.post("/user/realname/verify",o)).code===0&&M.alert("认证成功！","提示",{confirmButtonText:"确定",callback:()=>{window.location.reload()}})}catch(e){console.error(e)}finally{i.value=!1}}})};return(r,e)=>{const b=J,k=T,V=j,y=A,n=q,B=L,h=D,R=z,U=H,C=I;return l(),m("div",X,[t(C,{shadow:"never",class:"!rounded-xl"},{header:a(()=>{var s;return[f("div",Z,[e[4]||(e[4]=f("span",{class:"text-lg font-bold"},"实名认证",-1)),(s=_(g).info)!=null&&s.is_realname_verified?(l(),d(b,{key:1,type:"success"},{default:a(()=>[...e[3]||(e[3]=[p("已认证",-1)])]),_:1})):(l(),d(b,{key:0,type:"info"},{default:a(()=>[...e[2]||(e[2]=[p("未认证",-1)])]),_:1}))])]}),default:a(()=>{var s;return[(s=_(g).info)!=null&&s.is_realname_verified?(l(),m("div",G,[t(k,{icon:"success",title:"您已完成实名认证","sub-title":"您可以正常使用所有功能"})])):(l(),d(U,{key:1,ref_key:"formRef",ref:c,model:o,rules:v,"label-width":"120px",class:"max-w-lg mx-auto mt-8",size:"large"},{default:a(()=>[t(V,{title:"请务必填写真实有效的身份信息，否则无法通过审核",type:"warning","show-icon":"",class:"mb-6",closable:!1}),t(n,{label:"真实姓名",prop:"name"},{default:a(()=>[t(y,{modelValue:o.name,"onUpdate:modelValue":e[0]||(e[0]=u=>o.name=u),placeholder:"请输入您的真实姓名"},null,8,["modelValue"])]),_:1}),t(n,{label:"身份证号",prop:"id_card"},{default:a(()=>[t(y,{modelValue:o.id_card,"onUpdate:modelValue":e[1]||(e[1]=u=>o.id_card=u),placeholder:"请输入18位身份证号码"},null,8,["modelValue"])]),_:1}),t(n,{label:"人脸照片",prop:"face_img"},{default:a(()=>[t(h,{class:"avatar-uploader",action:"#","auto-upload":!1,"show-file-list":!1,"on-change":w},{tip:a(()=>[...e[5]||(e[5]=[f("div",{class:"text-xs text-gray-400 mt-2"},"（可选）请上传手持身份证照片或正脸照",-1)])]),default:a(()=>[o.face_img?(l(),m("img",{key:0,src:o.face_img,class:"w-32 h-32 object-cover rounded-md"},null,8,O)):(l(),d(B,{key:1,class:"avatar-uploader-icon border border-dashed border-gray-300 rounded-md p-8 text-2xl text-gray-400 hover:border-primary transition-colors"},{default:a(()=>[t(_(S))]),_:1}))]),_:1})]),_:1}),t(n,null,{default:a(()=>[t(R,{type:"primary",loading:i.value,onClick:E,class:"w-full !rounded-lg"},{default:a(()=>[...e[6]||(e[6]=[p(" 提交认证 ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"]))]}),_:1})])}}});export{te as default};
