import{d as m,h as c,g as u,t as h,i as p,T as f,j as t,z as o,B as C}from"./index.3bfa6a0e.js";import{C as g}from"./index.85c8c2f7.js";import"./index.79997a38.js";import{F as r}from"./index.983bfd1a.js";import{C as T}from"./index.c253c4e4.js";import{R as l,C as a}from"./index.bb2d59fe.js";import{I as _}from"./index.a7aeb53b.js";import{c as k}from"./validate.ba62cd4c.js";import{a as d}from"./index.c1948393.js";import{C as S}from"./index.645e7ddc.js";import"./use-id.7c44c16f.js";import"./index.0fd5538f.js";import"./auth.37c81a49.js";import"./routes-common.fec36607.js";const y="_login_1qk49_1",w="_loginTitle_1qk49_7",D="_codeText_1qk49_15",x="_margin34_1qk49_18",b="_formTitle_1qk49_21";var s={login:y,loginTitle:w,codeText:D,margin34:x,formTitle:b},j=m({name:"login",data(){return{username:"",password:"",smsCode:"",countDownStatus:!0,countDownTime:1e3*120,countDownRef:null,imgCodeStatus:!1}},computed:{codeDisable(){let e=!0;return this.username&&this.smsCode&&(e=!1),e}},mounted(){c(),this.directNext()},methods:{directNext(){if(u.user.status==="login"||u.user.status==="error"){const{returnUrl:e,isRegister:n,...i}=this.$route.query;this.$router.replace({path:"/home",query:{...i}})}},async onLogin(){try{const e=await d.post("/api-auth/smsLogin",{requestType:"form",data:{clientId:"student",clientSecret:"student",phone:this.username,smsCode:this.smsCode,isSurportRegister:!0}}),{authentication:n}=e.data;h(n.token_type+" "+n.access_token),postMessage({api:"setCache",content:{key:"h5-colexiu-token",value:n.token_type+" "+n.access_token}});const i=await d.get("/api-student/student/queryUserInfo",{initRequest:!0});p(i.data),postMessage({api:"bindUserAccount",content:{phone:this.username}}),this.directNext()}catch{}},async onSendCode(){if(!k(this.username))return f("\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()}},render(){return t("div",{class:s.login},[t(S,{border:!1,background:"transparent",title:" ",isBack:!0},null),t("div",{class:s.loginTitle},[o("\u60A8\u597D\uFF0C"),t("br",null,null),o(" \u6B22\u8FCE\u4F7F\u7528\u9177\u4E50\u79C0")]),t(g,{class:s.margin34,border:!1},{default:()=>[t(l,{style:{marginBottom:"16px"}},{default:()=>[t(a,{span:24,class:s.formTitle},{default:()=>[o("\u624B\u673A\u53F7")]}),t(a,{span:24,class:"van-hairline--bottom"},{default:()=>[t(r,{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)]})]}),t(l,null,{default:()=>[t(a,{span:24,class:s.formTitle},{default:()=>[o("\u9A8C\u8BC1\u7801")]}),t(a,{span:24,class:"van-hairline--bottom"},{default:()=>[t(r,{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(T,{ref:this.countDownRef,"auto-start":!1,time:this.countDownTime,onFinish:this.onFinished,format:"ss\u79D2"},null)})]})]})]}),t("div",{class:s.margin34},[t(C,{round:!0,block:!0,type:"primary",disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[o("\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{j as default};
