(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/commponent/goods/poster"],{"14cb":function(t,e,o){"use strict";o.r(e);var i=o("afb7"),s=o("a528");for(var n in s)"default"!==n&&function(t){o.d(e,t,(function(){return s[t]}))}(n);o("7202");var a,l=o("f0c5"),c=Object(l["a"])(s["default"],i["b"],i["c"],!1,null,"545628b2",null,!1,i["a"],a);e["default"]=c.exports},7202:function(t,e,o){"use strict";var i=o("f9e7"),s=o.n(i);s.a},a528:function(t,e,o){"use strict";o.r(e);var i=o("ad7c"),s=o.n(i);for(var n in i)"default"!==n&&function(t){o.d(e,t,(function(){return i[t]}))}(n);e["default"]=s.a},ad7c:function(t,e,o){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=getApp(),s=function(){o.e("pages/commponent/public/loading").then(function(){return resolve(o("7c23"))}.bind(null,o)).catch(o.oe)},n={data:function(){return{windowWidth:"",windowHeight:"",colors:"",ctx:"",imgUrl:"",userInfo:{name:"反转",logo:"/static/images/face.jpg",goodsImg:"/static/images/goods/one.jpg",price:"3599.00",goodsName:"魅族17 8GB+128GB 十七度灰 骁龙865 旗舰5G手机 30W快充 6400W后置主摄 90Hz屏幕 支持NFC 智能拍照游戏手机"}}},components:{loading:s},props:{posterData:{type:Object}},created:function(){this.getSystem(),this.setData({colors:i.globalData.newColor}),this.setPoster()},onReachBottom:function(){},onShareAppMessage:function(){},methods:{getSystem:function(){var e=this;t.getSystemInfo({success:function(t){console.log(t),e.setData({windowHeight:t.windowHeight,windowWidth:t.windowWidth})}})},setPoster:function(){t.showLoading({title:"海报生成中..."});var e=t.createCanvasContext("mycanvas",this);e.fillStyle="#FFFFFF",e.fillRect(0,0,this.windowWidth-60,520);var o=function(t,e,o,i,s,n,a){t.setFillStyle(o),t.setTextAlign("left"),t.font=a?"normal bold 20px Arial,sans-serif":"normal 20px Arial,sans-serif",t.setFontSize(e),t.fillText(n,i,s),t.restore()};o(e,14,"#333",85,35,this.userInfo.name,"bold"),o(e,12,"#999",85,58,"为您挑选了一个好礼物"),e.save(),e.beginPath();var i=60,s=60,n=15,a=15,l=8;this.setRadius(e,i,s,n,a,l),this.setGoodsImg(e);var c="￥ "+this.posterData.money;this.setGoodsPrice(e,20,this.colors,15,410,c),this.setGoodsName(e)},setEwm:function(e){var o=this;console.log("生成二维码");var i=100,s=100,n=this.windowWidth-170;e.drawImage("/static/images/ewm.png",n,410,i,s),setTimeout((function(){e.save(),e.draw(!1,(function(){setTimeout((function(){t.canvasToTempFilePath({canvasId:"mycanvas",success:function(t){console.log(t),o.imgUrl=t.tempFilePath}},o)}),200)})),t.hideLoading()}),1e3)},setRadius:function(t,e,o,i,s,n){t.arc(i+n,s+n,n,Math.PI,3*Math.PI/2),t.lineTo(e-n+i,s),t.arc(e-n+i,n+s,n,3*Math.PI/2,2*Math.PI),t.lineTo(e+i,o+s-n),t.arc(e-n+i,o-n+s,n,0,1*Math.PI/2),t.lineTo(n+i,o+s),t.arc(n+i,o-n+s,n,1*Math.PI/2,Math.PI),t.strokeStyle="#fff",t.fill(),t.clip(),t.drawImage(this.userInfo.logo,i,s,e,o),t.closePath(),t.restore()},setCircular:function(t,e,o,i,s){t.arc(e/2+i,o/2+s,e/2,0,2*Math.PI,!1),t.strokeStyle="#fff",t.fill(),t.clip(),t.drawImage(this.userInfo.logo,i,s,e,o),t.closePath(),t.restore()},setGoodsImg:function(t){var e=this.windowWidth-90;t.drawImage(this.posterData.img,15,95,e,e),t.save()},setGoodsPrice:function(t,e,o,i,s,n,a){t.setFillStyle(o),t.setTextAlign("left"),t.font=a?"normal bold 20px Arial,sans-serif":"normal 20px Arial,sans-serif",t.setFontSize(e),t.fillText(n,i,s),t.restore()},setGoodsName:function(t){for(var e={x:20,y:440,width:210,height:20,line:2,color:"#202020",size:14,align:"left",baseline:"top",text:this.posterData.title,bold:!0},o=Math.ceil(e.width/e.size),i=Math.ceil(e.text.length/o),s=0;s<i;s++){var n={x:e.x,y:e.y+s*e.height,color:e.color,size:e.size,align:e.align,baseline:e.baseline,text:e.text.substring(s*o,(s+1)*o),bold:e.bold};s<e.line&&(s==e.line-1&&(n.text=n.text.substring(0,n.text.length-3)+"......"),this.drawText(t,n))}this.setEwm(t)},drawText:function(t,e){console.log("渲染文字",e),t.save(),t.setFillStyle(e.color),t.setFontSize(e.size),t.setTextAlign(e.align),t.setTextBaseline(e.baseline),e.bold&&(console.log("字体加粗"),t.fillText(e.text,e.x,e.y-.1),t.fillText(e.text,e.x-.1,e.y)),t.fillText(e.text,e.x,e.y),e.bold&&(t.fillText(e.text,e.x,e.y+.1),t.fillText(e.text,e.x+.1,e.y)),t.restore()},saveImg:function(){t.showLoading({title:"保存中..."});var e=this;t.getSetting({success:function(o){t.hideLoading(),console.log(o),o.authSetting["scope.writePhotosAlbum"]?setTimeout((function(){t.saveImageToPhotosAlbum({filePath:e.imgUrl,success:function(e){t.hideLoading(),t.showToast({title:"保存成功",icon:"success"})},fail:function(e){console.log(e),t.showToast({title:"保存失败",icon:"none"})}})}),1e3):wx.authorize({scope:"scope.writePhotosAlbum",success:function(t){console.log(t)}})}})}}};e.default=n}).call(this,o("543d")["default"])},afb7:function(t,e,o){"use strict";var i;o.d(e,"b",(function(){return s})),o.d(e,"c",(function(){return n})),o.d(e,"a",(function(){return i}));var s=function(){var t=this,e=t.$createElement;t._self._c},n=[]},f9e7:function(t,e,o){}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
    'pages/commponent/goods/poster-create-component',
    {
        'pages/commponent/goods/poster-create-component':(function(module, exports, __webpack_require__){
            __webpack_require__('543d')['createComponent'](__webpack_require__("14cb"))
        })
    },
    [['pages/commponent/goods/poster-create-component']]
]);
