import{_ as k,b as z,r as f,M as S,o as g,y as W,q as p,v as y,x as c,p as a,n as t,c as h,C as M,P as q,t as Z,U as j,S as _,j as G,k as H,l as L,m as J,H as V,V as K,W as O,D as Q}from"./index.8d733f79.js";const X={class:"sub-title",style:{"font-size":"24px"}},Y={key:1,class:"codeTxt"},ee={style:{"margin-top":"24px","text-align":"center",width:"100%","font-size":"16px"}},oe={key:0,style:{color:"#8CAEE4"}},se={__name:"register",props:{formType:{type:String,default:"register"}},emits:["changePageType"],setup(C,{emit:v}){const l=C,{t:n,locale:re}=z(),m=f(),{proxy:$}=Q(),r=f({code:"",confirmPassword:"",password:"",phone:"",username:"",func:"register"}),u=f(60),P=f(!1),w=f(null),E=(s,e,o)=>{e===""?o(new Error(n("passWordP"))):/^(?=.*\d)(?=.*[A-Za-z])[A-Za-z\d!@#$%^&*()_+{}|:<>?]{8,20}$/.test(e)?(r.value.confirmPassword!==""&&m.value.validateField("confirmPassword",()=>null),o()):o(new Error(n("passWordP2")))},T=(s,e,o)=>{e===""?o(new Error(n("confirmPwP"))):e!==r.value.password?o(new Error(n("pwNotSame"))):o()},R=(s,e,o)=>{e===""?o(new Error(n("phoneP"))):/^\d{11}$/.test(e)?o():o(new Error(n("validatePhone")))},x=(s,e,o)=>{e===""?o(new Error(n("verifiyCodeP"))):/^\d{6}$/.test(e)?o():o(new Error(n("validateCode")))},D={username:[{required:!0,message:n("accountP"),trigger:"blur"}],password:[{validator:E,trigger:"blur"}],confirmPassword:[{validator:T,trigger:"blur"}],phone:[{validator:R,trigger:"blur"}],code:[{validator:x,trigger:"blur"}]};function B(){$.$refs.registerRule.validate(s=>{if(s){const e={...r.value};e.username=e.username.trim(),e.password=V.encrypt(r.value.username,r.value.password).replaceAll("+","%2B"),e.confirmPassword=V.encrypt(r.value.username,r.value.confirmPassword).replaceAll("+","%2B"),e.func=l.formType,l.formType==="register"?K(e).then(o=>{_.success(o.msg),v("changePageType","login")}).catch(()=>{}):O(e).then(o=>{_.success(o.msg),v("changePageType","login")}).catch(()=>{})}})}function F(){v("changePageType","login")}function I(){u.value--,w.value=setInterval(()=>{u.value>1?u.value--:(clearInterval(w.value),w.value=null,P.value=!0,u.value=60)},1e3)}function N(){m.value.clearValidate(),l.formType==="resetPwd"?m.value.validateField("username",e=>{s(e)}):s();function s(e){m.value.validateField("phone",o=>{o&&(l.formType==="register"||l.formType==="resetPwd"&&e)&&j({phone:r.value.phone,func:l.formType,username:r.value.username}).then(()=>{_.success(n("verifiyCodeS")),I()}).catch(()=>{})})}}return(s,e)=>{const o=G,i=H,A=S,U=L,b=J;return g(),W(b,{ref_key:"registerRule",ref:m,model:t(r),rules:D,class:"registerForm"},{default:p(()=>[y("div",X,c(l.formType==="register"?s.$t("welcomeRegister"):s.$t("resetPwd")),1),a(i,{prop:"username"},{default:p(()=>[a(o,{modelValue:t(r).username,"onUpdate:modelValue":e[0]||(e[0]=d=>t(r).username=d),type:"text","auto-complete":"off",placeholder:s.$t("accountP"),class:"login-input"},null,8,["modelValue","placeholder"])]),_:1}),a(i,{prop:"password"},{default:p(()=>[a(o,{modelValue:t(r).password,"onUpdate:modelValue":e[1]||(e[1]=d=>t(r).password=d),type:"password","show-password":"",placeholder:s.$t("passWordP"),class:"login-input"},null,8,["modelValue","placeholder"])]),_:1}),a(i,{prop:"confirmPassword"},{default:p(()=>[a(o,{modelValue:t(r).confirmPassword,"onUpdate:modelValue":e[2]||(e[2]=d=>t(r).confirmPassword=d),type:"password","show-password":"",placeholder:s.$t("confirmPwP"),class:"login-input"},null,8,["modelValue","placeholder"])]),_:1}),a(i,{prop:"phone"},{default:p(()=>[a(o,{modelValue:t(r).phone,"onUpdate:modelValue":e[3]||(e[3]=d=>t(r).phone=d),type:"text","auto-complete":"off",placeholder:s.$t("phoneP"),class:"login-input"},null,8,["modelValue","placeholder"])]),_:1}),a(i,{prop:"code"},{default:p(()=>[a(o,{modelValue:t(r).code,"onUpdate:modelValue":e[4]||(e[4]=d=>t(r).code=d),placeholder:s.$t("verifiyCodeP"),class:"login-input"},{append:p(()=>[a(A,{direction:"vertical",style:{color:"#4093E2"}}),t(u)===60?(g(),h("div",{key:0,class:"codeTxt",onClick:N},c(t(P)?s.$t("reGetCode"):s.$t("getCode")),1)):(g(),h("div",Y,c(t(u))+"s",1))]),_:1},8,["modelValue","placeholder"])]),_:1}),a(i,{style:{width:"100%"}},{default:p(()=>[a(U,{type:"primary",class:"loginBtn",size:"large",onClick:M(B,["prevent"])},{default:p(()=>[q(c(l.formType==="register"?s.$t("register"):s.$t("reset")),1)]),_:1},8,["onClick"]),y("div",ee,[l.formType==="register"?(g(),h("span",oe,c(s.$t("hasAccount"))+"\uFF0C",1)):Z("",!0),y("span",{style:{color:"#2E80FD",cursor:"pointer"},onClick:F},c(l.formType==="register"?s.$t("loginNow"):s.$t("backLogin")),1)])]),_:1})]),_:1},8,["model"])}}},ae=k(se,[["__scopeId","data-v-3e7b314d"]]);export{ae as default};
