uni-app微信小程序第二次地理位置授權失敗解決

微信小程序第一次拒絕地理位置授權,是不可以再次談起授權彈框的,想要再次授權只能打開設置面板

uni.openSetting({
  success(res) {
    console.log(res.authSetting)
  }
});
            getLocal() {
                uni.openSetting({
                    success: (res) => {
                        if(res.authSetting) {
                            var that = this
                            uni.getLocation({
                                type: 'gcj02',
                                success: function (res) {
                                    uni.request({
                                        url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + res.latitude + ',' + res.longitude + '&key=Y4ZBZ-4WO6X-NOD4G-7LUEA-YUC2T-PYFZT',
                                        success: (address) => {
                                            that.saveLocalCity(address.data.result.address_component.city)
                                            that.activeCity.cityName = address.data.result.address_component.city
                                            console.log(that.activeCity.cityName)
                                        }
                                    })
                                },
                                fail:function(e){
                                    console.log(e)
                                }
                            });
                        }
                    }
                })
            }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章