search.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. <template>
  2. <view>
  3. <ujp-navbar title="" ref='navbar' id='navbar' :height='nav_height'>
  4. <u-search id='search' ref='search' :input-style='inputStyle' placeholder="查询站点地址或站名" @change="search()" v-model="keyword" color="#c8c8c8" @search="search" @click="search" @clickicon='back' @custom='search'></u-search>
  5. </ujp-navbar>
  6. <view class="recommend">推荐充电站</view>
  7. <view class="carNone" v-if="stationslist.length == 0">
  8. <img src="static/img/暂无数据-缺省页.png" alt="">
  9. <p class="oldTextjp2" oldstyle="font-size: 18px;">暂无可用充电站</p>
  10. </view>
  11. <view v-for="(item,index) in stationslist" :key="item.id" class="charing-slow" @click="stationDetail(item)">
  12. <view class="address">
  13. <view class="name oldTextjp" oldstyle="font-size: 20px;">
  14. {{item.name}}
  15. </view>
  16. <view class="distance " oldstyle="font-size: 16px;" v-if="item.distance != '99999999'">
  17. <text class="iconfont" style="color:#666666">&#xe615;</text>
  18. {{item.distance!=null && item.distance>0.1 ? item.distance.toFixed(1)+'公里' : '小于100米'}}
  19. </view>
  20. <view class="distance " oldstyle="font-size: 16px;" v-else>
  21. <text class="iconfont" style="color:#666666">&#xe615;</text>
  22. 暂无定位
  23. </view>
  24. </view>
  25. <view class="sign" >
  26. {{item.address}}
  27. </view>
  28. <view class="sign" v-if="item.stationType!=50&&personInfo&&personInfo.userType!=1">
  29. <view class="sign-1" v-if="item.giveDiscount&&item.discountRatio&&item.discountRatio!=100">会员服务费{{discountRatio10(item.discountRatio)}}折</view>
  30. <view class="sign-3" v-if="item.category=='超充'">160kW超充站</view>
  31. <view class="sign-4" v-if="item.id=='3c554cea-f522-4281-b582-d761510ed91e'||item.id=='3865b3a3-13fd-461a-8145-ee9711df35a2'">夜间超低价</view>
  32. <view class="sign-2" v-if="item.tagList.length != 0" v-for="(tagName,tagIndex) in item.tagList" :key="tagIndex">{{tagName}}</view>
  33. </view>
  34. <view class="price-free price-freeList">
  35. <view class="price">
  36. <view class="price-1">
  37. <text class="num">{{!item.giveDiscount ? (item.electricityPrice+item.servicePrice).toFixed(2)
  38. : (item.electricityPrice+item.discountServicePrice).toFixed(2)}}</text>
  39. <text class="unit " oldstyle="font-size: 14px;">
  40. 元/度
  41. </text>
  42. </view>
  43. <view class="price-2 " oldstyle="font-size: 14px;" v-if="item.giveDiscount">
  44. <text class="num">{{(item.electricityPrice+item.servicePrice).toFixed(2)}}</text>
  45. <text class="unit">元/度</text>
  46. </view>
  47. </view>
  48. <view class="free" >
  49. <view class="fast" v-if="item.fastNum">
  50. <view class="fast-font">
  51. </view>
  52. <view class="num">
  53. {{item.fastAvailableNum}}/{{item.fastNum}}
  54. </view>
  55. </view>
  56. <view class="slow" v-if="item.slowNum">
  57. <view class="slow-font">
  58. </view>
  59. <view class="num">
  60. {{item.slowAvailableNum}}/{{item.slowNum}}
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <u-divider margin-top="20" bg-color="#F2F4F4" v-if="stationslist.length == recordsTotal">已经到底了</u-divider>
  67. </view>
  68. </template>
  69. <script>
  70. let _self;
  71. import * as API from '@/apis/site.js';
  72. import * as WxJsApi from '@/utils/wxJsApi.js'
  73. import MapLoader from '@/utils/AMap'
  74. export default {
  75. data() {
  76. return {
  77. elderMode:false,
  78. inputStyle:{
  79. backgroundColor: 'transparent',
  80. "font-size":'32rpx',
  81. },
  82. pageIndex:1,
  83. recordsTotal: 0,
  84. nav_height:54,
  85. personInfo:{},
  86. userId:'',
  87. keyword:'',
  88. stationslist:[],
  89. stations:[
  90. /* {name:'荆鹏软件园充电站',position:'湖北省荆州市沙市区江津东路附155号',price:1.2,idleNum:10,total:10,distance:0.1,time:1,type:'慢充',park:'2小时免费停车'},
  91. {name:'荆鹏软件园充电站2',position:'湖北省荆州市沙市区江津东路附156号',price:1.2,idleNum:10,total:10,distance:0.15,time:12,type:'快充',park:'3小时免费停车'},
  92. {name:'荆鹏软件园充电站3',position:'湖北省荆州市沙市区江津东路附157号',price:1.2,idleNum:10,total:10,distance:0.2,time:13,type:'慢充',park:'4小时免费停车'},
  93. {name:'荆鹏大道求助站充电站',position:'湖北省荆州市沙市区江津东路附158号',price:1.2,idleNum:10,total:10,distance:0.3,time:14,type:'快充',park:'5小时免费停车'},
  94. */
  95. ],
  96. }
  97. },
  98. onLoad(op){
  99. _self = this;
  100. //var px1 = uni.upx2px(88);
  101. //var rpx = 40/(uni.upx2px(100)/100);
  102. // 验证上面rpx的值
  103. var px = uni.upx2px(88);
  104. this.nav_height = px;
  105. // //('搜索框高度'+JSON.stringify(rpx))
  106. // //('搜索框高度'+JSON.stringify(px))
  107. /*
  108. if(op!= null && op.stationlist != null){
  109. this.stations = decodeURIComponent(op.stationlist)
  110. //('stations'+JSON.stringify(this.stations))
  111. }
  112. //('op'+JSON.stringify(op))*/
  113. },
  114. onReady() {
  115. this.elderMode = this.carhelp.get('getElderModeClass') == '长辈模式';
  116. if(this.elderMode)
  117. this.theme('elder')
  118. else
  119. this.theme('standard')
  120. if (this.carhelp.getPersonInfo()) {
  121. this.userId = this.carhelp.getPersonInfo().id;
  122. this.personInfo=this.carhelp.getPersonInfo();
  123. }
  124. WxJsApi.getWxConfig(['getLocation','openLocation', 'addEventListener']).then((res)=>{
  125. }).catch(error => {
  126. })
  127. this.getPoint();
  128. },
  129. onReachBottom() {
  130. if (this.stationslist.length < this.recordsTotal) {
  131. this.myLoadmore();
  132. }
  133. },
  134. // conponents:{charingSlows},
  135. methods: {
  136. theme(type) {
  137. if(type == 'elder')
  138. {
  139. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  140. let data = {
  141. backgroundColor: 'transparent',
  142. "font-size":'32rpx',
  143. };
  144. this.inputStyle = data;
  145. }
  146. else
  147. {
  148. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  149. let data ={
  150. backgroundColor: 'transparent',
  151. "font-size":'32rpx',
  152. };
  153. this.inputStyle = data;
  154. }
  155. },
  156. navigateTo(item){
  157. uni.showLoading({
  158. })
  159. WxJsApi.openLocation({
  160. latitude:parseFloat( item.latitude),//目的地latitude
  161. longitude:parseFloat( item.longitude),//目的地longitude
  162. name: item.name,
  163. address: item.address,
  164. scale: 15,//地图缩放大小,可根据情况具体调整
  165. success(res) {
  166. uni.hideLoading()
  167. },
  168. complete() {
  169. // uni.hideLoading()
  170. }
  171. });
  172. //window.location.href="https://uri.amap.com/marker?position="+ item.longitude+","+item.latitude+"&name="+item.name;
  173. },
  174. stationDetail(item){
  175. //('stationDetail item'+JSON.stringify(item))
  176. uni.navigateTo({
  177. url:'../searchPile/stationAndPile/stationDetails?id='+item.id
  178. })
  179. /*
  180. uni.navigateTo({
  181. url:'stationAndPile/stationDetails?station='+encodeURIComponent(JSON.stringify(item))
  182. })
  183. */
  184. // //('stationDetail'+JSON.stringify(item))
  185. },
  186. calculateDistance(startLngLat,obj){
  187. var _this = this;
  188. var endLngLat = [obj.longitude,obj.latitude];
  189. MapLoader().then(AMap1 => {
  190. this.AMap=AMap;
  191. var lnglat = new AMap.LngLat(startLngLat.longitude,startLngLat.latitude);
  192. var myDistance = lnglat.distance([obj.longitude, obj.latitude]);
  193. obj.distance = myDistance/1000;
  194. obj.time = myDistance/500;
  195. }, e => {
  196. //_this.mui.toast('地图加载失败');
  197. //('地图加载失败', e)
  198. })
  199. },
  200. getPoint() {
  201. var _this = this;
  202. //('getPoint')
  203. this.getChargingStationData(true);
  204. WxJsApi.getLocation().then((res) => {
  205. var latitude = parseFloat(res.latitude);
  206. var longitude = parseFloat(res.longitude);
  207. _this.latitude = latitude;
  208. _this.longitude = longitude;
  209. this.getChargingStationData(true);
  210. }).catch(error => {
  211. uni.showToast({
  212. title:JSON.stringify(error)
  213. })
  214. })
  215. },
  216. myLoadmore() {
  217. this.pageIndex += 1;
  218. this.getChargingStationData()
  219. },
  220. getChargingStationData(bl){
  221. uni.showLoading({
  222. title: "加载中",
  223. mask: true,
  224. })
  225. if (bl) {
  226. this.stationslist = [];
  227. this.pageIndex = 1;
  228. }
  229. var data = {
  230. pageIndex: this.pageIndex,
  231. pageSize:20,
  232. stationName:this.keyword,
  233. findType: 0,
  234. };
  235. if(this.longitude&&this.latitude){
  236. data.longitude=this.longitude;
  237. data.latitude=this.latitude;
  238. }
  239. if (this.carhelp.getPersonInfo()) {
  240. data.openId=this.carhelp.getOpenId()
  241. }
  242. API.getChargingStationData(data).then((response) => {
  243. if (bl) {
  244. this.stationslist = [];
  245. this.pageIndex = 1;
  246. }
  247. console.log(response)
  248. var stationDataList=response.data.data
  249. if(this.longitude&&this.latitude){
  250. MapLoader().then(AMap1 => {
  251. for(var i in stationDataList){
  252. var item=stationDataList[i]
  253. var lnglat = new AMap.LngLat(this.longitude,this.latitude);
  254. var myDistance = lnglat.distance([item.longitude,item.latitude]);
  255. item.distance = myDistance/1000;
  256. }
  257. })
  258. }
  259. this.stationslist = [
  260. ...this.stationslist,
  261. ...stationDataList
  262. ];
  263. this.recordsTotal = response.data.recordsTotal;
  264. //this.detail=response.data.monthlyRentCard
  265. uni.hideLoading()
  266. }).catch(error => {
  267. uni.showToast({
  268. title: error
  269. })
  270. })
  271. },
  272. back(){
  273. //('back');
  274. uni.navigateBack({
  275. delta:1
  276. })
  277. },
  278. search(){
  279. //('search keyword'+this.keyword + ' '+JSON.stringify(this.stations))
  280. this.getChargingStationData(true)
  281. //('search ' + this.keyword);
  282. }
  283. }
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. @import "@/_theme.scss";
  288. /deep/.u-content[data-v-1a326067] {
  289. flex: 0.95;
  290. color: #bdbdbd;
  291. }
  292. /deep/.u-action {
  293. margin-right: 0rpx;
  294. color: #c8c8c8;
  295. }
  296. .recommend {
  297. width: 100%;
  298. height: 88rpx;
  299. line-height: 88rpx;
  300. color: #101010;
  301. padding: 0 32rpx;
  302. background-color: #fff;
  303. font-weight: 600;
  304. }
  305. .charing-slow-2{
  306. margin: 0 0 10px 0 !important;
  307. // border-bottom: 1px solid rgba(238, 242, 240, 100);
  308. }
  309. .charing-slow {
  310. background-color: #fff;
  311. margin: 36rpx;
  312. border-radius: 16rpx;
  313. padding: 40rpx 24rpx 24rpx;
  314. position: relative;
  315. left: 0;
  316. right: 0;
  317. }
  318. .fast-charge {
  319. display: inline-block;
  320. border-radius: 50px;
  321. border-radius: 4px;
  322. background-color: rgba(208, 209, 255, 100);
  323. color: rgba(56, 60, 255, 100);
  324. margin: auto 0;
  325. @include themeify{
  326. width: themed('font-size18');
  327. font-size: themed('font-size2');
  328. line-height: themed('font-size7');
  329. height: themed('font-size8');
  330. }
  331. text-align: center;
  332. }
  333. .fast-trickle-charge {
  334. display: inline-block;
  335. margin: auto 0;
  336. border-radius: 4px;
  337. background-color: rgba(172, 236, 240, 100);
  338. color: rgba(0, 124, 134, 100);
  339. @include themeify{
  340. width: themed('font-size18');
  341. font-size: themed('font-size2');
  342. line-height: themed('font-size7');
  343. height: themed('font-size8');
  344. }
  345. text-align: center;
  346. }
  347. .trickle-charge {
  348. display: inline-block;
  349. border-radius: 4px;
  350. margin: auto 0;
  351. background-color: rgba(186, 240, 215, 100);
  352. color: rgba(0, 130, 69, 100);
  353. @include themeify{
  354. width: themed('font-size18');
  355. font-size: themed('font-size2');
  356. line-height: themed('font-size7');
  357. height: themed('font-size8');
  358. }
  359. text-align: center;
  360. }
  361. .station-items {
  362. display: inline-block;
  363. /* height: 16px;
  364. line-height: 16px;*/
  365. @include themeify{
  366. font-size: themed('font-size3');
  367. font-weight: themed('fontWeight');
  368. line-height: themed('font-size3');
  369. height: themed('font-size3');
  370. }
  371. margin-left: 8rpx;
  372. color: #101010;
  373. }
  374. //
  375. .address {
  376. width: 100%;
  377. line-height: 20px;
  378. display: flex;
  379. justify-content: space-between;
  380. .name{
  381. font-size: 16px;
  382. white-space: nowrap;
  383. overflow: hidden;
  384. text-overflow: ellipsis;
  385. }
  386. .distance{
  387. color: rgba(102, 102, 102, 100);
  388. font-size: 12px;
  389. text-align: right;
  390. width: 100px;
  391. .iconfont{
  392. font-size: 12px;
  393. margin-right: 2px;
  394. }
  395. }
  396. @include themeify{
  397. font-size: themed('font-size5');
  398. line-height: themed('font-size7');
  399. }
  400. /* font-size: 11px;*/
  401. font-weight: 600;
  402. color: #101010;
  403. }
  404. .price-free{
  405. width: 100%;
  406. display: flex;
  407. align-items: center;
  408. justify-content: space-between;
  409. }
  410. .price {
  411. display: flex;
  412. align-items: baseline;
  413. line-height: 40rpx;
  414. .price-1{
  415. .num {
  416. color: rgba(255, 98, 0, 100);
  417. font-size: 44rpx;
  418. height: 44rpx;
  419. text-align: left;
  420. font-family: Roboto-medium;
  421. }
  422. .unit {
  423. // font-size: 12px;
  424. color: rgba(102, 102, 102, 100);
  425. @include themeify{
  426. // font-size: themed('font-size2');
  427. font-size: 24rpx;
  428. height: themed('font-size2');
  429. }
  430. text-align: left;
  431. font-family: AlibabaPuHui-regular;
  432. margin-left: 8rpx;
  433. }
  434. }
  435. .price-2{
  436. color: rgba(153, 153, 153, 100);
  437. margin-left: 6rpx;
  438. text-decoration: line-through;
  439. font-size: 24rpx
  440. }
  441. }
  442. .free{
  443. display: flex;
  444. align-items: center;
  445. .slow,.fast{
  446. display: flex;
  447. .sp-font{
  448. width: 40rpx;
  449. height: 40rpx;
  450. line-height: 40rpx;
  451. border-radius: 4px;
  452. background-color: #7a68f6;
  453. color: #fff;
  454. font-size: 28rpx;
  455. text-align: center;
  456. margin-right: 2rpx;
  457. }
  458. .fast-font{
  459. width: 40rpx;
  460. height: 40rpx;
  461. line-height: 40rpx;
  462. border-radius: 4px;
  463. background-color: rgba(186, 240, 215, 100);
  464. color: rgba(0, 130, 69, 100);
  465. font-size: 28rpx;
  466. text-align: center;
  467. margin-right: 2rpx;
  468. }
  469. .slow-font{
  470. width: 40rpx;
  471. height: 40rpx;
  472. line-height: 40rpx;
  473. border-radius: 4px;
  474. background-color: rgba(226, 226, 226, 100);
  475. color: rgba(128, 128, 128, 100);
  476. font-size: 28rpx;
  477. text-align: center;
  478. margin-right: 2rpx;
  479. }
  480. .num{
  481. font-size: 32rpx;color: rgba(0, 145, 67, 100);
  482. line-height: 40rpx;
  483. }
  484. }
  485. .slow{
  486. margin-left: 16rpx;
  487. }
  488. }
  489. .park {
  490. margin-top: 16rpx;
  491. display: flex;
  492. }
  493. .park-p {
  494. display: inline-block;
  495. width: 20px;
  496. /* height: 18px;
  497. line-height: 12px;*/
  498. @include themeify{
  499. line-height: themed('font-size1');
  500. height: themed('font-size4');
  501. }
  502. text-align: center;
  503. // background-color: rgba(125, 177, 255, 100);
  504. background-color: #00b962;
  505. color: #fff;
  506. }
  507. .park-text {
  508. display: inline-block;
  509. color: rgba(102, 102, 102, 100);
  510. @include themeify{
  511. font-size: themed('font-size1');
  512. height:themed('font-size4');
  513. }
  514. /* font-size: 12px;*/
  515. text-align: left;
  516. margin-left: 4px;
  517. margin-top: 2px;
  518. }
  519. .map {
  520. width: 100%;
  521. height: 100%;
  522. position: relative;
  523. }
  524. #container {
  525. width: 100%;
  526. height: 100%;
  527. }
  528. .distance-font {
  529. @include themeify{
  530. font-size: themed('font-size3');
  531. }
  532. /* font-size: 16px*/
  533. }
  534. .position{
  535. color: #1677ff;
  536. @include themeify{
  537. font-size: themed('font-size2');
  538. }
  539. /* font-size: 14px*/
  540. }
  541. .position-box{
  542. position:absolute;
  543. top: 341px;
  544. right: 118px;
  545. width: 16px;
  546. height: 16px;
  547. /* line-height: 20px; */
  548. background-color: rgba(22, 119, 255, 100);
  549. text-align: center;
  550. box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.4);
  551. border: 2px solid rgba(255, 255, 255, 100);
  552. border-radius: 999px;
  553. }
  554. .min-h{
  555. min-height: 65px;
  556. }
  557. .sign{
  558. display: flex;
  559. flex-wrap: wrap;
  560. margin-top: 10px;
  561. .sign-1{
  562. height: 20px;
  563. line-height: 20px;
  564. border-radius: 4px;
  565. background-color: rgba(255, 255, 255, 100);
  566. color: rgba(255, 139, 0, 100);
  567. font-size: 12px;
  568. text-align: center;
  569. border: 1px solid rgba(255, 139, 0, 100);
  570. padding: 0 4px;
  571. margin-right: 8px;
  572. margin-bottom: 4px;
  573. }
  574. .sign-2{
  575. height: 20px;
  576. line-height: 20px;
  577. border-radius: 4px;
  578. background-color: rgba(255, 255, 255, 100);
  579. color: rgba(153, 153, 153, 100);
  580. font-size: 12px;
  581. text-align: center;
  582. border: 1px solid rgba(204, 204, 204, 100);
  583. padding: 0 4px;
  584. margin-right: 8px;
  585. margin-bottom: 4px;
  586. }
  587. .sign-3{
  588. line-height: 40rpx;
  589. border-radius: 8rpx;
  590. background-color: rgba(255, 255, 255, 100);
  591. color: #8161FF ;
  592. font-size: 24rpx;
  593. text-align: center;
  594. border: 1px solid #8161FF;
  595. padding: 0 8rpx;
  596. margin-right: 16rpx;
  597. margin-bottom: 8rpx;
  598. }
  599. .sign-4{
  600. line-height: 40rpx;
  601. border-radius: 8rpx;
  602. background-color: rgba(255, 255, 255, 100);
  603. color: #00B962 ;
  604. font-size: 24rpx;
  605. text-align: center;
  606. border: 1px solid #00B962 ;
  607. padding: 0 8rpx;
  608. margin-right: 16rpx;
  609. margin-bottom: 8rpx;
  610. }
  611. }
  612. .park-text2 {
  613. width: 140%;
  614. }
  615. .park-text3 {
  616. white-space: nowrap;
  617. text-overflow: ellipsis;
  618. overflow: hidden;
  619. }
  620. .carNone{
  621. display: flex;
  622. flex-direction: column;
  623. justify-content: center;
  624. align-items: center;
  625. img{
  626. width: 100%;
  627. height: 100%;
  628. }
  629. p{
  630. margin-top: -60px;
  631. }
  632. }
  633. </style>