stationDetailsMap.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. <template>
  2. <view >
  3. <ujp-navbar title="站点详情"></ujp-navbar>
  4. <view class="content" >
  5. <view>
  6. <Chargermap ref="amap" @onload="mapdown" @clickMap="clickMap"></Chargermap>
  7. <u-image style='position:absolute;z-index:1023;right:40rpx;bottom:440rpx;' src="@/static/img/location.png" width="30px" height="30px" @click="setCenter"></u-image>
  8. </view>
  9. <view class="chargerCard" @click="stationDetail(item)">
  10. <view class="card_item font4" style="padding-top: 5rpx;" >
  11. <view style="display: flex;flex-direction: row;">
  12. <view :class="item.type == '快充' ? 'fast-charge':(item.type == '慢充' ? 'trickle-charge':'fast-trickle-charge')"style="margin-right: 5rpx;">
  13. {{item.type}}
  14. </view>
  15. <view class='font-weight3'>
  16. {{item.name}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="card_item font3" style="color:#8898A9;">
  21. {{item.address}}
  22. </view>
  23. <view class="card_item2 " >
  24. <view class="font6" style="color:#FF6573;margin-right: 10rpx;">
  25. {{item.costPrice}}
  26. </view>
  27. <view style="display: flex; justify-content: center;align-items: center">
  28. 元/度 起
  29. </view>
  30. </view>
  31. <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">
  32. <view style="display: flex;flex-direction: row;">
  33. <view style="background-color: #7DB1FF;padding-left: 10rpx;padding-right: 10rpx;">
  34. P
  35. </view>
  36. <label>{{item.park}}</label>
  37. </view>
  38. <view style="display: flex;flex-direction: row;" class="font-weight2">
  39. <view style="color: #00B962;">
  40. 空闲{{item.availableNum}}
  41. </view>
  42. <view>
  43. /总数{{item.totalNum}}
  44. </view>
  45. </view>
  46. </view>
  47. <view class="card_item" style="padding-bottom: 20rpx;">
  48. <u-button shape='circle' style="color: #00B962;" @click="getScanCode">
  49. <u-icon name="scan" size="26" color="#00B962" style="margin-right: 20rpx;"></u-icon>
  50. <label>扫码充电</label></u-button>
  51. <view class="round" @click.stop="navigateTo(item)">
  52. <text class="iconfont distance-font">&#xe615;</text>
  53. <view style="margin-right: 10rpx;">
  54. {{item.distance!=null&&item.distance>0.1 ? item.distance.toFixed(1)+'公里':'小于100米'}}
  55. </view>
  56. <view style="margin-right: 10rpx;">
  57. {{item.time!=null?item.time.toFixed(0):''}}分钟
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. let _self;
  68. import * as api from '@/apis/site.js';
  69. import * as indexAPI from '@/apis/index.js'
  70. import Chargermap from '@/components/Chargermap.vue';
  71. import * as WxJsApi from '@/utils/wxJsApi.js'
  72. import MapLoader from '@/utils/AMap'
  73. export default {
  74. components: {
  75. Chargermap
  76. },
  77. data() {
  78. return {
  79. elderMode:false,
  80. userId:'',
  81. id: '',
  82. longitude: 112.28468,
  83. latitude: 30.307094,
  84. // longitude: '',
  85. // latitude: '',
  86. area: '荆州市',
  87. action: '筛选',
  88. item:{"id":"3865b3a3-13fd-461a-8145-ee9711df35a2","name":"荆鹏充电站","address":"江津东路附155号","longitude":112.276578,"latitude":30.306499,"type":"快/慢","costPrice":1.14,"electricityPrice":null,"servicePrice":null,"availableNum":5,"totalNum":5,"distance":null,"image":"http://oss.xiaoxinda.com/charging/chargingnewsInfo/2022/5/27/ccb8da40-7322-4448-9f9a-31fb64755a9c/0406204653.jpg","time":0,"park":"2小时免费停车"},
  89. /*{
  90. name:'',
  91. position:'',
  92. price:1,idleNum:0,total:0,distance:0,time:0,type:'慢充',id: 0,
  93. park: '2小时免费停车',
  94. longitude: 112.28541,
  95. latitude: 30.308354 },*/
  96. stations:[]
  97. }
  98. },
  99. methods:{
  100. theme(type) {
  101. if(type == 'elder')
  102. {
  103. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  104. }
  105. else
  106. {
  107. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  108. }
  109. },
  110. getPoint() {
  111. //('getPoint')
  112. WxJsApi.getLocation().then((res) => {
  113. if(res==null)
  114. return;
  115. //('站点地图当前位置'+JSON.stringify(res))
  116. _self.latitude = parseFloat(res.latitude);
  117. _self.longitude = parseFloat(res.longitude);
  118. var startLngLat = {longitude: _self.longitude ,latitude: _self.latitude };
  119. var endLngLat = {longitude: _self.item.longitude, latitude: _self.item.latitude};
  120. //('start'+JSON.stringify(startLngLat));
  121. //('end'+JSON.stringify(endLngLat));
  122. //_self.calculateDistance(startLngLat,endLngLat);
  123. //let posCenter= {longitude: _self.longitude,latitude: _self.latitude};
  124. var obj = {
  125. longitude: _self.longitude,
  126. latitude: _self.latitude
  127. };
  128. _self.$refs.amap.setPerson(obj);
  129. var lnglat = new AMap.LngLat(startLngLat.longitude,startLngLat.latitude);
  130. var myDistance = lnglat.distance([endLngLat.longitude, endLngLat.latitude]);
  131. _self.item.distance = myDistance/1000;
  132. _self.item.time = myDistance/500;
  133. /*
  134. _self.$refs.amap.calculateDistance(startLngLat,endLngLat).then(function(res){
  135. _self.item.distance = res.distance/1000;
  136. _self.item.time = res.time/60;
  137. ////(result)
  138. ////(result.routes[0].time)//秒
  139. ////(result.routes[0].distance)//米
  140. //('距离'+JSON.stringify(res))
  141. })*/
  142. //('当前位置' +JSON.stringify(data))
  143. //this.latitude2 = latitude;
  144. //this.longitude2 = longitude;
  145. /*uni.showToast({
  146. title:JSON.stringify(res)
  147. })*/
  148. //this.message=JSON.stringify(res)
  149. }).catch(error => {
  150. uni.showToast({
  151. title:error//JSON.stringify(error)
  152. })
  153. })
  154. },
  155. stationDetail(item){
  156. //('item'+JSON.stringify(item))
  157. uni.navigateTo({
  158. url:'stationDetails?id='+this.item.id
  159. //url:'stationDetails?station='+encodeURIComponent(JSON.stringify(this.item))
  160. })
  161. },
  162. setCenter(){
  163. //('getPoint')
  164. WxJsApi.getLocation().then((res) => {
  165. _self.latitude = parseFloat(res.latitude);
  166. _self.longitude = parseFloat(res.longitude);
  167. //let data = {position:{latitude:latitude,longitude:longitude}};
  168. let posCenter= {longitude: _self.longitude,latitude: _self.latitude};
  169. this.$refs.amap.setCenter(posCenter);
  170. }).catch(error => {
  171. uni.showToast({
  172. title:error//JSON.stringify(error)
  173. })
  174. })
  175. // //('setCenter')
  176. },
  177. getScanCode() {
  178. if (this.userId) {
  179. WxJsApi.scanQRCode(1).then(res => {
  180. if(res) {
  181. indexAPI.scanCode(res).then((response) => {
  182. }).catch(error => {
  183. uni.showToast({
  184. title: error,
  185. icon: "none"
  186. })
  187. })
  188. }
  189. }).catch(error => {
  190. })
  191. } else {
  192. uni.navigateTo({
  193. url: '/pages/login/login'
  194. })
  195. }
  196. },
  197. navigateTo(item){
  198. /*
  199. this.elderMode = !this.elderMode;
  200. if(this.elderMode)
  201. this.theme('elder')
  202. else
  203. this.theme('standard')
  204. return;
  205. */
  206. //this.guide('gd',item);
  207. //console.log('导航'+JSON.stringify(item))
  208. window.location.href="https://uri.amap.com/marker?position="+ item.longitude+","+item.latitude+"&name="+item.name;
  209. //Map.getRoute(item);
  210. //Map.openMap(this.latitude, this.longitude, this.name, 'wgs84')
  211. //var startLngLat = [this.longitude, this.latitude]
  212. //var endLngLat = [item.longitude, item.latitude]
  213. ///let platform = uni.getSystemInfoSync().platform
  214. //console.log('platform'+JSON.stringify(platform))
  215. //this.$refs.amap.navigate(startLngLat,endLngLat);
  216. },
  217. mapdown() {
  218. let data = {stationId:this.id};
  219. api.getChargingStationDetail(data).then(function(res){
  220. // //('站点详情'+JSON.stringify(res))
  221. //this.info.st
  222. if(res && res.result)
  223. {
  224. if(res.data){
  225. let data = res.data;
  226. data.station.time = 0;
  227. _self.item = data.station;
  228. if(_self.item.park == null)
  229. _self.item.park = '2小时免费停车'
  230. if(_self.item.type == '2')
  231. _self.item.type = '慢充'
  232. else if(_self.item.type == '1')
  233. _self.item.type = '快充'
  234. else {
  235. _self.item.type = '快/慢'
  236. }
  237. if(_self.item.costPrice == null){
  238. if(data.fastPrice != null){
  239. _self.item.costPrice = data.fastPrice.costPrice;
  240. if(data.slowPrice != null){
  241. if(_self.item.costPrice> data.slowPrice.costPrice){
  242. _self.item.costPrice = data.slowPrice.costPrice;
  243. }
  244. }
  245. }else if(data.slowPrice != null){
  246. _self.item.costPrice = data.slowPrice.costPrice;
  247. }
  248. }
  249. if(_self.item.distance == null){
  250. _self.getPoint();
  251. }
  252. var obj = {
  253. longitude: _self.item.longitude,
  254. latitude: _self.item.latitude
  255. };
  256. _self.$refs.amap.setCenter(obj)
  257. _self.stations = [];
  258. _self.stations.push(_self.item);
  259. // //('stations1'+JSON.stringify(this.stations[0]))
  260. // //('stations2'+JSON.stringify(this.item))
  261. _self.$refs.amap.setChargerList(_self.stations);
  262. //('站点项目'+JSON.stringify(_self.item))
  263. _self.$refs.amap.updateCharger(_self.item)
  264. //_self.stationDetail = data;
  265. //_self.processStationsInfo();
  266. //('data'+JSON.stringify(_self.item ));
  267. }
  268. }
  269. })
  270. }
  271. },
  272. onLoad(op) {
  273. _self = this;
  274. // //('longitude0 ' + _self.longitude);
  275. if (op != null) {
  276. if(op.stationId != null){
  277. //_self.item = this.carhelp.get(op.stationId);
  278. //return;
  279. this.id = op.stationId;
  280. return;
  281. }
  282. if(op.station!=null){
  283. //('op.station ' + op.station);
  284. this.item = JSON.parse(decodeURIComponent(op.station));
  285. //('item '+JSON.stringify(this.item));
  286. this.longitude = this.item.longitude;
  287. this.latitude = this.item.latitude;
  288. //this.mapdown();
  289. }
  290. if (op.longitude != null) this.longitude = op.longitude;
  291. if (op.latitude != null) this.latitude = op.latitude;
  292. if (op.id != null) this.id = op.id;
  293. }
  294. this.item.longitude = this.longitude;
  295. this.item.latitude = this.latitude;
  296. },
  297. onReady() {
  298. this.elderMode = this.carhelp.get('getElderModeClass') == '长辈模式';
  299. if(this.elderMode)
  300. this.theme('elder')
  301. else
  302. this.theme('standard')
  303. // //('longitude2 '+this.longitude)
  304. // //('latitude2 '+this.latitude)
  305. if (this.carhelp.getPersonInfo()) {
  306. this.userId = this.carhelp.getPersonInfo().id;
  307. }
  308. WxJsApi.getWxConfig(['getLocation', 'addEventListener', 'scanQRCode']).then((res) => {
  309. // //(res)
  310. }).catch(error => {
  311. //(res)
  312. })
  313. this.isReady = true;
  314. this.$refs.amap.init();
  315. //let state = {};
  316. uni.getSystemInfo({
  317. success: (res) => {
  318. // #ifndef MP
  319. let navbarH = 0
  320. // #endif
  321. // #ifdef MP
  322. let navbarH = uni.upx2px(90)
  323. // #endif
  324. /*state.status_width = res.windowWidth;
  325. //('window width'+state.status_width);*/
  326. let scrollH = res.windowHeight;// - uni.upx2px(88) - navbarH
  327. // //('布局结果'+ JSON.stringify(res));
  328. // //('scrollH'+scrollH)
  329. //#ifdef MP-WEIXIN
  330. const {
  331. statusBarHeight,
  332. windowWidth,
  333. } = uni.getSystemInfoSync();
  334. //('height ' + statusBarHeight);
  335. //this.status_height = uni.getStatusbarHeight();
  336. let res1 = uni.getMenuButtonBoundingClientRect()
  337. //('layout selectHeight '+JSON.stringify(res1))
  338. //state.selectHeight = (res1.top-res.statusBarHeight)*2+ res1.height;
  339. //#endif
  340. ////('status height'+state.status_height)
  341. _self.$refs.amap.setMyStyle("height:"+(scrollH-44)+ "px;width:100%;");
  342. }
  343. })
  344. },
  345. onShow() {
  346. },
  347. }
  348. </script>
  349. <style lang="scss" scoped>
  350. @import "@/_theme.scss";
  351. .preference_group_item {
  352. padding: 15rpx;
  353. }
  354. .preference_group {
  355. padding-bottom: 20rpx;
  356. }
  357. .preference {
  358. background-color: #ffffff;
  359. left: 0rpx;
  360. position: absolute;
  361. }
  362. .preference_item {
  363. margin-bottom: 10rpx;
  364. margin-left: 20rpx;
  365. text-align: center;
  366. border-style: none;
  367. width: 20%;
  368. }
  369. .preference_item_plus {
  370. margin-bottom: 10rpx;
  371. margin-left: 20rpx;
  372. align-items: center;
  373. justify-content: center;
  374. text-align: center;
  375. width: 25%;
  376. border-style: none;
  377. }
  378. .preference_label {
  379. color: #9f9c99;
  380. margin-left: 20rpx;
  381. margin-bottom: 100rpx;
  382. }
  383. .map{
  384. background-color: #ffffff;
  385. left: 0rpx;
  386. position: absolute;
  387. }
  388. .chargerCard{
  389. /* background-color: #fff;
  390. margin: 0 12px;
  391. border-radius: 8px;
  392. padding: 10px 12px 0px;
  393. position: absolute;
  394. bottom: 68px;
  395. left: 0;
  396. right: 0;
  397. z-index:1021
  398. */
  399. background-color: #fff;
  400. margin: 0 12px;
  401. border-radius: 8px;
  402. padding: 10px 12px 0px;
  403. bottom: 28px;
  404. left: 0;
  405. right: 0;
  406. position: fixed;
  407. height:360rpx;
  408. /*
  409. z-index: 1021;
  410. width: 80%;
  411. margin-left: 10%;
  412. bottom: 50rpx;
  413. */
  414. }
  415. .arrow{
  416. margin-right: 15rpx;
  417. }
  418. .card_item{
  419. display: flex;
  420. flex-direction: row;
  421. justify-content: space-between;
  422. margin-left: 20rpx;
  423. margin-right: 20rpx;
  424. margin-bottom: 10rpx;
  425. @include themeify{
  426. font-size: themed('font-size2');
  427. }
  428. }
  429. .card_item2{
  430. display: flex;
  431. flex-direction: row;
  432. margin-left: 20rpx;
  433. margin-right: 20rpx;
  434. margin-bottom: 10rpx;
  435. @include themeify{
  436. font-size: themed('font-size2');
  437. }
  438. }
  439. .round{
  440. border-radius:50rpx;
  441. background-color: #00B962;
  442. color: #ffffff;
  443. text-align: center;
  444. justify-content: center;
  445. align-items: center;
  446. @include themeify{
  447. width: themed('buttonWidth');
  448. }
  449. /* width: 250rpx;*/
  450. display: flex;
  451. flex-direction: row;
  452. }
  453. .round2{
  454. border-radius:50rpx;
  455. background-color: #00B962;
  456. color: #ffffff;
  457. text-align: center;
  458. justify-content: center;
  459. align-items: center;
  460. width:125rpx;
  461. }
  462. .swiper-item{
  463. }
  464. .list {
  465. margin-left: 2px;
  466. }
  467. .charing-slow {
  468. background-color: #fff;
  469. margin: 20rpx;
  470. border-radius: 8px;
  471. padding: 10px 12px 0px;
  472. position: relative;
  473. left: 0;
  474. right: 0;
  475. }
  476. .fast-charge {
  477. display: inline-block;
  478. width: 44px;
  479. height: 20px;
  480. line-height: 20px;
  481. border-radius: 50px;
  482. background-color: #9d9fff;
  483. color: rgba(255, 255, 255, 100);
  484. @include themeify{
  485. font-size: themed('font-size1');
  486. line-height: themed('font-size5');
  487. height: themed('font-size5');
  488. }
  489. /* font-size: 12px;*/
  490. text-align: center;
  491. }
  492. .fast-trickle-charge {
  493. display: inline-block;
  494. width: 66px;
  495. /* height: 20px;
  496. line-height: 20px;*/
  497. border-radius: 50px;
  498. background-color: #00BAC8;
  499. color: rgba(255, 255, 255, 100);
  500. @include themeify{
  501. font-size: themed('font-size1');
  502. line-height: themed('font-size5');
  503. height: themed('font-size5');
  504. }
  505. /* font-size: 12px;*/
  506. text-align: center;
  507. }
  508. .trickle-charge {
  509. display: inline-block;
  510. width: 44px;
  511. /* height: 20px;
  512. line-height: 20px;*/
  513. border-radius: 50px;
  514. background-color: rgba(0, 185, 98, 100);
  515. color: rgba(255, 255, 255, 100);
  516. /* font-size: 12px;*/
  517. @include themeify{
  518. font-size: themed('font-size1');
  519. line-height: themed('font-size5');
  520. height: themed('font-size5');
  521. }
  522. text-align: center;
  523. }
  524. .station-items {
  525. display: inline-block;
  526. /* height: 16px;
  527. line-height: 16px;
  528. font-size: 16px;*/
  529. @include themeify{
  530. font-size: themed('font-size3');
  531. line-height: themed('font-size3');
  532. height: themed('font-size3');
  533. }
  534. margin-left: 4px;
  535. color: #101010;
  536. }
  537. .fast-charge {
  538. display: inline-block;
  539. width: 44px;
  540. /* height: 20px;
  541. line-height: 20px;*/
  542. border-radius: 50px;
  543. background-color: #9d9fff;
  544. color: rgba(255, 255, 255, 100);
  545. /* font-size: 12px;*/
  546. @include themeify{
  547. font-size: themed('font-size1');
  548. line-height: themed('font-size5');
  549. height: themed('font-size5');
  550. }
  551. text-align: center;
  552. }
  553. .address {
  554. margin-top: 8px;
  555. @include themeify{
  556. font-size: themed('font-size1');
  557. line-height: themed('font-size3');
  558. }
  559. /* line-height: 16px;
  560. font-size: 11px;*/
  561. color: rgba(119, 119, 119, 100);
  562. }
  563. .price {
  564. display: flex;
  565. height: 20px;
  566. }
  567. .num {
  568. height: 20px;
  569. color: rgba(255, 98, 0, 100);
  570. @include themeify{
  571. font-size: themed('font-size5');
  572. }
  573. /* font-size: 20px;*/
  574. text-align: left;
  575. font-family: Roboto-medium;
  576. }
  577. .unit {
  578. /* height: 14px;
  579. line-height: 14px;*/
  580. color: rgba(102, 102, 102, 100);
  581. @include themeify{
  582. font-size: themed('font-size2');
  583. line-height: themed('font-size2');
  584. height: themed('font-size2');
  585. }
  586. /* font-size: 14px;*/
  587. text-align: left;
  588. font-family: AlibabaPuHui-regular;
  589. margin-top: 6px;
  590. margin-left: 4px;
  591. }
  592. .park {
  593. margin-top: 8px;
  594. display: flex;
  595. }
  596. .park-p {
  597. display: inline-block;
  598. width: 20px;
  599. @include themeify{
  600. /* font-size: themed('font-size1'); */
  601. line-height: themed('font-size1');
  602. height: themed('font-size4');
  603. }
  604. /* height: 18px;
  605. line-height: 12px;*/
  606. text-align: center;
  607. background-color: rgba(125, 177, 255, 100);
  608. color: #fff;
  609. }
  610. .park-text {
  611. display: inline-block;
  612. width: 300px;
  613. /* height: 17px;*/
  614. color: rgba(102, 102, 102, 100);
  615. /* font-size: 12px;*/
  616. @include themeify{
  617. font-size: themed('font-size1');
  618. height: themed('font-size4');
  619. }
  620. text-align: left;
  621. margin-left: 4px;
  622. margin-top: 2px;
  623. }
  624. .map {
  625. width: 100%;
  626. height: 100%;
  627. position: relative;
  628. }
  629. #container {
  630. width: 100%;
  631. height: 100%;
  632. }
  633. .free {
  634. display: flex;
  635. justify-content: space-between;
  636. height: 52px;
  637. border-top: 1px solid rgba(238, 242, 240, 100);
  638. margin-top: 10px;
  639. }
  640. .free-num {
  641. line-height: 52px;
  642. /* font-size: 16px*/
  643. @include themeify{
  644. font-size: themed('font-size3');
  645. }
  646. }
  647. .distance {
  648. width: 130px;
  649. /* height: 28px;
  650. line-height: 28px;*/
  651. color: rgba(255, 255, 255, 100);
  652. /* font-size: 14px;*/
  653. @include themeify{
  654. font-size: themed('font-size2');
  655. height: themed('font-size9');
  656. line-height: themed('font-size9');
  657. }
  658. background-color: #00b962;
  659. border-radius: 50px;
  660. margin: 12px;
  661. text-align: center;
  662. }
  663. .distance-font {
  664. font-size: 16px
  665. }
  666. </style>