import{C as e,D as a,F as l,y as r,G as t}from"./element-plus-DSMJnpwa.js";import{u as s,_ as o,t as n,a as u,b as d,d as i}from"./index-mv7arXuk.js";/* empty css                     *//* empty css                    */import{B as m,g as c,aE as g,e as p,m as v,H as f,L as b,M as I,O as w,P as y,u as _,ao as S,Y as M,Z as h,a9 as q,d as x}from"./vue-vendor-DZekML78.js";import{f as V}from"./utils-cPVb2Haz.js";const E={class:"login"},j={class:"remberBox"},k={key:0},C={key:1},$=i(m({__name:"login",setup(i){const{proxy:m}=c(),$=s(),B=g(),{t:U}=V(),z=x({tenantId:"000000",username:"",password:"",rememberMe:!1,code:"",uuid:""}),L={tenantId:[{required:!0,trigger:"blur",message:U("login.rule.tenantId.required")}],username:[{required:!0,trigger:"blur",message:U("login.rule.username.required")}],password:[{required:!0,trigger:"blur",message:U("login.rule.password.required")}],code:[{required:!0,trigger:"change",message:U("login.rule.code.required")}]},R=x(""),O=x(!1),P=x(!0),D=x(!0),F=x("/"),G=x(),H=x([]);p(()=>B.currentRoute.value,e=>{F.value=e.query&&e.query.redirect&&decodeURIComponent(e.query.redirect)},{immediate:!0});const K=()=>{G.value?.validate(async(e,a)=>{if(e){O.value=!0,z.value.rememberMe?(localStorage.setItem("tenantId",String(z.value.tenantId)),localStorage.setItem("username",String(z.value.username)),localStorage.setItem("rememberMe",String(z.value.rememberMe))):(localStorage.removeItem("tenantId"),localStorage.removeItem("username"),localStorage.removeItem("rememberMe"));const[e]=await n($.login(z.value));if(e)O.value=!1;else{const e=F.value||"/";await B.push(e),O.value=!1}}})};return v(()=>{(async()=>{const e=await u(),{data:a}=e;P.value=void 0===a.captchaEnabled||a.captchaEnabled,P.value&&(z.value.code="",R.value="data:image/gif;base64,"+a.img,z.value.uuid=a.uuid)})(),(async()=>{const{data:e}=await d(!1);D.value=void 0===e.tenantEnabled||e.tenantEnabled,D.value&&(H.value=e.voList,null!=H.value&&0!==H.value.length&&(z.value.tenantId=H.value[0].tenantId))})(),(()=>{const e=localStorage.getItem("tenantId"),a=localStorage.getItem("username"),l=localStorage.getItem("password"),r=localStorage.getItem("rememberMe");z.value={tenantId:null===e?String(z.value.tenantId):e,username:null===a?String(z.value.username):a,password:String(null===l?z.value.password:l),rememberMe:null!==r&&Boolean(r)}})()}),(s,n)=>{const u=o,d=a,i=e,c=l,g=r,p=t;return f(),b("div",E,[I(p,{ref_key:"loginRef",ref:G,model:_(z),rules:L,class:"login-form"},{default:w(()=>[n[3]||(n[3]=y("div",{class:"title-box"},[y("div",{class:"line"}),y("div",{class:"subtitle"},[y("div",null,"WELCOME"),y("div",null,"智慧物业后台管理系统")])],-1)),I(i,{prop:"username"},{default:w(()=>[I(d,{modelValue:_(z).username,"onUpdate:modelValue":n[0]||(n[0]=e=>_(z).username=e),modelModifiers:{trim:!0},type:"text",size:"large","auto-complete":"off",placeholder:_(m).$t("login.username")},{prefix:w(()=>[I(u,{"icon-class":"user",class:"el-input__icon input-icon"})]),_:1},8,["modelValue","placeholder"])]),_:1}),I(i,{prop:"password"},{default:w(()=>[I(d,{modelValue:_(z).password,"onUpdate:modelValue":n[1]||(n[1]=e=>_(z).password=e),modelModifiers:{trim:!0},type:"password",size:"large","auto-complete":"off",placeholder:_(m).$t("login.password"),onKeyup:S(K,["enter"])},{prefix:w(()=>[I(u,{"icon-class":"password",class:"el-input__icon input-icon"})]),_:1},8,["modelValue","placeholder"])]),_:1}),y("div",j,[I(c,{modelValue:_(z).rememberMe,"onUpdate:modelValue":n[2]||(n[2]=e=>_(z).rememberMe=e),style:{color:"#fff"}},{default:w(()=>[M(h(_(m).$t("login.rememberPassword")),1)]),_:1},8,["modelValue"])]),I(i,{style:{width:"100%"}},{default:w(()=>[I(g,{loading:_(O),size:"large",type:"primary",style:{width:"100%"},onClick:q(K,["prevent"])},{default:w(()=>[_(O)?(f(),b("span",C,h(_(m).$t("login.logging")),1)):(f(),b("span",k,h(_(m).$t("login.login")),1))]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"])])}}}),[["__scopeId","data-v-999b65eb"]]);export{$ as default};
