searchPile.vue 36 KB

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