|
@@ -175,15 +175,11 @@
|
|
|
getLocation() {
|
|
|
const that = this;
|
|
|
console.log('请求定位');
|
|
|
- // const obj = {
|
|
|
- // 0: 'getNearRoadsl',
|
|
|
- // 1: 'getParkingLotList'
|
|
|
- // }
|
|
|
- // this[obj[this.tabObj.current]]()
|
|
|
that.loading = true;
|
|
|
if (navigator.geolocation) {
|
|
|
// 判断是否有这个对象
|
|
|
navigator.geolocation.getCurrentPosition(function(pos) {
|
|
|
+ console.log('浏览器获取位置成功:', JSON.stringify(pos));
|
|
|
console.log('经度:' + pos.coords.longitude + '纬度:' + pos.coords.latitude);
|
|
|
that.latitude = pos.coords.latitude;
|
|
|
that.longitude = pos.coords.longitude;
|
|
@@ -195,7 +191,24 @@
|
|
|
1: 'getParkingLotList'
|
|
|
}
|
|
|
that[obj[that.tabObj.current]]()
|
|
|
- });
|
|
|
+ }, function(err) {
|
|
|
+ console.log('浏览器获取位置失败:', JSON.stringify(err));
|
|
|
+ uni.getLocation({
|
|
|
+ type: 'gcj02',
|
|
|
+ success: function (res) {
|
|
|
+ console.log('当前位置的经度:' + res.longitude);
|
|
|
+ console.log('当前位置的纬度:' + res.latitude);
|
|
|
+ that.currentPosition.latitude = res.latitude;
|
|
|
+ that.currentPosition.longitude = res.longitude;
|
|
|
+ that.loading = false;
|
|
|
+ const obj = {
|
|
|
+ 0: 'getNearRoadsl',
|
|
|
+ 1: 'getParkingLotList'
|
|
|
+ }
|
|
|
+ that[obj[that.tabObj.current]]()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
} else {
|
|
|
this.$refs.uToast.show({
|
|
|
title: '当前系统不支持GPS API',
|