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