|
@@ -2,7 +2,7 @@
|
|
|
<template>
|
|
|
<view>
|
|
|
<u-navbar title="">
|
|
|
- <u-search class="search" placeholder="搜索站点名称" @change="search" v-model="keyword" color="#c8c8c8" @search="search" @click="search" @clickicon='back' @custom='search'></u-search>
|
|
|
+ <u-search class="search" placeholder="搜索站点名称" @change="keyword.length>0?search():''" v-model="keyword" color="#c8c8c8" @search="search" @click="search" @clickicon='back' @custom='search'></u-search>
|
|
|
</u-navbar>
|
|
|
<view class="recommend">推荐充电站</view>
|
|
|
<view class="charing-slow" v-for="(item,index) in stations_filter" :key="item.id">
|
|
@@ -32,7 +32,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-
|
|
|
+ let _self;
|
|
|
+ import * as api from '@/apis/site.js';
|
|
|
+ import * as WxJsApi from '@/utils/wxJsApi.js'
|
|
|
+ import MapLoader from '@/utils/AMap'
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
@@ -50,14 +53,170 @@
|
|
|
}
|
|
|
},
|
|
|
onLoad(op){
|
|
|
+ _self = this;
|
|
|
+ /*
|
|
|
if(op!= null && op.stationlist != null){
|
|
|
this.stations = decodeURIComponent(op.stationlist)
|
|
|
console.log('stations'+JSON.stringify(this.stations))
|
|
|
}
|
|
|
- console.log('op'+JSON.stringify(op))
|
|
|
+ console.log('op'+JSON.stringify(op))*/
|
|
|
+ },
|
|
|
+ onReady() {
|
|
|
+
|
|
|
+ WxJsApi.getWxConfig(['getLocation','addEventListener']).then((res)=>{
|
|
|
+
|
|
|
+ // this.message=JSON.stringify(res)
|
|
|
+ // uni.showToast({
|
|
|
+ // title:JSON.stringify(res)
|
|
|
+ // })
|
|
|
+ console.log(res)
|
|
|
+
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
+ this.getPoint();
|
|
|
},
|
|
|
// conponents:{charingSlows},
|
|
|
methods: {
|
|
|
+ getPoint() {
|
|
|
+ var _this = this;
|
|
|
+ console.log('getPoint')
|
|
|
+ WxJsApi.getLocation().then((res) => {
|
|
|
+
|
|
|
+ var latitude = parseFloat(res.latitude);
|
|
|
+ var longitude = parseFloat(res.longitude);
|
|
|
+ _this.latitude = latitude;
|
|
|
+ _this.longitude = longitude;
|
|
|
+
|
|
|
+
|
|
|
+ let data = {latitude:_this.latitude,longtitude:_this.longitude};
|
|
|
+ this.getChargingStationData(data);
|
|
|
+
|
|
|
+ console.log('当前位置' +JSON.stringify(data))
|
|
|
+
|
|
|
+ //this.latitude2 = latitude;
|
|
|
+ //this.longitude2 = longitude;
|
|
|
+ /*uni.showToast({
|
|
|
+ title:JSON.stringify(res)
|
|
|
+ })*/
|
|
|
+ //this.message=JSON.stringify(res)
|
|
|
+ }).catch(error => {
|
|
|
+ uni.showToast({
|
|
|
+ title:JSON.stringify(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getChargingStationData(pos){
|
|
|
+ //return;
|
|
|
+ if(pos == null)
|
|
|
+ return ;
|
|
|
+ let data1 = { pageIndex:0,pageSize:20};
|
|
|
+ if(pos.longtitude != null)
|
|
|
+ data1.longitude = pos.longtitude.toString();
|
|
|
+ if(pos.latitude != null)
|
|
|
+ data1.latitude = pos.latitude.toString();
|
|
|
+ //data1.findType = "0";
|
|
|
+ //data1.type = "1";
|
|
|
+ data1.online = "0";
|
|
|
+/* if(this.info.obc_type[this.preference.obc_type_index].text.indexOf('直流快充')>=0)
|
|
|
+ data1.type = "1";
|
|
|
+ else if(this.info.obc_type[this.preference.obc_type_index].text.indexOf('交流慢充')>=0)
|
|
|
+ data1.type = "2";
|
|
|
+
|
|
|
+ if(this.info.miles_type[this.preference.miles_index].distance!=null)
|
|
|
+ data1.radius = this.info.miles_type[this.preference.miles_index].distance.toString();
|
|
|
+ data1.online = "0";//在线
|
|
|
+ if(pos.findType != null)
|
|
|
+ data1.findType = pos.findType;
|
|
|
+ else
|
|
|
+ data1.findType = "0";
|
|
|
+
|
|
|
+ if(this.preference.obc_power.minValue!=null)
|
|
|
+ data1.powerStart = this.preference.obc_power.minValue.toString();
|
|
|
+ if(this.preference.obc_power.maxValue!=null)
|
|
|
+ data1.powerEnd = this.preference.obc_power.maxValue.toString();
|
|
|
+ */
|
|
|
+ console.log('data1'+JSON.stringify(data1))
|
|
|
+ api.getChargingStationData(data1).then(function(res){
|
|
|
+
|
|
|
+ console.log('getChargingStationData'+JSON.stringify(res))
|
|
|
+ if(!res.result || !res.data || !res.data.data)
|
|
|
+ {
|
|
|
+ console.log('getChargingStationData res nulll')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let items = res.data.data;
|
|
|
+
|
|
|
+ _self.stations_filter = [];
|
|
|
+ for(let i = 0;i<items.length;i++)
|
|
|
+ {
|
|
|
+ let obj = {
|
|
|
+ name:'',
|
|
|
+ position:'',
|
|
|
+ price:1.2,
|
|
|
+ idleNum:10,
|
|
|
+ total:10,
|
|
|
+ type: data1.type == "2" ? '慢充':'快充',
|
|
|
+ id: i,
|
|
|
+ distance:0.9,
|
|
|
+ time:9,
|
|
|
+ park: '以实际费用为准',
|
|
|
+// longitude: 112.28541 + i * 0.001,
|
|
|
+// latitude: 30.308354 + i * 0.01
|
|
|
+ };
|
|
|
+ if(items[i].id != null)
|
|
|
+ obj.id = items[i].id;
|
|
|
+ else
|
|
|
+ continue;
|
|
|
+ if(items[i].name!=null)
|
|
|
+ obj.name = items[i].name;
|
|
|
+ if(items[i].address!=null)
|
|
|
+ obj.position = items[i].address;
|
|
|
+ if(items[i].coostPrice!=null)
|
|
|
+ obj.price = items[i].coostPrice;
|
|
|
+ if(items[i].availableNum!=null)
|
|
|
+ obj.idleNum = items[i].availableNum;
|
|
|
+ if(items[i].totalNum!=null)
|
|
|
+ obj.total = items[i].totalNum;
|
|
|
+ if(items[i].longitude!=null)
|
|
|
+ obj.longitude = items[i].longitude;
|
|
|
+ if(items[i].latitude!=null)
|
|
|
+ obj.latitude = items[i].latitude;
|
|
|
+ if(items[i].distance!=null)
|
|
|
+ obj.distance = items[i].distance;
|
|
|
+ if(items[i].time != null){
|
|
|
+ obj.time = items[i].time;
|
|
|
+ }
|
|
|
+ if(items[i].park != null)
|
|
|
+ obj.park = items[i].park;
|
|
|
+ /*
|
|
|
+ let obj = {name:items[i].name,
|
|
|
+ position:items[i].address,
|
|
|
+ price:items[i].coostPrice,
|
|
|
+ idleNum:items[i].availableNum,
|
|
|
+ total:items[i].totalNum,
|
|
|
+ distance:0.1,
|
|
|
+ time:1,
|
|
|
+ type:'慢充',
|
|
|
+ id: items[i].id,
|
|
|
+ park: i%2 == 0? '以实际费用为准':'2小时免费停车',
|
|
|
+ longitude: items[i].longitude,
|
|
|
+ latitude: items[i].latitude
|
|
|
+ };*/
|
|
|
+ _self.stations.push(obj);
|
|
|
+ }
|
|
|
+ _self.stations_filter = _self.stations;
|
|
|
+ //_self.$refs.amap.searchBtn([_self.longitude, _self.latitude],_self.stationsmap)
|
|
|
+ //_self.$refs.amap.setChargerList(_self.stationsmap);
|
|
|
+ //if(_self.stationsmap.length>0)
|
|
|
+ // _self.$refs.amap.updateCharger(_self.stationsmap[0]);
|
|
|
+
|
|
|
+ },function(err){
|
|
|
+ console.log('getChargingStationData err'+JSON.stringify(err))
|
|
|
+ }
|
|
|
+ )
|
|
|
+ console.log('getChargingStationData end')
|
|
|
+ },
|
|
|
back(){
|
|
|
console.log('back');
|
|
|
uni.navigateBack({
|
|
@@ -77,6 +236,7 @@
|
|
|
}
|
|
|
|
|
|
console.log('search ' + this.keyword);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|