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

你可能感兴趣的:(小程序,uni-app)