search.vue 16 KB

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