login.e4120ad1.js 6.5 KB

1
  1. var S=Object.defineProperty;var c=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;var f=(e,s,o)=>s in e?S(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o,C=(e,s)=>{for(var o in s||(s={}))p.call(s,o)&&f(e,o,s[o]);if(c)for(var o of c(s))g.call(s,o)&&f(e,o,s[o]);return e};var y=(e,s)=>{var o={};for(var n in e)p.call(e,n)&&s.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&c)for(var n of c(e))s.indexOf(n)<0&&g.call(e,n)&&(o[n]=e[n]);return o};import{d as w,T,b as t,P as F,j as i,k as r,C as a,l as h,I as D,L as b,u as v,m as k,F as x,B as _}from"./vendor.2bcdc9cf.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{s as u,r as m,a as I,b as B,c as A}from"./index.b8b9219f.js";import{c as L}from"./validate.47dbf779.js";const P="_imgCode_mywmt_1",V="_codeTitle_mywmt_4",j="_img_mywmt_1",$="_imgChange_mywmt_16",q="_field_mywmt_23",N="_imgCodePopup_mywmt_27";var d={imgCode:P,codeTitle:V,img:j,imgChange:$,field:q,imgCodePopup:N},R=w({name:"imgCode",props:{value:Boolean,phone:[String,Number],onClose:{type:Function,default:()=>{}},onSendCode:{type:Function,default:()=>{}}},data(){const e=window.location.origin;return{showStatus:!1,identifyingCode:e+u.platformApi+"/code/getLoginImage?phone="+this.phone,code:null}},mounted(){this.showStatus=this.value},watch:{value(e){this.showStatus=e},code(e){e.length>=4&&this.checkVerifyLoginImage()}},methods:{async updateIdentifyingCode(){const e=window.location.origin;this.identifyingCode=`${e}${u.platformApi}/code/getLoginImage?phone=${this.phone}&token=${Math.random()}`},async checkVerifyLoginImage(){try{if(this.code.length<4)return;await m.post(`${u.platformApi}/code/verifyLoginImage`,{requestType:"form",data:{phone:this.phone,code:this.code}}),await m.post(`${u.platformApi}/code/sendSms`,{requestType:"form",data:{mobile:this.phone,type:"LOGIN"}}),T("\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001"),this.onClose(),this.onSendCode()}catch{this.updateIdentifyingCode()}}},render(){return t(F,{show:this.showStatus,class:d.imgCodePopup,closeOnClickOverlay:!1,onClose:()=>{this.onClose()},closeable:!0,closeIcon:"close"},{default:()=>[t("div",{class:d.imgCode},[t("p",{class:d.codeTitle},[i("\u8F93\u5165\u56FE\u5F62\u9A8C\u8BC1\u7801")]),t(r,null,{default:()=>[t(a,{span:"14"},{default:()=>[t(h,{placeholder:"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801",modelValue:this.code,"onUpdate:modelValue":e=>this.code=e,class:d.field},null)]}),t(a,{span:"10",class:d.img},{default:()=>[t(D,{src:this.identifyingCode,onClick:()=>this.updateIdentifyingCode()},{loading:()=>t(b,{type:"spinner",size:"20"},null)})]})]}),t(r,{style:{display:"flex",justifyContent:"end"}},{default:()=>[t(a,{span:"10"},{default:()=>[t("span",{class:d.imgChange,onClick:()=>this.updateIdentifyingCode()},[i("\u770B\u4E0D\u6E05\uFF1F\u6362\u4E00\u6362")])]})]})])]})}});const E="_login_1rn8k_1",U="_loginTitle_1rn8k_7",W="_codeText_1rn8k_15",M="_margin34_1rn8k_18",O="_formTitle_1rn8k_21";var l={login:E,loginTitle:U,codeText:W,margin34:M,formTitle:O},ee=w({name:"login",data(){return{loginType:"SMS",username:"",password:"",smsCode:"",countDownStatus:!0,countDownTime:1e3*120,countDownRef:null,imgCodeStatus:!1}},computed:{codeDisable(){let e=!0;return this.loginType==="PWD"?this.username&&this.password&&(e=!1):this.username&&this.smsCode&&(e=!1),e}},mounted(){I(),this.directNext()},methods:{directNext(){if(u.user.status==="login"||u.user.status==="error"){const e=this.$route.query,{returnUrl:s,isRegister:o}=e,n=y(e,["returnUrl","isRegister"]);this.$router.replace({path:s,query:C({},n)})}},async onLogin(){try{let e;this.loginType==="PWD"?e=await m.post("/api-auth/usernameLogin",{requestType:"form",data:{username:this.username,password:this.password,clientId:"student",clientSecret:"student"}}):e=await m.post("/api-auth/smsLogin",{requestType:"form",data:{clientId:"student",clientSecret:"student",phone:this.username,smsCode:this.smsCode}});const{authentication:s}=e.data;B(s.token_type+" "+s.access_token);const o=await m.get("/api-student/student/queryUserInfo",{initRequest:!0});A(o.data),this.directNext()}catch{}},async onSendCode(){if(!L(this.username))return T("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u7801");this.imgCodeStatus=!0},onCodeSend(){this.countDownStatus=!1,this.countDownRef=v({time:this.countDownTime,onFinish:this.onFinished}),this.countDownRef.start()},onFinished(){this.countDownStatus=!0,this.countDownRef.reset()},onChange(){this.loginType==="PWD"?this.loginType="SMS":this.loginType==="SMS"&&(this.loginType="PWD")}},render(){return t("div",{class:l.login},[t("div",{class:l.loginTitle},[i("\u60A8\u597D\uFF0C"),t("br",null,null),i(" \u6B22\u8FCE\u4F7F\u7528\u7BA1\u4E50\u8FF7")]),t(k,{class:l.margin34,border:!1},{default:()=>[t(r,{style:{marginBottom:"16px"}},{default:()=>[t(a,{span:24,class:l.formTitle},{default:()=>[i("\u624B\u673A\u53F7")]}),t(a,{span:24,class:"van-hairline--bottom"},{default:()=>[t(h,{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(a,{span:24,class:l.formTitle},{default:()=>[i("\u5BC6\u7801")]}),t(a,{span:24,class:"van-hairline--bottom"},{default:()=>[t(h,{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(a,{span:24,class:l.formTitle},{default:()=>[i("\u9A8C\u8BC1\u7801")]}),t(a,{span:24,class:"van-hairline--bottom"},{default:()=>[t(h,{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:()=>{var e;return this.countDownStatus?t("span",{class:l.codeText,onClick:this.onSendCode},[i("\u83B7\u53D6\u9A8C\u8BC1\u7801")]):t(x,null,[Number(((((e=this.countDownRef)==null?void 0:e.current.total)||0)/1e3).toFixed()),i("\u79D2")])}})]})]})]}),t("div",{class:l.margin34},[t(_,{round:!0,block:!0,type:"primary",disabled:this.codeDisable,onClick:this.onLogin},{default:()=>[i("\u63D0\u4EA4")]}),t(_,{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(R,{value:this.imgCodeStatus,"onUpdate:value":e=>this.imgCodeStatus=e,phone:this.username,onClose:()=>{this.imgCodeStatus=!1},onSendCode:this.onCodeSend},null):null])}});export{ee as default};