index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <template>
  2. <view>
  3. <!-- ===================================== 搜索栏 ===================================== -->
  4. <view class="header-bar">
  5. <view class="city" @click="handleCitySelect">
  6. <view class="city-name">{{ city }}</view>
  7. <u-icon name="arrow-down" color="#fff" size="32"></u-icon>
  8. </view>
  9. <u-search
  10. placeholder="搜索停车点"
  11. :show-action="false"
  12. @search="handleSearch"
  13. v-model="keyword"
  14. ></u-search>
  15. <!-- <u-icon class="scan" name="scan" color="#fff" size="48" @click="$refs.uToast.show({title: '建设中'})"></u-icon> -->
  16. </view>
  17. <!-- ===================================== 轮播图 ===================================== -->
  18. <u-swiper
  19. :list="bannerList"
  20. border-radius="0"
  21. mode="none"
  22. @click="swiperClick"
  23. ></u-swiper>
  24. <!-- ===================================== 城市选择器 ===================================== -->
  25. <u-city-select
  26. v-model="cityOpen"
  27. @city-change="cityChange"
  28. :areaCode='["52", "5201"]'
  29. ></u-city-select>
  30. <!-- ===================================== 滚动信息栏 ===================================== -->
  31. <view
  32. class="notice-bar-wrap u-flex"
  33. v-if="noticeList.length >= 1"
  34. @click="openPage('pages/message/message', true)"
  35. >
  36. <u-icon custom-prefix="custom-icon" size="50" name="xiaoxi" color="#008CFF"></u-icon>
  37. <u-notice-bar
  38. class="u-flex-1"
  39. mode="vertical"
  40. :autoplay="true"
  41. :list="noticeList"
  42. :volume-icon="false"
  43. bg-color="#fff"
  44. color="#727272"
  45. :more-icon="true"
  46. ></u-notice-bar>
  47. </view>
  48. <!-- ===================================== 宫格菜单 ===================================== -->
  49. <u-card
  50. :show-head="false"
  51. :show-foot="false"
  52. border-radius="16"
  53. margin="20rpx 40rpx"
  54. padding="30"
  55. >
  56. <view class="content-nav" slot="body">
  57. <view
  58. class="content-nav-item"
  59. v-for="(grid, index) in gridList"
  60. :key="'g-' + index"
  61. @click="openPage(grid.url, true)"
  62. >
  63. <view class="content-nav-item-icon-wrap">
  64. <u-image
  65. :src="grid.imageUrl"
  66. :width="grid.width || '95rpx'"
  67. :height="grid.height || '95rpx'"
  68. :mode="grid.mode || 'heightFix'"
  69. ></u-image>
  70. </view>
  71. <view class="content-nav-item-icon-text">{{grid.title}}</view>
  72. </view>
  73. </view>
  74. </u-card>
  75. <u-card
  76. :show-head="false"
  77. :show-foot="false"
  78. border-radius="16"
  79. margin="20rpx 40rpx"
  80. padding="30">
  81. <view slot="body" class="">
  82. <view>已缴费{{totalCount}}笔,合计{{totalActualAmount}}元</view>
  83. <view>当前欠费{{totalPayCount}}笔,合计{{totalPayAmount}}元</view>
  84. </view>
  85. </u-card>
  86. <!-- ===================================== 无停车信息 ===================================== -->
  87. <view class="empty-data-box" v-if="!orderList || orderList.length < 1">
  88. <u-empty text="暂无停车信息" mode="list"></u-empty>
  89. </view>
  90. <!-- ===================================== 停车列表 ===================================== -->
  91. <template v-for="(item, index) in orderList">
  92. <u-card
  93. :show-foot="false"
  94. border-radius="16"
  95. margin="20rpx 40rpx"
  96. padding="30">
  97. <view class="pending-order-head" slot="head">
  98. <view class="pending-order-head-left">
  99. <b>P</b>
  100. {{ item.roadName }}
  101. </view>
  102. <view class="pending-order-head-right" @click=" onRoadInfo(item)">
  103. <u-icon class="arrow-down" name="arrow-down" size="32" color="#aaa"></u-icon>
  104. </view>
  105. </view>
  106. <view class="pending-order-body" slot="body">
  107. <view class="pending-order-body-nav">
  108. <view
  109. class="nav-item nav-manual"
  110. @click="orderNavclick()"
  111. :class="{ active: orderNav == 0 }"
  112. >手动缴费</view>
  113. <view
  114. class="nav-item nav-auto"
  115. @click="orderNavclick()"
  116. :class="{ active: orderNav == 1 }"
  117. >无感支付</view>
  118. </view>
  119. <view class="pending-order-body-wrap" v-show="orderNav == 0">
  120. <view class="pending-order-body-left">
  121. <view class="car-number">{{ item.vehicleNo }}</view>
  122. <view class="item-cell">
  123. <span class="pending-order-body-left-label">入场时间:</span>
  124. <span>{{ item.inTime }}</span>
  125. </view>
  126. <view class="item-cell">
  127. <span class="pending-order-body-left-label">出场时间:</span>
  128. <span>{{item.outTime}}</span>
  129. </view>
  130. <view class="item-cell">
  131. <span class="pending-order-body-left-label">预计金额:</span>
  132. <span>{{ item.payAmount }}</span>
  133. </view>
  134. <!-- <view class="item-cell">
  135. <span class="pending-order-body-left-label">出场时间:</span>
  136. <span>{{item.outTime||'停放中'}}</span>
  137. </view>
  138. <view class="item-cell">
  139. <span class="pending-order-body-left-label">停留时间:</span>
  140. <span>{{item.duration||'停放中'}}</span>
  141. </view>
  142. <view class="item-cell cost">
  143. <span class="pending-order-body-left-label">停车费用:</span>
  144. <span>
  145. <span class="number" v-if="item.payAmount">¥{{item.payAmount}}</span>
  146. <span class="number" v-else>停放中</span>
  147. </span>
  148. </view>-->
  149. </view>
  150. <view class="pending-order-body-right">
  151. <view class="order">停车泊位:{{ item.spaceName }}</view>
  152. </view>
  153. <view class="go-pay-wrap">
  154. <view class="go-pay" @click="goPay(item.id)"v-if="item.payAmount != 0">出场缴费</view>
  155. <view class="go-pay1" v-else>出场缴费</view>
  156. </view>
  157. </view>
  158. <view class="pending-order-body-wrap" v-show="orderNav == 1">
  159. <view v-if="contractStatus == 0" class="nosign">
  160. <view class="nosign1">您的车牌未签约贵州银行无感支付</view>
  161. <view class="nosign2">请下载贵州银行手机银行app进行签约</view>
  162. </view>
  163. <view v-if="contractStatus == 1" class="sign">
  164. <view class="sign1">您已签约贵州银行无感支付</view>
  165. <view class="sign2">停车出场时将默认使用无感支付进行支付</view>
  166. </view>
  167. </view>
  168. </view>
  169. </u-card>
  170. </template>
  171. <!-- ===================================== 优惠活动 ===================================== -->
  172. <view class="promotion-box">
  173. <view class="promotion-title">
  174. <text>优惠活动</text>
  175. </view>
  176. <view class="promotion-banner">
  177. <u-swiper :list="promotionBannerList" @click="promotionBannerClick" height="221"></u-swiper>
  178. </view>
  179. </view>
  180. <!-- ===================================== 绑定车牌号弹框 ===================================== -->
  181. <u-modal
  182. v-model="bindCarShow"
  183. title="绑定车牌号"
  184. :show-cancel-button="true"
  185. confirm-text="去绑定"
  186. content="首次使用请先绑定您的车牌"
  187. @confirm="$u.route({ url: 'pages/myCars/myCars' })"
  188. ></u-modal>
  189. <!-- ===================================== 停车场信息弹框 ===================================== -->
  190. <u-popup
  191. class="popup-order-details"
  192. v-model="showOrderDetails"
  193. mode="center"
  194. width="90%"
  195. border-radius="20"
  196. >
  197. <view class="popup-order-details-til">停车场信息</view>
  198. <view class="popup-order-details-con">
  199. <dl>
  200. <dt>路段名称:</dt>
  201. <dd>{{ popupOrderDetails.roadName }}</dd>
  202. </dl>
  203. <dl>
  204. <dt>路段编码:</dt>
  205. <dd>{{ popupOrderDetails.roadNo }}</dd>
  206. </dl>
  207. <dl>
  208. <dt>联系人:</dt>
  209. <dd>{{ popupOrderDetails.manager }}</dd>
  210. </dl>
  211. <dl>
  212. <dt>联系电话:</dt>
  213. <dd @click="phoneCall(popupOrderDetails.telephone)">{{ popupOrderDetails.telephone }}</dd>
  214. </dl>
  215. </view>
  216. <view class="popup-order-details-footer" @click="closeOrderDetails">知道了</view>
  217. </u-popup>
  218. <!-- ===================================== 支付方式弹框 ===================================== -->
  219. <PaymentMethod
  220. :payWayPop="payWayPop"
  221. :curOrderList="curOrderList"
  222. :jumpUrl="jumpUrl"
  223. @closePaymentMethod="closePaymentMethod"
  224. ></PaymentMethod>
  225. <u-toast ref="uToast" />
  226. </view>
  227. </template>
  228. <script>
  229. import getUrlParams from '../../utils/getUrlParams.js'
  230. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue'
  231. export default {
  232. components: {
  233. PaymentMethod
  234. },
  235. data () {
  236. return {
  237. // 城市选择框
  238. cityOpen: false,
  239. // 选中城市
  240. city: '贵州省',
  241. // 搜索框值
  242. keyword: '',
  243. // 轮播图
  244. bannerList: [
  245. {
  246. image: require('@/static/img/index-banner01.png')
  247. }
  248. ],
  249. // 订单列表
  250. orderList: [],
  251. // 微信code
  252. code: null,
  253. // 手动,无感
  254. orderNav: '',
  255. // 绑定车询问弹窗
  256. bindCarShow: false,
  257. // 是否线上订单细节
  258. showOrderDetails: false,
  259. // 订单详情
  260. popupOrderDetails: [],
  261. // 消息列表
  262. noticeList: [],
  263. // 优惠活动广告图
  264. promotionBannerList: [
  265. {
  266. id: 1,
  267. image: '/static/img/promotion-banner-1.png',
  268. title: '1分钱停车'
  269. },
  270. {
  271. id: 2,
  272. image: '/static/img/promotion-banner-2.png',
  273. title: '八折停车'
  274. }
  275. ],
  276. // 签约状态
  277. contractStatus: '',
  278. vehicleId: '',
  279. recordList: [],
  280. // 支付方式弹框
  281. payWayPop: false,
  282. // 订单号
  283. curOrderList: [],
  284. // 当前位置经纬度
  285. latLongItude: {},
  286. // 跳转地址
  287. jumpUrl: '',
  288. // 宫格菜单列表
  289. gridList: [
  290. {
  291. url: 'pages/payLists/payLists',
  292. imageUrl: '../../static/img/index-content-nav-01.png',
  293. title: '停车缴费'
  294. },
  295. {
  296. url: 'pages/favourableActivity/favourableActivity',
  297. imageUrl: '../../static/img/index-content-nav-02.png',
  298. title: '优惠活动'
  299. },
  300. {
  301. url: 'pages/myCars/myCars',
  302. imageUrl: '../../static/img/index-content-nav-03.png',
  303. title: '车辆管理'
  304. },
  305. {
  306. url: 'pages/searchparking/searchparking',
  307. imageUrl: '../../static/img/index-content-nav-04.png',
  308. title: '我的停车'
  309. }
  310. ],
  311. totalActualAmount: '', //缴费总额
  312. totalPayAmount: '', //应支付总额
  313. totalCount: '', //缴费总笔数
  314. totalPayCount: '' //应支付总笔数
  315. }
  316. },
  317. onShow () {
  318. this.handleGetIndexData()
  319. this.getLocation()
  320. const locationLocaturl = window.location.search
  321. this.code = getUrlParams(locationLocaturl, 'code')
  322. if (this.code && !this.$store.state.vuex_wxinfo.openId) { this.handleGetWXInfo(this.code) };
  323. },
  324. methods: {
  325. // 定位
  326. getLocation () {
  327. const that = this
  328. if (navigator.geolocation) {
  329. // 判断是否有这个对象
  330. navigator.geolocation.getCurrentPosition(function (pos) {
  331. that.latLongItude = { latitude: pos.coords.latitude, longitude: pos.coords.longitude }
  332. that.latitude = pos.coords.latitude
  333. that.longitude = pos.coords.longitude
  334. that.getCityNameByLonLat(that.latLongItude)
  335. }, function (err) {
  336. // 错误处理
  337. switch (err.code) {
  338. case 1:
  339. alert('位置服务被拒绝。')
  340. break
  341. case 2:
  342. alert('暂时获取不到位置信息。')
  343. break
  344. case 3:
  345. alert('获取信息超时。')
  346. break
  347. default:
  348. alert('未知错误。')
  349. break
  350. }
  351. })
  352. } else {
  353. alert('当前系统不支持GPS API')
  354. };
  355. },
  356. // 通过经纬度获取地区详细信息
  357. getCityNameByLonLat ({ longitude, latitude } = {}) {
  358. const that = this
  359. uni.showLoading({
  360. title: '加载中',
  361. mask: true
  362. })
  363. const str = `output=jsonp&key=BOGBZ-2BZ33-O4L32-Y3QJR-PGN66-RFFEL&location=${latitude},${longitude}`
  364. this.$jsonp('https://apis.map.qq.com/ws/geocoder/v1/?' + str, {}).then(res => {
  365. uni.hideLoading()
  366. if (res.status == 0) {
  367. if (res.result.ad_info) {
  368. that.city = res.result.ad_info.district
  369. }
  370. }
  371. })
  372. },
  373. // 轮播图点击
  374. swiperClick (item) {
  375. this.$u.route({
  376. url: 'pages/bannerDetails/bannerDetails',
  377. params: {
  378. id: this.bannerList[item].id
  379. }
  380. })
  381. },
  382. // 切换无感和手动
  383. orderNavclick () {
  384. uni.showLoading({
  385. title: '加载中'
  386. })
  387. this.$u.api.feePay({ vehicleId: this.recordList[1] })
  388. .then(res => {
  389. if (res.code == 200) {
  390. this.handleGetIndexData()
  391. } else {
  392. this.$refs.uToast.show({
  393. title: res.msg,
  394. type: 'error'
  395. })
  396. }
  397. uni.hideLoading()
  398. })
  399. },
  400. /**
  401. * 跳转页面
  402. * path 跳转路径
  403. * flag 是否存储
  404. * */
  405. openPage (path, flag) {
  406. this.$u.route({
  407. url: path
  408. })
  409. if (flag) {
  410. uni.setStorage({
  411. key: 'messageBack',
  412. data: 'pages/index/index'
  413. })
  414. }
  415. },
  416. // 搜索
  417. handleSearch () {
  418. uni.reLaunch({
  419. url: `/pages/parkingLists/parkingLists?keyword=${this.keyword}`
  420. })
  421. },
  422. // 城市选择
  423. handleCitySelect () {
  424. this.cityOpen = true
  425. },
  426. // 城市选择下拉变化
  427. cityChange (e) {
  428. if (e.area) {
  429. this.city = e.area.label
  430. } else if (e.city) {
  431. this.city = e.city.label
  432. } else {
  433. this.city = e.province.label
  434. }
  435. },
  436. // 获取首页数据
  437. handleGetIndexData () {
  438. uni.showLoading({
  439. title: '加载中'
  440. })
  441. this.$u.api.getIndexData()
  442. .then(res => {
  443. if (res.code === 200) {
  444. // 轮播
  445. const bannerList = []
  446. const banner = res.data?.advs
  447. banner.forEach(item => {
  448. const obj = {
  449. image: item.bannerUrl,
  450. id: item.id,
  451. name: item.name,
  452. content: item.content
  453. }
  454. bannerList.push(obj)
  455. })
  456. if (bannerList.length > 0) {
  457. this.bannerList = bannerList
  458. }
  459. // 是否有绑定车牌: 没有则通过弹框去绑定
  460. const vehicleList = res.data?.vehicleList ?? []
  461. if (vehicleList.length === 0) {
  462. this.bindCarShow = true
  463. }
  464. // 无感和手动
  465. const enableFeepay = []
  466. const orderList = res.data?.orderList ?? []
  467. orderList.forEach(item => {
  468. if (item.enableFeepay) {
  469. enableFeepay.push(item.enableFeepay)
  470. } else {
  471. enableFeepay.push(0)
  472. }
  473. enableFeepay.push(item.vehicleId)
  474. if (item.contractStatus) {
  475. enableFeepay.push(item.contractStatus)
  476. } else {
  477. enableFeepay.push(0)
  478. }
  479. })
  480. this.totalActualAmount = res.data.payedInfo.totalActualAmount
  481. this.totalCount = res.data.payedInfo.totalCount
  482. this.totalPayAmount = res.data.payingInfo.totalPayAmount
  483. this.totalPayCount = res.data.payingInfo.totalCount
  484. this.recordList = enableFeepay
  485. this.orderNav = enableFeepay[0]
  486. this.contractStatus = enableFeepay[2]
  487. this.orderList = res.data.orderList
  488. // 消息提示
  489. const newsList = []
  490. const news = res.data?.news ?? []
  491. news.forEach(item => {
  492. newsList.push(item.content)
  493. })
  494. this.noticeList = newsList
  495. uni.hideLoading()
  496. } else {
  497. this.$refs.uToast.show({
  498. title: res.msg,
  499. type: 'error'
  500. })
  501. uni.hideLoading()
  502. }
  503. }).catch(err => {
  504. this.$refs.uToast.show({
  505. title: '系统异常',
  506. type: 'error'
  507. })
  508. uni.hideLoading()
  509. })
  510. },
  511. // 去支付,选择支付方式
  512. goPay (orderId) {
  513. const href = location.href.split('#')
  514. this.jumpUrl = href[0] + '#/pages/center/order/orderDetails/orderDetails?orderId=' + orderId + '&type=open'
  515. this.payWayPop = true
  516. this.curOrderList = []
  517. this.curOrderList.push(orderId)
  518. },
  519. // 获取路段详情
  520. onRoadInfo (item) {
  521. this.$u.api.roadInfoById({
  522. id: item.roadId
  523. })
  524. .then(res => {
  525. this.popupOrderDetails = res.data
  526. this.showOrderDetails = true
  527. }).catch(err => {
  528. this.$refs.uToast.show({
  529. title: '系统异常',
  530. type: 'error'
  531. })
  532. })
  533. },
  534. // 关闭路段详情弹框
  535. closeOrderDetails () {
  536. this.showOrderDetails = false
  537. },
  538. // 打电话
  539. phoneCall (phone) {
  540. uni.makePhoneCall({
  541. phoneNumber: phone
  542. })
  543. },
  544. /**
  545. * 点击优惠活动的广告图
  546. * */
  547. promotionBannerClick (cur) {
  548. this.promotionBannerList.forEach((item, index) => {
  549. if (cur === index) {
  550. this.$u.route({
  551. url: 'pages/favourableActivity/favourableActivity',
  552. params: {
  553. title: item.title,
  554. id: item.id
  555. }
  556. })
  557. }
  558. })
  559. },
  560. // 关闭支付弹框
  561. closePaymentMethod () {
  562. this.payWayPop = false
  563. }
  564. }
  565. }
  566. </script>
  567. <style lang="scss" scoped>
  568. @import "./index.scss";
  569. </style>