1 |
- import{d as c,f as s,l as h,m as d,j as f,n as g,o as C,c as t,q as a,B as m}from"./index.ffe80dbe.js";import{c as T,R as r,C as l,I as y}from"./validate.5e9d8d60.js";import{C as S}from"./index.914765a1.js";import{F as u}from"./index.92ec0bf4.js";import{C as _}from"./index.b2ab72e6.js";import"./index.7e972106.js";import"./index.ea031708.js";const w="_login_9la03_1",D="_TEACHER_9la03_7",A="_SCHOOL_9la03_12",F="_loginTitle_9la03_17",x="_codeText_9la03_25",E="_margin34_9la03_28",R="_formTitle_9la03_31";var o={login:w,TEACHER:D,SCHOOL:A,loginTitle:F,codeText:x,margin34:E,formTitle:R},L=c({name:"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},appName(){return{STUDENT:"\u5B66\u751F\u7AEF",TEACHER:"\u8001\u5E08\u7AEF",SCHOOL:"\u7BA1\u7406\u7AEF"}[s.platformType]}},mounted(){h(),this.directNext()},methods:{directNext(){if(s.user.status==="login"||s.user.status==="error"){const{returnUrl:e,isRegister:i,...n}=this.$route.query;this.$router.replace({path:e,query:{...n}})}},async onLogin(){try{const e={username:this.username,client_id:s.clientId[s.platformType],client_secret:s.clientId[s.platformType]};console.log("\u{1F680} ~ state.clientId",s.clientId,s.platformType),this.loginType==="PWD"?(e.password=this.password,e.loginType="PASSWORD",e.grant_type="password"):(e.password=this.smsCode,e.loginType="SMS",e.grant_type="password");const{data:i}=await d.post("/api-oauth/userlogin",{requestType:"form",data:{...e}});f(i.token_type+" "+i.access_token);const n=await d.get(s.platformApi+"/user/getUserInfo",{initRequest:!0});if(s.platformType==="SCHOOL"){const p=n.data.schoolInfos?n.data.schoolInfos[0]:{};n.data.school=p}g(n.data),this.directNext()}catch{}},async onSendCode(){if(!T(this.username))return C("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u7801");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:[o.login,o[s.platformType]]},[t("div",{class:o.loginTitle},[a("\u60A8\u597D\uFF0C"),t("br",null,null),a(" \u6B22\u8FCE\u4F7F\u7528\u7BA1\u4E50\u56E2"),this.appName]),t(S,{class:o.margin34,border:!1},{default:()=>[t(r,{style:{marginBottom:"16px"}},{default:()=>[t(l,{span:24,class:o.formTitle},{default:()=>[a("\u624B\u673A\u53F7")]}),t(l,{span:24,class:"van-hairline--bottom"},{default:()=>[t(u,{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:o.formTitle},{default:()=>[a("\u5BC6\u7801")]}),t(l,{span:24,class:"van-hairline--bottom"},{default:()=>[t(u,{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:o.formTitle},{default:()=>[a("\u9A8C\u8BC1\u7801")]}),t(l,{span:24,class:"van-hairline--bottom"},{default:()=>[t(u,{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:o.codeText,onClick:this.onSendCode},[a("\u83B7\u53D6\u9A8C\u8BC1\u7801")]):t(_,{ref:"countDownRef","auto-start":!1,time:this.countDownTime,onFinish:this.onFinished,format:"ss\u79D2"},null)})]})]})]}),t("div",{class:o.margin34},[t(m,{round:!0,block:!0,type:"primary",disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[a("\u63D0\u4EA4")]}),t(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?t(y,{value:this.imgCodeStatus,"onUpdate:value":e=>this.imgCodeStatus=e,phone:this.username,onClose:()=>{this.imgCodeStatus=!1},onSendCode:this.onCodeSend},null):null])}});export{L as default};
|