index-a934fb09.js 3.2 KB

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