收藏
回答

canvas绘制海报在真机上文字不显示怎么回事?

这是开发工具的效果(想要的效果)

这是真机效果


var ctx = wx.createCanvasContext('shareFrends') 
ctx.setFillStyle('#ffffff')
ctx.fillRect(006701192)


let sharebg='https://tmjapp-dev.niceued.com/xcximages/index/sharebg2.png' 
wx.getImageInfo({
    src: sharebg,
    successfunction (res{  
        ctx.drawImage(res.path, 006701192)
        ctx.draw(true)     
        wx.getImageInfo({
            src'https://tmjapp-dev.niceued.com/xcximages/icon_add.png',
            successfunction (res{ 
                let pic =res.path 
                ctx.drawImage(pic, 120115,2828) 
                ctx.draw(true)    
                wx.getImageInfo({
                    src:that.data.dataForm.user.avatar,
                    successfunction (res{ 
                        let pic =res.path 
                        ctx.save(); 
                        ctx.arc(721123202 * Math.PI); 
                        ctx.clip(); 
                        ctx.fillRect(40806464); 
                        ctx.drawImage(pic, 4080,6464) 
                        ctx.draw(true)  
                        // 绘制文字 
                        ctx.font = "normal 500 26px PingFang SC";
                        ctx.setFillStyle('#342012') 
                        ctx.fillText(that.data.dataForm.user.uname, 120100);  
                        ctx.font = "normal 400 22px PingFang SC";
                        ctx.setFillStyle('#EAB06E') 
                        ctx.fillText(that.data.dataForm.user.part_name?that.data.dataForm.user.part_name:''152138);  
                        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,  72270,48);      
                        ctx.font = "normal bold 28px PingFang SC";
                        ctx.fillText('办理建议'72610);  
                        ctx.font = "normal 400 24px PingFang SC";
                        ctx.setFillStyle('#999999') 
                        ctx.textAlign = 'right'
                        ctx.fillText(that.data.dataForm.create_time, 598270);  
                        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, 72330,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, 72660,48);  
                        ctx.draw(true) 
                        ctx.draw(true, setTimeout(() => {
                            wx.canvasToTempFilePath({
                                x0,
                                y0,
                                canvasId'shareFrends',
                                successfunction (res{
                                    var shareImg = res.tempFilePath; 
                                    that.setData({
                                        shareImg: shareImg,
                                        hideModalfalse
                                    })
                                    wx.hideLoading()
                                },
                                failfunction (res{
                                }
                            })
                        }, 100)) 
                    }
                })
            }
        })   
       
    }
})      
回答关注问题邀请回答
收藏

1 个回答

  • Demons
    Demons
    07-07

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    07-07
    有用
    回复
登录 后发表内容