Browse Source

Merge branch 'master' of https://github.com/bailicangdu/node-elm

maguohua 7 years ago
parent
commit
00012afdb2
1 changed files with 10 additions and 4 deletions
  1. 10 4
      prototype/addressComponent.js

+ 10 - 4
prototype/addressComponent.js

@@ -10,6 +10,7 @@ class AddressComponent extends BaseComponent {
 		super();
 		this.tencentkey = 'RLHBZ-WMPRP-Q3JDS-V2IQA-JNRFH-EJBHL';
 		this.tencentkey2 = 'RRXBZ-WC6KF-ZQSJT-N2QU7-T5QIT-6KF5X';
+		this.tencentkey3 = 'OHTBZ-7IFRG-JG2QF-IHFUK-XTTK6-VXFBN';
 		this.baidukey = 'fjke3YUipM9N64GdOIh1DNeK2APO2WcT';
 		this.baidukey2 = 'fjke3YUipM9N64GdOIh1DNeK2APO2WcT';
 	}
@@ -23,20 +24,25 @@ class AddressComponent extends BaseComponent {
 	 		const ipArr = ip.split(':');
 	 		ip = ipArr[ipArr.length -1];
 	 		if (process.env.NODE_ENV == 'development') {
-	 			ip = '220.249.123.162';
+	 			ip = '180.158.102.141';
 	 		}
 	 		try{
-	 			let result;
-		 		result = await this.fetch('http://apis.map.qq.com/ws/location/v1/ip', {
+		 		let result = await this.fetch('http://apis.map.qq.com/ws/location/v1/ip', {
 		 			ip,
 		 			key: this.tencentkey,
 		 		})
-		 		if (result.status !== 0) {
+		 		if (result.status != 0) {
 		 			result = await this.fetch('http://apis.map.qq.com/ws/location/v1/ip', {
 			 			ip,
 			 			key: this.tencentkey2,
 			 		})
 		 		}
+		 		if (result.status != 0) {
+		 			result = await this.fetch('http://apis.map.qq.com/ws/location/v1/ip', {
+			 			ip,
+			 			key: this.tencentkey3,
+			 		})
+		 		}
 		 		if (result.status == 0) {
 		 			const cityInfo = {
 		 				lat: result.result.location.lat,