小程序权限验证
in 默认分类 with 0 comment

小程序权限验证

in 默认分类 with 0 comment
wx.getSetting({
  success: (res) => {
    if (!res.authSetting['scope.writePhotosAlbum'] && that.data.showOpenConfirm) {
      // scope.userInfo scope.userLocation scope.writePhotosAlbum
      that.openConfirm()
    }
  }
})
//对应权限字段 https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/AuthSetting.html
openConfirm: function () {
 wx.showModal({
  content: '检测到您没授权保存到相册,是否去设置打开?',
  confirmText: "确认",
  cancelText: "取消",
  success: function (res) {
    if (res.confirm) {
      wx.openSetting({
        success: (res) => { }
      })
    } else {
      // that.setData({
      //   showOpenConfirm: false,
      // })
    }
  }
 });
},
Responses