import{c as p,R as l,C as i,I as c}from"./validate.4163f0a2.js";import{d as m,bl as f,f as g,m as n,be as w,bf as C,g as d,s as y,n as S,o as D,c as e,bm as s,q as a,B as P,P as T}from"./index.d1dca38b.js";import{q as x}from"./index.339fc024.js";import{C as A}from"./index.1383acec.js";import{F as h}from"./index.a5f38096.js";import{C as b}from"./index.34ec1904.js";import"./index.6c52b1a0.js";import"./index.2f930c00.js";var $=m({name:"login-music",data(){return{loginType:"SMS",username:"",password:"",smsCode:"",countDownStatus:!0,countDownTime:1e3*120,imgCodeStatus:!1,showPopup:!1,showPopupMessage:"\u8BF7\u4F7F\u7528\u5FAE\u4FE1\u6253\u5F00",wxAppId:"",code:"",orchestraInfo:{},testIsWeixin:!1,noPaymentList:["1656572729093021697","1656488025144713217","1661221287237820418","1661222465069686785"]}},computed:{codeDisable(){let t=!0;return this.username&&this.smsCode&&(t=!1),t}},mounted(){f(),this.directNext(),!g().weixin&&!this.testIsWeixin&&(this.showPopup=!0),this.$route.query.id&&this.noPaymentList.indexOf(this.$route.query.id)!=-1&&(console.log("\u63D0\u793A\u4E50\u56E2\u62A5\u540D\u5931\u8D25"),this.showPopupMessage="\u4E50\u56E2\u62A5\u540D\u65F6\u95F4\u5DF2\u8FC7\uFF0C\u8BF7\u7B49\u5F85\u901A\u77E5",this.showPopup=!0),this.getDetails()},methods:{async getDetails(){try{if(!this.$route.query.id)return;const{data:o}=await n.get("/api-student/open/orchestra/detail/"+this.$route.query.id);this.orchestraInfo=o||{},o.canSignUp||(this.showPopup=!0,this.showPopupMessage="\u5B66\u6821\u5DF2\u5173\u95ED")}catch{}},async getAppIdAndCode(t){try{const{data:o}=await n.get("/api-student/open/paramConfig/wechatAppId");o&&(w(),C(o,t))}catch{}},directNext(){if(d.user.status==="login"||d.user.status==="error"){const{returnUrl:t,isRegister:o,...u}=this.$route.query,r=window.location.origin+window.location.pathname+"#"+t+"?"+x.stringify({...u});this.testIsWeixin?this.locationReplace(r):this.getAppIdAndCode(r)}},locationReplace(t){console.log(history.replaceState,"window.history.replaceState",t),history.replaceState?(history.replaceState(null,document.title,t),history.go(0)):location.replace(t)},async onLogin(){try{this.orchestraInfo.canSignUp||(this.showPopup=!0,this.showPopupMessage="\u5B66\u6821\u5DF2\u5173\u95ED");const t={username:this.username,client_id:"jmedu-student",client_secret:"jmedu-student",autoRegister:!0,password:this.smsCode,loginType:"SMS",grant_type:"password",extra:this.$route.query.id},{data:o}=await n.post("/api-oauth/userlogin",{requestType:"form",data:{...t}});y(o.token_type+" "+o.access_token);const u=await n.get("/api-student/user/getUserInfo",{initRequest:!0});S(u.data),this.directNext()}catch{}},async onSendCode(){if(!p(this.username))return D("\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},[a("\u60A8\u597D\uFF0C"),e("br",null,null),a(" \u6B22\u8FCE\u4F7F\u7528\u7BA1\u4E50\u56E2\u5B66\u5458\u7AEF")]),e(A,{class:s.margin34,border:!1},{default:()=>[e(l,{style:{marginBottom:"16px"}},{default:()=>[e(i,{span:24,class:s.formTitle},{default:()=>[a("\u624B\u673A\u53F7")]}),e(i,{span:24,class:"van-hairline--bottom"},{default:()=>[e(h,{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(l,null,{default:()=>[e(i,{span:24,class:s.formTitle},{default:()=>[a("\u9A8C\u8BC1\u7801")]}),e(i,{span:24,class:"van-hairline--bottom"},{default:()=>[e(h,{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},[a("\u83B7\u53D6\u9A8C\u8BC1\u7801")]):e(b,{ref:"countDownRef","auto-start":!1,time:this.countDownTime,onFinish:this.onFinished,format:"ss\u79D2"},null)})]})]})]}),e("div",{class:s.margin34},[e(P,{round:!0,block:!0,type:"primary",disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[a("\u63D0\u4EA4")]})]),this.imgCodeStatus?e(c,{value:this.imgCodeStatus,"onUpdate:value":t=>this.imgCodeStatus=t,phone:this.username,type:"REGISTER",onClose:()=>{this.imgCodeStatus=!1},onSendCode:this.onCodeSend},null):null,e(T,{show:this.showPopup,"onUpdate:show":t=>this.showPopup=t,round:!0,style:{width:"88%"},closeOnClickOverlay:!1,class:s.wxPopupDialog},{default:()=>[e("div",{class:s.popupContainer},[e("p",{class:s.title},[a("\u6E29\u99A8\u63D0\u793A")]),e("p",{class:s.popupTips,innerHTML:this.showPopupMessage},null)])]})])}});export{$ as default};
