import{d as f,h as g,g as m,x as u,t as C,T as l,i as T,W as y,j as t,z as o,B as p}from"./index.3bfa6a0e.js";import{C as S}from"./index.85c8c2f7.js";import"./index.79997a38.js";import{F as d}from"./index.983bfd1a.js";import{C as D}from"./index.c253c4e4.js";import{R as h,C as i}from"./index.bb2d59fe.js";import{I as w}from"./index.a7aeb53b.js";import{c as _}from"./validate.ba62cd4c.js";import"./use-id.7c44c16f.js";import"./index.0fd5538f.js";const x="_login_18sy9_1",F="_loginTitle_18sy9_7",q="_codeText_18sy9_15",b="_margin34_18sy9_18",v="_formTitle_18sy9_21";var s={login:x,loginTitle:F,codeText:q,margin34:b,formTitle:v},A=f({name:"login",data(){return{loginType:"SMS",username:"",password:"",smsCode:"",countDownStatus:!0,countDownTime:1e3*120,countDownRef:null,imgCodeStatus:!1,isTrainGroup:!1}},computed:{codeDisable(){let e=!0;return this.loginType==="PWD"?this.username&&this.password&&(e=!1):this.username&&this.smsCode&&(e=!1),e}},mounted(){this.$route.query.returnUrl==="/train-tool"&&this.$route.query.taId&&(this.isTrainGroup=!0),g(),this.directNext()},methods:{directNext(){if(m.user.status==="login"||m.user.status==="error"){const{returnUrl:e,isRegister:a,...n}=this.$route.query;this.$router.replace({path:e,query:{...n}})}},async onLogin(){try{let e;this.loginType==="PWD"?e=await u.post("/api-auth/usernameLogin",{requestType:"form",data:{username:this.username,password:this.password,clientId:"student",clientSecret:"student"}}):e=await u.post("/api-auth/smsLogin",{requestType:"form",hideErrorMessage:this.isTrainGroup,data:{clientId:"student",clientSecret:"student",phone:this.username,smsCode:this.smsCode}});const{authentication:a}=e.data;C(a.token_type+" "+a.access_token);const n=await u.get("/api-student/student/queryUserInfo",{initRequest:!0});if(this.isTrainGroup){const{tenantGroupId:r,tenantId:c}=this.$route.query;if(r!=n.data.tenantGroupId||c!=n.data.tenantId){setTimeout(()=>{l("\u60A8\u7684\u6240\u5728\u5C0F\u7EC4\u4E0D\u53EF\u8D2D\u4E70\u8BE5\u6559\u7A0B")},100);return}}T(n.data),this.directNext()}catch(e){if(e.message.indexOf("\u9A8C\u8BC1\u7801\u6821\u9A8C\u5931\u8D25")>-1){l("\u9A8C\u8BC1\u7801\u6821\u9A8C\u5931\u8D25");return}if(e.message.indexOf("409")>-1&&this.isTrainGroup&&this.loginType!=="PWD"){const{returnUrl:a,isRegister:n,...r}=this.$route.query;this.$router.replace({path:"/tenantStudentRejest",query:{...r}})}}},async onSendCode(){if(!_(this.username))return l("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u7801");this.imgCodeStatus=!0},onCodeSend(){this.countDownStatus=!1,y(()=>{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:s.login},[t("div",{class:s.loginTitle},[o("\u60A8\u597D\uFF0C"),t("br",null,null),o(" \u6B22\u8FCE\u4F7F\u7528\u9177\u4E50\u79C0")]),t(S,{class:s.margin34,border:!1},{default:()=>[t(h,{style:{marginBottom:"16px"}},{default:()=>[t(i,{span:24,class:s.formTitle},{default:()=>[o("\u624B\u673A\u53F7")]}),t(i,{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(h,null,{default:()=>[t(i,{span:24,class:s.formTitle},{default:()=>[o("\u5BC6\u7801")]}),t(i,{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(h,null,{default:()=>[t(i,{span:24,class:s.formTitle},{default:()=>[o("\u9A8C\u8BC1\u7801")]}),t(i,{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:s.codeText,onClick:this.onSendCode},[o("\u83B7\u53D6\u9A8C\u8BC1\u7801")]):t(D,{ref:e=>this.countDownRef=e,"auto-start":!1,time:this.countDownTime,onFinish:this.onFinished,format:"ss\u79D2"},null)})]})]})]}),t("div",{class:s.margin34},[t(p,{round:!0,block:!0,type:"primary",disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[o("\u63D0\u4EA4")]}),t(p,{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(w,{value:this.imgCodeStatus,"onUpdate:value":e=>this.imgCodeStatus=e,phone:this.username,onClose:()=>{this.imgCodeStatus=!1},onSendCode:this.onCodeSend},null):null])}});export{A as default};
