index-08b25dda.js 6.7 KB

1
  1. var te=Object.defineProperty,se=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var k=(p,l,u)=>l in p?te(p,l,{enumerable:!0,configurable:!0,writable:!0,value:u}):p[l]=u,T=(p,l)=>{for(var u in l||(l={}))ne.call(l,u)&&k(p,u,l[u]);if(V)for(var u of V(l))ae.call(l,u)&&k(p,u,l[u]);return p},C=(p,l)=>se(p,ie(l));var H=(p,l,u)=>new Promise((W,L)=>{var o=y=>{try{S(u.next(y))}catch(t){L(t)}},f=y=>{try{S(u.throw(y))}catch(t){L(t)}},S=y=>y.done?W(y.value):Promise.resolve(y.value).then(o,f);S((u=u.apply(p,l)).next())});import{a4 as q,d as z,f as G,r as N,bR as oe,A as $,j as J,a6 as re,e as h,u as g,a7 as K,bp as Q,bB as ce,ds as le,P as ue,dt as Z,ax as U,__tla as de}from"./index-b5895273.js";let Y,ee,ge=Promise.all([(()=>{try{return de}catch(p){}})()]).then(()=>H(void 0,null,function*(){const{t:p}=q(),l={value:{type:Boolean,default:!1},isSlot:{type:Boolean,default:!1},text:{type:[String],default:p("component.verify.dragText")},successText:{type:[String],default:p("component.verify.successText")},height:{type:[Number,String],default:40},width:{type:[Number,String],default:220},circle:{type:Boolean,default:!1},wrapStyle:{type:Object,default:{}},contentStyle:{type:Object,default:{}},barStyle:{type:Object,default:{}},actionStyle:{type:Object,default:{}}},u=C(T({},l),{src:{type:String},imgWidth:{type:Number,default:260},imgWrapStyle:{type:Object,default:{}},minDegree:{type:Number,default:90},maxDegree:{type:Number,default:270},diffDegree:{type:Number,default:20}}),W=z({name:"BaseDargVerify",props:l,emits:["success","update:value","change","start","move","end"],setup(o,{emit:f,slots:S,expose:y}){const t=G({isMoving:!1,isPassing:!1,moveDistance:0,toLeft:!1,startTime:0,endTime:0}),s=N(null),b=N(null),M=N(null),P=N(null);oe({el:document,name:"mouseup",listener:()=>{t.isMoving&&x()}});const X=$(()=>{const{height:e,actionStyle:n}=o,r=`${parseInt(e)}px`;return T({left:0,width:r,height:r},n)}),F=$(()=>{const{height:e,width:n,circle:r,wrapStyle:i}=o,c=parseInt(e);return T({width:`${parseInt(n)}px`,height:`${c}px`,lineHeight:`${c}px`,borderRadius:r?c/2+"px":0},i)}),j=$(()=>{const{height:e,circle:n,barStyle:r}=o,i=parseInt(e);return T({height:`${i}px`,borderRadius:n?i/2+"px 0 0 "+i/2+"px":0},r)}),B=$(()=>{const{height:e,width:n,contentStyle:r}=o,i=`${parseInt(e)}px`,c=`${parseInt(n)}px`;return T({height:i,width:c},r)});J(()=>t.isPassing,e=>{if(e){const{startTime:n,endTime:r}=t,i=(r-n)/1e3;f("success",{isPassing:e,time:i.toFixed(1)}),f("update:value",e),f("change",e)}}),re(()=>{t.isPassing=!!o.value});function I(e){return e.pageX||e.touches[0].pageX}function R(e){if(t.isPassing)return;const n=g(P);n&&(f("start",e),t.moveDistance=I(e)-parseInt(n.style.left.replace("px",""),10),t.startTime=new Date().getTime(),t.isMoving=!0)}function a(e){const n=parseInt(e.style.width),{width:r}=o,i=parseInt(r);return{offset:i-n-6,widthNum:i,actionWidth:n}}function d(e){const{isMoving:n,moveDistance:r}=t;if(n){const i=g(P),c=g(b);if(!i||!c)return;const{offset:v,widthNum:_,actionWidth:O}=a(i),w=I(e)-r;f("move",{event:e,moveDistance:r,moveX:w}),w>0&&w<=v?(i.style.left=`${w}px`,c.style.width=`${w+O/2}px`):w>v&&(i.style.left=`${_-O}px`,c.style.width=`${_-O/2}px`,o.isSlot||D())}}function m(e){const{isMoving:n,isPassing:r,moveDistance:i}=t;if(n&&!r){f("end",e);const c=g(P),v=g(b);if(!c||!v)return;const _=I(e)-i,{offset:O,widthNum:w,actionWidth:A}=a(c);_<O?o.isSlot?setTimeout(()=>{if(!o.value)x();else{const E=g(M);E&&(E.style.width=`${parseInt(v.style.width)}px`)}},0):x():(c.style.left=`${w-A}px`,v.style.width=`${w-A/2}px`,D()),t.isMoving=!1}}function D(){if(o.isSlot){x();return}t.endTime=new Date().getTime(),t.isPassing=!0,t.isMoving=!1}function x(){t.isMoving=!1,t.isPassing=!1,t.moveDistance=0,t.toLeft=!1,t.startTime=0,t.endTime=0;const e=g(P),n=g(b),r=g(M);!e||!n||!r||(t.toLeft=!0,K(()=>{t.toLeft=!1,e.style.left="0",n.style.width="0"},300),r.style.width=g(B).width)}return y({resume:x}),()=>{const e=()=>{const i=["darg-verify-bar"];return t.toLeft&&i.push("to-left"),h("div",{class:i,ref:b,style:g(j)},null)},n=()=>{const i=["darg-verify-content"],{isPassing:c}=t,{text:v,successText:_}=o;return c&&i.push("success"),h("div",{class:i,ref:M,style:g(B)},[Q(S,"text",c)||(c?_:v)])},r=()=>{const i=["darg-verify-action"],{toLeft:c,isPassing:v}=t;return c&&i.push("to-left"),h("div",{class:i,onMousedown:R,onTouchstart:R,style:g(X),ref:P},[Q(S,"actionIcon",v)||(v?h(ce,{class:"darg-verify-action__icon"},null):h(le,{class:"darg-verify-action__icon"},null))])};return h("div",{class:"darg-verify",ref:s,style:g(F),onMousemove:d,onTouchmove:d,onMouseleave:m,onMouseup:m,onTouchend:m},[e(),n(),r()])}}}),L=z({name:"ImgRotateDragVerify",inheritAttrs:!1,props:u,emits:["success","change","update:value"],setup(o,{emit:f,attrs:S,expose:y}){const t=N(null),s=G({showTip:!1,isPassing:!1,imgStyle:{},randomRotate:0,currentRotate:0,toOrigin:!1,startTime:0,endTime:0,draged:!1}),{t:b}=q();J(()=>s.isPassing,a=>{if(a){const{startTime:d,endTime:m}=s,D=(m-d)/1e3;f("success",{isPassing:a,time:D.toFixed(1)}),f("change",a),f("update:value",a)}});const M=$(()=>{const{imgWrapStyle:a,imgWidth:d}=o;return T({width:`${d}px`,height:`${d}px`},a)}),P=$(()=>{const{minDegree:a,maxDegree:d}=o;return a===d?Math.floor(1+Math.random()*1)/10+1:1});function X(){s.startTime=new Date().getTime()}function F(a){s.draged=!0;const{imgWidth:d,height:m,maxDegree:D}=o,{moveX:x}=a,e=Math.ceil(x/(d-parseInt(m))*D*g(P));s.currentRotate=e,s.imgStyle=Z("transform",`rotateZ(${s.randomRotate-e}deg)`)}function j(){const{minDegree:a,maxDegree:d}=o,m=Math.floor(a+Math.random()*(d-a));s.randomRotate=m,s.imgStyle=Z("transform",`rotateZ(${m}deg)`)}function B(){const{randomRotate:a,currentRotate:d}=s,{diffDegree:m}=o;Math.abs(a-d)>=(m||20)?(s.imgStyle=Z("transform",`rotateZ(${a}deg)`),s.toOrigin=!0,K(()=>{s.toOrigin=!1,s.showTip=!0},300)):I(),s.showTip=!0}function I(){s.isPassing=!0,s.endTime=new Date().getTime()}function R(){s.showTip=!1;const a=g(t);a&&(s.isPassing=!1,a.resume(),j())}return y({resume:R}),()=>{const{src:a}=o,{toOrigin:d,isPassing:m,startTime:D,endTime:x}=s,e=[];d&&e.push("to-origin");const n=(x-D)/1e3;return h("div",{class:"ir-dv"},[h("div",{class:"ir-dv-img__wrap",style:g(M)},[h("img",{src:a,onLoad:j,width:parseInt(o.width),class:e,style:s.imgStyle,onClick:()=>{R()},alt:"verify"},null),s.showTip&&h("span",{class:["ir-dv-img__tip",s.isPassing?"success":"error"]},[s.isPassing?b("component.verify.time",{time:n.toFixed(1)}):b("component.verify.error")]),!s.showTip&&!s.draged&&h("span",{class:["ir-dv-img__tip","normal"]},[b("component.verify.redoTip")])]),h(W,ue({class:"ir-dv-drag__bar",onMove:F,onEnd:B,onStart:X,ref:t},T(T({},S),o),{value:m,isSlot:!0}),null)])}}});Y=U(W),ee=U(L)}));export{Y as B,ee as R,ge as __tla};