康巴易测肤/伤疤uniapp小程序类
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12 行
6.7KB

  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/xiaogang-crop/index"],{374:function(t,e,o){"use strict";o.r(e);var i=o(375),r=o(377);for(var n in r)["default"].indexOf(n)<0&&function(t){o.d(e,t,(function(){return r[t]}))}(n);o(379);var c,s=o(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",e["default"]=h.exports},375:function(t,e,o){"use strict";o.r(e);var i=o(376);o.d(e,"render",(function(){return i["render"]})),o.d(e,"staticRenderFns",(function(){return i["staticRenderFns"]})),o.d(e,"recyclableRender",(function(){return i["recyclableRender"]})),o.d(e,"components",(function(){return i["components"]}))},376:function(t,e,o){"use strict";var i;o.r(e),o.d(e,"render",(function(){return r})),o.d(e,"staticRenderFns",(function(){return c})),o.d(e,"recyclableRender",(function(){return n})),o.d(e,"components",(function(){return i}));try{i={"u-Image":function(){return Promise.all([o.e("common/vendor"),o.e("node-modules/uview-ui/components/u--image/u--image")]).then(o.bind(null,327))}}}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,e=t.$createElement;t._self._c},n=!1,c=[];r._withStripped=!0},377:function(t,e,o){"use strict";o.r(e);var i=o(378),r=o.n(i);for(var n in i)["default"].indexOf(n)<0&&function(t){o.d(e,t,(function(){return i[t]}))}(n);e["default"]=r.a},378:function(t,e,o){"use strict";(function(t,i){var r=o(4);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n,c,s,h,a,u,p,d,g,l,f=r(o(56)),m=r(o(58)),x={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 e=this;l=t.getWindowInfo(),this.src&&t.getImageInfo({src:this.src,success:function(t){console.log("图片尺寸信息",t),console.log("当前屏幕尺寸",l),p=t.width,d=t.height;var o=p/l.windowWidth,i=d/l.windowHeight;g=o>i?o:i,e.imageBoxWidth=p/g,e.imageBoxHeight=d/g,console.log("this.imageBoxWidth",e.imageBoxWidth),console.log("this.imageBoxHeight",e.imageBoxHeight),e.setRatio("1:1")},fail:function(t){console.log("error",t)}})},touchstart:function(t){n=t.touches[0].clientX,c=t.touches[0].clientY,"handle"==t.target.dataset.body?(this.mode="zoom",a=this.cropBoxWidth,u=this.cropBoxHeight):(this.mode="move",s=this.cropBoxX,h=this.cropBoxY)},touchmove:function(t){var e=t.touches[0].clientX-n,o=t.touches[0].clientY-c,i=s+e,r=h+o,p=a+e,d=u+o,g=this.imageBoxWidth-this.cropBoxWidth,l=this.imageBoxHeight-this.cropBoxHeight,f=this.imageBoxWidth-this.cropBoxX,m=this.imageBoxHeight-this.cropBoxY;switch(this.mode){case"move":this.cropBoxX=i<0?0:i>g?g:i,this.cropBoxY=r<0?0:r>l?l:r;break;case"zoom":"rect"==this.cropShape?(this.cropBoxWidth=p>f?f:p,this.cropBoxHeight=d>m?m:d):(this.cropBoxHeight=d>m?m:d,this.cropBoxWidth=d>m?m:d);break}},touchend:function(){var t=this;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 e=t.split(":")[0],o=t.split(":")[1],i=e/o,r=o/e;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(e){var o=this;return(0,m.default)(f.default.mark((function r(){var n,c,s,h,a,u,p,d,l,m,x;return f.default.wrap((function(r){while(1)switch(r.prev=r.next){case 0:return n=o,c=o.cropBoxX*g,s=o.cropBoxY*g,h=o.cropBoxWidth*g,a=o.cropBoxHeight*g,u=t.createOffscreenCanvas({type:"2d",width:h,height:a}),p=u.getContext("2d"),p.fillStyle="#fff",p.globalCompositeOperation="source-over",d=u.createImage(),r.next=12,new Promise((function(t,e){d.onload=t,d.onerror=e,d.src=o.src}));case 12:p.clearRect(0,0,h,a),"circular"==o.cropShape&&(p.beginPath(),p.arc(h/2,a/2,h/2,0,2*Math.PI),p.fill(),p.clip(),p.clip()),p.drawImage(d,c,s,h,a,0,0,h,a),l=u.toDataURL(),m=i.getFileSystemManager(),x="".concat(i.env.USER_DATA_PATH,"/")+(new Date).getTime()+".jpg",m.writeFile({filePath:x,data:l.replace("data:image/png;base64,",""),encoding:"base64",success:function(t){n.$emit("completed",{tempFilePath:x}),n.cropImgPath=x},fail:function(t){console.error(t)}}),setTimeout((function(){e&&(n.$store.commit("setResultPath",n.cropImgPath),t.navigateTo({url:"/pages/details/index"}))}),800);case 20:case"end":return r.stop()}}),r)})))()},yuantu:function(){this.$emit("completed",{tempFilePath:this.src})},cancel:function(){this.$emit("cancel")},onPre:function(){this.cropImgPath&&t.previewImage({urls:[this.cropImgPath]})}}};e.default=x}).call(this,o(2)["default"],o(1)["default"])},379:function(t,e,o){"use strict";o.r(e);var i=o(380),r=o.n(i);for(var n in i)["default"].indexOf(n)<0&&function(t){o.d(e,t,(function(){return i[t]}))}(n);e["default"]=r.a},380:function(t,e,o){}}]);
  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__(374))
  8. })
  9. },
  10. [['components/xiaogang-crop/index-create-component']]
  11. ]);