wx.getLocation({
altitude: false,
success: function (res) {
var latitude = res.latitude;
var longitude = res.longitude;
that.globalData.location = {
latitude: latitude,
longitude: longitude
}
},
fail: function () {
setTimeout(function () {
wx.getSetting({
success: (res) => {
if (!res.authSetting['scope.userLocation']) {
wx.openSetting({
success: (response) => {
wx.showModal({
title: '请重新授权',
content: '需要获取您的地址信息',
success: function (data) {
// console.log("授权1" + data.cancel); //点击了取消data.cancel==true
// console.log("授权2" + data.confirm); //点击了确定data.confirm==true
wx.getLocation({
success: function (res) {
console.log("地址" + res.latitude)
var latitude = res.latitude;
var longitude = res.longitude;
that.globalData.location = {
latitude: latitude,
longitude: longitude
}
}
})
}
});
}
})
}
}
})
}, 1000);
}
});
}