searchPile.vue 37 KB

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