import{E as $,a as z}from"./el-form-item-BvJauXBe.js";import{d as F,h as R,i as D,a as N,j as T,k as K,b as j,o as _,c as f,m as n,p as l,q as i,t as A,e as o,_ as G,x as O,y as P,z as I,A as W,B as H,r as s,C as J,D as Q,F as X,G as Y}from"./index-XuO881sr.js";import{E as Z}from"./el-checkbox-Cxc7yQYm.js";import"./cloneDeep-CQdyn166.js";import"./_baseClone-CIlxLVYA.js";import"./omit-nuy_stBf.js";const ee={class:"login"},te={class:"remberBox"},ae={key:0},oe={key:1},ne=F({__name:"login",setup(le){const{proxy:d}=R(),x=D(),b=N(),{t:g}=T(),e=s({tenantId:"000000",username:"",password:"",rememberMe:!1,code:"",uuid:""}),M={tenantId:[{required:!0,trigger:"blur",message:g("login.rule.tenantId.required")}],username:[{required:!0,trigger:"blur",message:g("login.rule.username.required")}],password:[{required:!0,trigger:"blur",message:g("login.rule.password.required")}],code:[{required:!0,trigger:"change",message:g("login.rule.code.required")}]},q=s(""),m=s(!1),w=s(!0),S=s(!0),y=s("/"),E=s(),p=s([]);K(()=>b.currentRoute.value,a=>{y.value=a.query&&a.query.redirect&&decodeURIComponent(a.query.redirect)},{immediate:!0});const h=()=>{E.value?.validate(async(a,t)=>{if(a){m.value=!0,console.log(e.value),e.value.rememberMe?(localStorage.setItem("tenantId",String(e.value.tenantId)),localStorage.setItem("username",String(e.value.username)),localStorage.setItem("password",String(e.value.password)),localStorage.setItem("rememberMe",String(e.value.rememberMe))):(localStorage.removeItem("tenantId"),localStorage.removeItem("username"),localStorage.removeItem("password"),localStorage.removeItem("rememberMe"));const[r]=await J(x.login(e.value));if(r)m.value=!1;else{console.log("登录成功");const u=y.value||"/";await b.push(u),m.value=!1}}})},V=async()=>{const a=await Q(),{data:t}=a;w.value=t.captchaEnabled===void 0?!0:t.captchaEnabled,w.value&&(e.value.code="",q.value="data:image/gif;base64,"+t.img,e.value.uuid=t.uuid)},C=()=>{const a=localStorage.getItem("tenantId"),t=localStorage.getItem("username"),r=localStorage.getItem("password"),u=localStorage.getItem("rememberMe");e.value={tenantId:a===null?String(e.value.tenantId):a,username:t===null?String(e.value.username):t,password:String(r===null?e.value.password:r),rememberMe:u===null?!1:!!u}},k=async()=>{const{data:a}=await X(!1);S.value=a.tenantEnabled===void 0?!0:a.tenantEnabled,S.value&&(p.value=a.voList,p.value!=null&&p.value.length!==0&&(e.value.tenantId=p.value[0].tenantId))};return j(()=>{V(),k(),C()}),(a,t)=>{const r=G,u=A,v=$,B=Z,L=W,U=z;return _(),f("div",ee,[n(U,{ref_key:"loginRef",ref:E,model:o(e),rules:M,class:"login-form"},{default:l(()=>[t[4]||(t[4]=i("div",{class:"title-box"},[i("div",{class:"line"}),i("div",{class:"subtitle"},[i("div",null,"WELCOME"),i("div",null,"智慧物业后台管理系统")])],-1)),n(v,{prop:"username"},{default:l(()=>[n(u,{modelValue:o(e).username,"onUpdate:modelValue":t[0]||(t[0]=c=>o(e).username=c),type:"text",size:"large","auto-complete":"off",placeholder:o(d).$t("login.username")},{prefix:l(()=>[n(r,{"icon-class":"user",class:"el-input__icon input-icon"})]),_:1},8,["modelValue","placeholder"])]),_:1}),n(v,{prop:"password"},{default:l(()=>[n(u,{modelValue:o(e).password,"onUpdate:modelValue":t[1]||(t[1]=c=>o(e).password=c),type:"password",size:"large","auto-complete":"off",placeholder:o(d).$t("login.password"),onKeyup:O(h,["enter"])},{prefix:l(()=>[n(r,{"icon-class":"password",class:"el-input__icon input-icon"})]),_:1},8,["modelValue","placeholder"])]),_:1}),i("div",te,[n(B,{modelValue:o(e).rememberMe,"onUpdate:modelValue":t[2]||(t[2]=c=>o(e).rememberMe=c),style:{color:"#fff"}},{default:l(()=>[P(I(o(d).$t("login.rememberPassword")),1)]),_:1},8,["modelValue"]),t[3]||(t[3]=i("div",null,"忘记密码？",-1))]),n(v,{style:{width:"100%"}},{default:l(()=>[n(L,{loading:o(m),size:"large",type:"primary",style:{width:"100%"},onClick:H(h,["prevent"])},{default:l(()=>[o(m)?(_(),f("span",oe,I(o(d).$t("login.logging")),1)):(_(),f("span",ae,I(o(d).$t("login.login")),1))]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"])])}}}),ce=Y(ne,[["__scopeId","data-v-e3e3846a"]]);export{ce as default};
