小程序点击保存图片

wx.downloadFile({
      url: 'https:xxx/f686281da7e79c5ca68ac2e8119af84f.jpg', //仅为示例,并非真实的资源
      success: function (res) {
        // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
        if (res.statusCode === 200) {
          wx.saveImageToPhotosAlbum({
            title:"",
            filePath: res.tempFilePath,
            success(res) {
              ui.toast('保存图片成功')
              that.setData({
                bol:true
              })
              // 保存图片成功之后
              // 调用小程序的扫一扫功能
              // wx.scanCode({
              //   success(res) {
              //     console.log(res.result)
              //   }
              // })
            },
            fail(res) {
              console.log('fail')
              console.log(res)
              ui.toast('保存图片失败')



              wx.getSetting({
                success (res) {
                  console.log(res.authSetting)
                  res.authSetting = {
                    "scope.userInfo": true,
                    "scope.userLocation": true
                  }
                }
              })
            }
          })
        }
      }
    })
 
 
 
依然存在的bug  当用户第一次拒绝时,第二次依然是拒绝
posted @ 2020-09-24 18:04  倔强的代码人  阅读(449)  评论(0编辑  收藏  举报