import{d as n,D as s,E as u,a as e,V as l,A as d,L as m}from"./index-74aaacd7.js";import{R as a,C as i}from"./index-a691429a.js";import{F as c}from"./index-5fc0aef0.js";import{I as p}from"./index-418977f3.js";const h="_imgCode_mq980_1",g="_codeTitle_mq980_4",r="_img_mq980_1",f="_imgChange_mq980_16",C="_field_mq980_23",y="_imgCodePopup_mq980_27",o={imgCode:h,codeTitle:g,img:r,imgChange:f,field:C,imgCodePopup:y},S=n({name:"o-img-code",props:{value:Boolean,phone:[String,Number],type:{type:String,default:"LOGIN"},clientId:{type:String,default:"cooleshow-student"}},emits:["close","sendCode"],data(){return{isSuffix:"/edu-app",showStatus:!1,identifyingCode:null,code:""}},mounted(){this.showStatus=this.value,this.sendImgCode()},watch:{value(t){this.showStatus=t},code(t){t.length>=4&&this.checkVerifyLoginImage()}},methods:{async sendImgCode(){const{data:t}=await s.get(this.isSuffix+"/open/sendImgCode",{requestType:"form",hideLoading:!0,params:{phone:this.phone}});this.identifyingCode=t},async updateIdentifyingCode(){this.sendImgCode()},async checkVerifyLoginImage(){try{if(this.code.length<4)return;await s.post("/edu-app/open/verifyImgCode",{requestType:"form",hideLoading:!0,data:{phone:this.phone,code:this.code}}),await s.post("/edu-app/open/sendSms",{requestType:"form",hideLoading:!0,data:{clientId:this.clientId,type:"REGISTER",mobile:this.phone}}),setTimeout(()=>{u("验证码已发送")},100),this.$emit("close"),this.$emit("sendCode")}catch(t){this.code="",setTimeout(()=>{this.updateIdentifyingCode()},500)}}},render(){return e(l,{show:this.showStatus,class:o.imgCodePopup,closeOnClickOverlay:!1,onClose:()=>{this.$emit("close")},closeable:!0,closeIcon:"close"},{default:()=>[e("div",{class:o.imgCode},[e("p",{class:o.codeTitle},[d("输入图形验证码")]),e(a,null,{default:()=>[e(i,{span:"14"},{default:()=>[e(c,{placeholder:"请输入验证码",modelValue:this.code,"onUpdate:modelValue":t=>this.code=t,class:o.field,autocomplete:"off"},null)]}),e(i,{span:"10",class:o.img},{default:()=>[e(p,{src:this.identifyingCode,onClick:()=>this.updateIdentifyingCode()},{loading:()=>e(m,{type:"spinner",size:"20"},null)})]})]}),e(a,{style:{display:"flex",justifyContent:"end"}},{default:()=>[e(i,{span:"10"},{default:()=>[e("span",{class:o.imgChange,onClick:()=>this.updateIdentifyingCode()},[d("看不清?换一换")])]})]})])]})}});export{S as M};