import{d as h,h as c,g as d,x as l,t as p,i as f,T as g,j as e,z as o,B as m}from"./index.3bfa6a0e.js";import{C}from"./index.85c8c2f7.js";import"./index.79997a38.js";import{F as u}from"./index.983bfd1a.js";import{C as y}from"./index.c253c4e4.js";import{R as r,C as a}from"./index.bb2d59fe.js";import{I as T}from"./index.a7aeb53b.js";import{c as S}from"./validate.ba62cd4c.js";import"./use-id.7c44c16f.js";import"./index.0fd5538f.js";const w="_login_18sy9_1",D="_loginTitle_18sy9_7",_="_codeText_18sy9_15",F="_margin34_18sy9_18",x="_formTitle_18sy9_21";var s={login:w,loginTitle:D,codeText:_,margin34:F,formTitle:x},W=h({name:"login",data(){return{loginType:"SMS",username:"",password:"",smsCode:"",countDownStatus:!0,countDownTime:1e3*120,countDownRef:null,imgCodeStatus:!1}},computed:{codeDisable(){let t=!0;return this.loginType==="PWD"?this.username&&this.password&&(t=!1):this.username&&this.smsCode&&(t=!1),t}},mounted(){c(),this.directNext()},methods:{directNext(){if(d.user.status==="login"||d.user.status==="error"){const{returnUrl:t,isRegister:n,...i}=this.$route.query;this.$router.replace({path:t,query:{...i}})}},async onLogin(){try{let t;this.loginType==="PWD"?t=await l.post("/api-auth/usernameLogin",{requestType:"form",data:{username:this.username,password:this.password,clientId:"teacher",clientSecret:"teacher"}}):t=await l.post("/api-auth/smsLogin",{requestType:"form",data:{clientId:"teacher",clientSecret:"teacher",phone:this.username,smsCode:this.smsCode}});const{authentication:n}=t.data;p(n.token_type+" "+n.access_token);let i=await l.get("/api-teacher/teacher/queryUserInfo",{initRequest:!0});f(i.data),this.directNext()}catch{}},async onSendCode(){if(!S(this.username))return g("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u7801");this.imgCodeStatus=!0},onCodeSend(){this.countDownStatus=!1,this.countDownRef.start()},onFinished(){this.countDownStatus=!0,this.countDownRef.reset()},onChange(){this.loginType==="PWD"?this.loginType="SMS":this.loginType==="SMS"&&(this.loginType="PWD")}},render(){return e("div",{class:s.login},[e("div",{class:s.loginTitle},[o("\u60A8\u597D\uFF0C"),e("br",null,null),o(" \u6B22\u8FCE\u4F7F\u7528\u9177\u4E50\u79C0")]),e(C,{class:s.margin34,border:!1},{default:()=>[e(r,{style:{marginBottom:"16px"}},{default:()=>[e(a,{span:24,class:s.formTitle},{default:()=>[o("\u624B\u673A\u53F7")]}),e(a,{span:24,class:"van-hairline--bottom"},{default:()=>[e(u,{modelValue:this.username,"onUpdate:modelValue":t=>this.username=t,name:"\u624B\u673A\u53F7",placeholder:"\u8BF7\u8F93\u5165\u60A8\u7684\u624B\u673A\u53F7",type:"tel",maxlength:11},null)]})]}),this.loginType==="PWD"?e(r,null,{default:()=>[e(a,{span:24,class:s.formTitle},{default:()=>[o("\u5BC6\u7801")]}),e(a,{span:24,class:"van-hairline--bottom"},{default:()=>[e(u,{modelValue:this.password,"onUpdate:modelValue":t=>this.password=t,type:"password",name:"\u5BC6\u7801",placeholder:"\u8BF7\u8F93\u5165\u5BC6\u7801"},null)]})]}):e(r,null,{default:()=>[e(a,{span:24,class:s.formTitle},{default:()=>[o("\u9A8C\u8BC1\u7801")]}),e(a,{span:24,class:"van-hairline--bottom"},{default:()=>[e(u,{modelValue:this.smsCode,"onUpdate:modelValue":t=>this.smsCode=t,name:"\u9A8C\u8BC1\u7801",placeholder:"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801",type:"tel",maxlength:6},{button:()=>this.countDownStatus?e("span",{class:s.codeText,onClick:this.onSendCode},[o("\u83B7\u53D6\u9A8C\u8BC1\u7801")]):e(y,{ref:this.countDownRef,"auto-start":!1,time:this.countDownTime,onFinish:this.onFinished,format:"ss\u79D2"},null)})]})]})]}),e("div",{class:s.margin34},[e(m,{round:!0,block:!0,type:"primary",disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[o("\u63D0\u4EA4")]}),e(m,{block:!0,round:!0,color:"#F5F7FB",onClick:this.onChange},{default:()=>[this.loginType==="PWD"?"\u9A8C\u8BC1\u7801\u767B\u5F55":"\u5BC6\u7801\u767B\u5F55"]})]),this.imgCodeStatus?e(T,{value:this.imgCodeStatus,"onUpdate:value":t=>this.imgCodeStatus=t,phone:this.username,onClose:()=>{this.imgCodeStatus=!1},onSendCode:this.onCodeSend},null):null])}});export{W as default};
