From a9848961e1db7767207bf82795c3cb9186b4e846 Mon Sep 17 00:00:00 2001 From: meo <18801474720@163.com> Date: Tue, 28 May 2019 15:12:54 +0800 Subject: [PATCH] =?UTF-8?q?[canvas][=E4=BF=AE=E6=94=B9]:[=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=B5=B7=E6=8A=A5=E5=88=86=E4=BA=AB=E5=88=B0=E6=9C=8B?= =?UTF-8?q?=E5=8F=8B=E5=9C=88=E6=96=87=E5=AD=97=E7=9A=84=E4=BF=AE=E6=94=B9?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/canvas/index.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pages/canvas/index.js b/pages/canvas/index.js index e98d8de..0947b20 100644 --- a/pages/canvas/index.js +++ b/pages/canvas/index.js @@ -195,15 +195,20 @@ Page({ this.drawNormalText(ctx, "适用门店:", 30 * scale, 348 * scale, 16 * scale, "#000", "left", "middle", scale); //适用门店字体的排列 - this.data.data.merchantVoList.map(function (file, index) { - let word = file.merchantName; - let metrics = ctx.measureText(word).width; - metrics += metrics; - that.drawNormalText(ctx, that.data.data.merchantVoList[index].merchantName,metrics, 375 * scale, 14 * scale, "#000", "left", "middle", scale); - }) + for (let i = 0; i < that.data.data.merchantVoList.length;i++){ + let metrics; + if(i==0){ + metrics = 35; + that.drawNormalText(ctx, that.data.data.merchantVoList[i].merchantName, metrics, 375 * scale, 14 * scale, "#000", "left", "middle", scale); + }else{ + let word = that.data.data.merchantVoList[i - 1].merchantName; + let metrics = (ctx.measureText(word).width) * scale; + metrics += metrics; + that.drawNormalText(ctx,'、'+that.data.data.merchantVoList[i].merchantName, metrics, 375 * scale, 14 * scale, "#000", "left", "middle", scale); + } + } ctx.draw(true); } - ctx.draw(true); }, //绘制小程序码