zhupeng il y a 3 ans
Parent
commit
f3ba0ab57a
4 fichiers modifiés avec 55 ajouts et 36 suppressions
  1. 8 6
      components/Chargermap.vue
  2. 1 1
      manifest.json
  3. 44 27
      pages/searchPile/searchPile.vue
  4. 2 2
      vue.config.js

+ 8 - 6
components/Chargermap.vue

@@ -144,15 +144,17 @@
 				  
 				 //var startLngLat = [_this.longitude, _this.latitude]
 				 //var endLngLat = [116.427281, 39.903719]
-				 console.log('searchBtn'+JSON.stringify(endLst))
 				 for(let i=0;i< endLst.length;i++)
 				 {
 					 let item = endLst[i];
 					 let endLngLat = [item.longitude,item.latitude]
+					 console.log('search start['+JSON.stringify(startLngLat))					 
+					 console.log('search end]'+JSON.stringify(endLngLat))
+					 
 					  driving.search(startLngLat, endLngLat, function (status, result) {
-							//console.log(result)
-							//console.log(result.routes[0].time)//秒
-							//console.log(result.routes[0].distance)//米
+							console.log(result)
+							console.log('秒'+result.routes[0].time)//秒
+							console.log('距离'+result.routes[0].distance)//米
 							//uni.showToast({
 							//	title:result.routes[0].time+"秒,"+result.routes[0].distance+"米"
 							//})
@@ -173,8 +175,7 @@
 												})
 					  })*/
 				}
