index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  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" @click="toSearchPile">
  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" v-if="message == 'getLocation:ok'">
  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" v-else>
  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. onLoad(op) {
  219. if(op.jpcode){
  220. var k=API.codeOperation(op.jpcode);
  221. if(k){
  222. uni.navigateTo({
  223. url:k
  224. })
  225. }
  226. }
  227. },
  228. onReachBottom() {
  229. if (this.newsList.length < this.recordsTotal) {
  230. this.myLoadmore();
  231. }
  232. },
  233. onReady() {
  234. if (this.carhelp.getPersonInfo()) {
  235. this.userId = this.carhelp.getPersonInfo().id;
  236. }
  237. WxJsApi.getWxConfig(['getLocation', 'addEventListener', 'scanQRCode']).then((res) => {
  238. // console.log(res)
  239. }).catch(error => {
  240. console.log(res)
  241. })
  242. this.getPoint();
  243. this.getNewsList();
  244. this.getActivityInfoList();
  245. },
  246. methods: {
  247. toSearchPile() {
  248. uni.navigateTo({
  249. url: '/pages/searchPile/searchPile'
  250. })
  251. },
  252. toLogin() {
  253. uni.navigateTo({
  254. url: '/pages/login/login'
  255. })
  256. },
  257. toNewsNotice() {
  258. uni.navigateTo({
  259. url: '/pages/article/newsNotice'
  260. })
  261. },
  262. //微信扫二维码
  263. getScanCode() {
  264. if (this.userId) {
  265. WxJsApi.scanQRCode(1).then(res => {
  266. if(res) {
  267. API.scanCode(res).then((response) => {
  268. }).catch(error => {
  269. uni.showToast({
  270. title: error,
  271. icon: "none"
  272. })
  273. })
  274. }
  275. }).catch(error => {
  276. })
  277. } else {
  278. uni.navigateTo({
  279. url: '/pages/login/login'
  280. })
  281. }
  282. },
  283. fastRecharge() {
  284. if (this.userId) {
  285. this.gotoUrl('pages/user/finance/recharge?id=' + this.userId)
  286. } else {
  287. uni.navigateTo({
  288. url: '/pages/login/login'
  289. })
  290. }
  291. },
  292. chargingRecord() {
  293. if (this.userId) {
  294. this.gotoUrl('pages/user/finance/rechargeList?id=' + this.userId)
  295. } else {
  296. uni.navigateTo({
  297. url: '/pages/login/login'
  298. })
  299. }
  300. },
  301. rechargeActivity() {
  302. if (this.userId) {
  303. this.gotoUrl('pages/user/finance/recharge?id=' + this.userId)
  304. } else {
  305. uni.navigateTo({
  306. url: '/pages/login/login'
  307. })
  308. }
  309. },
  310. getActivityInfoList() {
  311. uni.showLoading({
  312. title: "加载中",
  313. mask: true,
  314. })
  315. API.activityInfoList({
  316. pageIndex: 1,
  317. pageSize: 10
  318. }).then((res) => {
  319. uni.hideLoading()
  320. this.activityList = res.data.data;
  321. }).catch(error => {
  322. uni.showToast({
  323. title: error,
  324. icon: "none"
  325. })
  326. })
  327. },
  328. getPoint() {
  329. WxJsApi.getLocation().then((res) => {
  330. this.latitude = parseFloat(res.latitude);
  331. this.longitude = parseFloat(res.longitude);
  332. this.message = res.errMsg;
  333. if (res.errMsg != 'getLocation:ok') {
  334. uni.showToast({
  335. title: res
  336. })
  337. }
  338. }).catch(error => {
  339. uni.showToast({
  340. title: JSON.stringify(error)
  341. })
  342. })
  343. },
  344. getNewsList(bl) {
  345. uni.showLoading({
  346. title: "加载中",
  347. mask: true,
  348. })
  349. if (bl) {
  350. this.newsList = [];
  351. this.pageIndex = 1;
  352. }
  353. newsApi.newsInfoList({
  354. pageIndex: 1,
  355. pageSize: 10
  356. }).then((res) => {
  357. uni.hideLoading()
  358. this.newsList = [
  359. ...this.newsList,
  360. ...res.data.data
  361. ];
  362. this.recordsTotal = res.data.recordsTotal
  363. }).catch(error => {
  364. uni.showToast({
  365. title: error,
  366. icon: "none"
  367. })
  368. })
  369. },
  370. myLoadmore() {
  371. this.pageIndex += 1;
  372. this.getNewsList()
  373. },
  374. }
  375. }
  376. </script>
  377. <style lang="scss" scoped>
  378. // 头部图片
  379. img {
  380. width: 100%;
  381. height: 100%;
  382. }
  383. .banner {
  384. width: 100%;
  385. height: 300px;
  386. }
  387. // 选项列表
  388. .option-list {
  389. padding-top: 18px;
  390. width: 343px;
  391. height: 100px;
  392. line-height: 20px;
  393. border-radius: 8px;
  394. text-align: center;
  395. background-color: #fff;
  396. position: absolute;
  397. top: 260px;
  398. left: 0;
  399. right: 0;
  400. margin: auto;
  401. display: flex;
  402. justify-content: space-around;
  403. .list-item {
  404. // 图标
  405. .icon {
  406. width: 40px;
  407. height: 40px;
  408. border-radius: 99px;
  409. line-height: 40px;
  410. font-size: 24px;
  411. text-align: center;
  412. margin: auto;
  413. color: #ffffff;
  414. }
  415. }
  416. }
  417. // 站点
  418. .station {
  419. // width: 343px;
  420. height: 120px;
  421. margin-top: 70px;
  422. padding-top: 20px;
  423. padding: 0 12px;
  424. position: relative;
  425. .img-box {
  426. width: 100%;
  427. height: 100%;
  428. border-radius: 8px;
  429. overflow: hidden;
  430. }
  431. img {
  432. width: 100%;
  433. height: 100%;
  434. }
  435. .text {
  436. position: absolute;
  437. top: 0;
  438. left: 20px;
  439. // 头部
  440. .station-title {
  441. display: flex;
  442. margin-top: 12px;
  443. .title-left {
  444. display: inline-block;
  445. height: 20px;
  446. width: 44px;
  447. // margin-left: 12px;
  448. line-height: 20px;
  449. border-radius: 50px;
  450. background-color: rgba(133, 140, 255, 100);
  451. color: rgba(255, 255, 255, 100);
  452. font-size: 12px;
  453. text-align: center;
  454. font-family: Arial;
  455. }
  456. .title-right {
  457. display: inline-block;
  458. margin-left: 4px;
  459. margin-top: 2px;
  460. width: 271px;
  461. height: 16px;
  462. line-height: 16px;
  463. color: rgba(16, 16, 16, 100);
  464. font-size: 16px;
  465. text-align: left;
  466. font-family: AlibabaPuHui-regular;
  467. }
  468. }
  469. // 价格
  470. .station-price {
  471. margin-top: 4px;
  472. display: flex;
  473. .price-left {
  474. width: 40px;
  475. height: 20px;
  476. color: rgba(255, 98, 0, 100);
  477. font-size: 20px;
  478. text-align: left;
  479. font-family: Roboto-medium;
  480. }
  481. .price-right {
  482. height: 20px;
  483. line-height: 20px;
  484. margin-left: 2px;
  485. margin-top: 3px;
  486. color: rgba(102, 102, 102, 100);
  487. font-size: 14px;
  488. text-align: left;
  489. font-family: AlibabaPuHui-regular;
  490. }
  491. }
  492. // park
  493. .park {
  494. margin-top: 4px;
  495. display: flex;
  496. .park-p {
  497. display: inline-block;
  498. width: 20px;
  499. height: 18px;
  500. line-height: 12px;
  501. text-align: center;
  502. background-color: rgba(125, 177, 255, 100);
  503. color: #fff;
  504. }
  505. .park-text {
  506. display: inline-block;
  507. width: 300px;
  508. height: 17px;
  509. color: rgba(102, 102, 102, 100);
  510. font-size: 12px;
  511. text-align: left;
  512. margin-left: 2px;
  513. margin-top: 2px;
  514. }
  515. }
  516. // 数量
  517. .count {
  518. margin-top: 12px !important;
  519. width: 96%;
  520. display: flex;
  521. justify-content: space-between;
  522. }
  523. }
  524. }
  525. //定位
  526. .location {
  527. width: 91.4%;
  528. background-color: #ffffff;
  529. height: 120px;
  530. display: flex;
  531. margin: 70px auto 0;
  532. border-radius: 8px;
  533. border: #F2F4F4 1px;
  534. .location-text {
  535. padding: 24px 28px;
  536. .text-1 {
  537. height: 16px;
  538. line-height: 16px;
  539. color: rgba(16, 16, 16, 100);
  540. font-size: 16px;
  541. text-align: left;
  542. }
  543. .text-2 {
  544. height: 17px;
  545. line-height: 17px;
  546. color: rgba(102, 102, 102, 100);
  547. font-size: 12px;
  548. text-align: left;
  549. margin-top: 4px;
  550. }
  551. .text-3 {
  552. width: 80px;
  553. height: 24px;
  554. border-radius: 50px;
  555. color: rgba(0, 185, 98, 100);
  556. font-size: 12px;
  557. text-align: center;
  558. font-family: Microsoft Yahei;
  559. border: 1px solid rgba(0, 185, 98, 100);
  560. margin-top: 11px;
  561. }
  562. }
  563. .img-box {
  564. width: 120px;
  565. height: 120px;
  566. float: right;
  567. }
  568. }
  569. .state{
  570. width: 91.4%;
  571. background-color: #ffffff;
  572. height: 120px;
  573. display: flex;
  574. margin: 70px auto 0;
  575. border-radius: 8px;
  576. border: #F2F4F4 1px;
  577. .state-text{
  578. width: 61.8%;
  579. padding: 24px 0 0 28px;
  580. .text-1 {
  581. height: 16px;
  582. line-height: 16px;
  583. color: blueviolet;
  584. font-size: 16px;
  585. text-align: left;
  586. }
  587. .text-2 {
  588. height: 17px;
  589. line-height: 17px;
  590. color: #101010;
  591. text-align: left;
  592. margin-top: 12px;
  593. }
  594. .text-3 {
  595. font-size: 12px;
  596. text-align: center;
  597. margin-top: 6px;
  598. color: #999999;
  599. }
  600. }
  601. .img-box {
  602. width: 120px;
  603. height: 120px;
  604. float: right;
  605. }
  606. }
  607. //充值
  608. .top-up {
  609. margin-left: 16px;
  610. margin-top: 17px;
  611. .top-up-title {
  612. color: rgba(16, 16, 16, 100);
  613. font-size: 16px;
  614. }
  615. .img-box {
  616. margin-top: 12px;
  617. width: 345px;
  618. height: 146px;
  619. display: flex;
  620. justify-content: space-between;
  621. .img-1 {
  622. width: 166px;
  623. height: 146px;
  624. position: relative;
  625. .img-text {
  626. position: absolute;
  627. top: 12px;
  628. left: 12px;
  629. height: 33px;
  630. color: #ff4444;
  631. font-size: 24px;
  632. text-align: left;
  633. margin-left: 12px;
  634. .img-text2 {
  635. font-size: 14px
  636. }
  637. }
  638. }
  639. img {
  640. width: 100%;
  641. height: 100%;
  642. }
  643. }
  644. }
  645. // 小竖线
  646. .line {
  647. display: inline-block;
  648. width: 3px;
  649. height: 12px;
  650. margin-right: 7px;
  651. background-color: rgba(0, 145, 67, 100);
  652. }
  653. // 新闻公告
  654. .news-title {
  655. padding: 0 16px;
  656. margin-top: 12px;
  657. color: rgba(16, 16, 16, 100);
  658. font-size: 16px;
  659. display: flex;
  660. justify-content: space-between;
  661. background-color: #F2F4F4;
  662. .news-title-left {
  663. display: flex;
  664. }
  665. .more {
  666. font-size: 14px;
  667. color: #777777;
  668. display: flex;
  669. line-height: 20px;
  670. .more-icon {
  671. font-size: 24px
  672. }
  673. }
  674. }
  675. .news {
  676. background-color: #fff;
  677. margin: 12px 16px 20px;
  678. border-radius: 8px;
  679. .news-content {
  680. display: flex;
  681. justify-content: space-between;
  682. padding: 12px;
  683. .content-text {
  684. width: 211px;
  685. height: 42px;
  686. line-height: 21px;
  687. color: #101010;
  688. text-align: left;
  689. font-size: 14px
  690. }
  691. ;
  692. .content-img {
  693. width: 100px;
  694. height: 80px;
  695. background-color: #777777;
  696. border-radius: 4px;
  697. overflow: hidden;
  698. img {
  699. width: 100%;
  700. height: 100%;
  701. }
  702. }
  703. .news-time {
  704. margin-top: 12px;
  705. color: #999999;
  706. width: 80px;
  707. height: 20px;
  708. font-size: 14px;
  709. }
  710. }
  711. }
  712. .bottom {
  713. width: 100%;
  714. height: 150px;
  715. .bot {
  716. width: 100%;
  717. padding-left: 66px;
  718. display: flex;
  719. .bot-line {
  720. margin-top: 20px;
  721. width: 80px;
  722. height: 0px;
  723. border: 1px solid rgba(207, 210, 213, 100);
  724. }
  725. .bot-text {
  726. width: 60px;
  727. height: 17px;
  728. margin-top: 13px;
  729. margin-left: 12px;
  730. margin-right: 12px;
  731. font-size: 12px;
  732. text-align: center;
  733. color: rgba(182, 189, 195, 100);
  734. }
  735. }
  736. }
  737. // 导航栏
  738. .navigation {
  739. width: 100%;
  740. // height: 40px;
  741. padding: 10px 0;
  742. background-color: #fff;
  743. position: fixed;
  744. bottom: 0;
  745. left: 0;
  746. display: flex;
  747. justify-content: space-around;
  748. text-align: center;
  749. color: #999999;
  750. .nav-icon {
  751. width: 54px;
  752. font-size: 24px
  753. }
  754. .nav-text {
  755. font-size: 14px;
  756. }
  757. }
  758. // 登录提示
  759. .login-prompt {
  760. width: 91.4%;
  761. height: 40px;
  762. line-height: 40px;
  763. border-radius: 50px;
  764. text-align: left;
  765. padding-left: 16px;
  766. padding-right: 4px;
  767. background-color: rgba(0, 0, 0, 0.6);
  768. position: fixed;
  769. bottom: 75px;
  770. color: #ffffff;
  771. .button {
  772. width: 88px;
  773. height: 32px;
  774. line-height: 32px;
  775. border-radius: 50px;
  776. background-color: rgba(0, 185, 98, 100);
  777. text-align: center;
  778. float: right;
  779. margin-top: 4px;
  780. }
  781. }
  782. </style>