index.vue 16 KB

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