index-8c614f61.js
6.68 KB
var Q=Object.defineProperty,U=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var k=(t,r,d)=>r in t?Q(t,r,{enumerable:!0,configurable:!0,writable:!0,value:d}):t[r]=d,v=(t,r)=>{for(var d in r||(r={}))ee.call(r,d)&&k(t,d,r[d]);if(L)for(var d of L(r))te.call(r,d)&&k(t,d,r[d]);return t},C=(t,r)=>U(t,Y(r));import{c as X,aF as se,k as A,aE as j,_ as Z,bB as B,aj as H}from"./index.js";import{d as q,r as z,k as M,e as S,w as G,s as ne,u,f as h,ad as ae}from"./vue-5a35c3f5.js";import{b1 as ie,am as oe}from"./antd-6b087f69.js";const{t:F}=X(),J={value:{type:Boolean,default:!1},isSlot:{type:Boolean,default:!1},text:{type:[String],default:F("component.verify.dragText")},successText:{type:[String],default:F("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:()=>({})}},re=C(v({},J),{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}}),ce=q({name:"BaseDargVerify",props:J,emits:["success","update:value","change","start","move","end"],setup(t,{emit:r,slots:d,expose:P}){const s=z({isMoving:!1,isPassing:!1,moveDistance:0,toLeft:!1,startTime:0,endTime:0}),n=M(null),w=M(null),D=M(null),_=M(null);se({el:document,name:"mouseup",listener:()=>{s.isMoving&&y()}});const O=S(()=>{const{height:e,actionStyle:i}=t,c=`${parseInt(e)}px`;return v({left:0,width:c,height:c},i)}),V=S(()=>{const{height:e,width:i,circle:c,wrapStyle:a}=t,l=parseInt(e),m=`${parseInt(i)}px`;return v({width:m,height:`${l}px`,lineHeight:`${l}px`,borderRadius:c?l/2+"px":0},a)}),I=S(()=>{const{height:e,circle:i,barStyle:c}=t,a=parseInt(e);return v({height:`${a}px`,borderRadius:i?a/2+"px 0 0 "+a/2+"px":0},c)}),$=S(()=>{const{height:e,width:i,contentStyle:c}=t,a=`${parseInt(e)}px`,l=`${parseInt(i)}px`;return v({height:a,width:l},c)});G(()=>s.isPassing,e=>{if(e){const{startTime:i,endTime:c}=s,a=(c-i)/1e3;r("success",{isPassing:e,time:a.toFixed(1)}),r("update:value",e),r("change",e)}}),ne(()=>{s.isPassing=!!t.value});function b(e){return e.pageX||e.touches[0].pageX}function R(e){if(s.isPassing)return;const i=u(_);i&&(r("start",e),s.moveDistance=b(e)-parseInt(i.style.left.replace("px",""),10),s.startTime=new Date().getTime(),s.isMoving=!0)}function o(e){const i=parseInt(e.style.width),{width:c}=t,a=parseInt(c);return{offset:a-i-6,widthNum:a,actionWidth:i}}function f(e){const{isMoving:i,moveDistance:c}=s;if(i){const a=u(_),l=u(w);if(!a||!l)return;const{offset:m,widthNum:T,actionWidth:E}=o(a),p=b(e)-c;r("move",{event:e,moveDistance:c,moveX:p}),p>0&&p<=m?(a.style.left=`${p}px`,l.style.width=`${p+E/2}px`):p>m&&(a.style.left=`${T-E}px`,l.style.width=`${T-E/2}px`,t.isSlot||x())}}function g(e){const{isMoving:i,isPassing:c,moveDistance:a}=s;if(i&&!c){r("end",e);const l=u(_),m=u(w);if(!l||!m)return;const T=b(e)-a,{offset:E,widthNum:p,actionWidth:N}=o(l);T<E?t.isSlot?setTimeout(()=>{if(!t.value)y();else{const W=u(D);W&&(W.style.width=`${parseInt(m.style.width)}px`)}},0):y():(l.style.left=`${p-N}px`,m.style.width=`${p-N/2}px`,x()),s.isMoving=!1}}function x(){if(t.isSlot){y();return}s.endTime=new Date().getTime(),s.isPassing=!0,s.isMoving=!1}function y(){s.isMoving=!1,s.isPassing=!1,s.moveDistance=0,s.toLeft=!1,s.startTime=0,s.endTime=0;const e=u(_),i=u(w),c=u(D);!e||!i||!c||(s.toLeft=!0,A(()=>{s.toLeft=!1,e.style.left="0",i.style.width="0"},300),c.style.width=u($).width)}return P({resume:y}),()=>{const e=()=>{const a=["darg-verify-bar"];return s.toLeft&&a.push("to-left"),h("div",{class:a,ref:w,style:u(I)},null)},i=()=>{const a=["darg-verify-content"],{isPassing:l}=s,{text:m,successText:T}=t;return l&&a.push("success"),h("div",{class:a,ref:D,style:u($)},[j(d,"text",l)||(l?T:m)])},c=()=>{const a=["darg-verify-action"],{toLeft:l,isPassing:m}=s;return l&&a.push("to-left"),h("div",{class:a,onMousedown:R,onTouchstart:R,style:u(O),ref:_},[j(d,"actionIcon",m)||(m?h(ie,{class:"darg-verify-action__icon"},null):h(oe,{class:"darg-verify-action__icon"},null))])};return h("div",{class:"darg-verify",ref:n,style:u(V),onMousemove:f,onTouchmove:f,onMouseleave:g,onMouseup:g,onTouchend:g},[e(),i(),c()])}}});const K=Z(ce,[["__file","E:/allcode/erp/test7901/order-erp-front/src/components/Verify/src/DragVerify.vue"]]),le=q({name:"ImgRotateDragVerify",inheritAttrs:!1,props:re,emits:["success","change","update:value"],setup(t,{emit:r,attrs:d,expose:P}){const s=M(null),n=z({showTip:!1,isPassing:!1,imgStyle:{},randomRotate:0,currentRotate:0,toOrigin:!1,startTime:0,endTime:0,draged:!1}),{t:w}=X();G(()=>n.isPassing,o=>{if(o){const{startTime:f,endTime:g}=n,x=(g-f)/1e3;r("success",{isPassing:o,time:x.toFixed(1)}),r("change",o),r("update:value",o)}});const D=S(()=>{const{imgWrapStyle:o,imgWidth:f}=t;return v({width:`${f}px`,height:`${f}px`},o)}),_=S(()=>{const{minDegree:o,maxDegree:f}=t;return o===f?Math.floor(1+Math.random()*1)/10+1:1});function O(){n.startTime=new Date().getTime()}function V(o){n.draged=!0;const{imgWidth:f,height:g,maxDegree:x}=t,{moveX:y}=o,e=Math.ceil(y/(f-parseInt(g))*x*u(_));n.currentRotate=e,n.imgStyle=B("transform",`rotateZ(${n.randomRotate-e}deg)`)}function I(){const{minDegree:o,maxDegree:f}=t,g=Math.floor(o+Math.random()*(f-o));n.randomRotate=g,n.imgStyle=B("transform",`rotateZ(${g}deg)`)}function $(){const{randomRotate:o,currentRotate:f}=n,{diffDegree:g}=t;Math.abs(o-f)>=(g||20)?(n.imgStyle=B("transform",`rotateZ(${o}deg)`),n.toOrigin=!0,A(()=>{n.toOrigin=!1,n.showTip=!0},300)):b(),n.showTip=!0}function b(){n.isPassing=!0,n.endTime=new Date().getTime()}function R(){n.showTip=!1;const o=u(s);o&&(n.isPassing=!1,o.resume(),I())}return P({resume:R}),()=>{const{src:o}=t,{toOrigin:f,isPassing:g,startTime:x,endTime:y}=n,e=[];f&&e.push("to-origin");const i=(y-x)/1e3;return h("div",{class:"ir-dv"},[h("div",{class:"ir-dv-img__wrap",style:u(D)},[h("img",{src:o,onLoad:I,width:parseInt(t.width),class:e,style:n.imgStyle,onClick:()=>{R()},alt:"verify"},null),n.showTip&&h("span",{class:["ir-dv-img__tip",n.isPassing?"success":"error"]},[n.isPassing?w("component.verify.time",{time:i.toFixed(1)}):w("component.verify.error")]),!n.showTip&&!n.draged&&h("span",{class:["ir-dv-img__tip","normal"]},[w("component.verify.redoTip")])]),h(K,ae({class:"ir-dv-drag__bar",onMove:V,onEnd:$,onStart:O,ref:s},v(v({},d),t),{value:g,isSlot:!0}),null)])}}});const fe=Z(le,[["__file","E:/allcode/erp/test7901/order-erp-front/src/components/Verify/src/ImgRotate.vue"]]),he=H(K),ye=H(fe);export{he as B,ye as R};