|
|
@@ -140,7 +140,6 @@ Page({ |
|
|
|
ctx.fillRect(0, 0, that.data.windowWidth, that.data.windowHeight); |
|
|
|
ctx.drawImage(res.path, 0, 50, topImageWidth, topImageHeight); |
|
|
|
that.roundRect(ctx, 15 * scale, 270 * scale, 325 * scale, 125 * scale, 10); |
|
|
|
that.drawOtherImage(ctx, scale); |
|
|
|
that.drawOtherContent(ctx, scale, options); |
|
|
|
that.drawAvatarimg(ctx, scale); |
|
|
|
that.drawqrCode(ctx, scale); |
|
|
@@ -213,9 +212,7 @@ Page({ |
|
|
|
this.data.qrCode + `?imageView/2/w/${coImageWidth}/h/${coImageHeight}`; |
|
|
|
src2 = util.getProxyImgUrl(src1); |
|
|
|
} else { |
|
|
|
src1 = |
|
|
|
this.data.data.qrCode + |
|
|
|
`?imageView/2/w/${coImageWidth}/h/${coImageHeight}`; |
|
|
|
src1 =this.data.data.qrCode +`?imageView/2/w/${coImageWidth}/h/${coImageHeight}`; |
|
|
|
src2 = util.getProxyImgUrl(src1); |
|
|
|
} |
|
|
|
wx.getImageInfo({ |
|
|
@@ -226,27 +223,7 @@ Page({ |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 绘制活动图片 |
|
|
|
drawOtherImage(ctx, scale) { |
|
|
|
var that = this; |
|
|
|
// 如果该商户有活动商品 |
|
|
|
if (that.data.couponList.length > 0) { |
|
|
|
let cotentImageWidth = parseInt(80 * scale); |
|
|
|
let cotentImageHeight = parseInt(80 * scale); |
|
|
|
for (let i = 0; i < that.data.couponList.length; i++) { |
|
|
|
let imageItem = that.data.couponList[i].coverImg; |
|
|
|
let src1 = imageItem + `?imageView/2/w/${cotentImageWidth}/h/${cotentImageHeight}`; |
|
|
|
let src2 = util.getProxyImgUrl(src1); |
|
|
|
wx.getImageInfo({ |
|
|
|
src: src2, |
|
|
|
success: function(res) { |
|
|
|
ctx.drawImage(res.path, 35 * scale + i * 110 * scale, 300 * scale, cotentImageWidth, cotentImageHeight); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
that.drawqrCode(ctx, scale); |
|
|
|
}, |
|
|
|
|
|
|
|
//截取商品名 |
|
|
|
substrTile(str) { |
|
|
|
return str.substr(0, 5) + "..."; |
|
|
@@ -263,15 +240,7 @@ Page({ |
|
|
|
* 绘制多行文本,自动换行,超出添加... |
|
|
|
* |
|
|
|
*/ |
|
|
|
canvasTextAutoLine: function( |
|
|
|
str, |
|
|
|
ctx, |
|
|
|
initX, |
|
|
|
initY, |
|
|
|
lineHeight, |
|
|
|
maxWidth, |
|
|
|
row = 1 |
|
|
|
) { |
|
|
|
canvasTextAutoLine: function(str,ctx,initX,initY,font,style,align,baseLine,lineHeight,maxWidth,row = 1) { |
|
|
|
var lineWidth = 0; |
|
|
|
var lastSubStrIndex = 0; |
|
|
|
var currentRow = 1; |
|
|
@@ -283,6 +252,10 @@ Page({ |
|
|
|
if (currentRow > row && str.length > i) { |
|
|
|
newStr = str.substring(lastSubStrIndex, i - 2) + "..."; |
|
|
|
} |
|
|
|
ctx.setFontSize(font); |
|
|
|
ctx.setFillStyle(style); |
|
|
|
ctx.setTextAlign(align); |
|
|
|
ctx.setTextBaseline(baseLine); |
|
|
|
ctx.fillText(newStr, initX, initY); |
|
|
|
initY += lineHeight; |
|
|
|
lineWidth = 0; |
|
|
@@ -293,6 +266,10 @@ Page({ |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == str.length - 1) { |
|
|
|
ctx.setFontSize(font); |
|
|
|
ctx.setFillStyle(style); |
|
|
|
ctx.setTextAlign(align); |
|
|
|
ctx.setTextBaseline(baseLine); |
|
|
|
ctx.fillText(str.substring(lastSubStrIndex, i + 1), initX, initY); |
|
|
|
} |
|
|
|
} |
|
|
|