cap-rq

 

wx.authorize({
    scope: \'scope.writePhotosAlbum\',
    success() {
        // 授权成功
        wx.saveImageToPhotosAlbum({
            filePath: that.data.tempFilePath,
            success() {
                app.func.setMask({
                    message: \'图片保存成功\',
                    bg: \'success\'
                }, that)
                return
            }
        })
    },
    fail:function(){
        // 授权失败
        wx.showModal({
            title: \'警告\',
            content: \'您点击了拒绝授权,将无法正常保存图片,点击确定重新获取授权。\',
            success: function (res) {
                if (res.confirm) {
                    wx.openSetting({
                        success: (res) => {
                            console.log(\'授权成功\')
                        }
                    })
                }
            }
        })
    }
}) 

 

 

uni-app小程序授权位置信息

toPositioin() {
    let that = this
    uni.getSetting({
        success(res) {
            if(res.authSetting[\'scope.userLocation\']){
                // 已授权 
                that.getChooseLocation()
            }else{
                uni.authorize({
                    scope: \'scope.userLocation\',
                    success(res) {
                        // 授权成功
                        that.getChooseLocation()
                    },
                    fail(err) {
                        wx.showModal({
                            title: \'警告\',
                            content: \'您点击了拒绝授权,将无法正常使用发布功能,点击确定重新获取授权。\',
                            success: function (res) {
                                if (res.confirm) {
                                    wx.openSetting({
                                        success: (res) => {
                                            that.toPositioin()
                                        }
                                    })
                                }
                            }
                        })
                    }
                });
            }
        }
    })
},

 

分类:

技术点:

相关文章:

  • 2021-12-09
  • 2021-11-23
  • 2021-12-10
  • 2022-01-30
  • 2021-12-05
  • 2021-11-21
  • 2021-07-04
猜你喜欢
  • 2022-12-23
  • 2021-05-19
  • 2021-12-05
  • 2021-12-05
相关资源
相似解决方案