瀏覽代碼

修改部分缺陷

zaijin 2 年之前
父節點
當前提交
db87f45804
共有 2 個文件被更改,包括 20 次插入7 次删除
  1. 1 1
      pages/center/phoneLogin/phoneLogin.vue
  2. 19 6
      pages/parkingLists/parkingLists.vue

+ 1 - 1
pages/center/phoneLogin/phoneLogin.vue

@@ -143,7 +143,7 @@
 			// 微信已登录则跳转到首页
 			jumpIndex() {
 				let ret = localStorage.getItem('backUrl');
-				if (ret.indexOf('wechatLogin') > (-1) || (ret && ret.indexOf('phoneLogin') < 0)) {
+				if ((ret && ret.indexOf('wechatLogin') > (-1)) || (ret && ret.indexOf('phoneLogin') < 0)) {
 					// 截取url
 					const pagesIndex = ret.indexOf('pages')
 					if (pagesIndex > (-1)) {

+ 19 - 6
pages/parkingLists/parkingLists.vue

@@ -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',