gcz 4 anos atrás
pai
commit
3133fe5545
3 arquivos alterados com 82 adições e 12 exclusões
  1. 3 0
      common/apiurl.js
  2. 4 1
      common/http.api.js
  3. 75 11
      pages/parkingLists/parkingLists.vue

+ 3 - 0
common/apiurl.js

@@ -36,6 +36,9 @@ const apiurl = {
 	// 获取订单详情
 	getOrderDetailUrl:'/orderinfo/detail/',
 	
+	// 获取附近的路段
+	nearRoadslUrl:'/roadinfo/nearRoads',
+	
 	
 	
 	// 贵州银行支付

+ 4 - 1
common/http.api.js

@@ -34,6 +34,8 @@ const install = (Vue, vm) => {
 	let getOrderinfo = (params = {}) => vm.$u.get(apiurl.getOrderinfoUrl+params.id);
 	let getOrderDetail = (params = {}) => vm.$u.get(apiurl.getOrderDetailUrl+params.id);
 	
+	let nearRoadsl = (params = {}) => vm.$u.post(apiurl.nearRoadslUrl,params);
+	
 	//贵州银行支付
 	let gzbank = (params = {}) => vm.$u.post(apiurl.gzbankurl, params);
 	
@@ -57,7 +59,8 @@ const install = (Vue, vm) => {
 		getOrderinfo,
 		getOrderList,
 		getOrderDetail,
-		gzbank
+		gzbank,
+		nearRoadsl
 	};
 }
 

+ 75 - 11
pages/parkingLists/parkingLists.vue

@@ -1,7 +1,16 @@
 <template>
 	<view>
-		<map style="width: 100%; height: 100vh;" :latitude="latitude" :longitude="longitude" :markers="covers"></map>
+		<map 
+		id="pagemap" 
+		style="width: 100%; height: 100vh;" 
+		:show-location="true" 
+		:latitude="latitude" 
+		:longitude="longitude" 
+		@markertap="markertap"
+		:markers="covers"></map>
 		<!-- <u-empty src="/static/img/empty.png" icon-size="335" text="正在建设中" color="#878787" mode="search"></u-empty> -->
+		
+		<u-toast ref="uToast" />
 	</view>
 </template>
 
@@ -9,24 +18,79 @@
 	export default{
 		data(){
 			return{
-				latitude: 26.605849,
-				longitude: 106.728733,
+				page_map:'',
+				id: 0, //使用 marker点击事件 需要填写id
+				latitude: 26.64969,
+				longitude: 106.636453,
 				covers: [{
-					latitude: 26.604745,
-					longitude: 106.724332,
-					iconPath: 'https://www.baidu.com/img/flexible/logo/pc/result.png'
-				}, {
-					latitude: 39.90,
-					longitude: 116.39,
-					// iconPath: '../../../static/location.png'
-				}]
+                latitude: 26.597864,
+                longitude: 106.72947,
+                iconPath: 'https://www.baidu.com/img/flexible/logo/pc/result.png'
+            }],
 				
 			}
 		},
 		onLoad(){
+			this.page_map = uni.createMapContext("pagemap",this);
+			// console.log('page_map',this.page_map);
+			this.getNearRoadsl();
+		},
+		onShow() {
+			this.getLocation();
 			
 		},
 		methods:{
+			getLocation(){
+				let that = this;
+				// console.log("请求定位")
+				uni.getLocation({
+					type:"gcj02",
+					success : function (res) {
+						// console.log("定位返回信息:", res);
+						that.latitude = res.latitude;
+						that.longitude = res.longitude;
+						// console.log('that.latitude',that.latitude)
+						// console.log(res.longitude + "," + res.latitude )
+					},
+					fail: function(res){
+						console.log("请求错误:", res)
+					}
+				})
+			},
+			async getNearRoadsl(){
+				await this.getLocation();
+				this.$u.api.nearRoadsl({latitude:this.latitude,longitude:this.longitude})
+				.then(res=>{
+					// this.$refs.uToast.show({
+					// 	title: res.msg,
+					// 	type: 'success',
+					// });
+					// this.covers = res.data;
+					// console.log('this.covers',this.covers)
+					res.data.forEach(item=>{
+						if(item.latitude&&item.longitude){
+							let marker = {
+								latitude: item.latitude,
+								longitude:item.longitude,
+								// id:'0',
+								iconPath: 'https://www.baidu.com/img/flexible/logo/pc/result.png'
+							}
+							this.covers.push(marker);
+						}
+					})
+					// this.covers = 
+					// console.log('getNearRoadsl',res)
+				}).catch(err=>{
+					this.$refs.uToast.show({
+						title: err.msg,
+						type: 'error',
+					});
+					console.log('getNearRoadsl ',err)
+				});
+			},
+			markertap(e){
+				console.log('markertap',e)
+			}
 			
 		}
 	}