diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index cfb698b..6838ec4 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -3330,7 +3330,7 @@ Page({ //-- 如果有自定义海报的时候,判断背景的图片 -- if(th.data.share_b_img){ - //pg_path=th.data.share_b_img; + pg_path=th.data.share_b_img; } context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); diff --git a/pages/team/team_success/team_success.js b/pages/team/team_success/team_success.js index 36f7ab5..80841fe 100644 --- a/pages/team/team_success/team_success.js +++ b/pages/team/team_success/team_success.js @@ -56,7 +56,34 @@ Page({ }) var pay_f = t.payf, order_sn = t.ordersn; this.setData({ pay_f: pay_f, order_sn: order_sn}), - this.init(order_sn) + this.init(order_sn); + + //-- 自定义海报 -- + getApp().request.promiseGet("/api/weshop/goods/poster/page",{ + data:{store_id:os.stoid, type:1, is_user:1 } + }).then(res=>{ + if(res.data.code==0){ + + var poster_data=res.data.data.pageData[0]; + var json_str=poster_data.jsonStr; + if(json_str){ + var json_data=JSON.parse(json_str); + if(json_data.bg_img){ + + //-- 把图片那到本地 -- + wx.getImageInfo({ + src:json_data.bg_img, + success: function(res) { + var path= res.path; + th.setData({share_b_img:path}) + }, + fail: function(res) {} + }); + } + th.setData({poster:json_data}) + } + } + }) }, //关闭展开列表 click:function(e){ @@ -377,19 +404,53 @@ Page({ console.log(vpath); //先画背景 - var pg_path = "../../../images/share/share_bg.png"; + var pg_path = "../../../images/share/share_bg.png"; + //-- 如果有自定义海报的时候,判断背景的图片 -- + if(th.data.share_b_img){ + pg_path=th.data.share_b_img; + } + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); - //--昵称--- - context.setFontSize(24 * unit) - context.setFillStyle("black") - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; - //强烈推荐 - var tj_path = "../../../images/share/q_tj.png"; - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 110 * unit, 30 * unit); - context.setFontSize(18 * unit) - context.setFillStyle("white") - context.fillText('强烈推荐', 152 * unit + width + 20 * unit, 76 * unit); + + //-- 是自定义海报的情况下 -- + if(th.data.poster){ + //在线上分享人的情况下 + if(parseInt(th.data.poster.show_headpic)){ + //获取坐标 + var x=parseFloat(th.data.poster.head_x)*2; + var y=parseFloat(th.data.poster.head_y)*2; + var x1=(x+90) *unit; + var y1=(y+50) *unit; + //--昵称--- + context.setFontSize(24 * unit) + context.setFillStyle("black") + context.fillText(app.globalData.userInfo.nickname, x1, y1); + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; + //强烈推荐 改许程 + var tj_path = "../../../images/share/q_tj.png"; + context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit); + context.setFontSize(16 * unit) + context.setLineJoin('round'); //交点设置成圆角 + context.setFillStyle("white") + context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit); + } + + }else{ + //--昵称--- + context.setFontSize(24 * unit) + context.setFillStyle("black") + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; + //强烈推荐 + var tj_path = "../../../images/share/q_tj.png"; + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 110 * unit, 30 * unit); + context.setFontSize(18 * unit) + context.setFillStyle("white") + context.fillText('强烈推荐', 152 * unit + width + 20 * unit, 76 * unit); + } + + + //---产品名称--- context.setFontSize(21.3 * unit); @@ -468,7 +529,15 @@ Page({ context.setFontSize(22 * unit) context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit); //---二维吗图--- - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); + //-- 自定义海报 -- + if(th.data.poster){ + var erm_x= parseFloat(th.data.poster.ewm_x)*2; + var erm_y= parseFloat(th.data.poster.ewm_y)*2; + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); + }else{ + //---二维吗图--- + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); + } break case 2://阶梯团的展示 //---画线--- @@ -503,24 +572,58 @@ Page({ context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); //---二维吗图--- - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); + //-- 自定义海报 -- + if(th.data.poster){ + var erm_x= parseFloat(th.data.poster.ewm_x)*2; + var erm_y= parseFloat(th.data.poster.ewm_y)*2; + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); + }else{ + //---二维吗图--- + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); + } break } - //---绘制圆形要放在最后---- - context.save(); - context.beginPath(); - var h_x = 60 * unit; - var h_y = 24 * unit; - var h_r = 40 * unit; - var cx = h_x + h_r; - var cy = h_y + h_r; - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); - context.closePath(); - context.fill(); - context.clip(); - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); - context.restore(); + //--- 如果是自定义海报的时候 --- + if(th.data.poster){ + + //如果显示会员信息的话 + if(parseInt(th.data.poster.show_headpic)){ + //获取坐标 + var x= parseFloat(th.data.poster.head_x)*2; + var y=parseFloat(th.data.poster.head_y)*2; + //---绘制圆形要放在最后---- + context.save(); + context.beginPath(); + var h_x = x* unit; + var h_y = y * unit; + var h_r = 40 * unit; + var cx = h_x + h_r; + var cy = h_y + h_r; + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); + context.closePath(); + context.fill(); + context.clip(); + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); + context.restore(); + } + + }else{ + //---绘制圆形要放在最后---- + context.save(); + context.beginPath(); + var h_x = 60 * unit; + var h_y = 24 * unit; + var h_r = 40 * unit; + var cx = h_x + h_r; + var cy = h_y + h_r; + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); + context.closePath(); + context.fill(); + context.clip(); + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); + context.restore(); + } //把画板内容绘制成图片,并回调 画板图片路径 context.draw(false, function () {