wx.saveImageToPhotosAlbum 有些手机执行 有些不执行
发布于 6 年前 作者 taoxia 12661 次浏览 来自 问答
  • 部分手机无法存图,ios 同一微信版本 7.0.2有的能存有的不能,不能存的 手机

success、fail、complate 回调都没数据。 而且查看权限设置没有 保存到相册的开关。

  • 保存图片
  • 复现路径
  • 提供一个最简复现 Demo

正常的手机有保存到相册开关,不正常的手机只有使用我的用户信息这项。

2 回复

麻烦提供出现问题的机型和微信版本,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

getsharepic: function (e) {
 
  var that = this
  that.setData({
    showfenxiang: false,
    showfenxiang_pic: true,
    showbaocunbutton: false
  })
 
  wx.showLoading({
    title: '海报生成中...',
  })
 
  wx.request({
    url: app.globalData.bastUrl + 'api/xcxv1/share/',
    data: {
      openid: wx.getStorageSync('openid'),
      hdid: that.data.huodong_info.id,
      tuid: wx.getStorageSync('tuid'),
    },
    header: {
      'content-type': 'application/json' // 默认值
    },
    success: function (res) {
      wx.downloadFile({
        url: res.data.data.share_pic,
        success(res) {
          wx.hideLoading()
          if (res.statusCode === 200) {
            that.setData({
              share_pic: res.tempFilePath,
              showbaocunbutton: true
            })
          }
        }
      })
 
 
 
    }
  })
},
 
savetoalbum: function (e) {
  var that = this
  var imgSrc = that.data.share_pic
 
  //图片保存到本地
  wx.saveImageToPhotosAlbum({
    filePath: imgSrc,
    success: function (data) {
      wx.showToast({
        title: '保存到相册成功,可以分享了。',
        icon: 'none',
        duration: 2000
      })
      that.hideall()
    },
    fail: function (err) {
      console.log(err);
      if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") {
        console.log("当初用户拒绝,再次发起授权")
        wx.showToast({
          title: '您拒绝了保存到相册的权限,请到我的栏目中的微信权限设置中打开。',
          icon: 'none',
          duration: 2000
        })
      }
    },
    complete(res) {
      console.log(res);
    }
  })
},

老师你好,苹果6s  \ 7plus   微信版本 7.0.2 。现在开发工具上正常,点击保存就让下载,生成二维码,手机扫描点击没有反应,开启调试也看不到 console.log 的显示。

回到顶部