diff --git a/packageA/pages/goodsInfo/goodsInfo.js b/packageA/pages/goodsInfo/goodsInfo.js index 459b82c..e58b483 100644 --- a/packageA/pages/goodsInfo/goodsInfo.js +++ b/packageA/pages/goodsInfo/goodsInfo.js @@ -3761,7 +3761,7 @@ Page({ var vpath = res.path; var context = wx.createCanvasContext('share'); //先画背景 - var pg_path = "../../../../images/share/share_bg.png"; + var pg_path = "../../../images/share/share_bg.png"; //-- 如果有自定义海报的时候,判断背景的图片 -- if (th.data.share_b_img) { @@ -3786,7 +3786,7 @@ Page({ context.fillText(nick, x1, y1); var width = 24 * nick.length * unit + 4 * unit; //强烈推荐 改许程 - var tj_path = "../../../../images/share/q_tj.png"; + 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'); //交点设置成圆角 @@ -3804,7 +3804,7 @@ Page({ context.fillText(nick, 152 * unit, 76 * unit); var width = 24 * nick.length * unit + 2 * unit; //强烈推荐 改许程 - var tj_path = "../../../../images/share/q_tj.png"; + var tj_path = "../../../images/share/q_tj.png"; context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); context.setFontSize(16 * unit); context.setLineJoin('round'); //交点设置成圆角 @@ -3812,8 +3812,18 @@ Page({ context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); } - var share_title = th.data.presellForm.share_title; - share_title=share_title ? share_title : th.data.data.goods_name; + var share_title = th.data.data.goods_name; + + if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { + share_title = th.data.prom_act.share_title; + if (!share_title) share_title = th.data.prom_act.title; + if (th.data.prom_type == 4) share_title = th.data.prom_act.name; + + //-- 显示活动时间 -- + if (th.data.share_b_img) { + act_time = "截止时间:" + ut.formatTime(th.data.prom_act.end_time); + } + } //---产品名称--- //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 @@ -3827,15 +3837,18 @@ Page({ context.setFontSize(22 * unit) context.setFillStyle("red") + // 7.商品价格 + let price = th.data.data.shop_price; + if (th.data.card_field && th.data.data[th.data.card_field]) { + price = th.data.data[th.data.card_field]; + } + if (th.data.prom_act) price = th.data.prom_price; + price = parseFloat(price).toFixed(2); - var pri0 = th.data.presellList.presell_money; - // if (th.data.prom_act) - // pri0 = th.data.prom_act.price; - pri0 = parseFloat(pri0).toFixed(2); - var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; + var wd1 = th.data.screenWidth - ut.measureText(price, 31 * unit) - 25; context.fillText("¥", wd1 - 15, 160 * unit); context.setFontSize(22 * unit) - context.fillText(pri0, wd1, 165 * unit); + context.fillText(price, wd1, 165 * unit); //---市场价划掉--- // context.setFillStyle("red") @@ -3844,23 +3857,18 @@ Page({ // var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; - if(th.data.presellForm.presell_type==1){ - // context.setStrokeStyle('gray'); - // context.fillText(pri0, wd2, 213 * unit); - // context.setLineWidth(1 * unit); - // context.moveTo(wd2 - 5, 206 * unit); - // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); - // context.stroke(); - //-- 零售价的优化 -- - var wp= th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 50; - var hp= 180 * unit - th.draw_pos_price(context,wp,hp,th.data.data.show_price,unit); + // context.setStrokeStyle('gray'); + // context.fillText(pri0, wd2, 213 * unit); + // context.setLineWidth(1 * unit); + // context.moveTo(wd2 - 5, 206 * unit); + // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); + // context.stroke(); - }else{ - var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 50; - context.fillText('定金', wd2, 190 * unit); - } + //-- 零售价的优化 -- + var wp= th.data.screenWidth - ut.measureText(price, 22 * unit) - 50; + var hp= 180 * unit + th.draw_pos_price(context,wp,hp,th.data.data.show_price,unit); //console.log(th.data.share_goods_img); @@ -3894,19 +3902,40 @@ Page({ // context.lineTo(520 * unit, 662 * unit) // context.stroke(); - //---文字--- - context.setFillStyle("black") - // context.setFontSize(22 * unit) - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 700 * unit); - context.setFillStyle("red") - context.setFontSize(20 * unit) - var presell_price = `预售价:${th.data.presellList.presell_price}` - context.fillText(presell_price, 40 * unit, 750 * unit); - context.setFillStyle("black") - context.setFontSize(22 * unit) - context.fillText("特惠好物,限时预售", 40 * unit, 800 * unit); - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 840 * unit); + + //-- 图片底部文字 -- + switch (type){ + case 0: + //---文字--- + context.setFillStyle("black") + // context.setFontSize(22 * unit) + context.setFontSize(24 * unit) + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); + + context.setFillStyle("black") + context.setFontSize(22 * unit) + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 800 * unit); + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 840 * unit); + + break; + + case 1: + context.setFillStyle("black") + context.setFontSize(24 * unit) + context.fillText(th.data.sto_sele_name_1, 40 * unit, 770 * unit); + //---文字--- + context.setFontSize(22 * unit) + context.setFillStyle("black") + if (th.data.is_share_text) { + context.fillText("特惠好物,限时秒杀", 40 * unit, 807 * unit); + } + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 844 * unit); + + break; + + } + + //---二维吗图--- //-- 自定义海报 -- @@ -3961,9 +3990,9 @@ Page({ } - if(th.data.poster.show_time==1){ + if(th.data.poster.show_time==1 && th.data.prom_act){ var act_time=''; - act_time="截止时间:"+ ut.formatTime(th.data.presellForm.end_time); + act_time="截止时间:"+ ut.formatTime(th.data.prom_act.end_time); context.setFillStyle("red") getApp().draw_Text(context, act_time,38 * unit, 880 * unit, 200 * unit, 340 * unit, unit); }