Commit 1d69edcd6417621c0635a1973ccfb6a64b5d8251
1 parent
f34e3334
秒杀和拼单分享海报修改
Showing
1 changed file
with
24 additions
and
5 deletions
pages/goods/goodsInfo/goodsInfo.js
@@ -4762,6 +4762,7 @@ Page({ | @@ -4762,6 +4762,7 @@ Page({ | ||
4762 | if(type == 1) { // 秒杀 | 4762 | if(type == 1) { // 秒杀 |
4763 | src = '../../../images/share/miao_share.png'; | 4763 | src = '../../../images/share/miao_share.png'; |
4764 | context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); | 4764 | context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); |
4765 | + context.setTextAlign('left'); | ||
4765 | }; | 4766 | }; |
4766 | if(type == 2) { // 商家和会员团 | 4767 | if(type == 2) { // 商家和会员团 |
4767 | src = '../../../images/share/ct_num.png'; | 4768 | src = '../../../images/share/ct_num.png'; |
@@ -4808,13 +4809,28 @@ Page({ | @@ -4808,13 +4809,28 @@ Page({ | ||
4808 | price = parseFloat(price).toFixed(2); | 4809 | price = parseFloat(price).toFixed(2); |
4809 | context.setFontSize(32 * unit); | 4810 | context.setFontSize(32 * unit); |
4810 | context.setFillStyle('#DE1117'); | 4811 | context.setFillStyle('#DE1117'); |
4811 | - context.fillText('¥' + price, 54 * unit, 730 * unit); | 4812 | + context.fillText('¥' + price, 54 * unit, 735 * unit); |
4813 | + | ||
4814 | + | ||
4812 | }; | 4815 | }; |
4813 | 4816 | ||
4817 | + //---市场价划掉--- | ||
4818 | + context.setFillStyle("gray") | ||
4819 | + context.setFontSize(22 * unit) | ||
4820 | + var pri0 = "¥" + this.data.data.market_price.toFixed(2); | ||
4821 | + var wd2 = this.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; | ||
4822 | + context.fillText(pri0, 54 * unit, 770 * unit); | ||
4823 | + | ||
4824 | + context.setStrokeStyle('gray'); | ||
4825 | + context.setLineWidth(1 * unit); | ||
4826 | + context.moveTo(54 * unit, 763 * unit); | ||
4827 | + context.lineTo(ut.measureText(pri0, 22 * unit) + 50, 763 * unit); | ||
4828 | + context.stroke(); | ||
4829 | + | ||
4814 | // 8.商品标题 | 4830 | // 8.商品标题 |
4815 | context.setFontSize(20 * unit); | 4831 | context.setFontSize(20 * unit); |
4816 | context.setFillStyle('#898989'); | 4832 | context.setFillStyle('#898989'); |
4817 | - this.draw_Text(context, this.data.data.goods_name, 54 * unit, 770 * unit, 240 * unit, 240 * unit, unit); | 4833 | + this.draw_Text(context, this.data.data.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); |
4818 | 4834 | ||
4819 | // 9.小程序码 | 4835 | // 9.小程序码 |
4820 | context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); | 4836 | context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); |
@@ -5385,18 +5401,21 @@ Page({ | @@ -5385,18 +5401,21 @@ Page({ | ||
5385 | 5401 | ||
5386 | 5402 | ||
5387 | //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | 5403 | //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 |
5388 | - draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { | 5404 | + draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit, lineNum) { |
5389 | var lineWidth = 0; | 5405 | var lineWidth = 0; |
5390 | var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | 5406 | var lastSubStrIndex = 0; //每次开始截取的字符串的索引 |
5391 | var han = 0; | 5407 | var han = 0; |
5392 | for (let i = 0; i < str.length; i++) { | 5408 | for (let i = 0; i < str.length; i++) { |
5409 | + if(lineNum) { | ||
5410 | + if(han == lineNum) return; | ||
5411 | + }; | ||
5393 | if (han == 2) return; | 5412 | if (han == 2) return; |
5394 | //lineWidth += ctx.measureText(str[i]).width; | 5413 | //lineWidth += ctx.measureText(str[i]).width; |
5395 | lineWidth += ut.measureText(str[i], 21.3 * unit); | 5414 | lineWidth += ut.measureText(str[i], 21.3 * unit); |
5396 | if (lineWidth > canvasWidth) { | 5415 | if (lineWidth > canvasWidth) { |
5397 | han++; | 5416 | han++; |
5398 | 5417 | ||
5399 | - if (han == 2) | 5418 | + if (han == 2 || han == lineNum) |
5400 | ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | 5419 | ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 |
5401 | else | 5420 | else |
5402 | ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | 5421 | ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); |
@@ -5409,7 +5428,7 @@ Page({ | @@ -5409,7 +5428,7 @@ Page({ | ||
5409 | if (i == str.length - 1) { //绘制剩余部分 | 5428 | if (i == str.length - 1) { //绘制剩余部分 |
5410 | ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | 5429 | ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); |
5411 | } | 5430 | } |
5412 | - } | 5431 | + }; |
5413 | }, | 5432 | }, |
5414 | 5433 | ||
5415 | // ----视频图片---- | 5434 | // ----视频图片---- |