import{c as m,R as i,C as a,I as h}from"./validate.598a2b58.js";import{d as c,aK as p,aL as r,aM as l,aN as f,aO as C,j as g,k as e,aP as s,l as o,B as S}from"./index.879f7421.js";import{C as y}from"./index.4aec72fa.js";import{F as d}from"./index.00975bf6.js";import{C as D}from"./index.fe392820.js";import"./index.c463dbd0.js";import"./index.9a3a3b84.js";var A=c({name:"login-music",data(){return{loginType:"SMS",username:"",password:"",smsCode:"",countDownStatus:!0,countDownTime:1e3*120,imgCodeStatus:!1}},computed:{codeDisable(){let t=!0;return this.username&&this.smsCode&&(t=!1),t}},mounted(){p(),this.directNext()},methods:{directNext(){if(r.user.status==="login"||r.user.status==="error"){const{returnUrl:t,isRegister:n,...u}=this.$route.query;this.$router.replace({path:t,query:{...u}})}},async onLogin(){try{const t={username:this.username,client_id:"jmedu-student",client_secret:"jmedu-student",autoRegister:!0,password:this.smsCode,loginType:"SMS",grant_type:"SMS"},{data:n}=await l.post("/api-oauth/userlogin",{requestType:"form",data:{...t}});f(n.token_type+" "+n.access_token);const u=await l.get("/api-student/appLoginUser/getUserInfo",{initRequest:!0});C(u.data),this.directNext()}catch{}},async onSendCode(){if(!m(this.username))return g("\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 e("div",{class:s.login},[e("div",{class:s.loginTitle},[o("\u60A8\u597D\uFF0C"),e("br",null,null),o(" \u6B22\u8FCE\u4F7F\u7528\u7BA1\u4E50\u56E2\u5B66\u751F\u7AEF")]),e(y,{class:s.margin34,border:!1},{default:()=>[e(i,{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(d,{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)]})]}),e(i,null,{default:()=>[e(a,{span:24,class:s.formTitle},{default:()=>[o("\u9A8C\u8BC1\u7801")]}),e(a,{span:24,class:"van-hairline--bottom"},{default:()=>[e(d,{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(D,{ref:"countDownRef","auto-start":!1,time:this.countDownTime,onFinish:this.onFinished,format:"ss\u79D2"},null)})]})]})]}),e("div",{class:s.margin34},[e(S,{round:!0,block:!0,type:"primary",disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[o("\u63D0\u4EA4")]})]),this.imgCodeStatus?e(h,{value:this.imgCodeStatus,"onUpdate:value":t=>this.imgCodeStatus=t,phone:this.username,onClose:()=>{this.imgCodeStatus=!1},onSendCode:this.onCodeSend},null):null])}});export{A as default};