-				console.log('search---'+JSON.stringify(startLngLat))
-				console.log('search+++'+JSON.stringify(endLst))
+				 
 				}) 
 			},
 			updateCharger(pos){
@@ -372,6 +373,7 @@
 					//使用地图容器ID创建
 					_this.mapcharger=new AMap.Map("container", {
 						resizeEnable: true,
+						dragEnable : true,
 						center: [this.longitude, this.latitude],
 						zoom: 14
 					});

+ 1 - 1
manifest.json

@@ -70,7 +70,7 @@
     },
     "h5" : {
         "devServer" : {
-            "port" : 8080,
+            "port" : 80,
             "https" : false,
             "disableHostCheck" : true
         },

+ 44 - 27
pages/searchPile/searchPile.vue

@@ -7,7 +7,8 @@
 						<label class="arrow">{{ area }}</label>
 						<u-icon name="arrow-down-fill" size="13" color="#c0c4cc"></u-icon>
 					</view>
-					<view style="margin-left: 20rpx;margin-right: 20rpx; flex:1"><u-search placeholder="搜索站点名称" v-model="keyword" :showAction="false"></u-search></view>
+					<view style="margin-left: 20rpx;margin-right: 20rpx; flex:1" >
+						<u-search placeholder="搜索站点名称" v-model="keyword" :showAction="false"  @focus="navigate"></u-search></view>
 					<view style="margin-right: 20rpx;" v-show="viewMode" @click="listMode">
 						<text class="iconfont">&#xe613;</text> <text class="list">列表</text>
 <!--						<u-icon name="list-dot" size="26" color="#c0c4cc"></u-icon>
@@ -229,6 +230,7 @@
 						</swiper-item>
 					</swiper>
 				</view>
+
 			</view>
 		</view>
 		<Tabbar :current="1"></Tabbar>
@@ -286,6 +288,7 @@ export default {
 				{name:'荆鹏大道求助站充电站',position:'湖北省荆州市沙市区江津东路附158号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'快充'},
 	*/			
 			],
+			first:true,
 			timer:null,
 			stationslist:[],
 			info: {
@@ -331,7 +334,6 @@ export default {
 		 		console.log(res)
 		 })
 		 
-		this.getPoint();
 		//		console.log('longitude2  '+this.longitude)
 		//		console.log('latitude2  '+this.latitude)
 		this.$refs.amap.init();
@@ -353,15 +355,34 @@ export default {
 		this.end();
 	},
 	methods: {
+		navigate(){
+			console.log('naviage to ')
+			uni.navigateTo({
+				url:'/pages/search/search'
+			})
+		},
 		getPoint() {
 		
-			
+			console.log('getPoint')
 			WxJsApi.getLocation().then((res) => {
 				
 				var latitude = parseFloat(res.latitude);
 				var longitude = parseFloat(res.longitude);
 				let data = {position:{latitude:latitude,longitude:longitude}};
+				
+				if(_self.first)
+				{
+					var obj = {
+									longitude: longitude,
+									latitude: latitude
+								};
+					this.$refs.amap.setPerson(obj);	
+					_self.first = false;
+				}
+			
 				this.location(data);
+				console.log('当前位置' +JSON.stringify(data))
+				
 				//this.latitude2 = latitude;
 				//this.longitude2 = longitude;
 				/*uni.showToast({
@@ -380,7 +401,7 @@ export default {
 		  this.timer = setInterval(() => {
 			//console.log("开始---");
 			
-			self.$refs.amap.getLocation1();
+			//self.$refs.amap.getLocation1();
 			//self.$refs.amap.getLocation ();
 		  }, 10000);
 		},
@@ -407,10 +428,10 @@ export default {
 			}
 		},
 		getChargingStationData(pos){
- 
+			//return;
 			if(pos == null)
 				return ;			
-//			console.log('getChargingStationData'+JSON.stringify(pos))
+			console.log('getChargingStationData'+JSON.stringify(pos))
 			let data1 = { pageIndex:0,pageSize:20};
 			if(this.info.obc_type[this.preference.obc_type_index].text.indexOf('直流快充')>=0)
 				data1.type = "1";
@@ -433,16 +454,20 @@ export default {
 			if(this.preference.obc_power.maxValue!=null)
 				data1.powerEnd = this.preference.obc_power.maxValue.toString();
 			
-//			console.log('data1'+JSON.stringify(data1))
+			console.log('data1'+JSON.stringify(data1))
 			api.geChargingStationData(data1).then(function(res){
+				
 				if(!res.result || !res.data || !res.data.data)
-					return;
+				{
+					console.log('getChargingStationData res nulll')
+					return;					
+				}
 				let items = res.data.data;
 				
 
 				if(data1.findType == "0")
 				{
-//					console.log('res1'+JSON.stringify(res));
+					console.log('getChargingStationData res1'+JSON.stringify(res));
 					_self.stationsmap = [];
 					for(let i = 0;i<items.length;i++)
 					{
@@ -502,7 +527,7 @@ export default {
 				}else if(data1.findType == "1")
 				{
 					_self.stationslist = [];
-//					console.log('res2'+JSON.stringify(res));
+					console.log('getChargingStationData res2'+JSON.stringify(res));
 					for(let i = 0;i<items.length;i++)
 					{
 						
@@ -546,14 +571,14 @@ export default {
 					}
 					_self.$refs.amap.searchBtn([_self.longitude, _self.latitude],_self.stationslist)
 					
-					console.log('stations'+JSON.stringify(_self.stationslist))
+					console.log(' getChargingStationData stations'+JSON.stringify(_self.stationslist))
 					 
 				}
 			},function(err){
-				console.log('err'+JSON.stringify(err))
+				console.log('getChargingStationData err'+JSON.stringify(err))
 			}
 			)
-			
+			console.log('getChargingStationData end')
 		},		
 		charge(item){
 			 console.log('扫码充电')
@@ -697,7 +722,7 @@ export default {
 //			console.log('latitude1  ' + this.latitude);
 			//this.start();
 			//this.$refs.amap.getLocation1();
-			this.getNearbyStationInfo();
+//			this.getNearbyStationInfo();
 			this.isReady = true;
 			//this.$refs.amap.getLocation ();
 			//let state = {};
@@ -730,20 +755,12 @@ export default {
 					_self.$refs.amap.setMyStyle("height:"+(scrollH-88-50)+ "px;width:100%;");
 				}
 			})
-			var obj = {
-				longitude: _self.longitude,
-				latitude: _self.latitude
-			};
-//			console.log('obj ' + JSON.stringify(obj));
-			this.$refs.amap.setPerson(obj);
-			/*			var obj2 = {
-				longitude: this.nearbyStationInfo.longitude,
-				latitude: this.nearbyStationInfo.latitude
-			};*/
 			
-			//this.$refs.amap.setPerson(obj);
-			//this.$refs.amap.setSite(obj2);
-		},
+		
+			
+			this.getPoint();
+			
+ 		},
 		gotoLine(item, downid) {
 			uni.navigateTo({
 				url: '/pages/route/index?id=' + item.routeId + '&upid=' + item.startStationId + '&downid=' + downid

+ 2 - 2
vue.config.js

@@ -17,8 +17,8 @@ if(process.env.NODE_ENV === "production"){
 		assetsDir: 'static',
 		lintOnSave: false,
 		devServer: {
-			host: 'localhost',
-			port: 8080,
+			host: 'xpgj.xiaoxinda.com',
+			port: 80,
 			//解析缓存
 			disableHostCheck: true,
 			//支持gzip