import{a1 as c,t as y,v as S,a2 as I,T as w,d as C,a3 as _,i as T,w as v,A as F,g as s,K as q,a as m,f as P,P as D,h as g,R as k}from"./index-374e58b6.js";import{R as r,C as h}from"./index-a01c79e3.js";import{F as x}from"./index-4343271b.js";import{I as E}from"./index-f223cbf0.js";function L(e,o){const{days:n}=o;let{hours:t,minutes:a,seconds:d,milliseconds:l}=o;if(e.includes("DD")?e=e.replace("DD",c(n)):t+=n*24,e.includes("HH")?e=e.replace("HH",c(t)):a+=t*60,e.includes("mm")?e=e.replace("mm",c(a)):d+=a*60,e.includes("ss")?e=e.replace("ss",c(d)):l+=d*1e3,e.includes("S")){const u=c(l,3);e.includes("SSS")?e=e.replace("SSS",u):e.includes("SS")?e=e.replace("SS",u.slice(0,2)):e=e.replace("S",u.charAt(0))}return e}const[B,H]=y("count-down"),N={time:S(0),format:I("HH:mm:ss"),autoStart:w,millisecond:Boolean};var V=C({name:B,props:N,emits:["change","finish"],setup(e,{emit:o,slots:n}){const{start:t,pause:a,reset:d,current:l}=_({time:+e.time,millisecond:e.millisecond,onChange:f=>o("change",f),onFinish:()=>o("finish")}),u=T(()=>L(e.format,l.value)),p=()=>{d(+e.time),e.autoStart&&t()};return v(()=>e.time,p,{immediate:!0}),F({start:t,pause:a,reset:p}),()=>s("div",{role:"timer",class:H()},[n.default?n.default(l.value):u.value])}});const Z=q(V),R="_imgCode_mq980_1",b="_codeTitle_mq980_4",A="_img_mq980_1",O="_imgChange_mq980_16",$="_field_mq980_23",G="_imgCodePopup_mq980_27",i={imgCode:R,codeTitle:b,img:A,imgChange:O,field:$,imgCodePopup:G},J=C({name:"o-img-code",props:{value:Boolean,phone:[String,Number],type:{type:String,default:"LOGIN"}},emits:["close","sendCode"],data(){return{isSuffix:"/edu-oauth",showStatus:!1,identifyingCode:null,code:""}},mounted(){this.showStatus=this.value,this.sendImgCode()},watch:{value(e){this.showStatus=e},code(e){e.length>=4&&this.checkVerifyLoginImage()}},methods:{async sendImgCode(){const{data:e}=await m.get(this.isSuffix+"/open/sendImgCode",{requestType:"form",hideLoading:!0,params:{phone:this.phone}});this.identifyingCode=e},async updateIdentifyingCode(){this.sendImgCode()},async checkVerifyLoginImage(){try{if(this.code.length<4)return;await m.post("/edu-oauth/open/verifyImgCode",{requestType:"form",hideLoading:!0,data:{phone:this.phone,code:this.code}}),await m.post("/edu-oauth/open/sendSms",{requestType:"form",hideLoading:!0,data:{clientId:"cooleshow-student",type:"REGISTER",mobile:this.phone}}),setTimeout(()=>{P("验证码已发送")},100),this.$emit("close"),this.$emit("sendCode")}catch(e){this.code="",this.updateIdentifyingCode()}}},render(){return s(D,{show:this.showStatus,class:i.imgCodePopup,closeOnClickOverlay:!1,onClose:()=>{this.$emit("close")},closeable:!0,closeIcon:"close"},{default:()=>[s("div",{class:i.imgCode},[s("p",{class:i.codeTitle},[g("输入图形验证码")]),s(r,null,{default:()=>[s(h,{span:"14"},{default:()=>[s(x,{placeholder:"请输入验证码",modelValue:this.code,"onUpdate:modelValue":e=>this.code=e,class:i.field,autocomplete:"off"},null)]}),s(h,{span:"10",class:i.img},{default:()=>[s(E,{src:this.identifyingCode,onClick:()=>this.updateIdentifyingCode()},{loading:()=>s(k,{type:"spinner",size:"20"},null)})]})]}),s(r,{style:{display:"flex",justifyContent:"end"}},{default:()=>[s(h,{span:"10"},{default:()=>[s("span",{class:i.imgChange,onClick:()=>this.updateIdentifyingCode()},[g("看不清?换一换")])]})]})])]})}});export{Z as C,J as I};