import{C as c,I as d}from"./index-006635e8.js";import{d as h,r as m,s as l,a as i,b as r,c as p,e as g,f as k,g as t,h as u,B as f}from"./index-6ef77773.js";import{C as R}from"./index-62b5de3e.js";import{F as a}from"./index-617c3e5c.js";import"./index-5313f793.js";import"./index-6cce5316.js";import"./index-2ab268f1.js";const y="_login_pvck2_1",E="_codeText_pvck2_6",S="_logo_pvck2_9",Y="_container_pvck2_21",s={login:y,codeText:E,logo:S,container:Y,"input-group":"_input-group_pvck2_24","code-text":"_code-text_pvck2_45","login-change":"_login-change_pvck2_62"},A="data:image/png;base64,[encoded data, 4960 characters]",V=h({name:"layout-login",data(){return{loginType:"SMS",username:"",password:"",smsCode:"",countDownStatus:!0,countDownTime:1e3*120,imgCodeStatus:!1}},computed:{codeDisable(){let e=!0;return this.loginType==="PWD"?this.username&&this.password&&(e=!1):this.username&&this.smsCode&&(e=!1),e}},mounted(){m(),this.directNext()},methods:{directNext(){if(l.user.status==="login"||l.user.status==="error"){const{returnUrl:e,isRegister:n,...o}=this.$route.query;this.$router.replace({path:e,query:{...o}})}},async onLogin(){try{const e={phone:this.username,clientId:"EDUCATION",clientSecret:"EDUCATION"};if(this.loginType==="PWD"){e.password=this.password,e.grant_type="password";const{data:o}=await i.post("/api-auth/usernameLogin",{requestType:"form",data:{...e}});r(o.authentication.token_type+" "+o.authentication.access_token)}else{e.smsCode=this.smsCode;const{data:o}=await i.post("/api-auth/smsLogin",{requestType:"form",data:{...e}});r(o.authentication.token_type+" "+o.authentication.access_token)}const n=await i.get("/api-web/schoolStaff/queryUserInfo",{initRequest:!0});p(n.data),this.directNext()}catch(e){}},async onSendCode(){if(!g(this.username))return k("请输入正确的手机号码");this.imgCodeStatus=!0},onCodeSend(){this.countDownStatus=!1,this.$nextTick(()=>{this.$refs.countDownRef.start()})},onFinished(){this.countDownStatus=!0,this.$refs.countDownRef.reset()},onChange(){this.loginType==="PWD"?this.loginType="SMS":this.loginType==="SMS"&&(this.loginType="PWD")}},render(){return t("div",{class:[s.login]},[t("div",{class:s.logo},[t("img",{src:A},null)]),t(R,{class:s.container,border:!1},{default:()=>[t(a,{modelValue:this.username,"onUpdate:modelValue":e=>this.username=e,name:"手机号",placeholder:"请输入您的手机号",type:"tel",class:s["input-group"],maxlength:11},null),this.loginType==="PWD"?t(a,{modelValue:this.password,"onUpdate:modelValue":e=>this.password=e,type:"password",name:"密码",class:s["input-group"],placeholder:"请输入密码"},null):t(a,{modelValue:this.smsCode,"onUpdate:modelValue":e=>this.smsCode=e,name:"验证码",placeholder:"请输入验证码",type:"tel",class:s["input-group"],maxlength:6},{button:()=>this.countDownStatus?t("span",{class:s.codeText,onClick:this.onSendCode},[u("获取验证码")]):t(c,{ref:"countDownRef","auto-start":!1,time:this.countDownTime,onFinish:this.onFinished,format:"ss秒"},null)})]}),t("div",{class:s.margin34},[t(f,{round:!0,block:!0,disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[u("提交")]}),t("span",{class:s["login-change"],onClick:this.onChange},[this.loginType==="PWD"?"验证码登录":"密码登录"])]),this.imgCodeStatus?t(d,{value:this.imgCodeStatus,"onUpdate:value":e=>this.imgCodeStatus=e,phone:this.username,onClose:()=>{this.imgCodeStatus=!1},onSendCode:this.onCodeSend},null):null])}});export{V as default};
