import{d as h,bd as c,e as m,m as i,be as f,bf as g,f as l,s as w,n as C,o as y,c as t,bg as s,q as a,B as S,P as D}from"./index.ffe80dbe.js";import{c as T,R as d,C as n,I as A}from"./validate.5e9d8d60.js";import{q as x}from"./index.339fc024.js";import{C as P}from"./index.914765a1.js";import{F as p}from"./index.92ec0bf4.js";import{C as b}from"./index.b2ab72e6.js";import"./index.7e972106.js";import"./index.ea031708.js";var E=h({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}},computed:{codeDisable(){let e=!0;return this.username&&this.smsCode&&(e=!1),e}},mounted(){c(),this.directNext(),!m().weixin&&!this.testIsWeixin&&(this.showPopup=!0),this.getDetails()},methods:{async getDetails(){try{if(!this.$route.query.id)return;const{data:o}=await i.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(e){try{const{data:o}=await i.get("/api-student/open/paramConfig/wechatAppId");o&&(f(),g(o,e))}catch{}},directNext(){if(l.user.status==="login"||l.user.status==="error"){const{returnUrl:e,isRegister:o,...u}=this.$route.query,r=window.location.origin+window.location.pathname+"#"+e+"?"+x.stringify({...u});this.testIsWeixin?this.locationReplace(r):this.getAppIdAndCode(r)}},locationReplace(e){console.log(history.replaceState,"window.history.replaceState",e),history.replaceState?(history.replaceState(null,document.title,e),history.go(0)):location.replace(e)},async onLogin(){try{this.orchestraInfo.canSignUp||(this.showPopup=!0,this.showPopupMessage="\u5B66\u6821\u5DF2\u5173\u95ED");const e={username:this.username,client_id:"jmedu-student",client_secret:"jmedu-student",autoRegister:!0,password:this.smsCode,loginType:"SMS",grant_type:"password"},{data:o}=await i.post("/api-oauth/userlogin",{requestType:"form",data:{...e}});w(o.token_type+" "+o.access_token);const u=await i.get("/api-student/user/getUserInfo",{initRequest:!0});C(u.data),this.directNext()}catch{}},async onSendCode(){if(!T(this.username))return y("\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:s.login},[t("div",{class:s.loginTitle},[a("\u60A8\u597D\uFF0C"),t("br",null,null),a(" \u6B22\u8FCE\u4F7F\u7528\u7BA1\u4E50\u56E2\u5B66\u751F\u7AEF")]),t(P,{class:s.margin34,border:!1},{default:()=>[t(d,{style:{marginBottom:"16px"}},{default:()=>[t(n,{span:24,class:s.formTitle},{default:()=>[a("\u624B\u673A\u53F7")]}),t(n,{span:24,class:"van-hairline--bottom"},{default:()=>[t(p,{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(d,null,{default:()=>[t(n,{span:24,class:s.formTitle},{default:()=>[a("\u9A8C\u8BC1\u7801")]}),t(n,{span:24,class:"van-hairline--bottom"},{default:()=>[t(p,{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},[a("\u83B7\u53D6\u9A8C\u8BC1\u7801")]):t(b,{ref:"countDownRef","auto-start":!1,time:this.countDownTime,onFinish:this.onFinished,format:"ss\u79D2"},null)})]})]})]}),t("div",{class:s.margin34},[t(S,{round:!0,block:!0,type:"primary",disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[a("\u63D0\u4EA4")]})]),this.imgCodeStatus?t(A,{value:this.imgCodeStatus,"onUpdate:value":e=>this.imgCodeStatus=e,phone:this.username,type:"REGISTER",onClose:()=>{this.imgCodeStatus=!1},onSendCode:this.onCodeSend},null):null,t(D,{show:this.showPopup,"onUpdate:show":e=>this.showPopup=e,round:!0,style:{width:"88%"},closeOnClickOverlay:!1,class:s.wxPopupDialog},{default:()=>[t("div",{class:s.popupContainer},[t("p",{class:s.title},[a("\u6E29\u99A8\u63D0\u793A")]),t("p",{class:s.popupTips},[this.showPopupMessage])])]})])}});export{E as default};