微信小程序拒絕授權后提示信息以及重新授權


 

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM