appid:wx88fec0ce8ea112bd
调试基础库2.6.5
微信:7.0.10
基础库2.10.4
如下代码
// 绘制分享图片
function createSharePicUrl(thatobj,shdata) {
var that = thatobj;
var context = wx.createCanvasContext('mycanvas');
context.rect(0, 0, 600, 900);
let hcount = 0;
let yheight = 35;
context.setFillStyle('#000000');
context.setFontSize(36);
context.fillText('【订单类型】'+shdata.ordertype, 0,yheight, 400);
if (shdata.workaddress !='')
{
yheight = yheight+35;
context.fillText('【工作地址】'+shdata.workaddress, 0, yheight, 500);
}
yheight = yheight+38;var content = '';hcount = 0;
context.fillText('【订单要求】', 0, yheight, 300);
var content = shdata.customer_demand;
let reg = new RegExp('\n','g')
content = content.replace(reg,'');
hcount = drawLongText(content, context, 0,yheight);
//console.log(content);
//console.log(hcount);
content = '【订单金额】'+shdata.servicepeople_price;
yheight = 110+hcount*38;
context.fillText(content, 0, yheight, 500);
yheight = yheight+38;
context.fillText('【上岗日期】', 0, yheight, 500);
content = shdata.expected_date_of_birth+'至'+shdata.endtime;
hcount = drawLongText(content, context, 0,yheight);
hcount = hcount+1;
if (shdata.jiguanrequire !='')
{
content = '【籍贯要求】'+shdata.jiguanrequire;
yheight = yheight+hcount*38;
context.fillText(content, 0, yheight, 500);
hcount = 0;
yheight = yheight+38;
}
else
{
yheight = yheight+hcount*38;
}
if (shdata.agerequire !='')
{
content = '【年龄要求】'+shdata.agerequire;
context.fillText(content, 0, yheight, 500);
}
context.draw();
//将生成好的图片保存到本地,需要延迟一会,绘制期间耗时
wx.showToast({
title: '',
icon: 'loading',
duration: 2000
});
//绘制图片
context.draw(false, wx.canvasToTempFilePath({
x:0,y:0,
Width: 600,
Height:900,
destWidth: 600,
destHeight:900,
canvasId: 'mycanvas',
// success: function (res) {
success: (res)=> {
var tempFilePath = res.tempFilePath;
that.setData({
imagePath: tempFilePath,
maskHidden: false
});
wx.hideToast()
},
fail: function (res) {
}
}, this) );
<canvas canvas-id="mycanvas" style="position:fixed;left:9000px; width: 600px;height: 900px;" />
有的订单信息能生成图片,有的订单生成的是空白图片,请问是什么原因?