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() } }) } } }) } }); } } }) },