// 开启地图服务for 微信
// #ifdef MP-WEIXIN
uni.getSetting({
success: res => {
console.log("res.authSetting",res.authSetting);
if (res && res.authSetting && res.authSetting.hasOwnProperty('scope.userLocation')) { //scope.userInfo字段存在
if (res.authSetting['scope.userLocation']) { //scope.userInfo:true为真
wx.getLocation({
type: 'gcj02',
success(res) {
that.lat = res.latitude;
that.lon = res.longitude;
let location = {
lat: res.latitude,
lon: res.longitude
};
uni.setStorageSync('location', location);
that._getNearParking2(res.latitude, res.longitude);
},
})
} else { // scope.userInfo:false
console.log("scope.userInfo:false");
//打开授权设置
wx.openSetting();
}
} else { //scope.userInfo字段不存在
wx.getLocation({
type: 'gcj02',
success(res) {
that.lat = res.latitude;
that.lon = res.longitude;
let location = {
lat: res.latitude,
lon: res.longitude
};
uni.setStorageSync('location', location);
that._getNearParking2(res.latitude, res.longitude);
},
})
}
},
});
// #endif