searchPile.vue 33 KB

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