小程序绘制海报wx.downloadFile下来素材,绘制文字图片
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);
}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

