var T=Object.defineProperty;var u=Object.getOwnPropertySymbols;var c=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var p=(e,s,o)=>s in e?T(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o,f=(e,s)=>{for(var o in s||(s={}))c.call(s,o)&&p(e,o,s[o]);if(u)for(var o of u(s))h.call(s,o)&&p(e,o,s[o]);return e};var g=(e,s)=>{var o={};for(var a in e)c.call(e,a)&&s.indexOf(a)<0&&(o[a]=e[a]);if(e!=null&&u)for(var a of u(e))s.indexOf(a)<0&&h.call(e,a)&&(o[a]=e[a]);return o};import{d as S,T as w,a as t,j as i,C as D,k as r,l,m as d,p as x,B as C}from"./vendor.a0144ce9.js";/* empty css              *//* empty css               *//* empty css               */import{I as _}from"./index.b2209e3c.js";/* empty css              */import{c as b}from"./validate.ba62cd4c.js";import{i as v,s as y,r as m,a as F,b as j}from"./index.3d95a92c.js";/* empty css               */const B="_login_18sy9_1",k="_loginTitle_18sy9_7",V="_codeText_18sy9_15",q="_margin34_18sy9_18",A="_formTitle_18sy9_21";var n={login:B,loginTitle:k,codeText:V,margin34:q,formTitle:A},G=S({name:"login",data(){return{loginType:"SMS",username:"",password:"",smsCode:"",countDownStatus:!0,countDownTime:1e3*120,countDownRef:null,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(){v(),this.directNext()},methods:{directNext(){if(y.user.status==="login"||y.user.status==="error"){const e=this.$route.query,{returnUrl:s,isRegister:o}=e,a=g(e,["returnUrl","isRegister"]);this.$router.replace({path:s,query:f({},a)})}},async onLogin(){try{let e;this.loginType==="PWD"?e=await m.post("/api-auth/usernameLogin",{requestType:"form",data:{username:this.username,password:this.password,clientId:"teacher",clientSecret:"teacher"}}):e=await m.post("/api-auth/smsLogin",{requestType:"form",data:{clientId:"teacher",clientSecret:"teacher",phone:this.username,smsCode:this.smsCode}});const{authentication:s}=e.data;F(s.token_type+" "+s.access_token);let o=await m.get("/api-teacher/teacher/queryUserInfo",{initRequest:!0});j(o.data),this.directNext()}catch{}},async onSendCode(){if(!b(this.username))return w("\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 t("div",{class:n.login},[t("div",{class:n.loginTitle},[i("\u60A8\u597D\uFF0C"),t("br",null,null),i(" \u6B22\u8FCE\u4F7F\u7528\u9177\u4E50\u79C0")]),t(D,{class:n.margin34,border:!1},{default:()=>[t(r,{style:{marginBottom:"16px"}},{default:()=>[t(l,{span:24,class:n.formTitle},{default:()=>[i("\u624B\u673A\u53F7")]}),t(l,{span:24,class:"van-hairline--bottom"},{default:()=>[t(d,{modelValue:this.username,"onUpdate:modelValue":e=>this.username=e,name:"\u624B\u673A\u53F7",placeholder:"\u8BF7\u8F93\u5165\u60A8\u7684\u624B\u673A\u53F7",type:"tel",maxlength:11},null)]})]}),this.loginType==="PWD"?t(r,null,{default:()=>[t(l,{span:24,class:n.formTitle},{default:()=>[i("\u5BC6\u7801")]}),t(l,{span:24,class:"van-hairline--bottom"},{default:()=>[t(d,{modelValue:this.password,"onUpdate:modelValue":e=>this.password=e,type:"password",name:"\u5BC6\u7801",placeholder:"\u8BF7\u8F93\u5165\u5BC6\u7801"},null)]})]}):t(r,null,{default:()=>[t(l,{span:24,class:n.formTitle},{default:()=>[i("\u9A8C\u8BC1\u7801")]}),t(l,{span:24,class:"van-hairline--bottom"},{default:()=>[t(d,{modelValue:this.smsCode,"onUpdate:modelValue":e=>this.smsCode=e,name:"\u9A8C\u8BC1\u7801",placeholder:"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801",type:"tel",maxlength:6},{button:()=>this.countDownStatus?t("span",{class:n.codeText,onClick:this.onSendCode},[i("\u83B7\u53D6\u9A8C\u8BC1\u7801")]):t(x,{ref:this.countDownRef,"auto-start":!1,time:this.countDownTime,onFinish:this.onFinished,format:"ss\u79D2"},null)})]})]})]}),t("div",{class:n.margin34},[t(C,{round:!0,block:!0,type:"primary",disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[i("\u63D0\u4EA4")]}),t(C,{block:!0,round:!0,color:"#F5F7FB",onClick:this.onChange},{default:()=>[this.loginType==="PWD"?"\u9A8C\u8BC1\u7801\u767B\u5F55":"\u5BC6\u7801\u767B\u5F55"]})]),this.imgCodeStatus?t(_,{value:this.imgCodeStatus,"onUpdate:value":e=>this.imgCodeStatus=e,phone:this.username,onClose:()=>{this.imgCodeStatus=!1},onSendCode:this.onCodeSend},null):null])}});export{G as default};
