import{_ as V,o as k,c as y,a as s,b as a,w as l,r as u,d as r,u as b,e as c,f as h,l as I,g as N,E as d}from"./index-CZe38Ow-.js";import{r as q}from"./request-DftRczcY.js";const B={class:"login-page"},C={class:"login-form"},E={__name:"Login",setup(L){const f=b(),t=u(!1),i=u(null),o=u({username:"",password:""}),g={username:[{required:!0,message:"请输入账号",trigger:"blur"}],password:[{required:!0,message:"请输入密码",trigger:"blur"}]},_=async()=>{if(await i.value.validate().catch(()=>!1)){t.value=!0;try{const e=await q.post("/auth/login",{username:o.value.username,password:o.value.password});e.success&&e.data&&e.data.token?(localStorage.setItem("token",e.data.token),localStorage.setItem("riderInfo",JSON.stringify(e.data)),d.success("登录成功"),f.push("/")):d.error(e.message||"登录失败")}catch(e){d.error(e.response?.data?.message||"登录失败，请检查账号密码")}finally{t.value=!1}}};return(v,e)=>{const m=r("el-input"),p=r("el-form-item"),w=r("el-form"),x=r("el-button");return k(),y("div",B,[e[4]||(e[4]=s("div",{class:"login-header"},[s("div",{class:"logo"},"🛵"),s("h1",null,"电动车租赁"),s("p",null,"骑手端")],-1)),s("div",C,[a(w,{ref_key:"formRef",ref:i,model:o.value,rules:g,size:"large"},{default:l(()=>[a(p,{prop:"username"},{default:l(()=>[a(m,{modelValue:o.value.username,"onUpdate:modelValue":e[0]||(e[0]=n=>o.value.username=n),placeholder:"请输入账号","prefix-icon":c(h)},null,8,["modelValue","prefix-icon"])]),_:1}),a(p,{prop:"password"},{default:l(()=>[a(m,{modelValue:o.value.password,"onUpdate:modelValue":e[1]||(e[1]=n=>o.value.password=n),type:"password",placeholder:"请输入密码","prefix-icon":c(I),"show-password":""},null,8,["modelValue","prefix-icon"])]),_:1})]),_:1},8,["model"]),a(x,{type:"primary",size:"large",loading:t.value,class:"login-btn",onClick:_},{default:l(()=>[...e[2]||(e[2]=[N(" 登录 ",-1)])]),_:1},8,["loading"]),e[3]||(e[3]=s("div",{class:"demo-hint"},[s("p",null,"演示账号：rider_demo / demo123")],-1))])])}}},z=V(E,[["__scopeId","data-v-73cdf8aa"]]);export{z as default};
