不仅是背景图和人物信息没有画上去,左上角有个头像也没画上去
画布在开发工具上绘画正常,在真机调试里画的不对怎么回事?[代码]/**[代码][代码] [代码][代码]* 绘制分享图片[代码][代码] [代码][代码]*/[代码][代码]function[代码] [代码]drawImage(page){[代码][代码] [代码][代码]if[代码] [代码](page != [代码][代码]null[代码] [代码]&& page != [代码][代码]''[代码] [代码]&& page != undefined){[代码][代码] [代码][代码]var[代码] [代码]that = page;[代码][代码] [代码][代码]const ctx = wx.createCanvasContext([代码][代码]'myCanvas'[代码][代码])[代码] [代码] [代码][代码]var[代码] [代码]partner_data = that.data.partner_data;[代码][代码] [代码][代码]var[代码] [代码]bj = partner_data.photo;[代码][代码] [代码][代码]//背景图片和昵称[代码][代码] [代码][代码]var[代码] [代码]txPath = bj ? bj : that.data.imgSrcList[7];[代码][代码] [代码][代码]var[代码] [代码]bjPath = that.data.imgSrcList[8];[代码][代码] [代码][代码]var[代码] [代码]qrCode = that.data.qrcode_temp;[代码][代码] [代码][代码]var[代码] [代码]hostNickname = app.globalData.userInfo.nickName;[代码] [代码] [代码][代码]//绘制背景图片[代码][代码] [代码][代码]ctx.setFillStyle([代码][代码]'#FFFEFF'[代码][代码]);[代码][代码] [代码][代码]ctx.drawImage(bjPath,0,0,380,426);[代码][代码] [代码][代码]ctx.drawImage(txPath, 0, 0, 137, 192);[代码] [代码] [代码][代码]//绘制小程序码:[代码][代码] [代码][代码]ctx.drawImage(qrCode, 122, 220, 136, 136);[代码][代码] [代码][代码]//绘制标题[代码] [代码] [代码][代码]ctx.setFontSize(15);[代码][代码] [代码][代码]ctx.setFillStyle([代码][代码]"#f56400"[代码][代码]);[代码][代码] [代码][代码]ctx.fillText(partner_data.partner_name, 315, 30)[代码][代码] [代码][代码]ctx.setFillStyle([代码][代码]"#ffffff"[代码][代码]);[代码][代码] [代码][代码]ctx.setFontSize(20)[代码][代码] [代码][代码]ctx.fillText(partner_data.name, 149, 50)[代码][代码] [代码][代码]ctx.fillText(partner_data.title, 149, 80)[代码][代码] [代码][代码]ctx.setFontSize(13)[代码][代码] [代码][代码]ctx.fillText(partner_data.depart, 165, 103)[代码][代码] [代码][代码]ctx.fillText(partner_data.phone, 165, 122)[代码][代码] [代码][代码]ctx.fillText(partner_data.email, 165, 142)[代码][代码] [代码][代码]ctx.fillText(partner_data.address, 165, 162)[代码][代码] [代码][代码]ctx.setFillStyle([代码][代码]"black"[代码][代码]);[代码][代码] [代码][代码]ctx.fillText([代码][代码]'长按识别二维码 收下名片'[代码][代码], 120, 378)[代码][代码] [代码][代码]ctx.draw([代码][代码] [代码][代码]false[代码][代码],[代码][代码] [代码][代码]setTimeout([代码][代码]function[代码][代码](){[代码][代码] [代码][代码]canvasToImage(that)[代码][代码] [代码][代码]},200)[代码][代码] [代码][代码])[代码][代码] [代码][代码]}[代码][代码]}[代码] [代码]/**[代码][代码] [代码][代码]* 分享图片生成临时文件[代码][代码] [代码][代码]*/[代码][代码]function[代码] [代码]canvasToImage(page){[代码][代码] [代码][代码]if[代码] [代码](page != [代码][代码]null[代码] [代码]&& page != [代码][代码]''[代码] [代码]&& page != undefined) {[代码][代码] [代码][代码]var[代码] [代码]that = page;[代码] [代码] [代码][代码]wx.canvasToTempFilePath({[代码][代码] [代码][代码]x: 0,[代码][代码] [代码][代码]y: 0,[代码][代码] [代码][代码]fileType:[代码][代码]'png'[代码][代码],[代码][代码] [代码][代码]width: 380,[代码][代码] [代码][代码]height: 426,[代码][代码] [代码][代码]destWidth: 380 * 4,[代码][代码] [代码][代码]destHeight: 426 * 4,[代码][代码] [代码][代码]canvasId: [代码][代码]'myCanvas'[代码][代码],[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码] [代码] [代码][代码]//展示窗口[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]showShareWindow: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]sharePicture: res.tempFilePath[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]fail: [代码][代码]function[代码] [代码](err) {[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]icon: [代码][代码]'none'[代码][代码],[代码][代码] [代码][代码]title: [代码][代码]'生成分享图片失败'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},that)[代码][代码] [代码][代码]}[代码][代码]}[代码] 在开发工具上表现出来的结果是正常的 [图片] 但是用手机真机调试发现背景图没有画出来,同时fillText()的所有信息也没能写上 [图片] 当我保存到手机上时,在相册中打开,发现 fillText() 的信息倒是写上了,但是还是没有背景图 [图片] 三处表现不一,这怎么解决?
2019-01-08