import{f as e,g as a,d as t,o as l,c as s,w as r,l as i,t as o,A as n,B as u,C as c,D as f,z as d,i as m}from"./index-CJxdOECQ.js";import{_ as p}from"./input.BkLVqGkG.js";import{r as _,b as v,_ as g}from"./button.BC3KjxGU.js";import{a as h}from"./api.U2gW6MFc.js";import"./parent-map.DJ2qhm0x.js";const b=g(e({__name:"register",setup(e){const g=a(""),b=a(""),x=a(!1),y=async()=>{if(g.value&&11===String(g.value).length)if(b.value&&0!==b.value.trim().length){x.value=!0;try{const e=await h.auth.register("+86"+g.value,b.value.trim());u("token",e.token),u("user",e.user),n({title:"注册成功",icon:"success"}),c({url:"/pages/index/index"})}catch(e){console.error("注册失败",e)}finally{x.value=!1}}else n({title:"请输入昵称",icon:"none"});else n({title:"请输入正确的手机号",icon:"none"})},j=()=>{f()};return(e,a)=>{const n=d,u=m,c=_(t("t-input"),p),f=_(t("t-button"),v);return l(),s(u,{class:"register-container"},{default:r((()=>[i(u,{class:"register-header"},{default:r((()=>[i(n,{class:"title"},{default:r((()=>[o("注册账号")])),_:1}),i(n,{class:"subtitle"},{default:r((()=>[o("创建您的预约系统账号")])),_:1})])),_:1}),i(u,{class:"register-form"},{default:r((()=>[i(u,{class:"form-item"},{default:r((()=>[i(c,{value:g.value,"onUpdate:value":a[0]||(a[0]=e=>g.value=e),placeholder:"请输入手机号",type:"number",maxlength:11,clearable:""},{prefixIcon:r((()=>[i(n,{class:"prefix-icon"},{default:r((()=>[o("📱")])),_:1})])),_:1},8,["value"])])),_:1}),i(u,{class:"form-item"},{default:r((()=>[i(c,{value:b.value,"onUpdate:value":a[1]||(a[1]=e=>b.value=e),placeholder:"请输入昵称",maxlength:20,clearable:""},{prefixIcon:r((()=>[i(n,{class:"prefix-icon"},{default:r((()=>[o("👤")])),_:1})])),_:1},8,["value"])])),_:1}),i(u,{class:"form-actions"},{default:r((()=>[i(f,{class:"btn-primary",theme:"primary",size:"large",block:"",loading:x.value,onClick:y},{default:r((()=>[o(" 注册 ")])),_:1},8,["loading"])])),_:1}),i(u,{class:"form-switch"},{default:r((()=>[i(n,{onClick:j},{default:r((()=>[o("已有账号？去登录")])),_:1})])),_:1})])),_:1})])),_:1})}}}),[["__scopeId","data-v-c8de2d17"]]);export{b as default};
