(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["components-uview-ui-components-u-avatar-cropper-u-avatar-cropper"],{1851:function(t,e,n){"use strict";var r=n("8bdb"),o=n("84d6"),i=n("1cb5");r({target:"Array",proto:!0},{fill:o}),i("fill")},"4ffa":function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"c",(function(){return o})),n.d(e,"a",(function(){}));var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("v-uni-view",{staticClass:"content"},[n("v-uni-view",{staticClass:"cropper-wrapper",style:{height:t.cropperOpt.height+"px"}},[n("v-uni-canvas",{staticClass:"cropper",style:{width:t.cropperOpt.width,height:t.cropperOpt.height,backgroundColor:"rgba(0, 0, 0, 0.8)"},attrs:{"disable-scroll":!0,"canvas-id":"cropper",id:"cropper"},on:{touchstart:function(e){arguments[0]=e=t.$handleEvent(e),t.touchStart.apply(void 0,arguments)},touchmove:function(e){arguments[0]=e=t.$handleEvent(e),t.touchMove.apply(void 0,arguments)},touchend:function(e){arguments[0]=e=t.$handleEvent(e),t.touchEnd.apply(void 0,arguments)}}}),n("v-uni-canvas",{staticClass:"cropper",style:{position:"fixed",top:"-"+t.cropperOpt.width*t.cropperOpt.pixelRatio+"px",left:"-"+t.cropperOpt.height*t.cropperOpt.pixelRatio+"px",width:t.cropperOpt.width*t.cropperOpt.pixelRatio+"px",height:""+t.cropperOpt.height*t.cropperOpt.pixelRatio},attrs:{"disable-scroll":!0,"canvas-id":"targetId",id:"targetId"}})],1),n("v-uni-view",{staticClass:"cropper-buttons safe-area-padding",style:{height:t.bottomNavHeight+"px"}},[n("v-uni-view",{staticClass:"upload",on:{click:function(e){arguments[0]=e=t.$handleEvent(e),t.uploadTap.apply(void 0,arguments)}}},[t._v("选择图片")]),n("v-uni-view",{staticClass:"getCropperImage",on:{click:function(e){arguments[0]=e=t.$handleEvent(e),t.getCropperImage(!1)}}},[t._v("确定")])],1)],1)},o=[]},6305:function(t,e,n){var r=n("981d");r.__esModule&&(r=r.default),"string"===typeof r&&(r=[[t.i,r,""]]),r.locals&&(t.exports=r.locals);var o=n("967d").default;o("52e5ae82",r,!0,{sourceMap:!1,shadowMode:!1})},6834:function(t,e,n){"use strict";var r=n("6305"),o=n.n(r);o.a},"843b":function(t,e,n){"use strict";n("6a54");var r=n("f5bd").default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,n("64aa");var o=r(n("8f72")),i={props:{boundStyle:{type:Object,default:function(){return{lineWidth:4,borderColor:"rgb(245, 245, 245)",mask:"rgba(0, 0, 0, 0.35)"}}}},data:function(){return{bottomNavHeight:50,originWidth:200,width:0,height:0,cropperOpt:{id:"cropper",targetId:"targetCropper",pixelRatio:1,width:0,height:0,scale:2.5,zoom:8,cut:{x:(this.width-this.originWidth)/2,y:(this.height-this.originWidth)/2,width:this.originWidth,height:this.originWidth},boundStyle:{lineWidth:uni.upx2px(this.boundStyle.lineWidth),mask:this.boundStyle.mask,color:this.boundStyle.borderColor}},destWidth:200,rectWidth:200,fileType:"jpg",src:""}},onLoad:function(t){var e=this,n=uni.getSystemInfoSync();if(this.width=n.windowWidth,this.height=n.windowHeight-this.bottomNavHeight,this.cropperOpt.width=this.width,this.cropperOpt.height=this.height,this.cropperOpt.pixelRatio=n.pixelRatio,t.destWidth&&(this.destWidth=t.destWidth),t.rectWidth){var r=Number(t.rectWidth);this.cropperOpt.cut={x:(this.width-r)/2,y:(this.height-r)/2,width:r,height:r}}this.rectWidth=t.rectWidth,t.fileType&&(this.fileType=t.fileType),this.cropper=new o.default(this.cropperOpt).on("ready",(function(t){})).on("beforeImageLoad",(function(t){})).on("imageLoad",(function(t){})).on("beforeDraw",(function(t,e){})),uni.setNavigationBarColor({frontColor:"#ffffff",backgroundColor:"#000000"}),uni.chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(t){e.src=t.tempFilePaths[0],e.cropper.pushOrign(e.src)}})},methods:{touchStart:function(t){this.cropper.touchStart(t)},touchMove:function(t){this.cropper.touchMove(t)},touchEnd:function(t){this.cropper.touchEnd(t)},getCropperImage:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.src)return this.$u.toast("请先选择图片再裁剪");var n={destHeight:Number(this.destWidth),destWidth:Number(this.destWidth),fileType:this.fileType};this.cropper.getCropperImage(n,(function(n,r){r?uni.showModal({title:"温馨提示",content:r.message}):e?uni.previewImage({current:"",urls:[n]}):(uni.$emit("uAvatarCropper",n),t.$u.route({type:"back"}))}))},uploadTap:function(){var t=this,e=this;uni.chooseImage({count:1,sizeType:["original","compressed"],sourceType:["album","camera"],success:function(n){e.src=n.tempFilePaths[0],e.cropper.pushOrign(t.src)}})}}};e.default=i},"8f72":function(t,e,n){(function(r,o){var i,a,c=n("bdbb").default;n("f7a5"),n("bf0f"),n("a03a"),n("6a54"),n("e838"),n("5ef2"),n("c223"),n("7a76"),n("c9b5"),n("5c47"),n("a1c1"),n("0506"),n("2c10"),n("1851"),n("2797"),n("dc8a"), /** * we-cropper v1.3.9 * (c) 2020 dlhandsome * @license MIT */ function(r,o){"object"===c(e)&&"undefined"!==typeof t?t.exports=o():(i=o,a="function"===typeof i?i.call(e,n,e,t):i,void 0===a||(t.exports=a))}(0,(function(){"use strict";var t=void 0,e=["touchstarted","touchmoved","touchended"];function n(t){var n=[],r=arguments.length-1;while(r-- >0)n[r]=arguments[r+1];e.forEach((function(e,r){void 0!==n[r]&&(t[e]=n[r])}))}function i(){return t||(t=uni.getSystemInfoSync()),t}var a={},u=i(),s=u.pixelRatio,h={id:{default:"cropper",get:function(){return a.id},set:function(t){"string"!==typeof t&&r.error("id:"+t+" is invalid"),a.id=t}},width:{default:750,get:function(){return a.width},set:function(t){"number"!==typeof t&&r.error("width:"+t+" is invalid"),a.width=t}},height:{default:750,get:function(){return a.height},set:function(t){"number"!==typeof t&&r.error("height:"+t+" is invalid"),a.height=t}},pixelRatio:{default:s,get:function(){return a.pixelRatio},set:function(t){"number"!==typeof t&&r.error("pixelRatio:"+t+" is invalid"),a.pixelRatio=t}},scale:{default:2.5,get:function(){return a.scale},set:function(t){"number"!==typeof t&&r.error("scale:"+t+" is invalid"),a.scale=t}},zoom:{default:5,get:function(){return a.zoom},set:function(t){"number"!==typeof t?r.error("zoom:"+t+" is invalid"):(t<0||t>10)&&r.error("zoom should be ranged in 0 ~ 10"),a.zoom=t}},src:{default:"",get:function(){return a.src},set:function(t){"string"!==typeof t&&r.error("src:"+t+" is invalid"),a.src=t}},cut:{default:{},get:function(){return a.cut},set:function(t){"object"!==c(t)&&r.error("cut:"+t+" is invalid"),a.cut=t}},boundStyle:{default:{},get:function(){return a.boundStyle},set:function(t){"object"!==c(t)&&r.error("boundStyle:"+t+" is invalid"),a.boundStyle=t}},onReady:{default:null,get:function(){return a.ready},set:function(t){a.ready=t}},onBeforeImageLoad:{default:null,get:function(){return a.beforeImageLoad},set:function(t){a.beforeImageLoad=t}},onImageLoad:{default:null,get:function(){return a.imageLoad},set:function(t){a.imageLoad=t}},onBeforeDraw:{default:null,get:function(){return a.beforeDraw},set:function(t){a.beforeDraw=t}}},d=i(),p=d.windowWidth;var f="undefined"!==typeof window?window:"undefined"!==typeof o?o:"undefined"!==typeof self?self:{};function l(t,e){return e={exports:{}},t(e,e.exports),e.exports}var g=l((function(t,e){e.isStr=function(t){return"string"===typeof t},e.isNum=function(t){return"number"===typeof t},e.isArr=Array.isArray,e.isUndef=function(t){return void 0===t},e.isTrue=function(t){return!0===t},e.isFalse=function(t){return!1===t},e.isFunc=function(t){return"function"===typeof t},e.isObj=e.isObject=function(t){return null!==t&&"object"===c(t)};var n=Object.prototype.toString;e.isPlainObject=function(t){return"[object Object]"===n.call(t)};var r=Object.prototype.hasOwnProperty;e.hasOwn=function(t,e){return r.call(t,e)},e.noop=function(t,e,n){},e.isValidArrayIndex=function(t){var e=parseFloat(String(t));return e>=0&&Math.floor(e)===e&&isFinite(t)}})),v=g.isFunc,b=g.isPlainObject,y=["ready","beforeImageLoad","beforeDraw","imageLoad"];function m(t){return function(e){var n=[],r=arguments.length-1;while(r-- >0)n[r]=arguments[r+1];return void 0===e&&(e={}),new Promise((function(r,o){e.success=function(t){r(t)},e.fail=function(t){o(t)},t.apply(void 0,[e].concat(n))}))}}function x(t,e){return void 0===e&&(e=!1),new Promise((function(n){t.draw(e,n)}))}var w=m(uni.getImageInfo),C=m(uni.canvasToTempFilePath),S=l((function(t,e){ /*! http://mths.be/base64 v0.1.0 by @mathias | MIT license */ (function(n){var r=e,o=t&&t.exports==r&&t,i="object"==c(f)&&f;i.global!==i&&i.window!==i||(n=i);var a=function(t){this.message=t};a.prototype=new Error,a.prototype.name="InvalidCharacterError";var u=function(t){throw new a(t)},s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=/[\t\n\f\r ]/g,d={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&u("The string to be encoded contains characters outside of the Latin1 range.");var e,n,r,o,i=t.length%3,a="",c=-1,h=t.length-i;while(++c>18&63)+s.charAt(o>>12&63)+s.charAt(o>>6&63)+s.charAt(63&o);return 2==i?(e=t.charCodeAt(c)<<8,n=t.charCodeAt(++c),o=e+n,a+=s.charAt(o>>10)+s.charAt(o>>4&63)+s.charAt(o<<2&63)+"="):1==i&&(o=t.charCodeAt(c),a+=s.charAt(o>>2)+s.charAt(o<<4&63)+"=="),a},decode:function(t){t=String(t).replace(h,"");var e=t.length;e%4==0&&(t=t.replace(/==?$/,""),e=t.length),(e%4==1||/[^+a-zA-Z0-9/]/.test(t))&&u("Invalid character: the string to be decoded is not correctly encoded.");var n,r,o=0,i="",a=-1;while(++a>(-2*o&6)));return i},version:"0.1.0"};if(r&&!r.nodeType)if(o)o.exports=d;else for(var p in d)d.hasOwnProperty(p)&&(r[p]=d[p]);else n.base64=d})(f)}));function O(t){var e="";if("string"===typeof t)e=t;else for(var n=0;n>8&255,o>>16&255,o>>24&255,0,0,0,0,54,0,0,0],a=[40,0,0,0,255&e,e>>8&255,e>>16&255,e>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255,1,0,24,0,0,0,0,0,255&r,r>>8&255,r>>16&255,r>>24&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=(4-3*e%4)%4,u=t.data,s="",h=e<<2,d=n,p=String.fromCharCode;do{for(var f=h*(d-1),l="",g=0;g=2&&this.__twoTouchStart(r,o))},touchMove:function(t){var e=t.touches,r=e[0],o=e[1];this.src&&(n(this,null,!0),1===t.touches.length&&this.__oneTouchMove(r),t.touches.length>=2&&this.__twoTouchMove(r,o))},touchEnd:function(t){this.src&&(n(this,!1,!1,!0),this.__xtouchEnd())}};var W=function(t){var e={};return function(t,e){Object.defineProperties(t,e)}(this,h),Object.keys(h).forEach((function(t){e[t]=h[t].default})),Object.assign(this,e,t),this.prepare(),this.attachPage(),this.createCtx(),this.observer(),this.cutt(),this.methods(),this.init(),this.update(),this};return W.prototype.init=function(){var t=this.src;return this.version="1.3.9","function"===typeof this.onReady&&this.onReady(this.ctx,this),t?this.pushOrign(t):this.updateCanvas(),n(this,!1,!1,!1),this.oldScale=1,this.newScale=1,this},Object.assign(W.prototype,M),W.prototype.prepare=function(){var t=this;t.attachPage=function(){var e=getCurrentPages(),n=e[e.length-1];Object.defineProperty(n,"wecropper",{get:function(){return r.warn("Instance will not be automatically bound to the page after v1.4.0\n\nPlease use a custom instance name instead\n\nExample: \nthis.mycropper = new WeCropper(options)\n\n// ...\nthis.mycropper.getCropperImage()"),t},configurable:!0})},t.createCtx=function(){var e=t.id,n=t.targetId;e?(t.ctx=t.ctx||uni.createCanvasContext(e),t.targetCtx=t.targetCtx||uni.createCanvasContext(n)):r.error("constructor: create canvas context failed, 'id' must be valuable")},t.deviceRadio=p/750},W.prototype.observer=function(){var t=this;t.on=function(e,n){return y.indexOf(e)>-1?v(n)&&("ready"===e?n(t):t["on"+function(t){return t.charAt(0).toUpperCase()+t.slice(1)}(e)]=n):r.error("event: "+e+" is invalid"),t}},W.prototype.methods=function(){var t=this,e=t.width,n=t.height,r=t.id,o=t.targetId,i=t.pixelRatio,a=t.cut,c=a.x;void 0===c&&(c=0);var u=a.y;void 0===u&&(u=0);var s=a.width;void 0===s&&(s=e);var h=a.height;void 0===h&&(h=n),t.updateCanvas=function(e){return t.croperTarget&&t.ctx.drawImage(t.croperTarget,t.imgLeft,t.imgTop,t.scaleWidth,t.scaleHeight),v(t.onBeforeDraw)&&t.onBeforeDraw(t.ctx,t),t.setBoundStyle(t.boundStyle),t.ctx.draw(!1,e),t},t.pushOrigin=t.pushOrign=function(e){return t.src=e,v(t.onBeforeImageLoad)&&t.onBeforeImageLoad(t.ctx,t),w({src:e}).then((function(e){var n=e.width/e.height,r=s/h;return t.croperTarget=e.path,n=o?o:t.scaleWidth+e-o<=a?o+a-t.scaleWidth:e,t.imgTop=n>=i?i:t.scaleHeight+n-i<=c?i+c-t.scaleHeight:n},t.setBoundStyle=function(r){void 0===r&&(r={});var u=r.color;void 0===u&&(u="#04b00f");var s=r.mask;void 0===s&&(s="rgba(0, 0, 0, 0.3)");var h=r.lineWidth;void 0===h&&(h=1);var d=h/2,p=[{start:{x:o-d,y:i+10-d},step1:{x:o-d,y:i-d},step2:{x:o+10-d,y:i-d}},{start:{x:o-d,y:i+c-10+d},step1:{x:o-d,y:i+c+d},step2:{x:o+10-d,y:i+c+d}},{start:{x:o+a-10+d,y:i-d},step1:{x:o+a+d,y:i-d},step2:{x:o+a+d,y:i+10-d}},{start:{x:o+a+d,y:i+c-10+d},step1:{x:o+a+d,y:i+c+d},step2:{x:o+a-10+d,y:i+c+d}}];t.ctx.beginPath(),t.ctx.setFillStyle(s),t.ctx.fillRect(0,0,o,n),t.ctx.fillRect(o,0,a,i),t.ctx.fillRect(o,i+c,a,n-i-c),t.ctx.fillRect(o+a,0,e-o-a,n),t.ctx.fill(),p.forEach((function(e){t.ctx.beginPath(),t.ctx.setStrokeStyle(u),t.ctx.setLineWidth(h),t.ctx.moveTo(e.start.x,e.start.y),t.ctx.lineTo(e.step1.x,e.step1.y),t.ctx.lineTo(e.step2.x,e.step2.y),t.ctx.stroke()}))}},W.prototype.update=function(){var t=this;t.src&&(t.__oneTouchStart=function(e){t.touchX0=Math.round(e.x),t.touchY0=Math.round(e.y)},t.__oneTouchMove=function(e){var n,r;if(t.touchended)return t.updateCanvas();n=Math.round(e.x-t.touchX0),r=Math.round(e.y-t.touchY0);var o=Math.round(t.rectX+n),i=Math.round(t.rectY+r);t.outsideBound(o,i),t.updateCanvas()},t.__twoTouchStart=function(e,n){var r,o,i;t.touchX1=Math.round(t.rectX+t.scaleWidth/2),t.touchY1=Math.round(t.rectY+t.scaleHeight/2),r=Math.round(n.x-e.x),o=Math.round(n.y-e.y),i=Math.round(Math.sqrt(r*r+o*o)),t.oldDistance=i},t.__twoTouchMove=function(e,n){var r=t.oldScale,o=t.oldDistance,i=t.scale,a=t.zoom;t.newScale=function(t,e,n,r,o){var i,a,c;return i=Math.round(o.x-r.x),a=Math.round(o.y-r.y),c=Math.round(Math.sqrt(i*i+a*a)),t+.001*n*(c-e)}(r,o,a,e,n),t.newScale<=1&&(t.newScale=1),t.newScale>=i&&(t.newScale=i),t.scaleWidth=Math.round(t.newScale*t.baseWidth),t.scaleHeight=Math.round(t.newScale*t.baseHeight);var c=Math.round(t.touchX1-t.scaleWidth/2),u=Math.round(t.touchY1-t.scaleHeight/2);t.outsideBound(c,u),t.updateCanvas()},t.__xtouchEnd=function(){t.oldScale=t.newScale,t.rectX=t.imgLeft,t.rectY=t.imgTop})},W}))}).call(this,n("ba7c")["default"],n("0ee4"))},"981d":function(t,e,n){var r=n("c86c");e=r(!1),e.push([t.i,'@charset "UTF-8";\n/**\n * 这里是uni-app内置的常用样式变量\n *\n * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量\n * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App\n *\n */\n/**\n * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能\n *\n * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件\n */\n/* 颜色变量 */\n/* 行为相关颜色 */.content[data-v-41792762]{background:#fff}.cropper[data-v-41792762]{position:absolute;top:0;left:0;width:100%;height:100%;z-index:11}.cropper-buttons[data-v-41792762]{background-color:#000;color:#eee}.cropper-wrapper[data-v-41792762]{position:relative;display:flex;flex-direction:row;flex-direction:row;justify-content:space-between;align-items:center;width:100%;background-color:#000}.cropper-buttons[data-v-41792762]{width:100vw;display:flex;flex-direction:row;flex-direction:row;justify-content:space-between;align-items:center;position:fixed;bottom:0;left:0;font-size:%?28?%}.cropper-buttons .upload[data-v-41792762],\n.cropper-buttons .getCropperImage[data-v-41792762]{width:50%;text-align:center}.cropper-buttons .upload[data-v-41792762]{text-align:left;padding-left:%?50?%}.cropper-buttons .getCropperImage[data-v-41792762]{text-align:right;padding-right:%?50?%}',""]),t.exports=e},cb28:function(t,e,n){"use strict";n.r(e);var r=n("4ffa"),o=n("f290");for(var i in o)["default"].indexOf(i)<0&&function(t){n.d(e,t,(function(){return o[t]}))}(i);n("6834");var a=n("828b"),c=Object(a["a"])(o["default"],r["b"],r["c"],!1,null,"41792762",null,!1,r["a"],void 0);e["default"]=c.exports},f290:function(t,e,n){"use strict";n.r(e);var r=n("843b"),o=n.n(r);for(var i in r)["default"].indexOf(i)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(i);e["default"]=o.a}}]);