这是开发工具的效果(想要的效果)
这是真机效果
var ctx = wx.createCanvasContext('shareFrends')
ctx.setFillStyle('#ffffff')
ctx.fillRect(0, 0, 670, 1192)
let sharebg='https://tmjapp-dev.niceued.com/xcximages/index/sharebg2.png'
wx.getImageInfo({
src: sharebg,
success: function (res) {
ctx.drawImage(res.path, 0, 0, 670, 1192)
ctx.draw(true)
wx.getImageInfo({
src: 'https://tmjapp-dev.niceued.com/xcximages/icon_add.png',
success: function (res) {
let pic =res.path
ctx.drawImage(pic, 120, 115,28, 28)
ctx.draw(true)
wx.getImageInfo({
src:that.data.dataForm.user.avatar,
success: function (res) {
let pic =res.path
ctx.save();
ctx.arc(72, 112, 32, 0, 2 * Math.PI);
ctx.clip();
ctx.fillRect(40, 80, 64, 64);
ctx.drawImage(pic, 40, 80,64, 64)
ctx.draw(true)
// 绘制文字
ctx.font = "normal 500 26px PingFang SC";
ctx.setFillStyle('#342012')
ctx.fillText(that.data.dataForm.user.uname, 120, 100);
ctx.font = "normal 400 22px PingFang SC";
ctx.setFillStyle('#EAB06E')
ctx.fillText(that.data.dataForm.user.part_name?that.data.dataForm.user.part_name:'', 152, 138);
ctx.font = "normal bold 32px PingFang SC";
ctx.setFillStyle('#3E3737')
let erweimaTxt1 = that.data.dataForm.title.length > 30 ? `${that.data.dataForm.title.slice(0,30)}...` : that.data.dataForm.title; //文字标题
that.wordsWrap(ctx,erweimaTxt1, 72, 270,48);
ctx.font = "normal bold 28px PingFang SC";
ctx.fillText('办理建议', 72, 610);
ctx.font = "normal 400 24px PingFang SC";
ctx.setFillStyle('#999999')
ctx.textAlign = 'right'
ctx.fillText(that.data.dataForm.create_time, 598, 270);
ctx.font = "normal 400 26px PingFang SC";
ctx.textAlign = 'left'
ctx.setFillStyle('rgba(52, 32, 18, 0.7)')
let erweimaTxt2 = that.data.dataForm.content.length > 88 ? `${that.data.dataForm.content.slice(0,88)}...` : that.data.dataForm.content; //文字标题
that.wordsWrap(ctx,erweimaTxt2, 72, 330,48);
let remark=that.data.operateRecord[0].remark?that.data.operateRecord[0].remark:that.data.operateRecord[0].status_name
let erweimaTxt3 = remark.length > 44 ? `${remark.slice(0,44)}...` : remark; //文字标题
that.wordsWrap(ctx,erweimaTxt3, 72, 660,48);
ctx.draw(true)
ctx.draw(true, setTimeout(() => {
wx.canvasToTempFilePath({
x: 0,
y: 0,
canvasId: 'shareFrends',
success: function (res) {
var shareImg = res.tempFilePath;
that.setData({
shareImg: shareImg,
hideModal: false
})
wx.hideLoading()
},
fail: function (res) {
}
})
}, 100))
}
})
}
})
}
})
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。