index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. <template>
  2. <view>
  3. <!-- 头部图片 -->
  4. <view class="banner">
  5. <img src="static/img/banner1.jpg" alt="">
  6. </view>
  7. <!-- 选项列表 -->
  8. <view class="option-list">
  9. <view class="list-item" @click="getScanCode">
  10. <view class="icon iconfont" style="background-color:#59d96e;">
  11. &#xe61a;
  12. </view>
  13. <view class="text">
  14. 扫码充电
  15. </view>
  16. </view>
  17. <view class="list-item" @click="fastRecharge">
  18. <view class="icon iconfont" style="background-color:#4BD2C0;">
  19. &#xe629;
  20. </view>
  21. <view class="text">
  22. 快速充值
  23. </view>
  24. </view>
  25. <view class="list-item" @click="chargingRecord">
  26. <view class="icon iconfont" style="background-color: #6FA5FF;">
  27. &#xe625;
  28. </view>
  29. <view class="text">
  30. 充电记录
  31. </view>
  32. </view>
  33. <view class="list-item">
  34. <view class="icon iconfont" style="background-color: #9D9FFF;">
  35. &#xe622;
  36. </view>
  37. <view class="text">
  38. 附近站点
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 站点 -->
  43. <!-- <view class="station">
  44. <view class="img-box">
  45. <img src="static/img/Frame 198 (1).png" alt="">
  46. </view>
  47. <view class="text">
  48. <view class="station-title">
  49. <text class="title-left">快充</text>
  50. <text class="title-right">荆沙大道救助站充电站</text>
  51. </view>
  52. <view class="station-price">
  53. <view class="price-left">1.25</view>
  54. <view class="price-right">
  55. 起 元/度
  56. </view>
  57. </view>
  58. <view class="park">
  59. <text class="park-p">p</text>
  60. <text class="park-text">2小时免费停车</text>
  61. </view>
  62. <view class="count">
  63. <view class="count-left">空闲10/总数10</view>
  64. <view class="count-right"><text class="iconfont">&#xe615;</text>10公里</view>
  65. </view>
  66. </view>
  67. </view> -->
  68. <!-- 定位 -->
  69. <view class="location-box">
  70. <view class="location">
  71. <view class="location-text">
  72. <view class="text-1">
  73. 定位中...
  74. </view>
  75. <view class="text-2">
  76. 授权定位后可查询附近充电站
  77. </view>
  78. <view class="text-3" @click="getPoint()">
  79. 重新定位
  80. </view>
  81. </view>
  82. <view class="img-box">
  83. <img src="static/img/暂无网络信号-缺省页 1.png">
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 充电状态 -->
  88. <!-- <view class="state1 state">
  89. <view class="state-text">
  90. <view class="text-1">
  91. 排队中
  92. </view>
  93. <view class="text-2">
  94. 前方等待两位
  95. </view>
  96. <view class="text-3">
  97. 荆鹏软件园充电站/1号有序充电桩
  98. </view>
  99. </view>
  100. <view class="img-box">
  101. <img src="static/img/等待中-缺省页.png">
  102. </view>
  103. </view> -->
  104. <!-- <view class="state2 state">
  105. <view class="state-text">
  106. <view class="text-1" style="color: green">
  107. 充电中
  108. </view>
  109. <view class="text-2">
  110. 前方等待两位
  111. </view>
  112. <view class="text-3">
  113. 荆鹏软件园充电站/1号有序充电桩
  114. </view>
  115. </view>
  116. <view class="img-box">
  117. <img src="static/img/充电中-缺省页.png">
  118. </view>
  119. </view> -->
  120. <!-- <view class="state3 state">
  121. <view class="state-text">
  122. <view class="text-1" style="color: red;">
  123. 已充满
  124. </view>
  125. <view class="text-2" style="color: red;">
  126. 超出时间将收取占位费
  127. </view>
  128. <view class="text-3">
  129. 荆鹏软件园充电站/1号有序充电桩
  130. </view>
  131. </view>
  132. <view class="img-box">
  133. <img src="static/img/已充满-缺省页.png">
  134. </view>
  135. </view> -->
  136. <!-- 充值活动 -->
  137. <view class=" top-up">
  138. <view class="top-up-title"><text class="line"></text>充值活动</view>
  139. <view class="img-box">
  140. <view class="img-1" v-for="(item,index) in activityList" :key="item.id" @click="rechargeActivity">
  141. <img :src="item.picUrl" alt="">
  142. </view>
  143. </view>
  144. </view>
  145. <!-- 新闻 -->
  146. <view class="news-title">
  147. <view class="news-title-left">
  148. <view class="line" style="margin-top:4px;"></view>新闻公告
  149. </view>
  150. <view class="more" @click="toNewsNotice">更多<view class="more-icon iconfont"> &#xe600;</view>
  151. </view>
  152. </view>
  153. <view class="news">
  154. <view class="news-content" v-for="(item,index) in newsList" :key="item.id" @click="gotoUrl('pages/article/articleDetails?id=' + item.id)">
  155. <view class="content-text">
  156. {{item.title}}
  157. <view class="news-time">{{item.createTime.slice(5)}}</view>
  158. </view>
  159. <view class="content-img">
  160. <img :src="item.pic" alt="">
  161. </view>
  162. </view>
  163. </view>
  164. <view class="bottom" v-if="newsList.length == recordsTotal">
  165. <view class="bot">
  166. <view class="bot-line"></view>
  167. <view class="bot-text">已经到底了</view>
  168. <view class="bot-line"></view>
  169. </view>
  170. </view>
  171. <!-- 导航栏 -->
  172. <view class="navigation">
  173. <!-- <view class="nav-items">
  174. <view class="nav-icon iconfont ">
  175. &#xe610;
  176. </view>
  177. <view class="nav-text">主页</view>
  178. </view>
  179. <view class="nav-items">
  180. <view class="nav-icon iconfont">&#xe622;</view>
  181. <view class="nav-text">找桩</view>
  182. </view>
  183. <view class="nav-items">
  184. <view class="nav-icon iconfont">&#xe627;</view>
  185. <view class="nav-text">我的</view>
  186. </view> -->
  187. <!-- 登录提示 -->
  188. <view class="login-prompt" v-if="!userId">
  189. 登录显示更多会员服务
  190. <text class="button" @click="toLogin">登录/注册</text>
  191. </view>
  192. <Tabbar :current="0"></Tabbar>
  193. </view>
  194. </view>
  195. </template>
  196. <script>
  197. import * as Api from '@/apis/index.js'
  198. import * as newsApi from '@/apis/news.js'
  199. import * as WxJsApi from '@/utils/wxJsApi.js'
  200. import MapLoader from '@/utils/AMap'
  201. import Tabbar from '@/components/Tabbar.vue'
  202. export default {
  203. components: {
  204. Tabbar
  205. },
  206. data() {
  207. return {
  208. activityList: [],
  209. userId: '',
  210. newsList: [],
  211. pageIndex: 1,
  212. recordsTotal: 0,
  213. longitude: '',
  214. latitude: '',
  215. message: '',
  216. }
  217. },
  218. onReachBottom() {
  219. if (this.newsList.length < this.recordsTotal) {
  220. this.myLoadmore();
  221. }
  222. },
  223. onReady() {
  224. if (this.carhelp.getPersonInfo()) {
  225. this.userId = this.carhelp.getPersonInfo().id;
  226. }
  227. WxJsApi.getWxConfig(['getLocation', 'addEventListener', 'scanQRCode']).then((res) => {
  228. // console.log(res)
  229. }).catch(error => {
  230. console.log(res)
  231. })
  232. this.getPoint();
  233. this.getNewsList();
  234. this.getActivityInfoList();
  235. },
  236. methods: {
  237. toLogin() {
  238. uni.navigateTo({
  239. url: '/pages/login/login'
  240. })
  241. },
  242. toNewsNotice() {
  243. uni.navigateTo({
  244. url: '/pages/article/newsNotice'
  245. })
  246. },
  247. //微信扫二维码
  248. getScanCode() {
  249. if (this.userId) {
  250. WxJsApi.scanQRCode(1).then(res => {
  251. if(res) {
  252. Api.scanCode(res).then((response) => {
  253. }).catch(error => {
  254. uni.showToast({
  255. title: error,
  256. icon: "none"
  257. })
  258. })
  259. }
  260. }).catch(error => {
  261. })
  262. } else {
  263. uni.navigateTo({
  264. url: '/pages/login/login'
  265. })
  266. }
  267. },
  268. fastRecharge() {
  269. if (this.userId) {
  270. this.gotoUrl('pages/user/finance/recharge?id=' + this.userId)
  271. } else {
  272. uni.navigateTo({
  273. url: '/pages/login/login'
  274. })
  275. }
  276. },
  277. chargingRecord() {
  278. if (this.userId) {
  279. this.gotoUrl('pages/user/finance/rechargeList?id=' + this.userId)
  280. } else {
  281. uni.navigateTo({
  282. url: '/pages/login/login'
  283. })
  284. }
  285. },
  286. rechargeActivity() {
  287. if (this.userId) {
  288. this.gotoUrl('pages/user/finance/recharge?id=' + this.userId)
  289. } else {
  290. uni.navigateTo({
  291. url: '/pages/login/login'
  292. })
  293. }
  294. },
  295. getActivityInfoList() {
  296. uni.showLoading({
  297. title: "加载中",
  298. mask: true,
  299. })
  300. Api.activityInfoList({
  301. pageIndex: 1,
  302. pageSize: 10
  303. }).then((res) => {
  304. uni.hideLoading()
  305. this.activityList = res.data.data;
  306. }).catch(error => {
  307. uni.showToast({
  308. title: error,
  309. icon: "none"
  310. })
  311. })
  312. },
  313. getPoint() {
  314. WxJsApi.getLocation().then((res) => {
  315. this.latitude = parseFloat(res.latitude);
  316. this.longitude = parseFloat(res.longitude);
  317. this.message = res.errMsg;
  318. if (res.errMsg != 'getLocation:ok') {
  319. uni.showToast({
  320. title: JSON.stringify(res)
  321. })
  322. }
  323. }).catch(error => {
  324. uni.showToast({
  325. title: JSON.stringify(error)
  326. })
  327. })
  328. },
  329. getNewsList(bl) {
  330. uni.showLoading({
  331. title: "加载中",
  332. mask: true,
  333. })
  334. if (bl) {
  335. this.newsList = [];
  336. this.pageIndex = 1;
  337. }
  338. newsApi.newsInfoList({
  339. pageIndex: 1,
  340. pageSize: 10
  341. }).then((res) => {
  342. uni.hideLoading()
  343. this.newsList = [
  344. ...this.newsList,
  345. ...res.data.data
  346. ];
  347. this.recordsTotal = res.data.recordsTotal
  348. }).catch(error => {
  349. uni.showToast({
  350. title: error,
  351. icon: "none"
  352. })
  353. })
  354. },
  355. myLoadmore() {
  356. this.pageIndex += 1;
  357. this.getNewsList()
  358. },
  359. }
  360. }
  361. </script>
  362. <style lang="scss" scoped>
  363. // 头部图片
  364. img {
  365. width: 100%;
  366. height: 100%;
  367. }
  368. .banner {
  369. width: 100%;
  370. height: 300px;
  371. }
  372. // 选项列表
  373. .option-list {
  374. padding-top: 18px;
  375. width: 343px;
  376. height: 100px;
  377. line-height: 20px;
  378. border-radius: 8px;
  379. text-align: center;
  380. background-color: #fff;
  381. position: absolute;
  382. top: 260px;
  383. left: 0;
  384. right: 0;
  385. margin: auto;
  386. display: flex;
  387. justify-content: space-around;
  388. .list-item {
  389. // 图标
  390. .icon {
  391. width: 40px;
  392. height: 40px;
  393. border-radius: 99px;
  394. line-height: 40px;
  395. font-size: 24px;
  396. text-align: center;
  397. margin: auto;
  398. color: #ffffff;
  399. }
  400. }
  401. }
  402. // 站点
  403. .station {
  404. // width: 343px;
  405. height: 120px;
  406. margin-top: 70px;
  407. padding-top: 20px;
  408. padding: 0 12px;
  409. position: relative;
  410. .img-box {
  411. width: 100%;
  412. height: 100%;
  413. border-radius: 8px;
  414. overflow: hidden;
  415. }
  416. img {
  417. width: 100%;
  418. height: 100%;
  419. }
  420. .text {
  421. position: absolute;
  422. top: 0;
  423. left: 20px;
  424. // 头部
  425. .station-title {
  426. display: flex;
  427. margin-top: 12px;
  428. .title-left {
  429. display: inline-block;
  430. height: 20px;
  431. width: 44px;
  432. // margin-left: 12px;
  433. line-height: 20px;
  434. border-radius: 50px;
  435. background-color: rgba(133, 140, 255, 100);
  436. color: rgba(255, 255, 255, 100);
  437. font-size: 12px;
  438. text-align: center;
  439. font-family: Arial;
  440. }
  441. .title-right {
  442. display: inline-block;
  443. margin-left: 4px;
  444. margin-top: 2px;
  445. width: 271px;
  446. height: 16px;
  447. line-height: 16px;
  448. color: rgba(16, 16, 16, 100);
  449. font-size: 16px;
  450. text-align: left;
  451. font-family: AlibabaPuHui-regular;
  452. }
  453. }
  454. // 价格
  455. .station-price {
  456. margin-top: 4px;
  457. display: flex;
  458. .price-left {
  459. width: 40px;
  460. height: 20px;
  461. color: rgba(255, 98, 0, 100);
  462. font-size: 20px;
  463. text-align: left;
  464. font-family: Roboto-medium;
  465. }
  466. .price-right {
  467. height: 20px;
  468. line-height: 20px;
  469. margin-left: 2px;
  470. margin-top: 3px;
  471. color: rgba(102, 102, 102, 100);
  472. font-size: 14px;
  473. text-align: left;
  474. font-family: AlibabaPuHui-regular;
  475. }
  476. }
  477. // park
  478. .park {
  479. margin-top: 4px;
  480. display: flex;
  481. .park-p {
  482. display: inline-block;
  483. width: 20px;
  484. height: 18px;
  485. line-height: 12px;
  486. text-align: center;
  487. background-color: rgba(125, 177, 255, 100);
  488. color: #fff;
  489. }
  490. .park-text {
  491. display: inline-block;
  492. width: 300px;
  493. height: 17px;
  494. color: rgba(102, 102, 102, 100);
  495. font-size: 12px;
  496. text-align: left;
  497. margin-left: 2px;
  498. margin-top: 2px;
  499. }
  500. }
  501. // 数量
  502. .count {
  503. margin-top: 12px !important;
  504. width: 96%;
  505. display: flex;
  506. justify-content: space-between;
  507. }
  508. }
  509. }
  510. //定位
  511. .location {
  512. width: 91.4%;
  513. background-color: #ffffff;
  514. height: 120px;
  515. display: flex;
  516. margin: 70px auto 0;
  517. border-radius: 8px;
  518. border: #F2F4F4 1px;
  519. .location-text {
  520. padding: 24px 28px;
  521. .text-1 {
  522. height: 16px;
  523. line-height: 16px;
  524. color: rgba(16, 16, 16, 100);
  525. font-size: 16px;
  526. text-align: left;
  527. }
  528. .text-2 {
  529. height: 17px;
  530. line-height: 17px;
  531. color: rgba(102, 102, 102, 100);
  532. font-size: 12px;
  533. text-align: left;
  534. margin-top: 4px;
  535. }
  536. .text-3 {
  537. width: 80px;
  538. height: 24px;
  539. border-radius: 50px;
  540. color: rgba(0, 185, 98, 100);
  541. font-size: 12px;
  542. text-align: center;
  543. font-family: Microsoft Yahei;
  544. border: 1px solid rgba(0, 185, 98, 100);
  545. margin-top: 11px;
  546. }
  547. }
  548. .img-box {
  549. width: 120px;
  550. height: 120px;
  551. float: right;
  552. }
  553. }
  554. .state{
  555. width: 91.4%;
  556. background-color: #ffffff;
  557. height: 120px;
  558. display: flex;
  559. margin: 70px auto 0;
  560. border-radius: 8px;
  561. border: #F2F4F4 1px;
  562. .state-text{
  563. width: 61.8%;
  564. padding: 24px 0 0 28px;
  565. .text-1 {
  566. height: 16px;
  567. line-height: 16px;
  568. color: blueviolet;
  569. font-size: 16px;
  570. text-align: left;
  571. }
  572. .text-2 {
  573. height: 17px;
  574. line-height: 17px;
  575. color: #101010;
  576. text-align: left;
  577. margin-top: 12px;
  578. }
  579. .text-3 {
  580. font-size: 12px;
  581. text-align: center;
  582. margin-top: 6px;
  583. color: #999999;
  584. }
  585. }
  586. .img-box {
  587. width: 120px;
  588. height: 120px;
  589. float: right;
  590. }
  591. }
  592. //充值
  593. .top-up {
  594. margin-left: 16px;
  595. margin-top: 17px;
  596. .top-up-title {
  597. color: rgba(16, 16, 16, 100);
  598. font-size: 16px;
  599. }
  600. .img-box {
  601. margin-top: 12px;
  602. width: 345px;
  603. height: 146px;
  604. display: flex;
  605. justify-content: space-between;
  606. .img-1 {
  607. width: 166px;
  608. height: 146px;
  609. position: relative;
  610. .img-text {
  611. position: absolute;
  612. top: 12px;
  613. left: 12px;
  614. height: 33px;
  615. color: #ff4444;
  616. font-size: 24px;
  617. text-align: left;
  618. margin-left: 12px;
  619. .img-text2 {
  620. font-size: 14px
  621. }
  622. }
  623. }
  624. img {
  625. width: 100%;
  626. height: 100%;
  627. }
  628. }
  629. }
  630. // 小竖线
  631. .line {
  632. display: inline-block;
  633. width: 3px;
  634. height: 12px;
  635. margin-right: 7px;
  636. background-color: rgba(0, 145, 67, 100);
  637. }
  638. // 新闻公告
  639. .news-title {
  640. padding: 0 16px;
  641. margin-top: 12px;
  642. color: rgba(16, 16, 16, 100);
  643. font-size: 16px;
  644. display: flex;
  645. justify-content: space-between;
  646. background-color: #F2F4F4;
  647. .news-title-left {
  648. display: flex;
  649. }
  650. .more {
  651. font-size: 14px;
  652. color: #777777;
  653. display: flex;
  654. line-height: 20px;
  655. .more-icon {
  656. font-size: 24px
  657. }
  658. }
  659. }
  660. .news {
  661. background-color: #fff;
  662. margin: 12px 16px 20px;
  663. border-radius: 8px;
  664. .news-content {
  665. display: flex;
  666. justify-content: space-between;
  667. padding: 12px;
  668. .content-text {
  669. width: 211px;
  670. height: 42px;
  671. line-height: 21px;
  672. color: #101010;
  673. text-align: left;
  674. font-size: 14px
  675. }
  676. ;
  677. .content-img {
  678. width: 100px;
  679. height: 80px;
  680. background-color: #777777;
  681. border-radius: 4px;
  682. overflow: hidden;
  683. img {
  684. width: 100%;
  685. height: 100%;
  686. }
  687. }
  688. .news-time {
  689. margin-top: 12px;
  690. color: #999999;
  691. width: 80px;
  692. height: 20px;
  693. font-size: 14px;
  694. }
  695. }
  696. }
  697. .bottom {
  698. width: 100%;
  699. height: 150px;
  700. .bot {
  701. width: 100%;
  702. padding-left: 66px;
  703. display: flex;
  704. .bot-line {
  705. margin-top: 20px;
  706. width: 80px;
  707. height: 0px;
  708. border: 1px solid rgba(207, 210, 213, 100);
  709. }
  710. .bot-text {
  711. width: 60px;
  712. height: 17px;
  713. margin-top: 13px;
  714. margin-left: 12px;
  715. margin-right: 12px;
  716. font-size: 12px;
  717. text-align: center;
  718. color: rgba(182, 189, 195, 100);
  719. }
  720. }
  721. }
  722. // 导航栏
  723. .navigation {
  724. width: 100%;
  725. // height: 40px;
  726. padding: 10px 0;
  727. background-color: #fff;
  728. position: fixed;
  729. bottom: 0;
  730. left: 0;
  731. display: flex;
  732. justify-content: space-around;
  733. text-align: center;
  734. color: #999999;
  735. .nav-icon {
  736. width: 54px;
  737. font-size: 24px
  738. }
  739. .nav-text {
  740. font-size: 14px;
  741. }
  742. }
  743. // 登录提示
  744. .login-prompt {
  745. width: 91.4%;
  746. height: 40px;
  747. line-height: 40px;
  748. border-radius: 50px;
  749. text-align: left;
  750. padding-left: 16px;
  751. padding-right: 4px;
  752. background-color: rgba(0, 0, 0, 0.6);
  753. position: fixed;
  754. bottom: 75px;
  755. color: #ffffff;
  756. .button {
  757. width: 88px;
  758. height: 32px;
  759. line-height: 32px;
  760. border-radius: 50px;
  761. background-color: rgba(0, 185, 98, 100);
  762. text-align: center;
  763. float: right;
  764. margin-top: 4px;
  765. }
  766. }
  767. </style>