Переглянути джерело

更新在前端调天地图获取city

朱秀平 1 рік тому
батько
коміт
49d3f062f9
4 змінених файлів з 105 додано та 36 видалено
  1. 3 0
      common/config.js
  2. 2 0
      common/httpRequest.js
  3. 72 25
      pages/index/index.vue
  4. 28 11
      pages/index/luma.vue

+ 3 - 0
common/config.js

@@ -5,6 +5,7 @@
 // const ROOTPATH2 = "wss://mxys.chuanghai-tech.com/wss/websocket/"; //联系客服
 // const ROOTPATH2 = "wss://mxys.chuanghai-tech.com/wss/websocket/"; //联系客服
 // const ROOTPATH3 = "wss://mxys.chuanghai-tech.com/wss/ordersChat/"; //聊天
 // const ROOTPATH3 = "wss://mxys.chuanghai-tech.com/wss/ordersChat/"; //聊天
 
 
+const ROOH111="https://api.tianditu.gov.cn/"//天地图调用
 
 
 const ROOTPATH1 = "https://mxys.chuanghai-tech.com/wm-test/wm-api/sqx_fast";
 const ROOTPATH1 = "https://mxys.chuanghai-tech.com/wm-test/wm-api/sqx_fast";
 const ROO2 = "https://mxys.chuanghai-tech.com/wm-test/wm-api/sqx_fast";
 const ROO2 = "https://mxys.chuanghai-tech.com/wm-test/wm-api/sqx_fast";
@@ -21,4 +22,6 @@ module.exports = {
 	APIHOST2: ROO2,
 	APIHOST2: ROO2,
 	WSHOST: ROOTPATH2,
 	WSHOST: ROOTPATH2,
 	WSHOST1: ROOTPATH3,
 	WSHOST1: ROOTPATH3,
+	
+	ROOAA:ROOH111
 };
 };

+ 2 - 0
common/httpRequest.js

