收藏
回答

canvas 2d canvasToTempFilePath在微信PC端不渲染?

回答关注问题邀请回答
收藏

4 个回答

  • 社区技术运营专员--阳光
    社区技术运营专员--阳光
    2022-06-14

    已知问题,后续修复

    2022-06-14
    有用
    回复 4
  • 深圳市金鸣科技有限公司
    深圳市金鸣科技有限公司
    2023-01-29

    我也遇到这个问题了,IDE和真机都正常,就是PC端不行,出来的图片空白,调高了线上基础库还是这样,而且PC端微信登录还能获取到用户头像和昵称,明显是基础库或是其它组件还比较旧导致的,怎么这么久了还没修复?

    compressImage: function(path, width, height,picwidth,picheight,pathhd) {//2d画板等比缩小图片
        let that = this;
        const query = wx.createSelectorQuery().in(that);
        query.select('#compress-canvas').fields({
            node: true,
            size: true
        }).exec((res) => {
           try 
    		{
                const canvas = res[0].node;
                const ctx = canvas.getContext('2d');
                let dpr = wx.getSystemInfoSync().pixelRatio;
                that.setData({canvasWidth: picwidth / dpr,canvasHeight: picheight / dpr})
                canvas.width = picwidth;
                canvas.height = picheight;			
                const img = canvas.createImage()
                img.src = path;
                img.onload = () => 
    			{
                  setTimeout(function () 
    			  { 
    	            ctx.drawImage(img, 0, 0, width, height, 0, 0, picwidth, picheight); 
                    wx.canvasToTempFilePath({
    	            x: 0,y: 0,width:width,height:height,destWidth:picwidth,destHeight:picheight,
                    canvas: canvas,quality:0.7,fileType:"jpg",
                    success: function (res) 
    	            {
    	               wx.compressImage({
      	               src:res.tempFilePath, // 图片路径
    	               quality: 80, // 压缩质量
    				   success: function (res) 
    	               {					
    	                   pathhd(res.tempFilePath);							   
    				   }
    	              })					
    	            },
    	            fail(err)
    	            {	
    	               app.setShowModal('格式不支持!请用网页版jm189.cn',false);
                       that.setData({[itemsarr]:picarr});				
    	            }
    	          })
                 },50) 			  
              }
            }
    		catch (e) 
    		{
              	app.setShowModal('优化图片异常!请用网页版jm189.cn',false);
                that.setData({[itemsarr]:picarr});				
            }
        })
    }
    
    
    
    2023-01-29
    有用
    回复
  • 单引
    单引
    2022-10-31

    都快十一月了,请问修复了吗

    2022-10-31
    有用
    回复
  • DF
    DF
    2022-06-15

    2022-06-15
    有用
    回复
登录 后发表内容