canvas canvas-id="myCanvas" class="ml26 " style='width:350px; height:350px;'/

wx.downloadFile({

url: 'http://192.168.1.240:8080/ypStatic/img/sale/code.jpg', //仅为示例,并非真实的资源

success (res) {

if (res.statusCode === 200) {

const ctx = wx.createCanvasContext('myCanvas');

ctx.fillStyle="#FFFFFF";

ctx.fillRect(0,0,350,350);

ctx.drawImage(res.tempFilePath, 36, 32, 268, 268);

ctx.fillStyle="#999999";

ctx.setFontSize(14);

ctx.fillText("长按识别小程序码",119,332);

ctx.draw();

setTimeout(function () {

wx.canvasToTempFilePath({

x: 0,

y: 0,

width: 350,

height: 350,

canvasId: 'myCanvas',

success: function (res) {

console.log(res.tempFilePath);

utils.preview(res.tempFilePath);

}

})

}, 2000)

}

}

})

 

 

//预览

previewImg(src){

utils.preview(src);

}

TAG标签: 微信小程序小程序海报

http://www.xiaochengxub.com/read-100125.html