import{d as q,N as M,a as m,b as e,w as r,au as $,av as C,az as R,aB as B,aC as I,aD as N,ai as G,aE as L,J as w,a5 as V,K as E,r as n,o as F,Z as f,a1 as P,v as c}from"./vendor-Cv2dYodt.js";import{_ as j}from"./index-D5nbxFF0.js";const J=q({name:"register",components:{UserOutlined:$,LockOutlined:C,MobileOutlined:R,MailOutlined:B,IdcardOutlined:I,GiftOutlined:N},setup(){const o=G(),a=L(),p=w(),u=w(!1),i=V({invitation_code:"",username:"",password:"",confirm_password:"",real_name:"",mobile:"",email:""}),_={invitation_code:[{required:!0,message:"请输入邀请码"},{len:20,message:"邀请码长度必须为20位"}],username:[{required:!0,message:"请输入用户名"},{min:4,message:"用户名长度不能小于4位"}],password:[{required:!0,message:"请输入密码"},{min:6,message:"密码长度不能小于6位"}],confirm_password:[{required:!0,message:"请确认密码"},{validator:(l,s)=>s&&s!==i.password?Promise.reject("两次输入的密码不一致"):Promise.resolve()}],real_name:[{required:!0,message:"请输入真实姓名"}],mobile:[{required:!0,message:"请输入手机号"},{pattern:/^1[3-9]\d{9}$/,message:"请输入正确的手机号"}],email:[{required:!0,message:"请输入邮箱"},{type:"email",message:"请输入正确的邮箱格式"}]};return E(()=>{const l=a.query.code;l&&(i.invitation_code=l)}),{registerForm:p,formData:i,rules:_,loading:u,handleRegister:async()=>{var l,s;try{u.value=!0,await p.value.validate();const d=await P.post(`https://aiapi.raycos.com.cn/user/register_by_invitation?code=${i.invitation_code}`,{username:i.username,password:i.password,confirm_password:i.confirm_password,real_name:i.real_name,mobile:i.mobile,email:i.email});d.data.code===200?(c.success("注册成功"),o.push("/login")):c.error(d.data.message||"注册失败")}catch(d){console.error("注册失败:",d),c.error(((s=(l=d.response)==null?void 0:l.data)==null?void 0:s.message)||"注册失败，请检查输入信息")}finally{u.value=!1}}}}}),K={class:"register-page"},T={class:"register-container"},Z={class:"register-content"},h={class:"form-footer"},A={class:"login-tip"};function H(o,a,p,u,i,_){const g=n("GiftOutlined"),l=n("a-input"),s=n("a-form-item"),d=n("UserOutlined"),v=n("LockOutlined"),b=n("a-input-password"),y=n("IdcardOutlined"),O=n("MobileOutlined"),D=n("MailOutlined"),k=n("a-button"),U=n("router-link"),z=n("a-form");return F(),M("div",K,[m("div",T,[m("div",Z,[a[10]||(a[10]=m("div",{class:"register-header"},[m("h2",{style:{"margin-top":"0"}},"用户注册"),m("p",{class:"sub-title"},"请填写以下信息完成注册")],-1)),e(z,{ref:"registerForm",model:o.formData,rules:o.rules,layout:"vertical"},{default:r(()=>[e(s,{label:"邀请码",name:"invitation_code"},{default:r(()=>[e(l,{value:o.formData.invitation_code,"onUpdate:value":a[0]||(a[0]=t=>o.formData.invitation_code=t),placeholder:"请输入邀请码",size:"large"},{prefix:r(()=>[e(g,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),e(s,{label:"用户名",name:"username"},{default:r(()=>[e(l,{value:o.formData.username,"onUpdate:value":a[1]||(a[1]=t=>o.formData.username=t),placeholder:"请输入用户名",size:"large"},{prefix:r(()=>[e(d,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),e(s,{label:"密码",name:"password"},{default:r(()=>[e(b,{value:o.formData.password,"onUpdate:value":a[2]||(a[2]=t=>o.formData.password=t),placeholder:"请输入密码",size:"large"},{prefix:r(()=>[e(v,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),e(s,{label:"确认密码",name:"confirm_password"},{default:r(()=>[e(b,{value:o.formData.confirm_password,"onUpdate:value":a[3]||(a[3]=t=>o.formData.confirm_password=t),placeholder:"请再次输入密码",size:"large"},{prefix:r(()=>[e(v,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),e(s,{label:"真实姓名",name:"real_name"},{default:r(()=>[e(l,{value:o.formData.real_name,"onUpdate:value":a[4]||(a[4]=t=>o.formData.real_name=t),placeholder:"请输入真实姓名",size:"large"},{prefix:r(()=>[e(y,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),e(s,{label:"手机号",name:"mobile"},{default:r(()=>[e(l,{value:o.formData.mobile,"onUpdate:value":a[5]||(a[5]=t=>o.formData.mobile=t),placeholder:"请输入手机号",size:"large"},{prefix:r(()=>[e(O,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),e(s,{label:"邮箱",name:"email"},{default:r(()=>[e(l,{value:o.formData.email,"onUpdate:value":a[6]||(a[6]=t=>o.formData.email=t),placeholder:"请输入邮箱",size:"large"},{prefix:r(()=>[e(D,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),e(s,null,{default:r(()=>[e(k,{type:"primary",loading:o.loading,size:"large",block:"",onClick:o.handleRegister},{default:r(()=>a[7]||(a[7]=[f(" 注册 ")])),_:1},8,["loading","onClick"])]),_:1}),m("div",h,[m("p",A,[a[9]||(a[9]=f(" 已有账号？")),e(U,{to:"/login",class:"login-link"},{default:r(()=>a[8]||(a[8]=[f("立即登录")])),_:1})])])]),_:1},8,["model","rules"])])])])}const W=j(J,[["render",H],["__scopeId","data-v-2ad2892c"]]);export{W as default};
