import{d as l,T as u,a as e,P as m,j as n,l as d,m as i,p as c,I as p,L as h}from"./vendor.405ecf9c.js";/* empty css *//* empty css *//* empty css *//* empty css */import{s as g,r as a}from"./index.085f961d.js";const r="_imgCode_mywmt_1",f="_codeTitle_mywmt_4",C="_img_mywmt_1",y="_imgChange_mywmt_16",w="_field_mywmt_23",_="_imgCodePopup_mywmt_27";var t={imgCode:r,codeTitle:f,img:C,imgChange:y,field:w,imgCodePopup:_},j=l({name:"imgCode",props:{value:Boolean,phone:[String,Number],onClose:{type:Function,default:()=>{}},onSendCode:{type:Function,default:()=>{}}},data(){let o=window.location.origin,s=g.platformType==="STUDENT"?"/api-student":"/api-teacher";return{isSuffix:s,showStatus:!1,identifyingCode:o+s+"/code/getImageCode?phone="+this.phone,code:null}},mounted(){this.showStatus=this.value},watch:{value(o){this.showStatus=o},code(o){o.length>=4&&this.checkVerifyLoginImage()}},methods:{async updateIdentifyingCode(){let o=window.location.origin;this.identifyingCode=`${o}${this.isSuffix}/code/getImageCode?phone=${this.phone}&token=${Math.random()}`},async checkVerifyLoginImage(){try{if(this.code.length<4)return;await a.post(`${this.isSuffix}/code/verifyImageCode`,{requestType:"form",data:{phone:this.phone,code:this.code}}),await a.post(`${this.isSuffix}/code/sendSmsCode`,{requestType:"form",data:{mobile:this.phone,type:"LOGIN"}}),u("\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001"),this.onClose(),this.onSendCode()}catch{this.updateIdentifyingCode()}}},render(){return e(m,{show:this.showStatus,class:t.imgCodePopup,closeOnClickOverlay:!1,onClose:()=>{this.onClose()},closeable:!0,closeIcon:"close"},{default:()=>[e("div",{class:t.imgCode},[e("p",{class:t.codeTitle},[n("\u8F93\u5165\u56FE\u5F62\u9A8C\u8BC1\u7801")]),e(d,null,{default:()=>[e(i,{span:"14"},{default:()=>[e(c,{placeholder:"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801",modelValue:this.code,"onUpdate:modelValue":o=>this.code=o,class:t.field},null)]}),e(i,{span:"10",class:t.img},{default:()=>[e(p,{src:this.identifyingCode,onClick:()=>this.updateIdentifyingCode()},{loading:()=>e(h,{type:"spinner",size:"20"},null)})]})]}),e(d,{style:{display:"flex",justifyContent:"end"}},{default:()=>[e(i,{span:"10"},{default:()=>[e("span",{class:t.imgChange,onClick:()=>this.updateIdentifyingCode()},[n("\u770B\u4E0D\u6E05\uFF1F\u6362\u4E00\u6362")])]})]})])]})}});export{j as I};