import{f as b,u as x,B as k,c as l,a as s,b as v,w as c,m as V,i as o,d as w,t as C,k as q,v as u,x as h,y as N,j as B,q as p,e as M,o as d,z as D,A as T,_ as U}from"./2JCroH3R.js";import{u as z}from"./Ba751Df4.js";import"./CbPNayBJ.js";import"./DrJDeGiv.js";const A={class:"auth-page"},R={class:"auth-container"},S={class:"auth-header"},$={key:0,class:"error-banner"},j={class:"form-group"},E={class:"input-wrapper"},H={class:"form-group"},I={class:"input-wrapper"},L=["type"],P={class:"form-group"},F={class:"input-wrapper"},G=["disabled"],J={key:0,class:"loading-spinner",style:{width:"18px",height:"18px","border-width":"2px"}},K={key:1},O={class:"auth-footer"},Q=b({__name:"register",setup(W){x({title:"注册 - 智享生活",meta:[{name:"description",content:"注册智享生活账号,获取今日菜价、百事圈社区等本地民生资讯服务"},{name:"robots",content:"noindex"}]});const{register:g}=z(),y=k().query.invite||"",t=D({username:"",password:"",phone:""}),r=p(!1),i=p(!1),a=p(""),_=async()=>{if(a.value="",!t.username.trim()){a.value="请输入用户名";return}if(t.username.trim().length<4||t.username.trim().length>20){a.value="用户名需要4-20位字符";return}if(!t.password||t.password.length<6){a.value="密码至少需要6位";return}if(!t.phone.trim()){a.value="请输入手机号";return}if(!/^1[3-9]\d{9}$/.test(t.phone.trim())){a.value="请输入正确的手机号";return}i.value=!0;try{await g({username:t.username.trim(),password:t.password,phone:t.phone.trim(),invite_code:y||void 0}),T("/")}catch(m){a.value=m.message||"注册失败,请稍后重试"}finally{i.value=!1}};return(m,e)=>{const f=M;return d(),l("div",A,[s("div",R,[s("div",S,[v(f,{to:"/",class:"auth-logo"},{default:c(()=>[...e[4]||(e[4]=[s("i",{class:"fas fa-home"},null,-1)])]),_:1}),e[5]||(e[5]=s("h1",{class:"auth-title"},"注册智享生活",-1)),e[6]||(e[6]=s("p",{class:"auth-subtitle text-secondary"},"创建账号,加入本地社区",-1))]),s("form",{class:"auth-form card",onSubmit:V(_,["prevent"])},[o(a)?(d(),l("div",$,[e[7]||(e[7]=s("i",{class:"fas fa-exclamation-circle"},null,-1)),w(" "+C(o(a)),1)])):q("",!0),s("div",j,[e[9]||(e[9]=s("label",{for:"username"},"用户名",-1)),s("div",E,[e[8]||(e[8]=s("i",{class:"fas fa-user"},null,-1)),u(s("input",{id:"username","onUpdate:modelValue":e[0]||(e[0]=n=>o(t).username=n),type:"text",placeholder:"请输入用户名(4-20位字母数字)",required:"",autocomplete:"username"},null,512),[[h,o(t).username]])])]),s("div",H,[e[11]||(e[11]=s("label",{for:"password"},"密码",-1)),s("div",I,[e[10]||(e[10]=s("i",{class:"fas fa-lock"},null,-1)),u(s("input",{id:"password","onUpdate:modelValue":e[1]||(e[1]=n=>o(t).password=n),type:o(r)?"text":"password",placeholder:"请输入密码(至少6位)",required:"",autocomplete:"new-password"},null,8,L),[[N,o(t).password]]),s("button",{type:"button",class:"toggle-password",onClick:e[2]||(e[2]=n=>r.value=!o(r))},[s("i",{class:B(o(r)?"fas fa-eye-slash":"fas fa-eye")},null,2)])])]),s("div",P,[e[13]||(e[13]=s("label",{for:"phone"},"手机号",-1)),s("div",F,[e[12]||(e[12]=s("i",{class:"fas fa-phone"},null,-1)),u(s("input",{id:"phone","onUpdate:modelValue":e[3]||(e[3]=n=>o(t).phone=n),type:"tel",placeholder:"请输入手机号",required:"",autocomplete:"tel"},null,512),[[h,o(t).phone]])])]),s("button",{type:"submit",class:"btn btn-primary btn-block",disabled:o(i)},[o(i)?(d(),l("div",J)):(d(),l("span",K,"注册"))],8,G)],32),s("div",O,[e[15]||(e[15]=s("span",{class:"text-secondary"},"已有账号?",-1)),v(f,{to:"/login"},{default:c(()=>[...e[14]||(e[14]=[w("去登录",-1)])]),_:1})])])])}}}),te=U(Q,[["__scopeId","data-v-fc889aed"]]);export{te as default};