zoukankan      html  css  js  c++  java
  • 小程序保存图片到手机相册

    item.tempFilePath :图片地址(如果网路地址先下载)
            //图片保存到本地
            wx.saveImageToPhotosAlbum({
              filePath: item.tempFilePath,
              success: function (data) {
                console.log(data)
                wx.hideLoading()
                wx.showToast({
                  title: '保存成功',
                  icon: 'success',
                  duration: 2000
                })
              },
              fail: function (err) {
                console.log(err);
                // $yjpToast.show({
                //   text: `保存失败`
                // })
                if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg === "saveImageToPhotosAlbum:fail:auth denied") {
                  console.log("当初用户拒绝,再次发起授权")
                  wx.showModal({
                    title: '提示',
                    content: '需要您授权保存相册',
                    showCancel: false,
                    success: modalSuccess => {
                      wx.openSetting({
                        success(settingdata) {
                          console.log("settingdata", settingdata)
                          if (settingdata.authSetting['scope.writePhotosAlbum']) {
                            wx.showModal({
                              title: '提示',
                              content: '获取权限成功,再次点击图片即可保存',
                              showCancel: false,
                            })
                          } else {
                            wx.showModal({
                              title: '提示',
                              content: '获取权限失败,将无法保存到相册哦~',
                              showCancel: false,
                            })
                          }
                        },
                        fail(failData) {
                          console.log("failData", failData)
                        },
                        complete(finishData) {
                          console.log("finishData", finishData)
                        }
                      })
                    }
                  })
                }
              }
            });
  • 相关阅读:
    超详细从零记录Hadoop2.7.3完全分布式集群部署过程
    hadoop学习之hadoop完全分布式集群安装
    Fine-tune with Pretrained Models
    Module
    Symbol API
    Gluon parameters 和 Blocks 命名
    mxnet 数据读取
    Adversarial Latent Autoencoders
    A New Meta-Baseline for Few-Shot Learning
    Deploy a plain HTTP registry
  • 原文地址:https://www.cnblogs.com/fps2tao/p/12532863.html
Copyright © 2011-2022 走看看