• 授权保存到相册


    /**
       * 保存到相册
       */
      savePhone: function() {
        var that = this
        //一、判断用户是否开启权限
        wx.getSetting({
          success: function(res) {
            if (res.authSetting["scope.writePhotosAlbum"] == true) {
              console.log("用户已开启相册访问");
            } else {
              console.log("用户未开启相册访问");
              var status = res.authSetting["scope.writePhotosAlbum"]
              if (typeof(status) == "undefined") {
                console.log("--------未定义------");
              } else {
                wx.showModal({
                  title: '相册访问授权',
                  content: '相册访问授权未开启,无法完成操作',
                  confirmText: '开启授权',
                  confirmColor: '#345391',
                  cancelText: '仍然拒绝',
                  cancelColor: '#999999',
                  success: function(res) {
                    if (res.confirm) {
                      wx.openSetting({
                      })
                    }
                    if (res.cancel) {
                      wx.showModal({
                        title: '操作失败',
                        content: '相册访问授权未开启,操作失败',
                        confirmText: '太遗憾了',
                        confirmColor: '#345391',
                        showCancel: false
                      })
                    }
                  }
                })
              }
            }
          } 
        })
        //二、保存图片到相册
        wx.saveImageToPhotosAlbum({
          filePath: that.data.prurl,
          success(res) {
            wx.showModal({
              content: '图片已保存到相册,赶紧晒一下吧~',
              showCancel: false,
              confirmText: '好哒',
              confirmColor: '#72B9C3',
              success: function(res) {
                if (res.confirm) {
                  console.log('用户点击确定');
                  that.setData({
                    canvasHidden: true
                  })
                }
              }
            })
          }
        })
      },
    

      

  • 相关阅读:
    qq链接
    HTML5获取地理坐标
    AJAX的同步和异步的区别
    取消版本控制
    格式化打印数组函数
    图片返回刷新
    从哪些方面优化网站
    朋友圈的基本数据结构设计是怎样的?既能做到完美阅读权限设置,又能兼顾性能?
    表单提交数据安全性验证
    自然世界的划分
  • 原文地址:https://www.cnblogs.com/lorin/p/12821450.html
Copyright © 2020-2023  润新知