Commit d171166a967ba96668bc1900e4bbdf3819d3a214
1 parent
59f6ed4e
分享的优化
Showing
1 changed file
with
70 additions
and
41 deletions
packageA/pages/goodsInfo/goodsInfo.js
... | ... | @@ -3761,7 +3761,7 @@ Page({ |
3761 | 3761 | var vpath = res.path; |
3762 | 3762 | var context = wx.createCanvasContext('share'); |
3763 | 3763 | //先画背景 |
3764 | - var pg_path = "../../../../images/share/share_bg.png"; | |
3764 | + var pg_path = "../../../images/share/share_bg.png"; | |
3765 | 3765 | |
3766 | 3766 | //-- 如果有自定义海报的时候,判断背景的图片 -- |
3767 | 3767 | if (th.data.share_b_img) { |
... | ... | @@ -3786,7 +3786,7 @@ Page({ |
3786 | 3786 | context.fillText(nick, x1, y1); |
3787 | 3787 | var width = 24 * nick.length * unit + 4 * unit; |
3788 | 3788 | //强烈推荐 改许程 |
3789 | - var tj_path = "../../../../images/share/q_tj.png"; | |
3789 | + var tj_path = "../../../images/share/q_tj.png"; | |
3790 | 3790 | context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); |
3791 | 3791 | context.setFontSize(16 * unit) |
3792 | 3792 | context.setLineJoin('round'); //交点设置成圆角 |
... | ... | @@ -3804,7 +3804,7 @@ Page({ |
3804 | 3804 | context.fillText(nick, 152 * unit, 76 * unit); |
3805 | 3805 | var width = 24 * nick.length * unit + 2 * unit; |
3806 | 3806 | //强烈推荐 改许程 |
3807 | - var tj_path = "../../../../images/share/q_tj.png"; | |
3807 | + var tj_path = "../../../images/share/q_tj.png"; | |
3808 | 3808 | context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); |
3809 | 3809 | context.setFontSize(16 * unit); |
3810 | 3810 | context.setLineJoin('round'); //交点设置成圆角 |
... | ... | @@ -3812,8 +3812,18 @@ Page({ |
3812 | 3812 | context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); |
3813 | 3813 | } |
3814 | 3814 | |
3815 | - var share_title = th.data.presellForm.share_title; | |
3816 | - share_title=share_title ? share_title : th.data.data.goods_name; | |
3815 | + var share_title = th.data.data.goods_name; | |
3816 | + | |
3817 | + if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { | |
3818 | + share_title = th.data.prom_act.share_title; | |
3819 | + if (!share_title) share_title = th.data.prom_act.title; | |
3820 | + if (th.data.prom_type == 4) share_title = th.data.prom_act.name; | |
3821 | + | |
3822 | + //-- 显示活动时间 -- | |
3823 | + if (th.data.share_b_img) { | |
3824 | + act_time = "截止时间:" + ut.formatTime(th.data.prom_act.end_time); | |
3825 | + } | |
3826 | + } | |
3817 | 3827 | |
3818 | 3828 | //---产品名称--- |
3819 | 3829 | //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 |
... | ... | @@ -3827,15 +3837,18 @@ Page({ |
3827 | 3837 | context.setFontSize(22 * unit) |
3828 | 3838 | context.setFillStyle("red") |
3829 | 3839 | |
3840 | + // 7.商品价格 | |
3841 | + let price = th.data.data.shop_price; | |
3842 | + if (th.data.card_field && th.data.data[th.data.card_field]) { | |
3843 | + price = th.data.data[th.data.card_field]; | |
3844 | + } | |
3845 | + if (th.data.prom_act) price = th.data.prom_price; | |
3846 | + price = parseFloat(price).toFixed(2); | |
3830 | 3847 | |
3831 | - var pri0 = th.data.presellList.presell_money; | |
3832 | - // if (th.data.prom_act) | |
3833 | - // pri0 = th.data.prom_act.price; | |
3834 | - pri0 = parseFloat(pri0).toFixed(2); | |
3835 | - var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; | |
3848 | + var wd1 = th.data.screenWidth - ut.measureText(price, 31 * unit) - 25; | |
3836 | 3849 | context.fillText("¥", wd1 - 15, 160 * unit); |
3837 | 3850 | context.setFontSize(22 * unit) |
3838 | - context.fillText(pri0, wd1, 165 * unit); | |
3851 | + context.fillText(price, wd1, 165 * unit); | |
3839 | 3852 | |
3840 | 3853 | //---市场价划掉--- |
3841 | 3854 | // context.setFillStyle("red") |
... | ... | @@ -3844,23 +3857,18 @@ Page({ |
3844 | 3857 | // var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; |
3845 | 3858 | |
3846 | 3859 | |
3847 | - if(th.data.presellForm.presell_type==1){ | |
3848 | - // context.setStrokeStyle('gray'); | |
3849 | - // context.fillText(pri0, wd2, 213 * unit); | |
3850 | - // context.setLineWidth(1 * unit); | |
3851 | - // context.moveTo(wd2 - 5, 206 * unit); | |
3852 | - // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); | |
3853 | - // context.stroke(); | |
3854 | 3860 | |
3855 | - //-- 零售价的优化 -- | |
3856 | - var wp= th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 50; | |
3857 | - var hp= 180 * unit | |
3858 | - th.draw_pos_price(context,wp,hp,th.data.data.show_price,unit); | |
3861 | + // context.setStrokeStyle('gray'); | |
3862 | + // context.fillText(pri0, wd2, 213 * unit); | |
3863 | + // context.setLineWidth(1 * unit); | |
3864 | + // context.moveTo(wd2 - 5, 206 * unit); | |
3865 | + // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); | |
3866 | + // context.stroke(); | |
3859 | 3867 | |
3860 | - }else{ | |
3861 | - var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 50; | |
3862 | - context.fillText('定金', wd2, 190 * unit); | |
3863 | - } | |
3868 | + //-- 零售价的优化 -- | |
3869 | + var wp= th.data.screenWidth - ut.measureText(price, 22 * unit) - 50; | |
3870 | + var hp= 180 * unit | |
3871 | + th.draw_pos_price(context,wp,hp,th.data.data.show_price,unit); | |
3864 | 3872 | |
3865 | 3873 | |
3866 | 3874 | //console.log(th.data.share_goods_img); |
... | ... | @@ -3894,19 +3902,40 @@ Page({ |
3894 | 3902 | // context.lineTo(520 * unit, 662 * unit) |
3895 | 3903 | // context.stroke(); |
3896 | 3904 | |
3897 | - //---文字--- | |
3898 | - context.setFillStyle("black") | |
3899 | - // context.setFontSize(22 * unit) | |
3900 | - context.setFontSize(24 * unit) | |
3901 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 700 * unit); | |
3902 | - context.setFillStyle("red") | |
3903 | - context.setFontSize(20 * unit) | |
3904 | - var presell_price = `预售价:${th.data.presellList.presell_price}` | |
3905 | - context.fillText(presell_price, 40 * unit, 750 * unit); | |
3906 | - context.setFillStyle("black") | |
3907 | - context.setFontSize(22 * unit) | |
3908 | - context.fillText("特惠好物,限时预售", 40 * unit, 800 * unit); | |
3909 | - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 840 * unit); | |
3905 | + | |
3906 | + //-- 图片底部文字 -- | |
3907 | + switch (type){ | |
3908 | + case 0: | |
3909 | + //---文字--- | |
3910 | + context.setFillStyle("black") | |
3911 | + // context.setFontSize(22 * unit) | |
3912 | + context.setFontSize(24 * unit) | |
3913 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | |
3914 | + | |
3915 | + context.setFillStyle("black") | |
3916 | + context.setFontSize(22 * unit) | |
3917 | + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 800 * unit); | |
3918 | + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 840 * unit); | |
3919 | + | |
3920 | + break; | |
3921 | + | |
3922 | + case 1: | |
3923 | + context.setFillStyle("black") | |
3924 | + context.setFontSize(24 * unit) | |
3925 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 770 * unit); | |
3926 | + //---文字--- | |
3927 | + context.setFontSize(22 * unit) | |
3928 | + context.setFillStyle("black") | |
3929 | + if (th.data.is_share_text) { | |
3930 | + context.fillText("特惠好物,限时秒杀", 40 * unit, 807 * unit); | |
3931 | + } | |
3932 | + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 844 * unit); | |
3933 | + | |
3934 | + break; | |
3935 | + | |
3936 | + } | |
3937 | + | |
3938 | + | |
3910 | 3939 | |
3911 | 3940 | //---二维吗图--- |
3912 | 3941 | //-- 自定义海报 -- |
... | ... | @@ -3961,9 +3990,9 @@ Page({ |
3961 | 3990 | } |
3962 | 3991 | |
3963 | 3992 | |
3964 | - if(th.data.poster.show_time==1){ | |
3993 | + if(th.data.poster.show_time==1 && th.data.prom_act){ | |
3965 | 3994 | var act_time=''; |
3966 | - act_time="截止时间:"+ ut.formatTime(th.data.presellForm.end_time); | |
3995 | + act_time="截止时间:"+ ut.formatTime(th.data.prom_act.end_time); | |
3967 | 3996 | context.setFillStyle("red") |
3968 | 3997 | getApp().draw_Text(context, act_time,38 * unit, 880 * unit, 200 * unit, 340 * unit, unit); |
3969 | 3998 | } | ... | ... |