@@ -223,6 +223,8 @@ module.exports = {
 						"token": token
 						"token": token
 					},
 					},
 					success: function(result) {
 					success: function(result) {
+						// var jie="RPX3_v1bTP4fLfrEMWHegBp_pJPh8TGDaN-SHZFjyyJOcNlwZJ7dREaKJR5KCYvBzrwWTORQbAiVxUbeM9yR64iuxF9KkcVI8l0OUbwqixblBww6nd-9X48KfSNXwBs3TIT_GvK62Syyawj6uxrW8w=="
+						// console.log('结果',decrypt(urlSafeBase64Decode(jie)))
 						if(ifShangxian==1){
 						if(ifShangxian==1){
 							const decryptData =decrypt(urlSafeBase64Decode(result.data))
 							const decryptData =decrypt(urlSafeBase64Decode(result.data))
 							result.data=JSON.parse(decryptData)
 							result.data=JSON.parse(decryptData)

+ 72 - 25
pages/index/index.vue

@@ -1114,7 +1114,8 @@ export default {
 			jiedanNo: false, //当前不能接
 			jiedanNo: false, //当前不能接
 			list2: [],
 			list2: [],
 			//画板边长默认是屏幕宽度,正方形画布
 			//画板边长默认是屏幕宽度,正方形画布
-			cw: uni.getSystemInfoSync().windowWidth
+			cw: uni.getSystemInfoSync().windowWidth,
+			tianToken:'',//天地图token
 		}
 		}
 	},
 	},
 	onHide() {
 	onHide() {
@@ -1163,6 +1164,14 @@ export default {
 		let that = this
 		let that = this
 		that.getOrderNum()
 		that.getOrderNum()
 		that.getZhandian()
 		that.getZhandian()
+		//获取天地图token
+		that.$Request.getT('/app/common/type/417').then((res) => {
+			if (res.code === 0) {
+				that.tianToken = res.data.value
+			}
+		})
+		
+		
 		//是否开启骑手新订单推送 340
 		//是否开启骑手新订单推送 340
 		that.$Request.getT('/app/common/type/340').then((res) => {
 		that.$Request.getT('/app/common/type/340').then((res) => {
 			if (res.code === 0) {
 			if (res.code === 0) {
@@ -1236,18 +1245,37 @@ export default {
 				success: function (res) {
 				success: function (res) {
 					console.log('当前位置的经度:' + res.longitude)
 					console.log('当前位置的经度:' + res.longitude)
 					console.log('当前位置的纬度:' + res.latitude)
 					console.log('当前位置的纬度:' + res.latitude)
-					let data = {
-						lat: res.latitude,
-						lng: res.longitude
-					}
-
-					that.$Request.getT('/app/Login/selectCity', data).then((res) => {
-						if (res.code == 0) {
-							that.province = res.data.province
-							that.city = res.data.city
-							that.district = res.data.district
-						}
+					
+					uni.request({ 
+						url: that.config("ROOAA") +'geocoder?postStr={%27ver%22:%221%22,%22lon%22:'+res.longitude+',%22lat%22:'+res.latitude+'}&type=geocode&tk=ad07f7a00b20b7f4cd4af3b6f7590330',
+						success: res => {
+							console.log(res,'ppp运行')
+							that.province = res.data.result.addressComponent.province
+							that.city = res.data.result.addressComponent.city
+							that.district = res.data.result.addressComponent.county
+						},
+						fail: err => {
+							console.log("请求超时");
+							console.log(err); 
+						},
+						// complete: () => { //无论成功都会调用
+						// 	uni.hideLoading()
+						// }
 					})
 					})
+					
+					// let data = {
+					// 	lat: res.latitude,
+					// 	lng: res.longitude
+					// }
+
+					// that.$Request.getT('/app/Login/selectCity', data).then((res) => {
+					// 	if (res.code == 0) {
+					// 		console.log(res,'天天')
+					// 		that.province = res.data.province
+					// 		that.city = res.data.city
+					// 		that.district = res.data.district
+					// 	}
+					// })
 				},
 				},
 				fail(e) {
 				fail(e) {
 					uni.hideLoading()
 					uni.hideLoading()
@@ -1470,18 +1498,35 @@ export default {
 				success: function (res) {
 				success: function (res) {
 					console.log('当前位置的经度:' + res.longitude)
 					console.log('当前位置的经度:' + res.longitude)
 					console.log('当前位置的纬度:' + res.latitude)
 					console.log('当前位置的纬度:' + res.latitude)
-					let data = {
-						lat: res.latitude,
-						lng: res.longitude
-					}
-
-					that.$Request.getT('/app/Login/selectCity', data).then((res) => {
-						if (res.code == 0) {
-							that.province = res.data.province
-							that.city = res.data.city
-							that.district = res.data.district
-						}
+					
+					uni.request({
+						url: that.config("ROOAA") +'geocoder?postStr={%27ver%22:%221%22,%22lon%22:'+res.longitude+',%22lat%22:'+res.latitude+'}&type=geocode&tk=ad07f7a00b20b7f4cd4af3b6f7590330',
+						success: res => {
+							console.log(res,'ppp运行')
+							that.province = res.data.result.addressComponent.province
+							that.city = res.data.result.addressComponent.city
+							that.district = res.data.result.addressComponent.county
+						},
+						fail: err => {
+							console.log("请求超时");
+							console.log(err); 
+						},
+						// complete: () => { //无论成功都会调用
+						// 	uni.hideLoading()
+						// }
 					})
 					})
+					// let data = {
+					// 	lat: res.latitude,
+					// 	lng: res.longitude
+					// }
+
+					// that.$Request.getT('/app/Login/selectCity', data).then((res) => {
+					// 	if (res.code == 0) {
+					// 		that.province = res.data.province
+					// 		that.city = res.data.city
+					// 		that.district = res.data.district
+					// 	}
+					// })
 				},
 				},
 				fail(e) {
 				fail(e) {
 					uni.hideLoading()
 					uni.hideLoading()
@@ -1976,7 +2021,8 @@ export default {
 					page: this.page1,
 					page: this.page1,
 					receivingPattern: this.receivingPettern,
 					receivingPattern: this.receivingPettern,
 					riderLat: this.latitude,
 					riderLat: this.latitude,
-					riderLng: this.longitude
+					riderLng: this.longitude,
+					city:this.city
 				})
 				})
 				.then((res) => {
 				.then((res) => {
 					uni.hideLoading()
 					uni.hideLoading()
@@ -2013,7 +2059,8 @@ export default {
 					indentType: this.indentType,
 					indentType: this.indentType,
 					shopId: this.shopId,
 					shopId: this.shopId,
 					riderLat: this.latitude,
 					riderLat: this.latitude,
-					riderLng: this.longitude
+					riderLng: this.longitude,
+					city:this.city
 				})
 				})
 				.then((res) => {
 				.then((res) => {
 					uni.hideLoading()
 					uni.hideLoading()

+ 28 - 11
pages/index/luma.vue

@@ -864,18 +864,35 @@ export default {
 				success: function (res) {
 				success: function (res) {
 					console.log('当前位置的经度:' + res.longitude)
 					console.log('当前位置的经度:' + res.longitude)
 					console.log('当前位置的纬度:' + res.latitude)
 					console.log('当前位置的纬度:' + res.latitude)
-					let data = {
-						lat: res.latitude,
-						lng: res.longitude
-					}
-
-					that.$Request.getT('/app/Login/selectCity', data).then((res) => {
-						if (res.code == 0) {
-							that.province = res.data.province
-							that.city = res.data.city
-							that.district = res.data.district
-						}
+					
+					uni.request({
+						url: that.config("ROOAA") +'geocoder?postStr={%27ver%22:%221%22,%22lon%22:'+res.longitude+',%22lat%22:'+res.latitude+'}&type=geocode&tk=ad07f7a00b20b7f4cd4af3b6f7590330',
+						success: res => {
+							console.log(res,'ppp运行')
+							that.province = res.data.result.addressComponent.province
+							that.city = res.data.result.addressComponent.city
+							that.district = res.data.result.addressComponent.county
+						},
+						fail: err => {
+							console.log("请求超时");
+							console.log(err); 
+						},
+						// complete: () => { //无论成功都会调用
+						// 	uni.hideLoading()
+						// }
 					})
 					})
+					// let data = {
+					// 	lat: res.latitude,
+					// 	lng: res.longitude
+					// }
+
+					// that.$Request.getT('/app/Login/selectCity', data).then((res) => {
+					// 	if (res.code == 0) {
+					// 		that.province = res.data.province
+					// 		that.city = res.data.city
+					// 		that.district = res.data.district
+					// 	}
+					// })
 				},
 				},
 				fail(e) {
 				fail(e) {
 					uni.hideLoading()
 					uni.hideLoading()