hldy_xcx/unpackage/dist/build/app-plus/app-renderjs.js

3 lines
11 KiB
JavaScript

var __renderjsModules={};
__renderjsModules.c0c7256a=(()=>{var G=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var et=Object.prototype.hasOwnProperty;var it=(e,i)=>{for(var o in i)G(e,o,{get:i[o],enumerable:!0})},ht=(e,i,o,g)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of tt(i))!et.call(e,a)&&a!==o&&G(e,a,{get:()=>i[a],enumerable:!(g=V(i,a))||g.enumerable});return e};var rt=e=>ht(G({},"__esModule",{value:!0}),e);var I=(e,i,o)=>new Promise((g,a)=>{var n=w=>{try{s(o.next(w))}catch(v){a(v)}},f=w=>{try{s(o.throw(w))}catch(v){a(v)}},s=w=>w.done?g(w.value):Promise.resolve(w.value).then(n,f);s((o=o.apply(e,i)).next())});var ft={};it(ft,{default:()=>lt});var l={x:0,y:0},u=1,W=1,P=0,S=[],r={},b={},t={},B="",E=0,h={left:0,right:0,top:0,bottom:0},U={imageStyles:"crop-image",maskStylesList:"crop-mask-block",borderStyles:"crop-border",circleBoxStyles:"crop-circle-box",circleStyles:"crop-circle",gridStylesList:"crop-grid",angleStylesList:"crop-angle"},_=0,z="H5",z="APP",L=1e-6;function F(e,i){return e>0&&i<0?e:e<0&&i>0?i:e>0&&i>0?Math.min(e,i):0}function d(e){var i=parseFloat(e.toFixed(6));return i===L||i===-L?0:i}function ot(e,i){return Math.abs(e-i)<=L}function O(e,i){var o=e-i;return o<0?o<-L:o<L}function k(e,i,o,g,a,n){if(typeof i=="number"){if(o&&ot(i,a)){var f=d(i*n);return f<=g?f:g}return i}return e}function C(e){if(typeof e=="string")return e;var i="";for(let o in e)i+=o+":"+e[o]+";";return i}function M(e,i,o){if(z==="APP")if(Object.prototype.toString.call(o)==="[object Array]")for(var g=0,a=o.length;g<a;g++){var n=window.document.getElementById(U[i]+"-"+(g+1));n&&(n.style=C(o[g]))}else{var n=window.document.getElementById(U[i]);n&&(n.style=C(o))}z==="H5"&&(e[i]=o)}function at(e,i,o){z==="APP"&&e.callMethod(i,o),z==="H5"&&e[i](o)}function Y(e){var i=e[1].pageX-e[0].pageX,o=e[1].pageY-e[0].pageY,g=Math.sqrt(Math.pow(i,2)+Math.pow(o,2)),a=e[1].pageX-i/2,n=e[1].pageY-o/2;return{c:g,x:a,y:n}}function $(e,i,o,g){return d(g?Math.max(Math.min(e,i),o):Math.min(Math.max(e,i),o))}function x(e,i,o){var g=d((r.height-r.width)/2);return{x:$(e.x,-r.height+g+t.width+t.left,t.left+g,i),y:$(e.y,-r.width-g+t.height+t.top,t.top-g,o)}}function nt(e){var i=P/90%2;if(i===1){if(t.width===t.height)return x(e,r.height<t.height,r.width<t.width);var o=r.height<t.width&&r.width<t.height;if(r.width<t.height||r.height<t.width){if(t.width<t.height&&r.width<r.height)return o?x(e,t.width<t.height,t.width<t.height):x(e,!1,!0);if(t.height<t.width&&r.height<r.width)return o?x(e,t.height<t.width,t.height<t.width):x(e,!0,!1)}return r.height>=t.width&&r.width>=t.height?x(e,!1,!1):o?t.height<t.width?x(e,!0,!0):x(e,t.width<t.height,t.width<t.height):r.height<t.width&&!r.width<t.height?x(e,!0,!1):!r.height<t.width&&r.width<t.height?x(e,!1,!0):x(e,r.height<t.height,r.width<t.width)}return{x:$(e.x,-r.width+t.width+t.left,t.left,r.width<t.width),y:$(e.y,-r.height+t.height+t.top,t.top,r.height<t.height)}}function H(e){if(l.x+=e.x||0,l.y+=e.y||0,e.check&&t.checkRange){var i=nt(l);(l.x!==i.x||l.y!==i.y)&&(l=i)}var o=(r.width-r.oldWidth)/2,g=(r.height-r.oldHeight)/2;M(e.instance,"imageStyles",{width:r.oldWidth+"px",height:r.oldHeight+"px",transform:(r.gpu?"translateZ(0) ":"")+"translate("+(l.x+o)+"px, "+(l.y+g)+"px) rotate("+P+"deg) scale("+u+")"}),at(e.instance,"dataChange",{width:r.width,height:r.height,x:l.x,y:l.y,rotate:P})}function Z(e){if(M(e.instance,"maskStylesList",[{left:0,width:t.left+h.left+"px",top:0,bottom:0,"z-index":t.zIndex+2},{left:t.right+h.right+"px",right:0,top:0,bottom:0,"z-index":t.zIndex+2},{left:t.left+h.left+"px",width:t.width+h.right-h.left+"px",top:0,height:t.top+h.top+"px","z-index":t.zIndex+2},{left:t.left+h.left+"px",width:t.width+h.right-h.left+"px",top:t.bottom+h.bottom+"px",bottom:0,"z-index":t.zIndex+2}]),t.showBorder&&M(e.instance,"borderStyles",{left:t.left+h.left+"px",top:t.top+h.top+"px",width:t.width+h.right-h.left+"px",height:t.height+h.bottom-h.top+"px","z-index":t.zIndex+3}),t.showGrid&&M(e.instance,"gridStylesList",[{"border-width":"1px 0 0 0",left:t.left+h.left+"px",right:t.right+h.right+"px",top:t.top+h.top+(t.height+h.bottom-h.top)/3-.5+"px",width:t.width+h.right-h.left+"px","z-index":t.zIndex+3},{"border-width":"1px 0 0 0",left:t.left+h.left+"px",right:t.right+h.right+"px",top:t.top+h.top+(t.height+h.bottom-h.top)*2/3-.5+"px",width:t.width+h.right-h.left+"px","z-index":t.zIndex+3},{"border-width":"0 1px 0 0",top:t.top+h.top+"px",bottom:t.bottom+h.bottom+"px",left:t.left+h.left+(t.width+h.right-h.left)/3-.5+"px",height:t.height+h.bottom-h.top+"px","z-index":t.zIndex+3},{"border-width":"0 1px 0 0",top:t.top+h.top+"px",bottom:t.bottom+h.bottom+"px",left:t.left+h.left+(t.width+h.right-h.left)*2/3-.5+"px",height:t.height+h.bottom-h.top+"px","z-index":t.zIndex+3}]),t.showAngle&&M(e.instance,"angleStylesList",[{"border-width":t.angleBorderWidth+"px 0 0 "+t.angleBorderWidth+"px",left:t.left+h.left-t.angleBorderWidth+"px",top:t.top+h.top-t.angleBorderWidth+"px","z-index":t.zIndex+3},{"border-width":t.angleBorderWidth+"px "+t.angleBorderWidth+"px 0 0",left:t.right+h.right-t.angleSize+"px",top:t.top+h.top-t.angleBorderWidth+"px","z-index":t.zIndex+3},{"border-width":"0 0 "+t.angleBorderWidth+"px "+t.angleBorderWidth+"px",left:t.left+h.left-t.angleBorderWidth+"px",top:t.bottom+h.bottom-t.angleSize+"px","z-index":t.zIndex+3},{"border-width":"0 "+t.angleBorderWidth+"px "+t.angleBorderWidth+"px 0",left:t.right+h.right-t.angleSize+"px",top:t.bottom+h.bottom-t.angleSize+"px","z-index":t.zIndex+3}]),t.radius>0){var i=t.radius;t.width===t.height&&t.radius>=t.width/2?i=t.width/2:t.width!==t.height&&(i=Math.min(t.width/2,t.height/2,i)),M(e.instance,"circleBoxStyles",{left:t.left+h.left+"px",top:t.top+h.top+"px",width:t.width+h.right-h.left+"px",height:t.height+h.bottom-h.top+"px","z-index":t.zIndex+2}),M(e.instance,"circleStyles",{"box-shadow":"0 0 0 "+Math.max(t.width,t.height)+"px rgba(51, 51, 51, 0.8)","border-radius":i+"px"})}}function q(e){var i=u;return u=Math.min(Math.max(e.scale+u,W),r.maxScale),i!==u?(r.width=d(r.oldWidth*u),r.height=d(r.oldHeight*u),e.x=d((e.x-l.x)*(1-u/i)),e.y=d((e.y-l.y)*(1-u/i)),H(e),!0):!1}function gt(e,i){var o=t.angleBorderWidth,g=b.navigation?0:b.windowTop;if(i>=t.top-o+g&&i<=t.top+t.angleSize+o+g){if(e>=t.left-o&&e<=t.left+t.angleSize+o)return 1;if(e>=t.right-t.angleSize-o&&e<=t.right+o)return 2}else if(i>=t.bottom-t.angleSize-o+g&&i<=t.bottom+o+g){if(e>=t.left-o&&e<=t.left+t.angleSize+o)return 3;if(e>=t.right-t.angleSize-o&&e<=t.right+o)return 4}return 0}function dt(){l={x:0,y:0},u=1,W=r.minScale,P=0}function J(e){for(var i=[],o=e?e.length:0,g=0;g<o;g++)i[g]={pageX:e[g].pageX,pageY:e[g].pageY+b.windowTop};return i}var D=!1,K={data(){return{imageStyles:{},maskStylesList:[{},{},{},{}],borderStyles:{},gridStylesList:[{},{},{},{}],angleStylesList:[{},{},{},{}],circleBoxStyles:{},circleStyles:{}}},created(){z==="H5"&&window.addEventListener("mousewheel",e=>I(this,null,function*(){var i=J([e]);r.src&&q({instance:yield this.getInstance(),check:!0,scale:e.deltaY>0?-.05:.05,x:i[0].pageX,y:i[0].pageY})}))},mounted(){z==="H5"&&this.initH5Events()},setPlatform(e){z=e},methods:{getTouchEvent(e){return e.touches=[{pageX:e.pageX,pageY:e.pageY}],e},initH5Events(){let e=document.getElementById("pic-preview");e==null||e.addEventListener("mousedown",(i,o)=>{D=!0,this.touchstart(this.getTouchEvent(i))}),e==null||e.addEventListener("mousemove",i=>{D&&this.touchmove(this.getTouchEvent(i))}),e==null||e.addEventListener("mouseup",i=>{D=!1,this.touchend(this.getTouchEvent(i))}),e==null||e.addEventListener("mouseleave",i=>{D=!1,this.touchend(this.getTouchEvent(i))})},getInstance(){return I(this,null,function*(){if(z==="APP")return this.$ownerInstance?Promise.resolve(this.$ownerInstance):new Promise(e=>{setTimeout(()=>I(this,null,function*(){e(yield this.getInstance())}))});if(z==="H5")return Promise.resolve(this)})},initObserver:function(e,i,o,g){return I(this,null,function*(){if(e&&(!r.src||_!==e.timestamp)){_=e.timestamp,r=e.img,b=e.sys,t=e.area,W=r.minScale,dt();let a=yield this.getInstance();r.src&&H({instance:a,x:(b.windowWidth-r.width)/2,y:(b.windowHeight+b.windowTop-b.offsetBottom-r.height)/2}),Z({instance:a})}})},mousewheel:function(e,i){},touchstart:function(e,i){r.src&&(S=J(e.touches),E=t.showAngle?gt(S[0].pageX,S[0].pageY):0,S.length===1&&E!==0?B="stretch":B="")},touchmove:function(e,i){return I(this,null,function*(){if(r.src){if(e.touches=J(e.touches),B==="stretch"){var o=e.touches[0],g=S[0],a=o.pageX-g.pageX,n=o.pageY-g.pageY;if(a!==0||n!==0){var f=d(t.width*(1-t.minScale)),s=d(t.height*(1-t.minScale));S[0]=o;var w=P/90%2,v=w===1?d((r.height-r.width)/2):0,N=O(w===1?r.height:r.width,t.width),Q=O(w===1?r.width:r.height,t.height),y=N&&Q,A=t.checkRange&&(N||Q),R=!y||d((l.x-t.left)/t.width)<=d((l.y-t.top)/t.height)||t.width>t.height&&r.width<r.height&&w===1;switch(E){case 1:if(a=d(a+h.left),n=d(n+h.top),a>=0&&n>=0){var c=d(l.y+v-t.top),p=d(l.x-v-t.left),m=A&&(p>=0||c>=0)?F(c,p):!1;a>n&&R?(f=k(f,m,y,p,c,t.width/t.height),a>f&&(a=f),n=d(a*t.height/t.width)):(s=k(s,m,y,c,p,t.height/t.width),n>s&&(n=s),a=d(n*t.width/t.height)),h.left=a,h.top=n}break;case 2:if(a=d(a+h.right),n=d(n+h.top),a<=0&&n>=0){var T=w===1?r.height:r.width,c=d(l.y+v-t.top),p=d(t.right+v-l.x-T),m=A&&(c>=0||p>=0)?F(c,p):!1;-a>n&&R?(f=k(f,m,y,p,c,t.width/t.height),-a>f&&(a=-f),n=d(-a*t.height/t.width)):(s=k(s,m,y,c,p,t.height/t.width),n>s&&(n=s),a=d(-n*t.width/t.height)),h.right=a,h.top=n}break;case 3:if(a+=d(a+h.left),n+=d(n+h.bottom),a>=0&&n<=0){var T=w===1?r.width:r.height,c=d(t.bottom-v-l.y-T),p=d(l.x-v-t.left),m=A&&(p>=0||c>=0)?F(c,p):!1;a>-n&&R?(f=k(f,m,y,p,c,t.width/t.height),a>f&&(a=f),n=d(-a*t.height/t.width)):(s=k(s,m,y,c,p,t.height/t.width),-n>s&&(n=-s),a=d(-n*t.width/t.height)),h.left=a,h.bottom=n}break;case 4:if(a=d(a+h.right),n=d(n+h.bottom),a<=0&&n<=0){var T=w===1?r.height:r.width,X=w===1?r.width:r.height,c=d(t.bottom-l.y-X-v),p=d(t.right+v-l.x-T),m=A&&(p>=0||c>=0)?F(c,p):!1;-a>-n&&R?(f=k(f,m,y,p,c,t.width/t.height),-a>f&&(a=-f),n=d(a*t.height/t.width)):(s=k(s,m,y,c,p,t.height/t.width),-n>s&&(n=-s),a=d(n*t.width/t.height)),h.right=a,h.bottom=n}break}Z({instance:yield this.getInstance()})}}else if(e.touches.length==2){var g=Y(S),j=Y(e.touches);q({instance:yield this.getInstance(),check:!t.bounce,scale:(j.c-g.c)/100,x:j.x,y:j.y}),B="scale"}else B==="scale"||H({instance:yield this.getInstance(),check:!t.bounce,x:e.touches[0].pageX-S[0].pageX,y:e.touches[0].pageY-S[0].pageY}),B="move";S=e.touches}})},touchend:function(e,i){return I(this,null,function*(){if(r.src)if(B==="stretch"){var o=h.left,g=h.right,a=h.top,n=h.bottom,f=t.width+g-o,s=t.height+n-a,w=u*(t.width/f)-u;h={left:0,right:0,top:0,bottom:0},Z({instance:yield this.getInstance()}),q({instance:yield this.getInstance(),scale:w,x:t.left+o+(E===1||E===3?f:0),y:t.top+a+(E===1||E===2?s:0)})}else t.bounce&&H({instance:yield this.getInstance(),check:!0})})},rotateImage:function(e){return I(this,null,function*(){P=(P+(e||90))%360,r.minScale>=1&&t.checkRange&&(W=1,r.width<t.height?W=t.height/r.oldWidth:r.height<t.width&&(W=t.width/r.oldHeight),W!==1&&q({instance:yield this.getInstance(),scale:W-u,x:b.windowWidth/2,y:(b.windowHeight-b.offsetBottom)/2}));var i=(l.x+r.width-t.right-(t.left-l.x))/2,o=(l.y+r.height-t.bottom-(t.top-l.y))/2;H({instance:yield this.getInstance(),check:!0,x:-i-o,y:-o+i})})},rotateImage90:function(){this.rotateImage(90)},rotateImage270:function(){this.rotateImage(270)}}};K.setPlatform("APP");var lt={mixins:[K]};return rt(ft);})();