searchPile.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. <template>
  2. <view>
  3. <u-navbar :is-back="false" height="88" style="background-color: bisque;">
  4. <view style="display: flex;flex-direction: column; width: 100%;height: 100%;">
  5. <view style="display: flex;flex-direction: row; height: 100%; align-items: center;margin-top:0rpx;padding-top: 0rpx;padding-bottom: 20rpx;">
  6. <view style="margin-left:20rpx;">
  7. <label class="arrow">{{ area }}</label>
  8. <u-icon name="arrow-down-fill" size="13" color="#c0c4cc"></u-icon>
  9. </view>
  10. <view style="margin-left: 20rpx;margin-right: 20rpx; flex:1" >
  11. <u-search placeholder="搜索站点名称" v-model="keyword" :showAction="false" @focus="navigate"></u-search></view>
  12. <view style="margin-right: 20rpx;" v-show="viewMode" @click="listMode">
  13. <text class="iconfont">&#xe613;</text> <text class="list">列表</text>
  14. <!-- <u-icon name="list-dot" size="26" color="#c0c4cc"></u-icon>
  15. <label>列表</label>-->
  16. </view>
  17. <view style="margin-right: 20rpx;" v-show="!viewMode" @click="mapMode">
  18. <text class="iconfont">&#xe622;</text> <text class="list">地图</text>
  19. <!--<u-icon name="map" size="26" color="#c0c4cc"></u-icon>
  20. <label>地图</label>
  21. -->
  22. </view>
  23. </view>
  24. <view style="display: flex;flex-direction: row;width:100%; justify-content: space-between;align-items: center;">
  25. <view style="margin-left: 20rpx;">
  26. <label class="arrow">{{ info.miles_type[preference.miles_index].text }}</label>
  27. <u-icon name="arrow-down-fill" size="13" color="#c0c4cc"></u-icon>
  28. </view>
  29. <view style="margin-left: 20rpx;margin-right: 20rpx;flex:1">
  30. <label class="arrow">{{ info.obc_type[preference.obc_type_index].text }}</label>
  31. <u-icon name="arrow-down-fill" size="13" color="#c0c4cc"></u-icon>
  32. </view>
  33. <view style="margin-right: 20rpx;" @click="open">
  34. <label class="arrow">{{ action }}</label>
  35. <u-icon v-if="show" name="arrow-down-fill" size="13" color="#00B962"></u-icon>
  36. <u-icon v-else name="arrow-down-fill" size="13" color="#c0c4cc"></u-icon>
  37. </view>
  38. </view>
  39. </view>
  40. </u-navbar>
  41. <view class="content" >
  42. <view v-if="show" class="preference" :style="show ? 'z-index:1024;top:'+navBarHeight+'px;' : 'z-index:0'">
  43. <view class="preference_group">
  44. <view class="preference_group_item"><label class="preference_label">距离我</label></view>
  45. <view>
  46. <u-tag
  47. class="preference_item"
  48. v-for="(item, index) in info.miles_type"
  49. :key="index"
  50. :style="index == preference.miles_index ? 'background-color:#00B962;color:#FFFFFF' : 'background-color:#EFF4F2;color:#926666'"
  51. shape="circle"
  52. :text="item.text"
  53. @click="selectMiles(index)"
  54. ></u-tag>
  55. </view>
  56. </view>
  57. <view class="preference_group">
  58. <view class="preference_group_item"><label class="preference_label">充电站类型</label></view>
  59. <view>
  60. <u-tag
  61. class="preference_item"
  62. v-for="(item, index) in info.obc_type"
  63. :key="index"
  64. :style="index == preference.obc_type_index ? 'background-color:#00B962;color:#FFFFFF' : 'background-color:#EFF4F2;color:#926666'"
  65. shape="circle"
  66. :text="item.text"
  67. @click="selectOBSType(index)"
  68. ></u-tag>
  69. </view>
  70. </view>
  71. <view class="preference_group">
  72. <view class="preference_group_item"><label class="preference_label">是否对外开放</label></view>
  73. <view>
  74. <u-tag
  75. class="preference_item_plus"
  76. v-for="(item, index) in info.obc_status"
  77. :key="index"
  78. :style="index == preference.obc_status_index ? 'background-color:#00B962;color:#FFFFFF' : 'background-color:#EFF4F2;color:#926666'"
  79. shape="circle"
  80. :text="item.text"
  81. @click="selectOBSStatus(index)"
  82. ></u-tag>
  83. </view>
  84. </view>
  85. <view class="preference_group">
  86. <view class="preference_group_item"><label class="preference_label">充电桩电压 (V)</label></view>
  87. <view>
  88. <u-tag
  89. class="preference_item_plus"
  90. v-for="(item, index) in info.obc_voltage"
  91. :key="index"
  92. :style="index == preference.obc_voltage_index ? 'background-color:#00B962;color:#FFFFFF' : 'background-color:#EFF4F2;color:#926666'"
  93. shape="circle"
  94. :text="item.text"
  95. @click="selectOBCVoltage(index)"
  96. ></u-tag>
  97. </view>
  98. </view>
  99. <view class="preference_group">
  100. <view class="preference_group_item"><label class="preference_label">充电桩电压 (kW)</label></view>
  101. <view style="height: 50rpx;margin-left: 30rpx;">
  102. <DoubleSlider
  103. ref="obc_voltage"
  104. sliderHeight="15rpx"
  105. blockSize="36rpx"
  106. :minValue="info.obc_power.minValue"
  107. :maxValue="info.obc_power.maxValue"
  108. v-model="preference.obc_power"
  109. :currentMinValue="preference.obc_power.minValue"
  110. :currentMaxValue="preference.obc_power.maxValue"
  111. labelColor="#B8C9C5"
  112. borderRadius="25rpx"
  113. borderColor="#00B962"
  114. borderStyle="solid"
  115. borderWidth="3rpx"
  116. blockColor="#FFFFFF"
  117. activeColor="#00B962"
  118. indicatorColor="#DBDBDB"
  119. @change="handlerDoubleSlider"
  120. > </DoubleSlider>
  121. </view>
  122. </view>
  123. <view class="preference_group">
  124. <view style="margin-left: 30rpx;"><u-checkbox shape="circle" v-model="preference.save_preference" @change="radioChange">保存偏好设置</u-checkbox></view>
  125. </view>
  126. <view style="display: flex;flex-direction: row;">
  127. <u-button @click="reset" style="width: 30%;">重置</u-button>
  128. <u-button @click="close" style="width: 70%;background-color: #00B962;">确定</u-button>
  129. </view>
  130. </view>
  131. <view v-show="!viewMode" >
  132. <view v-for="(item,index) in stationslist" :key="item.id" class="charing-slow" >
  133. <text :class="item.type == '快充' ? 'fast-charge':'trickle-charge'">{{item.type}}</text> <text class="station-items">{{item.name}}</text>
  134. <view class="address">
  135. {{item.position}}
  136. </view>
  137. <view class="price">
  138. <view class="num">{{item.price}}</view>
  139. <view class="unit">
  140. 起 元/度
  141. </view>
  142. </view>
  143. <view class="park">
  144. <text class="park-p">p</text>
  145. <text class="park-text">2小时免费停车</text>
  146. </view>
  147. <view class="free">
  148. <view class="free-num">
  149. <text style="color:#009143;">空闲{{item.idleNum}}</text>/总数{{item.total}}
  150. </view>
  151. <view class="distance">
  152. <text class="iconfont distance-font">&#xe615;</text>{{item.distance.toFixed(2)}}公里 {{item.time.toFixed(0)}}分钟
  153. </view>
  154. </view>
  155. </view>
  156. <u-divider margin-top="20" bg-color="#F2F4F4">已经到底了</u-divider>
  157. </view>
  158. <view v-show="viewMode" >
  159. <view>
  160. <Chargermap @location="location" @onMoveEnd="moveEnd" ref="amap" @onload="mapdown" @clickMap="clickMap"></Chargermap>
  161. </view>
  162. <view v-if="stationsmap.length>0" class="chargerCard" style="border-radius: 20rpx;" >
  163. <swiper :current="currentIndex" @change="swiperChange" @transition="swiperTransition" style="height: 100%;">
  164. <swiper-item v-for="(item,index) in stationsmap" :key="item.id" style="height: 100%;">
  165. <view class="swiper-item" style="height: 100%; background-color: #ffffff;">
  166. <view class="card_item" style="font-size: 35rpx;padding-top: 5rpx;">
  167. <view style="display: flex;flex-direction: row;">
  168. <view :class="item.type == '快充'? 'fast-charge':'trickle-charge'" >
  169. {{item.type}}
  170. </view>
  171. <view>
  172. {{item.name}}
  173. </view>
  174. </view>
  175. </view>
  176. <view class="card_item" style="color:#8898A9;font-size: 15rpx;">
  177. {{item.position}}
  178. </view>
  179. <view class="card_item2" >
  180. <view style="color:#FF6573;font-size:45rpx;margin-right: 10rpx;">
  181. {{item.price}}
  182. </view>
  183. <view style="display: flex; justify-content: center;align-items: center">
  184. 起 元/度
  185. </view>
  186. </view>
  187. <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">
  188. <view style="display: flex;flex-direction: row;">
  189. <view style="background-color: #7DB1FF;padding-left: 10rpx;padding-right: 10rpx;">
  190. P
  191. </view>
  192. <label>{{item.park}}</label>
  193. </view>
  194. <view style="display: flex;flex-direction: row;">
  195. <view style="color: #00B962;">
  196. 空闲{{item.idleNum}}
  197. </view>
  198. <view>
  199. /总数{{item.total}}
  200. </view>
  201. </view>
  202. </view>
  203. <view class="card_item" style="padding-bottom: 20rpx;">
  204. <u-button shape='circle' style="color: #00B962;" @click="charge(item)">
  205. <u-icon name="scan" size="26" color="#00B962" style="margin-right: 20rpx;"></u-icon>
  206. <label>扫码充电</label></u-button>
  207. <view class="round">
  208. <text class="iconfont distance-font">&#xe615;</text>
  209. <view style="margin-right: 10rpx;">
  210. {{item.distance.toFixed(2)}}公里
  211. </view>
  212. <view style="margin-right: 10rpx;">
  213. {{item.time.toFixed(0)}}分钟
  214. </view>
  215. </view>
  216. </view>
  217. </view>
  218. </swiper-item>
  219. </swiper>
  220. </view>
  221. </view>
  222. </view>
  223. <Tabbar :current="1"></Tabbar>
  224. </view>
  225. </template>
  226. <script>
  227. // import api from './site-index.js'
  228. // export default api
  229. import * as api from '@/apis/site.js';
  230. import Chargermap from '@/components/Chargermap.vue';
  231. import DoubleSlider from '@/components/double-slider/DoubleSlider.vue';
  232. import Tabbar from '@/components/Tabbar.vue';
  233. import * as WxJsApi from '@/utils/wxJsApi.js'
  234. import MapLoader from '@/utils/AMap'
  235. //import * as navigation from '@/pages/navigation/index.vue'
  236. let _self;
  237. export default {
  238. components: {
  239. Chargermap,
  240. DoubleSlider,
  241. Tabbar
  242. },
  243. data() {
  244. return {
  245. currentIndex:-1,
  246. navBarHeight:88,
  247. viewMode: true, //地图
  248. keyword: '',
  249. show: false,
  250. mapopen: false,
  251. isReady: false,
  252. id: '',
  253. longitude: 112.28308,
  254. latitude: 30.312084,
  255. // longitude: '',
  256. // latitude: '',
  257. nearbyStationInfo: {
  258. nearbyShiftDTOList: []
  259. },
  260. area: '荆州市',
  261. action: '筛选',
  262. preference: {
  263. miles_index: 3,
  264. obc_type_index: 0,
  265. obc_status_index: 0,
  266. obc_voltage_index: 0,
  267. save_preference: false,
  268. obc_power: { minValue: 0, maxValue: 500 }
  269. },
  270. stationsmap:[
  271. /* {name:'荆鹏软件园充电站',position:'湖北省荆州市沙市区江津东路附155号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'慢充'},
  272. {name:'荆鹏软件园充电站2',position:'湖北省荆州市沙市区江津东路附156号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'快充'},
  273. {name:'荆鹏软件园充电站3',position:'湖北省荆州市沙市区江津东路附157号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'慢充'},
  274. {name:'荆鹏大道求助站充电站',position:'湖北省荆州市沙市区江津东路附158号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'快充'},
  275. */
  276. ],
  277. first:true,
  278. timer:null,
  279. stationslist:[],
  280. info: {
  281. miles_type: [
  282. { distance: 1, text: '1公里' },
  283. { distance: 2, text: '2公里' },
  284. { distance: 5, text: '5公里' },
  285. { distance: 10, text: '10公里' },
  286. { distance: 20, text: '20公里' },
  287. { distance: 50, text: '50公里' },
  288. { distance: 100, text: '100公里' },
  289. { distance: 200, text: '200公里' }
  290. ],
  291. obc_type: [{ value: 0, text: '直流快充' }, { value: 1, text: '交流慢充' }],
  292. obc_status: [{ value: 0, text: '对外开放' }, { value: 1, text: '不对外开放' }],
  293. obc_voltage: [{ value: 0, text: '低于700V' }, { value: 1, text: '700V及以上' }],
  294. obc_power: { minValue: 0, maxValue: 1000 }
  295. }
  296. };
  297. },
  298. onLoad(op) {
  299. _self = this;
  300. console.log('longitude0 ' + _self.longitude);
  301. console.log('latitude0 ' + _self.latitude);
  302. if (op != null) {
  303. if (op.longitude != null) this.longitude = op.longitude;
  304. if (op.latitude != null) this.latitude = op.latitude;
  305. if (op.id != null) this.id = op.id;
  306. }
  307. },
  308. onReady() {
  309. WxJsApi.getWxConfig(['getLocation','addEventListener']).then((res)=>{
  310. // this.message=JSON.stringify(res)
  311. // uni.showToast({
  312. // title:JSON.stringify(res)
  313. // })
  314. console.log(res)
  315. }).catch(error => {
  316. console.log(res)
  317. })
  318. // console.log('longitude2 '+this.longitude)
  319. // console.log('latitude2 '+this.latitude)
  320. this.$refs.amap.init();
  321. // this.$refs.amap.setMyStyle("height:1500rpx;width:100%;");
  322. // this.$refs.amap.setMyStyle("height:calc(100%-176rpx);width:100%;");
  323. // console.log('longitude3 '+this.longitude)
  324. // console.log('latitude3 '+this.latitude)
  325. },
  326. onShow() {
  327. console.log('onShow')
  328. if (this.isReady) {
  329. }
  330. },
  331. onHide(){
  332. this.end();
  333. },
  334. methods: {
  335. navigate(){
  336. console.log('naviage to ')
  337. uni.navigateTo({
  338. url:'/pages/search/search'
  339. })
  340. },
  341. getPoint() {
  342. console.log('getPoint')
  343. WxJsApi.getLocation().then((res) => {
  344. var latitude = parseFloat(res.latitude);
  345. var longitude = parseFloat(res.longitude);
  346. let data = {position:{latitude:latitude,longitude:longitude}};
  347. if(_self.first)
  348. {
  349. var obj = {
  350. longitude: longitude,
  351. latitude: latitude
  352. };
  353. this.$refs.amap.setPerson(obj);
  354. _self.first = false;
  355. }
  356. this.location(data);
  357. console.log('当前位置' +JSON.stringify(data))
  358. //this.latitude2 = latitude;
  359. //this.longitude2 = longitude;
  360. /*uni.showToast({
  361. title:JSON.stringify(res)
  362. })*/
  363. //this.message=JSON.stringify(res)
  364. }).catch(error => {
  365. uni.showToast({
  366. title:JSON.stringify(error)
  367. })
  368. })
  369. },
  370. start() {
  371. let self = this;
  372. // 将定时器名字赋值到变量中
  373. this.timer = setInterval(() => {
  374. //console.log("开始---");
  375. //self.$refs.amap.getLocation1();
  376. //self.$refs.amap.getLocation ();
  377. }, 10000);
  378. },
  379. end() {
  380. clearInterval(this.timer);
  381. this.timer = null // 这里最好清除一下,回归默认值
  382. // 众所周知,定时器返回一个随机整数,用于表示定时器的编号,后面通过名字可以取消这个定时器的执行。
  383. console.log(this.timer);
  384. },
  385. location(e){
  386. if(e.position){
  387. if(e.position.latitude && e.position.longitude)
  388. if(this.latitude != e.position.latitude ||
  389. this.longitude != e.position.longitude)
  390. {
  391. this.longitude = e.position.longitude;
  392. this.latitude = e.position.latitude;
  393. let data = {latitude:this.latitude,longtitude:this.longitude,findType:"1"};
  394. this.getChargingStationData(data);
  395. console.log('获取定位'+JSON.stringify(e));
  396. }
  397. }
  398. },
  399. getChargingStationData(pos){
  400. //return;
  401. if(pos == null)
  402. return ;
  403. console.log('getChargingStationData'+JSON.stringify(pos))
  404. let data1 = { pageIndex:0,pageSize:20};
  405. if(this.info.obc_type[this.preference.obc_type_index].text.indexOf('直流快充')>=0)
  406. data1.type = "1";
  407. else if(this.info.obc_type[this.preference.obc_type_index].text.indexOf('交流慢充')>=0)
  408. data1.type = "2";
  409. if(pos.longtitude != null)
  410. data1.longitude = pos.longtitude.toString();
  411. if(pos.latitude != null)
  412. data1.latitude = pos.latitude.toString();
  413. if(this.info.miles_type[this.preference.miles_index].distance!=null)
  414. data1.radius = this.info.miles_type[this.preference.miles_index].distance.toString();
  415. data1.online = "0";//在线
  416. if(pos.findType != null)
  417. data1.findType = pos.findType;
  418. else
  419. data1.findType = "0";
  420. if(this.preference.obc_power.minValue!=null)
  421. data1.powerStart = this.preference.obc_power.minValue.toString();
  422. if(this.preference.obc_power.maxValue!=null)
  423. data1.powerEnd = this.preference.obc_power.maxValue.toString();
  424. console.log('data1'+JSON.stringify(data1))
  425. api.geChargingStationData(data1).then(function(res){
  426. if(!res.result || !res.data || !res.data.data)
  427. {
  428. console.log('getChargingStationData res nulll')
  429. return;
  430. }
  431. let items = res.data.data;
  432. if(data1.findType == "0")
  433. {
  434. console.log('getChargingStationData res1'+JSON.stringify(res));
  435. _self.stationsmap = [];
  436. for(let i = 0;i<items.length;i++)
  437. {
  438. let obj = {
  439. name:'',
  440. position:'',
  441. price:1.2,
  442. idleNum:10,
  443. total:10,
  444. type: data1.type == "2" ? '慢充':'快充',
  445. id: i,
  446. distance:0.9,
  447. time:9,
  448. park: '以实际费用为准',
  449. // longitude: 112.28541 + i * 0.001,
  450. // latitude: 30.308354 + i * 0.01
  451. };
  452. if(items[i].name!=null)
  453. obj.name = items[i].name;
  454. if(items[i].address!=null)
  455. obj.position = items[i].address;
  456. if(items[i].coostPrice!=null)
  457. obj.price = items[i].coostPrice;
  458. if(items[i].availableNum!=null)
  459. obj.idleNum = items[i].availableNum;
  460. if(items[i].totalNum!=null)
  461. obj.total = items[i].totalNum;
  462. if(items[i].longitude!=null)
  463. obj.longitude = items[i].longitude;
  464. if(items[i].latitude!=null)
  465. obj.latitude = items[i].latitude;
  466. if(items[i].distance!=null)
  467. obj.distance = items[i].distance;
  468. if(items[i].time != null){
  469. obj.time = items[i].time;
  470. }
  471. if(items[i].park != null)
  472. obj.park = items[i].park;
  473. /*
  474. let obj = {name:items[i].name,
  475. position:items[i].address,
  476. price:items[i].coostPrice,
  477. idleNum:items[i].availableNum,
  478. total:items[i].totalNum,
  479. distance:0.1,
  480. time:1,
  481. type:'慢充',
  482. id: items[i].id,
  483. park: i%2 == 0? '以实际费用为准':'2小时免费停车',
  484. longitude: items[i].longitude,
  485. latitude: items[i].latitude
  486. };*/
  487. _self.stationsmap.push(obj);
  488. }
  489. _self.$refs.amap.searchBtn([_self.longitude, _self.latitude],_self.stationsmap)
  490. _self.$refs.amap.setChargerList(_self.stationsmap);
  491. }else if(data1.findType == "1")
  492. {
  493. _self.stationslist = [];
  494. console.log('getChargingStationData res2'+JSON.stringify(res));
  495. for(let i = 0;i<items.length;i++)
  496. {
  497. let obj = {
  498. name:'',
  499. position:'',
  500. price:1.2,
  501. idleNum:10,
  502. total:10,
  503. type: data1.type == "2" ? '慢充':'快充',
  504. id: i,
  505. distance:0.9,
  506. time:9,
  507. park: '以实际费用为准',
  508. // longitude: 112.28541 + i * 0.001,
  509. // latitude: 30.308354 + i * 0.01
  510. };
  511. if(items[i].name!=null)
  512. obj.name = items[i].name;
  513. if(items[i].address!=null)
  514. obj.position = items[i].address;
  515. if(items[i].coostPrice!=null)
  516. obj.price = items[i].coostPrice;
  517. if(items[i].availableNum!=null)
  518. obj.idleNum = items[i].availableNum;
  519. if(items[i].totalNum!=null)
  520. obj.total = items[i].totalNum;
  521. if(items[i].longitude!=null)
  522. obj.longitude = items[i].longitude;
  523. if(items[i].latitude!=null)
  524. obj.latitude = items[i].latitude;
  525. if(items[i].distance!=null)
  526. obj.distance = items[i].distance;
  527. if(items[i].time != null){
  528. obj.time = items[i].time;
  529. }
  530. if(items[i].park != null)
  531. obj.park = items[i].park;
  532. //arr.push(obj);
  533. _self.stationslist.push(obj);
  534. }
  535. _self.$refs.amap.searchBtn([_self.longitude, _self.latitude],_self.stationslist)
  536. console.log(' getChargingStationData stations'+JSON.stringify(_self.stationslist))
  537. }
  538. },function(err){
  539. console.log('getChargingStationData err'+JSON.stringify(err))
  540. }
  541. )
  542. console.log('getChargingStationData end')
  543. },
  544. charge(item){
  545. console.log('扫码充电')
  546. //#ifdef MP-WEIXIN
  547. uni.scanCode({
  548. success:function(res){
  549. uni.navigateTo({
  550. url:'chargingPileDetails?pile='+encodeURIComponent(JSON.stringify(data))
  551. })
  552. }
  553. })
  554. return;
  555. //#endif
  556. console.log('扫码充电1')
  557. uni.navigateTo({
  558. url:'stationAndPile/chargingPileDetails'
  559. })
  560. },
  561. moveEnd(e){
  562. console.log('moveEnd'+JSON.stringify(e))
  563. let data = {latitude:e.center.lat,longtitude:e.center.lng};
  564. this.getChargingStationData(data);
  565. },
  566. clickTabItem (index) {
  567. this.currentIndex = index
  568. },
  569. swiperChange (e) {
  570. this.currentIndex = e.detail.current
  571. let station = this.stationsmap[this.currentIndex];
  572. let posCenter= {longitude: station.longitude,latitude: station.latitude};
  573. // console.log('currentIndex'+JSON.stringify(this.currentIndex))
  574. // console.log('currentIndex'+JSON.stringify(posCenter))
  575. // console.log('station'+JSON.stringify(station))
  576. let bounds = this.$refs.amap.logMapInfo();
  577. /*if( (posCenter.latitude<bounds.bounds.northeast.lat && posCenter.latitude>bounds.bounds.sourthwest.lat)
  578. && (posCenter.longitude<bounds.bounds.northeast.lng && posCenter.longitude>bounds.bounds.sourthwest.lng)
  579. ){
  580. console.log('bounds'+JSON.stringify(bounds));
  581. }else{
  582. this.$refs.amap.setCenter(posCenter);
  583. }*/
  584. this.$refs.amap.updateCharger(station);
  585. },
  586. swiperTransition (e) {
  587. // console.log(e)
  588. },
  589. listMode() {
  590. this.viewMode = false
  591. },
  592. mapMode() {
  593. this.viewMode = true
  594. },
  595. radioChange(e) {
  596. // console.log('e'+JSON.stringify(e))
  597. this.preference.save_preference = e.value;
  598. // console.log('save_preference '+this.preference.save_preference);
  599. },
  600. handlerDoubleSlider(e) {
  601. // console.log('e'+JSON.stringify(e))
  602. this.preference.obc_power = e;
  603. //this.preference.obc_power.minValue = e.minValue;
  604. //this.preference.obc_power.maxValue = e.maxValue;
  605. },
  606. selectOBSType(index) {
  607. this.preference.obc_type_index = index;
  608. },
  609. selectOBSStatus(index) {
  610. this.preference.obc_status_index = index;
  611. },
  612. selectOBCVoltage(index) {
  613. this.preference.obc_voltage_index = index;
  614. },
  615. selectMiles(index) {
  616. this.preference.miles_index = index;
  617. },
  618. reset() {
  619. this.preference.obc_status_index = 0;
  620. this.preference.obc_voltage_index = 0;
  621. this.preference.obc_type_index = 0;
  622. this.preference.miles_index = 3;
  623. this.preference.save_preference = false;
  624. // this.$refs.obc_voltage.currentValue = [0,100];
  625. this.preference.obc_power.minValue = 0;
  626. this.preference.obc_power.maxValue = 500;
  627. this.preference.obc_power.minP = Math.floor((this.preference.obc_power.minValue / (this.info.obc_power.maxValue - this.info.obc_power.minValue)) * 100);
  628. this.preference.obc_power.maxP = Math.floor((this.preference.obc_power.maxValue / (this.info.obc_power.maxValue - this.info.obc_power.minValue)) * 100);
  629. // console.log('minP'+this.preference.obc_power.minP)
  630. // console.log('maxP'+this.preference.obc_power.maxP)
  631. this.$refs.obc_voltage.reset(this.preference.obc_power);
  632. // this.$refs.obc_voltage.currentMaxValue = this.preference.obc_power[1];
  633. // console.log('reset')
  634. },
  635. open() {
  636. this.show = true;
  637. //this.$refs.obc_voltage.currentMinValue = this.preference.obc_power[0];
  638. //this.$refs.obc_voltage.currentMaxValue = this.preference.obc_power[1];
  639. console.log('open');
  640. },
  641. close() {
  642. console.log('偏好设置' + JSON.stringify(this.preference));
  643. this.show = false;
  644. let data = {latitude:this.latitude,longtitude:this.longitude};
  645. this.getChargingStationData(data);
  646. // console.log('close');
  647. },
  648. // 获取当前位置
  649. clickMap(obj) {
  650. //this.currentIndex = 5;
  651. // console.log('longitude1 ' + _self.longitude);
  652. // console.log('latitude1 ' + _self.latitude);
  653. if (obj == null || obj.type == null) return;
  654. if (obj.type == 'charger') {
  655. api.getChargerInfoById(obj).then(
  656. function(data) {
  657. if (obj.obj != null) {
  658. //obj.obj.price = 2.25;
  659. //obj.obj.idleNum = 12;
  660. _self.$refs.amap.updateCharger(obj.obj);
  661. let index = _self.stationsmap.findIndex(item => item.id == obj.obj.id);
  662. _self.currentIndex = index;
  663. console.log('find Index'+index);
  664. }
  665. // console.log('点击1'+JSON.stringify(obj));
  666. },
  667. function(err) {
  668. console.log('点击2' + JSON.stringify(obj));
  669. }
  670. );
  671. }
  672. },
  673. mapdown() {
  674. //console.log('this'+JSON.stringify(this))
  675. // console.log('longitude1 ' + this.longitude);
  676. // console.log('latitude1 ' + this.latitude);
  677. //this.start();
  678. //this.$refs.amap.getLocation1();
  679. // this.getNearbyStationInfo();
  680. this.isReady = true;
  681. //this.$refs.amap.getLocation ();
  682. //let state = {};
  683. uni.getSystemInfo({
  684. success: (res) => {
  685. // #ifndef MP
  686. let navbarH = 0
  687. // #endif
  688. // #ifdef MP
  689. let navbarH = uni.upx2px(90)
  690. // #endif
  691. /*state.status_width = res.windowWidth;
  692. console.log('window width'+state.status_width);*/
  693. let scrollH = res.windowHeight;// - uni.upx2px(88) - navbarH
  694. // console.log('布局结果'+ JSON.stringify(res));
  695. // console.log('scrollH'+scrollH)
  696. //#ifdef MP-WEIXIN
  697. const {
  698. statusBarHeight,
  699. windowWidth,
  700. } = uni.getSystemInfoSync();
  701. // console.log('height ' + statusBarHeight);
  702. //this.status_height = uni.getStatusbarHeight();
  703. let res1 = uni.getMenuButtonBoundingClientRect()
  704. // console.log('layout selectHeight '+JSON.stringify(res1))
  705. //state.selectHeight = (res1.top-res.statusBarHeight)*2+ res1.height;
  706. //#endif
  707. //console.log('status height'+state.status_height)
  708. _self.$refs.amap.setMyStyle("height:"+(scrollH-88-50)+ "px;width:100%;");
  709. }
  710. })
  711. this.getPoint();
  712. },
  713. gotoLine(item, downid) {
  714. uni.navigateTo({
  715. url: '/pages/route/index?id=' + item.routeId + '&upid=' + item.startStationId + '&downid=' + downid
  716. });
  717. },
  718. mapopenBtn() {
  719. this.mapopen = !this.mapopen;
  720. if (this.mapopen) {
  721. this.$refs.amap.setMyStyle('width: 100%; height: 340px;');
  722. } else {
  723. this.$refs.amap.setMyStyle('width: 100%; height: 140px;');
  724. }
  725. },
  726. getNearbyStationInfo() {
  727. let data1 = {latitude:this.latitude,longtitude:this.longitude,findType:"1"};
  728. this.getChargingStationData(data1);
  729. let data2 = {latitude:this.latitude,longtitude:this.longitude,findType:"0"};
  730. this.getChargingStationData(data2);
  731. }
  732. }
  733. };
  734. </script>
  735. <style>
  736. .cj-slider {
  737. width: 90%;
  738. margin: auto;
  739. }
  740. .cj-slide__text {
  741. text-align: center;
  742. padding: 20rpx;
  743. }
  744. .preference_group_item {
  745. padding: 15rpx;
  746. }
  747. .preference_group {
  748. padding-bottom: 20rpx;
  749. }
  750. .preference {
  751. background-color: #ffffff;
  752. left: 0rpx;
  753. position: absolute;
  754. }
  755. .preference_item {
  756. margin-bottom: 10rpx;
  757. margin-left: 20rpx;
  758. text-align: center;
  759. border-style: none;
  760. width: 20%;
  761. }
  762. .preference_item_plus {
  763. margin-bottom: 10rpx;
  764. margin-left: 20rpx;
  765. align-items: center;
  766. justify-content: center;
  767. text-align: center;
  768. width: 25%;
  769. border-style: none;
  770. }
  771. .preference_label {
  772. color: #9f9c99;
  773. margin-left: 20rpx;
  774. margin-bottom: 100rpx;
  775. }
  776. .map{
  777. background-color: #ffffff;
  778. left: 0rpx;
  779. position: absolute;
  780. }
  781. .chargerCard{
  782. /* background-color: #fff;
  783. margin: 0 12px;
  784. border-radius: 8px;
  785. padding: 10px 12px 0px;
  786. position: absolute;
  787. bottom: 68px;
  788. left: 0;
  789. right: 0;
  790. z-index:1021
  791. */
  792. background-color: #fff;
  793. margin: 0 12px;
  794. border-radius: 8px;
  795. padding: 10px 12px 0px;
  796. bottom: 68px;
  797. left: 0;
  798. right: 0;
  799. position: fixed;
  800. height:360rpx;
  801. /*
  802. z-index: 1021;
  803. width: 80%;
  804. margin-left: 10%;
  805. bottom: 50rpx;
  806. */
  807. }
  808. .arrow{
  809. margin-right: 15rpx;
  810. }
  811. .card_item{
  812. display: flex;
  813. flex-direction: row;
  814. justify-content: space-between;
  815. margin-left: 20rpx;
  816. margin-right: 20rpx;
  817. margin-bottom: 10rpx;
  818. }
  819. .card_item2{
  820. display: flex;
  821. flex-direction: row;
  822. margin-left: 20rpx;
  823. margin-right: 20rpx;
  824. margin-bottom: 10rpx;
  825. }
  826. .round{
  827. border-radius:50rpx;
  828. background-color: #00B962;
  829. color: #ffffff;
  830. text-align: center;
  831. justify-content: center;
  832. align-items: center;
  833. width: 250rpx;
  834. display: flex;
  835. flex-direction: row;
  836. }
  837. .round2{
  838. border-radius:50rpx;
  839. background-color: #00B962;
  840. color: #ffffff;
  841. text-align: center;
  842. justify-content: center;
  843. align-items: center;
  844. width:125rpx;
  845. }
  846. .swiper-item{
  847. }
  848. .list {
  849. margin-left: 2px;
  850. }
  851. .charing-slow {
  852. background-color: #fff;
  853. margin: 20rpx;
  854. border-radius: 8px;
  855. padding: 10px 12px 0px;
  856. position: relative;
  857. left: 0;
  858. right: 0;
  859. }
  860. .fast-charge {
  861. display: inline-block;
  862. width: 44px;
  863. height: 20px;
  864. line-height: 20px;
  865. border-radius: 50px;
  866. background-color: #9d9fff;
  867. color: rgba(255, 255, 255, 100);
  868. font-size: 12px;
  869. text-align: center;
  870. }
  871. .trickle-charge {
  872. display: inline-block;
  873. width: 44px;
  874. height: 20px;
  875. line-height: 20px;
  876. border-radius: 50px;
  877. background-color: rgba(0, 185, 98, 100);
  878. color: rgba(255, 255, 255, 100);
  879. font-size: 12px;
  880. text-align: center;
  881. }
  882. .station-items {
  883. display: inline-block;
  884. height: 16px;
  885. line-height: 16px;
  886. font-size: 16px;
  887. margin-left: 4px;
  888. color: #101010;
  889. }
  890. .fast-charge {
  891. display: inline-block;
  892. width: 44px;
  893. height: 20px;
  894. line-height: 20px;
  895. border-radius: 50px;
  896. background-color: #9d9fff;
  897. color: rgba(255, 255, 255, 100);
  898. font-size: 12px;
  899. text-align: center;
  900. }
  901. .address {
  902. margin-top: 8px;
  903. line-height: 16px;
  904. font-size: 11px;
  905. color: rgba(119, 119, 119, 100);
  906. }
  907. .price {
  908. display: flex;
  909. height: 20px;
  910. }
  911. .num {
  912. height: 20px;
  913. color: rgba(255, 98, 0, 100);
  914. font-size: 20px;
  915. text-align: left;
  916. font-family: Roboto-medium;
  917. }
  918. .unit {
  919. height: 14px;
  920. line-height: 14px;
  921. color: rgba(102, 102, 102, 100);
  922. font-size: 14px;
  923. text-align: left;
  924. font-family: AlibabaPuHui-regular;
  925. margin-top: 6px;
  926. margin-left: 4px;
  927. }
  928. .park {
  929. margin-top: 8px;
  930. display: flex;
  931. }
  932. .park-p {
  933. display: inline-block;
  934. width: 20px;
  935. height: 18px;
  936. line-height: 12px;
  937. text-align: center;
  938. background-color: rgba(125, 177, 255, 100);
  939. color: #fff;
  940. }
  941. .park-text {
  942. display: inline-block;
  943. width: 300px;
  944. height: 17px;
  945. color: rgba(102, 102, 102, 100);
  946. font-size: 12px;
  947. text-align: left;
  948. margin-left: 4px;
  949. margin-top: 2px;
  950. }
  951. .map {
  952. width: 100%;
  953. height: 100%;
  954. position: relative;
  955. }
  956. #container {
  957. width: 100%;
  958. height: 100%;
  959. }
  960. .free {
  961. display: flex;
  962. justify-content: space-between;
  963. height: 52px;
  964. border-top: 1px solid rgba(238, 242, 240, 100);
  965. margin-top: 10px;
  966. }
  967. .free-num {
  968. line-height: 52px;
  969. font-size: 16px
  970. }
  971. .distance {
  972. width: 130px;
  973. height: 28px;
  974. line-height: 28px;
  975. color: rgba(255, 255, 255, 100);
  976. font-size: 14px;
  977. background-color: #00b962;
  978. border-radius: 50px;
  979. margin: 12px;
  980. text-align: center;
  981. }
  982. .distance-font {
  983. font-size: 16px
  984. }
  985. </style>