123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146 |
- <template>
- <view>
- <u-navbar :is-back="false" height="88" style="background-color: bisque;">
- <view style="display: flex;flex-direction: column; width: 100%;height: 100%;">
- <view style="display: flex;flex-direction: row; height: 100%; align-items: center;margin-top:0rpx;padding-top: 0rpx;padding-bottom: 20rpx;">
- <view style="margin-left:20rpx;">
- <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" @focus="navigate"></u-search></view>
- <view style="margin-right: 20rpx;" v-show="viewMode" @click="listMode">
- <text class="iconfont"></text> <text class="list">列表</text>
- <!-- <u-icon name="list-dot" size="26" color="#c0c4cc"></u-icon>
- <label>列表</label>-->
- </view>
- <view style="margin-right: 20rpx;" v-show="!viewMode" @click="mapMode">
- <text class="iconfont"></text> <text class="list">地图</text>
- <!--<u-icon name="map" size="26" color="#c0c4cc"></u-icon>
- <label>地图</label>
- -->
- </view>
- </view>
- <view style="display: flex;flex-direction: row;width:100%; justify-content: space-between;align-items: center;">
- <view style="margin-left: 20rpx;">
- <label class="arrow">{{ info.miles_type[preference.miles_index].text }}</label>
- <u-icon name="arrow-down-fill" size="13" color="#c0c4cc"></u-icon>
- </view>
- <view style="margin-left: 20rpx;margin-right: 20rpx;flex:1">
- <label class="arrow">{{ info.obc_type[preference.obc_type_index].text }}</label>
- <u-icon name="arrow-down-fill" size="13" color="#c0c4cc"></u-icon>
- </view>
- <view style="margin-right: 20rpx;" @click="open">
- <label class="arrow">{{ action }}</label>
- <u-icon v-if="show" name="arrow-down-fill" size="13" color="#00B962"></u-icon>
- <u-icon v-else name="arrow-down-fill" size="13" color="#c0c4cc"></u-icon>
- </view>
- </view>
- </view>
- </u-navbar>
- <view class="content" >
- <view v-if="show" class="preference" :style="show ? 'z-index:1024;top:'+navBarHeight+'px;' : 'z-index:0'">
- <view class="preference_group">
- <view class="preference_group_item"><label class="preference_label">距离我</label></view>
- <view>
- <u-tag
- class="preference_item"
- v-for="(item, index) in info.miles_type"
- :key="index"
- :style="index == preference.miles_index ? 'background-color:#00B962;color:#FFFFFF' : 'background-color:#EFF4F2;color:#926666'"
- shape="circle"
- :text="item.text"
- @click="selectMiles(index)"
- ></u-tag>
- </view>
- </view>
- <view class="preference_group">
- <view class="preference_group_item"><label class="preference_label">充电站类型</label></view>
- <view>
- <u-tag
- class="preference_item"
- v-for="(item, index) in info.obc_type"
- :key="index"
- :style="index == preference.obc_type_index ? 'background-color:#00B962;color:#FFFFFF' : 'background-color:#EFF4F2;color:#926666'"
- shape="circle"
- :text="item.text"
- @click="selectOBSType(index)"
- ></u-tag>
- </view>
- </view>
-
- <view class="preference_group">
- <view class="preference_group_item"><label class="preference_label">是否对外开放</label></view>
- <view>
- <u-tag
- class="preference_item_plus"
- v-for="(item, index) in info.obc_status"
- :key="index"
- :style="index == preference.obc_status_index ? 'background-color:#00B962;color:#FFFFFF' : 'background-color:#EFF4F2;color:#926666'"
- shape="circle"
- :text="item.text"
- @click="selectOBSStatus(index)"
- ></u-tag>
- </view>
- </view>
- <view class="preference_group">
- <view class="preference_group_item"><label class="preference_label">充电桩电压 (V)</label></view>
- <view>
- <u-tag
- class="preference_item_plus"
- v-for="(item, index) in info.obc_voltage"
- :key="index"
- :style="index == preference.obc_voltage_index ? 'background-color:#00B962;color:#FFFFFF' : 'background-color:#EFF4F2;color:#926666'"
- shape="circle"
- :text="item.text"
- @click="selectOBCVoltage(index)"
- ></u-tag>
- </view>
- </view>
- <view class="preference_group">
- <view class="preference_group_item"><label class="preference_label">充电桩电压 (kW)</label></view>
- <view style="height: 50rpx;margin-left: 30rpx;">
- <DoubleSlider
- ref="obc_voltage"
- sliderHeight="15rpx"
- blockSize="36rpx"
- :minValue="info.obc_power.minValue"
- :maxValue="info.obc_power.maxValue"
- v-model="preference.obc_power"
- :currentMinValue="preference.obc_power.minValue"
- :currentMaxValue="preference.obc_power.maxValue"
- labelColor="#B8C9C5"
- borderRadius="25rpx"
- borderColor="#00B962"
- borderStyle="solid"
- borderWidth="3rpx"
- blockColor="#FFFFFF"
- activeColor="#00B962"
- indicatorColor="#DBDBDB"
- @change="handlerDoubleSlider"
- > </DoubleSlider>
- </view>
- </view>
- <view class="preference_group">
- <view style="margin-left: 30rpx;"><u-checkbox shape="circle" v-model="preference.save_preference" @change="radioChange">保存偏好设置</u-checkbox></view>
- </view>
- <view style="display: flex;flex-direction: row;">
- <u-button @click="reset" style="width: 30%;">重置</u-button>
- <u-button @click="close" style="width: 70%;background-color: #00B962;">确定</u-button>
- </view>
- </view>
- <view v-show="!viewMode" >
-
- <view v-for="(item,index) in stationslist" :key="item.id" class="charing-slow" @click="stationDetail(item)">
- <text :class="item.type == '快充' ? 'fast-charge':'trickle-charge'">{{item.type}}</text> <text class="station-items">{{item.name}}</text>
- <view class="address">
- {{item.position}}
- </view>
- <view class="price">
- <view class="num">{{item.price}}</view>
- <view class="unit">
- 起 元/度
- </view>
- </view>
- <view class="park">
- <text class="park-p">p</text>
- <text class="park-text">2小时免费停车</text>
- </view>
- <view class="free">
- <view class="free-num">
- <text style="color:#009143;">空闲{{item.idleNum}}</text>/总数{{item.total}}
- </view>
- <view class="distance">
- <text class="iconfont distance-font"></text>{{item.distance.toFixed(2)}}公里 {{item.time.toFixed(0)}}分钟
- </view>
- </view>
- </view>
-
- <u-divider margin-top="20" bg-color="#F2F4F4">已经到底了</u-divider>
-
-
-
- </view>
- <view v-show="viewMode" >
- <view>
- <Chargermap @onMoveEnd="moveEnd" ref="amap" @onload="mapdown" @clickMap="clickMap"></Chargermap>
- <!--@location="location"-->
- <u-image style='position:absolute;z-index:1023;right:20px;bottom:260px;' src="@/static/img/location.png" width="30px" height="30px" @click="setCenter"></u-image>
-
- </view>
- <view v-if="stationsmap.length>0" class="chargerCard" style="border-radius: 20rpx;" >
- <swiper :current="currentIndex" @change="swiperChange" @transition="swiperTransition" style="height: 100%;">
- <swiper-item v-for="(item,index) in stationsmap" :key="item.id" style="height: 100%;">
-
- <view class="swiper-item" style="height: 100%; background-color: #ffffff;" @click="stationDetail(item)">
- <view class="card_item" style="font-size: 35rpx;padding-top: 5rpx;">
- <view style="display: flex;flex-direction: row;">
- <view :class="item.type == '快充'? 'fast-charge':'trickle-charge'" >
- {{item.type}}
- </view>
- <view>
- {{item.name}}
- </view>
-
- </view>
- </view>
- <view class="card_item" style="color:#8898A9;font-size: 15rpx;">
- {{item.position}}
- </view>
-
- <view class="card_item2" >
- <view style="color:#FF6573;font-size:45rpx;margin-right: 10rpx;">
- {{item.price}}
- </view>
- <view style="display: flex; justify-content: center;align-items: center">
- 起 元/度
- </view>
- </view>
- <view class="card_item" style="border-bottom: #F1F4F3; border-bottom-width: 2rpx;border-style: solid;border-top-width: 0rpx;border-left-width: 0rpx;border-right-width:0rpx; padding-bottom:20rpx">
- <view style="display: flex;flex-direction: row;">
- <view style="background-color: #7DB1FF;padding-left: 10rpx;padding-right: 10rpx;">
- P
- </view>
- <label>{{item.park}}</label>
- </view>
- <view style="display: flex;flex-direction: row;">
- <view style="color: #00B962;">
- 空闲{{item.idleNum}}
- </view>
-
- <view>
- /总数{{item.total}}
- </view>
- </view>
- </view>
- <view class="card_item" style="padding-bottom: 20rpx;">
- <u-button shape='circle' style="color: #00B962;" @click="getScanCode">
- <u-icon name="scan" size="26" color="#00B962" style="margin-right: 20rpx;"></u-icon>
- <label>扫码充电</label></u-button>
- <view class="round" >
- <text class="iconfont distance-font"></text>
- <view style="margin-right: 10rpx;">
- {{item.distance.toFixed(2)}}公里
- </view>
- <view style="margin-right: 10rpx;">
- {{item.time.toFixed(0)}}分钟
- </view>
- </view>
- </view>
- </view>
- </swiper-item>
- </swiper>
- </view>
- </view>
- </view>
- <Tabbar :current="1"></Tabbar>
- </view>
- </template>
- <script>
- // import api from './site-index.js'
- // export default api
- import * as indexAPI from '@/apis/index.js'
- import * as api from '@/apis/site.js';
- import Chargermap from '@/components/Chargermap.vue';
- import DoubleSlider from '@/components/double-slider/DoubleSlider.vue';
- import Tabbar from '@/components/Tabbar.vue';
- import * as WxJsApi from '@/utils/wxJsApi.js'
- import MapLoader from '@/utils/AMap'
-
- let _self;
- export default {
- components: {
- Chargermap,
- DoubleSlider,
- Tabbar,
- },
- data() {
- return {
- centerImg:'@/static/img/location.png',
- currentIndex:-1,
- navBarHeight:88,
- viewMode: true, //地图
- keyword: '',
- show: false,
- mapopen: false,
- isReady: false,
- id: '',
- longitude: 112.28308,
- latitude: 30.312084,
- // longitude: '',
- // latitude: '',
- nearbyStationInfo: {
- nearbyShiftDTOList: []
- },
- area: '荆州市',
- action: '筛选',
- preference: {
- miles_index: 3,
- obc_type_index: 0,
- obc_status_index: 0,
- obc_voltage_index: 0,
- save_preference: false,
- obc_power: { minValue: 0, maxValue: 500 }
- },
- stationsmap:[
- /* {name:'荆鹏软件园充电站',position:'湖北省荆州市沙市区江津东路附155号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'慢充'},
- {name:'荆鹏软件园充电站2',position:'湖北省荆州市沙市区江津东路附156号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'快充'},
- {name:'荆鹏软件园充电站3',position:'湖北省荆州市沙市区江津东路附157号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'慢充'},
- {name:'荆鹏大道求助站充电站',position:'湖北省荆州市沙市区江津东路附158号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'快充'},
- */
- ],
- first:true,
- timer:null,
- stationslist:[],
- info: {
- miles_type: [
- { distance: 1, text: '1公里' },
- { distance: 2, text: '2公里' },
- { distance: 5, text: '5公里' },
- { distance: 10, text: '10公里' },
- { distance: 20, text: '20公里' },
- { distance: 50, text: '50公里' },
- { distance: 100, text: '100公里' },
- { distance: 200, text: '200公里' }
- ],
- obc_type: [{ value: 0, text: '直流快充' }, { value: 1, text: '交流慢充' }],
- obc_status: [{ value: 0, text: '对外开放' }, { value: 1, text: '不对外开放' }],
- obc_voltage: [{ value: 0, text: '低于700V' }, { value: 1, text: '700V及以上' }],
- obc_power: { minValue: 0, maxValue: 1000 }
- },
- userId:'',
- };
- },
- onLoad(op) {
- _self = this;
- console.log('longitude0 ' + _self.longitude);
- console.log('latitude0 ' + _self.latitude);
- if (op != null) {
- if (op.longitude != null) this.longitude = op.longitude;
- if (op.latitude != null) this.latitude = op.latitude;
- if (op.id != null) this.id = op.id;
- }
-
- //navigation.getPoint();
-
- },
- onReady() {
- if (this.carhelp.getPersonInfo()) {
- this.userId = this.carhelp.getPersonInfo().id;
-
- }
- WxJsApi.getWxConfig(['getLocation', 'addEventListener', 'scanQRCode']).then((res) => {
- // console.log(res)
- }).catch(error => {
- console.log(res)
- })
-
-
- // console.log('longitude2 '+this.longitude)
- // console.log('latitude2 '+this.latitude)
- this.$refs.amap.init();
- //this.getPositionByLonLats();
- // this.$refs.amap.setMyStyle("height:1500rpx;width:100%;");
- // this.$refs.amap.setMyStyle("height:calc(100%-176rpx);width:100%;");
-
- // console.log('longitude3 '+this.longitude)
- // console.log('latitude3 '+this.latitude)
- },
- onShow() {
-
- console.log('onShow')
- if (this.isReady) {
-
- }
- },
- onHide(){
- this.end();
- },
- methods: {
- setCenter(){
- console.log('getPoint')
- WxJsApi.getLocation().then((res) => {
-
- _self.latitude = parseFloat(res.latitude);
- _self.longitude = parseFloat(res.longitude);
- //let data = {position:{latitude:latitude,longitude:longitude}};
-
- let posCenter= {longitude: _self.longitude,latitude: _self.latitude};
- this.$refs.amap.setCenter(posCenter);
- }).catch(error => {
- uni.showToast({
- title:JSON.stringify(error)
- })
- })
-
- // console.log('setCenter')
- },
- getScanCode() {
- if (this.userId) {
- WxJsApi.scanQRCode(1).then(res => {
- if(res) {
- indexAPI.scanCode(res).then((response) => {
-
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- }
- }).catch(error => {
-
- })
- } else {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }
- },
- navigateTo(){
- console.log('导航')
- this.$refs.amap.navigate();
- },
- navigate(){
- console.log('naviage to ')
- uni.navigateTo({
- url:'/pages/search/search?stationlist='+encodeURIComponent(JSON.stringify(_self.stationsmap))
-
- })
- },
- 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}};
- _self.location(data);
-
- if(_self.first)
- {
- var obj = {
- longitude: longitude,
- latitude: latitude
- };
- this.$refs.amap.setPerson(obj);
- //let data = {latitude:latitude,longtitude:longitude};
- //this.getChargingStationData(data);
- this.getNearbyStationInfo();
- _self.first = false;
- //this.$refs.amap.listenMove();
- }
-
-
- 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)
- })
- })
- },
- start() {
- let self = this;
- // 将定时器名字赋值到变量中
- this.timer = setInterval(() => {
- //console.log("开始---");
-
- //self.$refs.amap.getLocation1();
- //self.$refs.amap.getLocation ();
- }, 10000);
- },
- end() {
- clearInterval(this.timer);
- this.timer = null // 这里最好清除一下,回归默认值
- // 众所周知,定时器返回一个随机整数,用于表示定时器的编号,后面通过名字可以取消这个定时器的执行。
- console.log(this.timer);
- },
- stationDetail(item){
- uni.navigateTo({
- url:'stationAndPile/stationDetails?station='+encodeURIComponent(JSON.stringify(item))
- })
- // console.log('stationDetail'+JSON.stringify(item))
- },
- location(e){
- if(e.position){
- this.$refs.amap.getPositionByLonLats(e.position);
- if(e.position.latitude && e.position.longitude)
- if(this.latitude != e.position.latitude ||
- this.longitude != e.position.longitude)
- {
- this.longitude = e.position.longitude;
- this.latitude = e.position.latitude;
-
- let data = {latitude:this.latitude,longtitude:this.longitude,findType:"1"};
- this.getChargingStationData(data);
- console.log('获取定位'+JSON.stringify(e));
-
- }
- }
- },
- getChargingStationData(pos){
- //return;
- if(pos == null)
- return ;
- 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";
- else if(this.info.obc_type[this.preference.obc_type_index].text.indexOf('交流慢充')>=0)
- data1.type = "2";
- if(pos.longtitude != null)
- data1.longitude = pos.longtitude.toString();
- if(pos.latitude != null)
- data1.latitude = pos.latitude.toString();
- 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){
-
- if(!res.result || !res.data || !res.data.data)
- {
- console.log('getChargingStationData res nulll')
- return;
- }
- let items = res.data.data;
-
- if(data1.findType == "0")
- {
- console.log('getChargingStationData res1'+JSON.stringify(res));
- _self.stationsmap = [];
- 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.stationsmap.push(obj);
- }
- _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]);
- }else if(data1.findType == "1")
- {
- _self.stationslist = [];
- console.log('getChargingStationData res2'+JSON.stringify(res));
- 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;
- //arr.push(obj);
- _self.stationslist.push(obj);
- }
- _self.$refs.amap.searchBtn([_self.longitude, _self.latitude],_self.stationslist)
-
- console.log(' getChargingStationData stations'+JSON.stringify(_self.stationslist))
-
- }
- },function(err){
- console.log('getChargingStationData err'+JSON.stringify(err))
- }
- )
- console.log('getChargingStationData end')
- },
- /*
- charge(item){
- console.log('扫码充电')
- //#ifdef MP-WEIXIN
- uni.scanCode({
- success:function(res){
- uni.navigateTo({
- url:'chargingPileDetails?pile='+encodeURIComponent(JSON.stringify(data))
- })
-
- }
- })
- return;
- //#endif
-
- console.log('扫码充电1')
- uni.navigateTo({
- url:'stationAndPile/chargingPileDetails'
- })
-
- }, */
- moveEnd(e){
- console.log('moveEnd'+JSON.stringify(e))
- let data = {latitude:e.center.lat,longtitude:e.center.lng};
- this.getChargingStationData(data);
- },
- clickTabItem (index) {
-
- this.currentIndex = index
- },
- swiperChange (e) {
- this.currentIndex = e.detail.current
- let station = this.stationsmap[this.currentIndex];
-
- let posCenter= {longitude: station.longitude,latitude: station.latitude};
- // console.log('currentIndex'+JSON.stringify(this.currentIndex))
- // console.log('currentIndex'+JSON.stringify(posCenter))
- // console.log('station'+JSON.stringify(station))
- let bounds = this.$refs.amap.logMapInfo();
- /*if( (posCenter.latitude<bounds.bounds.northeast.lat && posCenter.latitude>bounds.bounds.sourthwest.lat)
- && (posCenter.longitude<bounds.bounds.northeast.lng && posCenter.longitude>bounds.bounds.sourthwest.lng)
- ){
- console.log('bounds'+JSON.stringify(bounds));
-
- }else{
- this.$refs.amap.setCenter(posCenter);
- }*/
- this.$refs.amap.updateCharger(station);
-
- },
- swiperTransition (e) {
- // console.log(e)
- },
- listMode() {
- this.viewMode = false
- },
- mapMode() {
- this.viewMode = true
- },
- radioChange(e) {
- // console.log('e'+JSON.stringify(e))
- this.preference.save_preference = e.value;
- // console.log('save_preference '+this.preference.save_preference);
- },
- handlerDoubleSlider(e) {
- // console.log('e'+JSON.stringify(e))
- this.preference.obc_power = e;
- //this.preference.obc_power.minValue = e.minValue;
- //this.preference.obc_power.maxValue = e.maxValue;
- },
- selectOBSType(index) {
- this.preference.obc_type_index = index;
- },
- selectOBSStatus(index) {
- this.preference.obc_status_index = index;
- },
- selectOBCVoltage(index) {
- this.preference.obc_voltage_index = index;
- },
- selectMiles(index) {
- this.preference.miles_index = index;
- },
- reset() {
- this.preference.obc_status_index = 0;
- this.preference.obc_voltage_index = 0;
- this.preference.obc_type_index = 0;
- this.preference.miles_index = 3;
- this.preference.save_preference = false;
- // this.$refs.obc_voltage.currentValue = [0,100];
- this.preference.obc_power.minValue = 0;
- this.preference.obc_power.maxValue = 500;
- this.preference.obc_power.minP = Math.floor((this.preference.obc_power.minValue / (this.info.obc_power.maxValue - this.info.obc_power.minValue)) * 100);
- this.preference.obc_power.maxP = Math.floor((this.preference.obc_power.maxValue / (this.info.obc_power.maxValue - this.info.obc_power.minValue)) * 100);
- // console.log('minP'+this.preference.obc_power.minP)
- // console.log('maxP'+this.preference.obc_power.maxP)
- this.$refs.obc_voltage.reset(this.preference.obc_power);
- // this.$refs.obc_voltage.currentMaxValue = this.preference.obc_power[1];
- // console.log('reset')
- },
- open() {
- this.show = true;
- //this.$refs.obc_voltage.currentMinValue = this.preference.obc_power[0];
- //this.$refs.obc_voltage.currentMaxValue = this.preference.obc_power[1];
- console.log('open');
- },
- close() {
- console.log('偏好设置' + JSON.stringify(this.preference));
- this.show = false;
- let data = {latitude:this.latitude,longtitude:this.longitude};
- this.carhelp.set('aa',this.preference)
-
- this.getChargingStationData(data);
- // console.log('close');
- },
- // 获取当前位置
- clickMap(obj) {
- this.show=false;
- //this.currentIndex = 5;
- // console.log('longitude1 ' + _self.longitude);
- // console.log('latitude1 ' + _self.latitude);
- if (obj == null || obj.type == null) return;
- if (obj.type == 'charger') {
- api.getChargerInfoById(obj).then(
- function(data) {
- if (obj.obj != null) {
- //obj.obj.price = 2.25;
- //obj.obj.idleNum = 12;
- _self.$refs.amap.updateCharger(obj.obj);
- let index = _self.stationsmap.findIndex(item => item.id == obj.obj.id);
- _self.currentIndex = index;
- console.log('find Index'+index);
- }
- // console.log('点击1'+JSON.stringify(obj));
- },
- function(err) {
- console.log('点击2' + JSON.stringify(obj));
- }
- );
- }
- },
- mapdown() {
- //console.log('this'+JSON.stringify(this))
- // console.log('longitude1 ' + this.longitude);
- // console.log('latitude1 ' + this.latitude);
- //this.start();
- //this.$refs.amap.getLocation1();
- this.getNearbyStationInfo();
- this.isReady = true;
- //this.$refs.amap.getLocation ();
- //let state = {};
- uni.getSystemInfo({
- success: (res) => {
- // #ifndef MP
- let navbarH = 0
- // #endif
- // #ifdef MP
- let navbarH = uni.upx2px(90)
- // #endif
- /*state.status_width = res.windowWidth;
- console.log('window width'+state.status_width);*/
-
- let scrollH = res.windowHeight;// - uni.upx2px(88) - navbarH
- // console.log('布局结果'+ JSON.stringify(res));
- // console.log('scrollH'+scrollH)
- //#ifdef MP-WEIXIN
- const {
- statusBarHeight,
- windowWidth,
- } = uni.getSystemInfoSync();
- // console.log('height ' + statusBarHeight);
- //this.status_height = uni.getStatusbarHeight();
- let res1 = uni.getMenuButtonBoundingClientRect()
- // console.log('layout selectHeight '+JSON.stringify(res1))
- //state.selectHeight = (res1.top-res.statusBarHeight)*2+ res1.height;
- //#endif
- //console.log('status height'+state.status_height)
- _self.$refs.amap.setMyStyle("height:"+(scrollH-88-50)+ "px;width:100%;");
- }
- })
-
-
-
- this.getPoint();
-
- },
- gotoLine(item, downid) {
- uni.navigateTo({
- url: '/pages/route/index?id=' + item.routeId + '&upid=' + item.startStationId + '&downid=' + downid
- });
- },
- mapopenBtn() {
- this.mapopen = !this.mapopen;
- if (this.mapopen) {
- this.$refs.amap.setMyStyle('width: 100%; height: 340px;');
- } else {
- this.$refs.amap.setMyStyle('width: 100%; height: 140px;');
- }
- },
- getNearbyStationInfo() {
-
- let data1 = {latitude:this.latitude,longtitude:this.longitude,findType:"1"};
- this.getChargingStationData(data1);
- let data2 = {latitude:this.latitude,longtitude:this.longitude,findType:"0"};
- this.getChargingStationData(data2);
-
- }
- }
- };
- </script>
- <style>
- .cj-slider {
- width: 90%;
- margin: auto;
- }
- .cj-slide__text {
- text-align: center;
- padding: 20rpx;
- }
- .preference_group_item {
- padding: 15rpx;
- }
- .preference_group {
- padding-bottom: 20rpx;
- }
- .preference {
- background-color: #ffffff;
- left: 0rpx;
- position: absolute;
- }
- .preference_item {
- margin-bottom: 10rpx;
- margin-left: 20rpx;
- text-align: center;
- border-style: none;
- width: 20%;
- }
- .preference_item_plus {
- margin-bottom: 10rpx;
- margin-left: 20rpx;
- align-items: center;
- justify-content: center;
- text-align: center;
- width: 25%;
- border-style: none;
- }
- .preference_label {
- color: #9f9c99;
- margin-left: 20rpx;
- margin-bottom: 100rpx;
- }
- .map{
- background-color: #ffffff;
- left: 0rpx;
- position: absolute;
-
- }
- .chargerCard{
- /* background-color: #fff;
- margin: 0 12px;
- border-radius: 8px;
- padding: 10px 12px 0px;
- position: absolute;
- bottom: 68px;
- left: 0;
- right: 0;
- z-index:1021
- */
- background-color: #fff;
- margin: 0 12px;
- border-radius: 8px;
- padding: 10px 12px 0px;
- bottom: 68px;
- left: 0;
- right: 0;
- position: fixed;
- height:360rpx;
- /*
- z-index: 1021;
- width: 80%;
- margin-left: 10%;
- bottom: 50rpx;
-
- */
- }
- .arrow{
- margin-right: 15rpx;
- }
- .card_item{
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- margin-left: 20rpx;
- margin-right: 20rpx;
- margin-bottom: 10rpx;
- }
- .card_item2{
- display: flex;
- flex-direction: row;
- margin-left: 20rpx;
- margin-right: 20rpx;
- margin-bottom: 10rpx;
- }
- .round{
- border-radius:50rpx;
- background-color: #00B962;
- color: #ffffff;
- text-align: center;
- justify-content: center;
- align-items: center;
- width: 250rpx;
- display: flex;
- flex-direction: row;
- }
- .round2{
- border-radius:50rpx;
- background-color: #00B962;
- color: #ffffff;
- text-align: center;
- justify-content: center;
- align-items: center;
- width:125rpx;
- }
- .swiper-item{
- }
-
- .list {
- margin-left: 2px;
-
- }
-
- .charing-slow {
- background-color: #fff;
- margin: 20rpx;
- border-radius: 8px;
- padding: 10px 12px 0px;
- position: relative;
- left: 0;
- right: 0;
- }
- .fast-charge {
- display: inline-block;
- width: 44px;
- height: 20px;
- line-height: 20px;
- border-radius: 50px;
- background-color: #9d9fff;
- color: rgba(255, 255, 255, 100);
- font-size: 12px;
- text-align: center;
- }
- .trickle-charge {
- display: inline-block;
- width: 44px;
- height: 20px;
- line-height: 20px;
- border-radius: 50px;
- background-color: rgba(0, 185, 98, 100);
- color: rgba(255, 255, 255, 100);
- font-size: 12px;
- text-align: center;
- }
-
- .station-items {
- display: inline-block;
- height: 16px;
- line-height: 16px;
- font-size: 16px;
- margin-left: 4px;
- color: #101010;
-
-
- }
-
- .fast-charge {
- display: inline-block;
- width: 44px;
- height: 20px;
- line-height: 20px;
- border-radius: 50px;
- background-color: #9d9fff;
- color: rgba(255, 255, 255, 100);
- font-size: 12px;
- text-align: center;
- }
-
- .address {
- margin-top: 8px;
- line-height: 16px;
- font-size: 11px;
- color: rgba(119, 119, 119, 100);
- }
-
- .price {
- display: flex;
- height: 20px;
-
- }
-
-
- .num {
- height: 20px;
- color: rgba(255, 98, 0, 100);
- font-size: 20px;
- text-align: left;
- font-family: Roboto-medium;
- }
-
- .unit {
- height: 14px;
- line-height: 14px;
- color: rgba(102, 102, 102, 100);
- font-size: 14px;
- text-align: left;
- font-family: AlibabaPuHui-regular;
- margin-top: 6px;
- margin-left: 4px;
- }
- .park {
- margin-top: 8px;
- display: flex;
-
-
-
-
- }
- .park-p {
- display: inline-block;
- width: 20px;
- height: 18px;
- line-height: 12px;
- text-align: center;
- background-color: rgba(125, 177, 255, 100);
- color: #fff;
- }
- .park-text {
- display: inline-block;
- width: 300px;
- height: 17px;
- color: rgba(102, 102, 102, 100);
- font-size: 12px;
- text-align: left;
- margin-left: 4px;
- margin-top: 2px;
- }
-
- .map {
- width: 100%;
-
- height: 100%;
- position: relative;
- }
- #container {
- width: 100%;
- height: 100%;
- }
- .free {
- display: flex;
- justify-content: space-between;
- height: 52px;
- border-top: 1px solid rgba(238, 242, 240, 100);
- margin-top: 10px;
-
-
- }
- .free-num {
- line-height: 52px;
- font-size: 16px
- }
- .distance {
- width: 130px;
- height: 28px;
- line-height: 28px;
- color: rgba(255, 255, 255, 100);
- font-size: 14px;
- background-color: #00b962;
- border-radius: 50px;
- margin: 12px;
- text-align: center;
-
- }
- .distance-font {
- font-size: 16px
- }
- </style>
|