微信小程序第一次拒绝地理位置受权,是不能够再次谈起受权弹框的,想要再次受权只能打开设置面板git
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) } }); } } }) }