import{d as h,o as V,c as x,a as m,f as o,j as l,r as d,k as a,l as f,E as y,u as C,_ as U}from"./index-Bg3n6gLm.js";import{u as B}from"./user-BPR5ihh8.js";import{a as E}from"./index-BuBKbyog.js";const L={class:"login-page"},N={class:"login-card card"},R=h({__name:"Login",setup(q){const c=C(),i=B(),p=d(),r=d(!1),t=d({phone:"",password:""}),_={phone:[{required:!0,message:"请输入手机号",trigger:"blur"},{pattern:/^1[3-9]\d{9}$/,message:"手机号格式不正确",trigger:"blur"}],password:[{required:!0,message:"请输入密码",trigger:"blur"},{min:6,message:"密码长度不能少于6位",trigger:"blur"}]},g=async()=>{var e;if(await((e=p.value)==null?void 0:e.validate())){r.value=!0;try{const s=await E.login(t.value);i.setToken(s.data.token),i.setUserInfo(s.data),y.success("登录成功"),c.push("/")}catch{console.error("登录失败")}finally{r.value=!1}}};return(v,e)=>{const s=a("el-input"),n=a("el-form-item"),w=a("el-button"),b=a("router-link"),k=a("el-form");return V(),x("div",L,[m("div",N,[e[4]||(e[4]=m("h2",{class:"title"},"登录",-1)),o(k,{ref_key:"formRef",ref:p,model:t.value,rules:_,"label-width":"80px"},{default:l(()=>[o(n,{label:"手机号",prop:"phone"},{default:l(()=>[o(s,{modelValue:t.value.phone,"onUpdate:modelValue":e[0]||(e[0]=u=>t.value.phone=u),placeholder:"请输入手机号",maxlength:"11"},null,8,["modelValue"])]),_:1}),o(n,{label:"密码",prop:"password"},{default:l(()=>[o(s,{modelValue:t.value.password,"onUpdate:modelValue":e[1]||(e[1]=u=>t.value.password=u),type:"password",placeholder:"请输入密码","show-password":""},null,8,["modelValue"])]),_:1}),o(n,null,{default:l(()=>[o(w,{type:"primary",onClick:g,loading:r.value},{default:l(()=>[...e[2]||(e[2]=[f("登录",-1)])]),_:1},8,["loading"]),o(b,{to:"/register",class:"register-link"},{default:l(()=>[...e[3]||(e[3]=[f("没有账号？立即注册",-1)])]),_:1})]),_:1})]),_:1},8,["model"])])])}}}),j=U(R,[["__scopeId","data-v-ff456fbb"]]);export{j as default};
