微信小程序定位授權


wx.getLocation({
    type: 'wgs84',
    success: function (res) {
        var latitude = res.latitude;
        var longitude = res.longitude;
        wx.login({
            
        });
    },
    fail: function (res) {
        //未開啟定位權限,拉起授權
        if (res.errMsg == 'getLocation:fail auth deny') {
            //重新拉起授權
            wx.openSetting({
                success: function (res) {
                    if (res.authSetting['scope.userLocation'] == false) {
                        wx.showModal({
                            title: '提示',
                            content: '您未開啟定位權限,將導致無法使用本軟件',
                            showCancel: false
                        });
                    } else {
                        wx.showModal({
                            title: '提示',
                            content: '您已開啟定位權限,請重新點擊登錄',
                            showCancel: false
                        });
                    }
                }
            });
        }
    }
})

轉自:https://gitee.com/yangad/codes/619jwfzx0r4dcl7boatqg40


免責聲明!

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



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