import{d as O,ad as T,u as G,r as g,e as K,a as e,x as k,w as Q,l as W,v as X,o as f,A as w,B as l,f as a,E as h,c as S,D as C,H as Y,ce as Z,an as $,ao as ee,aj as V,cf as ae,a9 as le,S as oe,J as te,a6 as ne,M as ie,U as se}from"./index-24b5bd0d.js";import{_ as re}from"./XButton-7ae933e9.js";import{u as y}from"./useIcon-5b813215.js";import{_ as de}from"./LoginFormTitle.vue_vue_type_script_setup_true_lang-6601c6be.js";import{u as me,L as pe,a as ue}from"./useLogin-1d4ad091.js";import{u as ce}from"./useMessage-6f610bbd.js";import{r as _}from"./formRules-41bf030d.js";import{_ as ge}from"./_plugin-vue_export-helper-1b428a4d.js";const fe={key:1,class:"getMobileCode",style:{cursor:"pointer"}},be=ge(O({name:"MobileForm",__name:"MobileForm",setup(he){const{t:i}=Y(),M=ce(),I=T(),{currentRoute:L,push:E}=G(),x=g(),u=g(!1),U=y({icon:"ep:house"}),B=y({icon:"ep:cellphone"}),P=y({icon:"ep:circle-check"}),{validForm:R}=ue(x),{handleBackLogin:j,getLoginState:q}=me(),z=K(()=>e(q)===pe.MOBILE),A={tenantName:[_],mobileNumber:[_],code:[_]},o=k({codeImg:"",tenantEnable:"false",token:"",loading:{signIn:!1},loginForm:{uuid:"",tenantName:"\u975E\u7E41\u6E90\u7801",mobileNumber:"",code:""}}),p=k({smsCode:{mobile:"",scene:21},loginSms:{mobile:"",code:""}}),s=g(0),c=g(""),D=async()=>{await v(),p.smsCode.mobile=o.loginForm.mobileNumber,await Z(p.smsCode).then(async()=>{M.success(i("login.SmsSendMsg")),s.value=60;let n=setInterval(()=>{s.value=s.value-1,s.value<=0&&clearInterval(n)},1e3)})};Q(()=>L.value,n=>{var t;c.value=(t=n==null?void 0:n.query)==null?void 0:t.redirect},{immediate:!0});const v=async()=>{if(o.tenantEnable==="true"){const n=await $(o.loginForm.tenantName);ee(n)}};return(n,t)=>{const m=oe,r=te,b=ne,F=ie,N=re,H=se;return W((f(),w(H,{ref_key:"formSmsLogin",ref:x,model:e(o).loginForm,rules:A,class:"login-form","label-position":"top","label-width":"120px",size:"large"},{default:l(()=>[a(F,{style:{"margin-right":"-10px","margin-left":"-10px"}},{default:l(()=>[a(r,{span:24,style:{"padding-right":"10px","padding-left":"10px"}},{default:l(()=>[a(m,null,{default:l(()=>[a(de,{style:{width:"100%"}})]),_:1})]),_:1}),a(r,{span:24,style:{"padding-right":"10px","padding-left":"10px"}},{default:l(()=>[e(o).tenantEnable==="true"?(f(),w(m,{key:0,prop:"tenantName"},{default:l(()=>[a(b,{modelValue:e(o).loginForm.tenantName,"onUpdate:modelValue":t[0]||(t[0]=d=>e(o).loginForm.tenantName=d),placeholder:e(i)("login.tenantNamePlaceholder"),"prefix-icon":e(U),type:"primary",link:""},null,8,["modelValue","placeholder","prefix-icon"])]),_:1})):h("",!0)]),_:1}),a(r,{span:24,style:{"padding-right":"10px","padding-left":"10px"}},{default:l(()=>[a(m,{prop:"mobileNumber"},{default:l(()=>[a(b,{modelValue:e(o).loginForm.mobileNumber,"onUpdate:modelValue":t[1]||(t[1]=d=>e(o).loginForm.mobileNumber=d),placeholder:e(i)("login.mobileNumberPlaceholder"),"prefix-icon":e(B)},null,8,["modelValue","placeholder","prefix-icon"])]),_:1})]),_:1}),a(r,{span:24,style:{"padding-right":"10px","padding-left":"10px"}},{default:l(()=>[a(m,{prop:"code"},{default:l(()=>[a(F,{gutter:5,justify:"space-between",style:{width:"100%"}},{default:l(()=>[a(r,{span:24},{default:l(()=>[a(b,{modelValue:e(o).loginForm.code,"onUpdate:modelValue":t[2]||(t[2]=d=>e(o).loginForm.code=d),placeholder:e(i)("login.codePlaceholder"),"prefix-icon":e(P)},{append:l(()=>[e(s)<=0?(f(),S("span",{key:0,class:"getMobileCode",style:{cursor:"pointer"},onClick:D},C(e(i)("login.getSmsCode")),1)):h("",!0),e(s)>0?(f(),S("span",fe,C(e(s))+"\u79D2\u540E\u53EF\u91CD\u65B0\u83B7\u53D6 ",1)):h("",!0)]),_:1},8,["modelValue","placeholder","prefix-icon"])]),_:1})]),_:1})]),_:1})]),_:1}),a(r,{span:24,style:{"padding-right":"10px","padding-left":"10px"}},{default:l(()=>[a(m,null,{default:l(()=>[a(N,{loading:e(u),title:e(i)("login.login"),class:"w-[100%]",type:"primary",onClick:t[3]||(t[3]=d=>(async()=>{await v(),await R()&&(V.service({lock:!0,text:"\u6B63\u5728\u52A0\u8F7D\u7CFB\u7EDF\u4E2D...",background:"rgba(0, 0, 0, 0.7)"}),u.value=!0,p.loginSms.mobile=o.loginForm.mobileNumber,p.loginSms.code=o.loginForm.code,await ae(p.loginSms).then(async J=>{le(J),c.value||(c.value="/"),E({path:c.value||I.addRouters[0].path})}).catch(()=>{}).finally(()=>{u.value=!1,setTimeout(()=>{V.service().close()},400)}))})())},null,8,["loading","title"])]),_:1})]),_:1}),a(r,{span:24,style:{"padding-right":"10px","padding-left":"10px"}},{default:l(()=>[a(m,null,{default:l(()=>[a(N,{loading:e(u),title:e(i)("login.backLogin"),class:"w-[100%]",onClick:t[4]||(t[4]=d=>e(j)())},null,8,["loading","title"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])),[[X,e(z)]])}}}),[["__scopeId","data-v-e63d5b39"]]);export{be as default};