康巴易测肤/伤疤uniapp小程序类
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
6.7KB

  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/xiaogang-crop/index"],{375:function(t,o,e){"use strict";e.r(o);var i=e(376),r=e(378);for(var n in r)["default"].indexOf(n)<0&&function(t){e.d(o,t,(function(){return r[t]}))}(n);e(380);var c,s=e(32),h=Object(s["default"])(r["default"],i["render"],i["staticRenderFns"],!1,null,"b6fe683a",null,!1,i["components"],c);h.options.__file="components/xiaogang-crop/index.vue",o["default"]=h.exports},376:function(t,o,e){"use strict";e.r(o);var i=e(377);e.d(o,"render",(function(){return i["render"]})),e.d(o,"staticRenderFns",(function(){return i["staticRenderFns"]})),e.d(o,"recyclableRender",(function(){return i["recyclableRender"]})),e.d(o,"components",(function(){return i["components"]}))},377:function(t,o,e){"use strict";var i;e.r(o),e.d(o,"render",(function(){return r})),e.d(o,"staticRenderFns",(function(){return c})),e.d(o,"recyclableRender",(function(){return n})),e.d(o,"components",(function(){return i}));try{i={"u-Image":function(){return Promise.all([e.e("common/vendor"),e.e("node-modules/uview-ui/components/u--image/u--image")]).then(e.bind(null,328))}}}catch(s){if(-1===s.message.indexOf("Cannot find module")||-1===s.message.indexOf(".vue"))throw s;console.error(s.message),console.error("1. 排查组件名称拼写是否正确"),console.error("2. 排查组件是否符合 easycom 规范,文档:https://uniapp.dcloud.net.cn/collocation/pages?id=easycom"),console.error("3. 若组件不符合 easycom 规范,需手动引入,并在 components 中注册该组件")}var r=function(){var t=this,o=t.$createElement;t._self._c},n=!1,c=[];r._withStripped=!0},378:function(t,o,e){"use strict";e.r(o);var i=e(379),r=e.n(i);for(var n in i)["default"].indexOf(n)<0&&function(t){e.d(o,t,(function(){return i[t]}))}(n);o["default"]=r.a},379:function(t,o,e){"use strict";(function(t){var i=e(4);Object.defineProperty(o,"__esModule",{value:!0}),o.default=void 0;var r,n,c,s,h,a,u,p,l,d,g=i(e(56)),f=i(e(396)),x=i(e(58)),m={name:"imageCropping",props:{src:{type:String},ratioGroup:{type:Array,default:function(){return[]}},isFixedSize:{type:Boolean,default:!1},cropShape:{type:String,default:"circular"}},data:function(){return{imageBoxWidth:0,imageBoxHeight:0,cropBoxX:0,cropBoxY:0,cropBoxWidth:0,cropBoxHeight:0,mode:"",cropSize:100,cropImgPath:""}},mounted:function(){this.getImageInfo()},methods:{getImageInfo:function(){var o=this;d=t.getWindowInfo(),this.src&&t.getImageInfo({src:this.src,success:function(t){console.log("图片尺寸信息",t),console.log("当前屏幕尺寸",d),u=t.width,p=t.height;var e=u/d.windowWidth,i=p/d.windowHeight;l=e>i?e:i,o.imageBoxWidth=u/l,o.imageBoxHeight=p/l,console.log("this.imageBoxWidth",o.imageBoxWidth),console.log("this.imageBoxHeight",o.imageBoxHeight),o.setRatio("1:1")},fail:function(t){console.log("error",t)}})},touchstart:function(t){r=t.touches[0].clientX,n=t.touches[0].clientY,"handle"==t.target.dataset.body?(this.mode="zoom",h=this.cropBoxWidth,a=this.cropBoxHeight):(this.mode="move",c=this.cropBoxX,s=this.cropBoxY)},touchmove:function(t){var o=t.touches[0].clientX-r,e=t.touches[0].clientY-n,i=c+o,u=s+e,p=h+o,l=a+e,d=this.imageBoxWidth-this.cropBoxWidth,g=this.imageBoxHeight-this.cropBoxHeight,f=this.imageBoxWidth-this.cropBoxX,x=this.imageBoxHeight-this.cropBoxY;switch(this.mode){case"move":this.cropBoxX=i<0?0:i>d?d:i,this.cropBoxY=u<0?0:u>g?g:u;break;case"zoom":"rect"==this.cropShape?(this.cropBoxWidth=p>f?f:p,this.cropBoxHeight=l>x?x:l):(this.cropBoxHeight=l>x?x:l,this.cropBoxWidth=l>x?x:l);break}},touchend:function(){var t=this;console.log("拖拽结束"),setTimeout((function(){t.cropping(!1)}),500)},setRatio:function(t){if("full"===t)this.cropBoxWidth=this.imageBoxWidth,this.cropBoxHeight=this.imageBoxHeight,this.cropBoxX=0,this.cropBoxY=0;else{var o=t.split(":")[0],e=t.split(":")[1],i=o/e,r=e/o;if(this.imageBoxWidth<this.imageBoxHeight){console.log("1");var n=this.imageBoxWidth;n/i>this.imageBoxHeight?(n=this.imageBoxHeight,this.cropBoxWidth=(n/r-this.cropSize)/2,this.cropBoxHeight=(n-this.cropSize)/2,this.cropBoxX=this.cropSize/2,this.cropBoxY=(this.imageBoxWidth-this.imageBoxWidth)/2):(this.cropBoxWidth=(n-this.cropSize)/2,this.cropBoxHeight=(n/i-this.cropSize)/2,this.cropBoxX=this.cropSize/2,this.cropBoxY=(this.imageBoxHeight-this.cropBoxHeight)/2)}else{console.log("2");var c=this.imageBoxHeight;c/i>this.imageBoxWidth?(c=this.imageBoxWidth,this.cropBoxWidth=(c-this.cropSize)/2,this.cropBoxHeight=c/r-this.cropSize,this.cropBoxX=(this.imageBoxWidth-this.cropBoxWidth)/2,this.cropBoxY=(this.imageBoxHeight-this.cropBoxHeight)/2):(this.cropBoxWidth=(c/i-this.cropSize)/2,this.cropBoxHeight=(c-this.cropSize)/2,this.cropBoxX=(this.imageBoxWidth-this.cropBoxWidth)/2,this.cropBoxY=(this.imageBoxWidth-this.cropBoxWidth)/2)}}},cropping:function(o){var e=this;return(0,x.default)(g.default.mark((function o(){var i,r,n,c,s,h,a,u;return g.default.wrap((function(o){while(1)switch(o.prev=o.next){case 0:return console.log("绘制中"),i=e,r=e.cropBoxX*l,n=e.cropBoxY*l,c=e.cropBoxWidth*l,s=e.cropBoxHeight*l,h=t.createOffscreenCanvas({type:"2d",width:c,height:s}),console.log("canvas",h),a=h.getContext("2d"),a.fillStyle="#fff",a.globalCompositeOperation="source-over",u&&(0,f.default)("image"),u=h.createImage(),o.next=15,new Promise((function(t,o){u.onload=t,u.onerror=o,u.src=e.src}));case 15:return a.clearRect(0,0,c,s),"circular"===e.cropShape&&(console.log("裁剪前",a),a.beginPath(),a.arc(c/2,s/2,c/2,0,2*Math.PI),a.fill(),a.clip(),a.clip(),console.log("裁剪后",a)),a.drawImage(u,r,n,c,s,0,0,c,s),console.log("context",a),t.canvasToTempFilePath({x:0,y:0,width:c,height:s,canvas:h,success:function(t){console.log("图片绘制",t);var o=t.tempFilePath;i.cropImgPath=o,console.log("绘制后的临时图片路径",o)},fail:function(t){console.error("转换图片失败:",t)}}),o.abrupt("return");case 26:case"end":return o.stop()}}),o)})))()},yuantu:function(){this.$emit("completed",{tempFilePath:this.src})},cancel:function(){this.$emit("cancel")},onPre:function(){this.cropImgPath&&t.previewImage({urls:[this.cropImgPath]})}}};o.default=m}).call(this,e(2)["default"])},380:function(t,o,e){"use strict";e.r(o);var i=e(381),r=e.n(i);for(var n in i)["default"].indexOf(n)<0&&function(t){e.d(o,t,(function(){return i[t]}))}(n);o["default"]=r.a},381:function(t,o,e){}}]);
  2. //# sourceMappingURL=../../../.sourcemap/mp-weixin/components/xiaogang-crop/index.js.map
  3. ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
  4. 'components/xiaogang-crop/index-create-component',
  5. {
  6. 'components/xiaogang-crop/index-create-component':(function(module, exports, __webpack_require__){
  7. __webpack_require__('2')['createComponent'](__webpack_require__(375))
  8. })
  9. },
  10. [['components/xiaogang-crop/index-create-component']]
  11. ]);