import{H as V,L as k,P as s,M as a,O as r,e as u,ag as l,az as y,u as f,Y as b}from"./vendor-DeEI1rpK.js";import{u as h,l as I,a as d}from"./element-plus-pbz_d-qS.js";import{r as L}from"./request-BEmSsgoM.js";import{_ as N}from"./index-CxJCpQ-E.js";const q={class:"login-page"},z={class:"login-form"},B={__name:"Login",setup(C){const c=y(),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 L.post("/auth/login",{username:o.value.username.trim(),password:o.value.password.trim()});e.success&&e.data&&e.data.token?(localStorage.setItem("token",e.data.token),localStorage.setItem("riderInfo",JSON.stringify(e.data)),d.success("登录成功"),c.push("/")):d.error(e.message||"登录失败")}catch(e){d.error(e.response?.data?.message||"登录失败，请检查账号密码")}finally{t.value=!1}}};return(v,e)=>{const m=l("el-input"),p=l("el-form-item"),w=l("el-form"),x=l("el-button");return V(),k("div",q,[e[4]||(e[4]=s("div",{class:"login-header"},[s("div",{class:"logo"},"🛵"),s("h1",null,"电动车租赁"),s("p",null,"骑手端")],-1)),s("div",z,[a(w,{ref_key:"formRef",ref:i,model:o.value,rules:g,size:"large"},{default:r(()=>[a(p,{prop:"username"},{default:r(()=>[a(m,{modelValue:o.value.username,"onUpdate:modelValue":e[0]||(e[0]=n=>o.value.username=n),placeholder:"请输入账号","prefix-icon":f(h)},null,8,["modelValue","prefix-icon"])]),_:1}),a(p,{prop:"password"},{default:r(()=>[a(m,{modelValue:o.value.password,"onUpdate:modelValue":e[1]||(e[1]=n=>o.value.password=n),type:"password",placeholder:"请输入密码","prefix-icon":f(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:r(()=>[...e[2]||(e[2]=[b(" 登录 ",-1)])]),_:1},8,["loading"]),e[3]||(e[3]=s("div",{class:"demo-hint"},[s("p",null,"演示账号：rider_demo / demo123")],-1))])])}}},O=N(B,[["__scopeId","data-v-9b312d7e"]]);export{O as default};
