收藏
回答

base64保存到相册一片黑?

手机:iphone11

微信版本号:IOS 7.0.12

基础库:2.10.3

base64编码串百度在线工具转换图片正常

wx.showLoading({title: "保存图片中..."}) // 显示loading
console.log('doSave');
const filePath = wx.env.USER_DATA_PATH + '/poster.png';
console.log(filePath);
const base64 = this.data.canvas.toDataURL();
const fileSystemManager = wx.getFileSystemManager();
fileSystemManager.writeFile({
  filePath: filePath,
  data: base64.slice(22),
  encoding: 'base64',
  success: (res) => {
    console.log(res);
    wx.saveImageToPhotosAlbum({
      filePath: filePath,
      success: res1 => {
        console.log(res1);
        wx.hideLoading();
        wx.showToast({
          title: '保存成功',
          icon: 'success',
          duration: 2000
        })
      },
      fail: err => {
        console.log(err);
      }
    });
  },
  fail: err1 => {
    console.log(err1);
    wx.hideLoading();
  }
})


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

1 个回答

登录 后发表内容
问题标签