import{d as m,r as u,u as y,j as l,ee as k,k as S,aa as v,B as T,c as w,o as B,w as f,W as $,l as _,X as V}from"./index-9PRMimni.js";const j={seconds:{type:Number,default:60},value:{type:String,default:""},startText:{type:String,default:"发送验证码"},endText:{type:String,default:"重新获取"},changeText:{type:String,default:"重新获取"},isVerify:{type:Boolean,default:!1},inputProps:Object,buttonProps:Object},g=m({name:"ProCheckbox",props:j,emits:["start","end","change","update:value"],setup(e,{emit:n,expose:r}){const t=u(!1),o=u(""),d=u(!1),a=u(e.seconds),c=y();let i;function s(){o.value="",a.value=e.seconds,d.value=!1,n("end"),clearInterval(i)}function b(){i=setInterval(()=>{d.value=!0,t.value=!0,o.value=`${a.value}S${e.changeText}`,a.value===0?s():(a.value--,n("change",a.value))},1e3)}function C(){b()}function P(){s()}function x(){if(e.isVerify){const p=e.value;if(!p)return c.error("请填写手机号码");if(!/^1[3456789]\d{9}$/.test(p))return c.error("手机号码不正确")}n("start")}function h(p){n("update:value",p)}return r({start:C,reset:P}),()=>l(k,null,{default:()=>[l(S,v(e.inputProps,{"onUpdate:value":h}),null),l(T,v({type:"primary"},e.buttonProps,{disabled:d.value,onClick:x}),{default:()=>[t.value&&o.value===""?e.endText:d.value?o.value:e.startText]})]})}}),R=m({__name:"proCode",setup(e){const n=y(),r=u(),t=u();function o(){if(console.log(t.value),!t.value||t.value.length<11)return n.error("手机号码不正确");n.loading("正在获取验证码"),setTimeout(()=>{n.success("获取成功，请查收"),r.value.start()},2e3)}return(d,a)=>{const c=$,i=V;return B(),w(i,{title:"验证码输入框 ProCode",content:"考虑到用户实际发送验证码的场景较多，特此封装，无需考虑交互逻辑，只需发起请求获取验证码",showFooter:""},{default:f(()=>[l(c,{bordered:!1,class:"mt-3 proCard",title:"基本使用","content-style":"padding-top: 0;"},{default:f(()=>[l(_(g),{ref_key:"proCodeRef",ref:r,style:{width:"280px"},value:t.value,"onUpdate:value":a[0]||(a[0]=s=>t.value=s),inputProps:{placeholder:"请输入手机号码",clearable:!0},buttonProps:{type:"primary"},onStart:o},null,8,["value"])]),_:1}),l(c,{bordered:!1,class:"mt-3 proCard",title:"内部验证","content-style":"padding-top: 0;"},{default:f(()=>[l(_(g),{ref_key:"proCodeRef",ref:r,style:{width:"280px"},value:t.value,"onUpdate:value":a[1]||(a[1]=s=>t.value=s),isVerify:"",inputProps:{placeholder:"请输入手机号码",clearable:!0},buttonProps:{type:"primary"},onStart:o},null,8,["value"])]),_:1})]),_:1})}}});export{R as default};
