import{d,g as l,x as u,T as c,j as e,aR as g,z as n,aS as p}from"./index.3bfa6a0e.js";import{R as a,C as i}from"./index.bb2d59fe.js";import{I as h}from"./index.0fd5538f.js";import"./index.79997a38.js";import{F as r}from"./index.983bfd1a.js";const m="_imgCode_w5vq4_1",f="_codeTitle_w5vq4_4",C="_img_w5vq4_1",y="_imgChange_w5vq4_16",w="_field_w5vq4_23",_="_imgCodePopup_w5vq4_27";var t={imgCode:m,codeTitle:f,img:C,imgChange:y,field:w,imgCodePopup:_},x=d({name:"imgCode",props:{value:Boolean,phone:[String,Number],onClose:{type:Function,default:()=>{}},registerType:{type:String,default:"LOGIN"},onSendCode:{type:Function,default:()=>{}}},data(){const o=window.location.origin,s=l.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(){const 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 u.post(`${this.isSuffix}/code/sendSmsCode`,{requestType:"form",data:{mobile:this.phone,type:this.registerType,code:this.code}}),c("\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001"),this.onClose(),this.onSendCode()}catch{this.updateIdentifyingCode()}}},render(){return e(g,{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(a,null,{default:()=>[e(i,{span:"14"},{default:()=>[e(r,{placeholder:"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801",modelValue:this.code,"onUpdate:modelValue":o=>this.code=o,class:t.field,maxlength:"4",autocomplete:"off"},null)]}),e(i,{span:"10",class:t.img},{default:()=>[e(h,{src:this.identifyingCode,onClick:()=>this.updateIdentifyingCode()},{loading:()=>e(p,{type:"spinner",size:"20"},null)})]})]}),e(a,{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{x as I};
