index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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="myorders">
  82. <view class="myorders-item">当前已缴费<text style="color: #008CFF;">{{totalCount||'0'}}</text>笔,合计<text style="color: #008CFF;">{{totalActualAmount||'0'}}</text>元</view>
  83. <view class="myorders-item">当前欠费<text style="color: #FF482B;">{{totalPayCount||'0'}}</text>笔,合计<text style="color: #FF482B;">{{totalPayAmount||'0'}}</text>元</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. onLoad(page) {
  318. const type = page?.type
  319. if (type && type === 'jumpurl') {
  320. const jumpurl = localStorage.getItem('jumpUrl')
  321. if (jumpurl) {
  322. uni.showLoading({
  323. title: '正在跳转中...'
  324. })
  325. setTimeout(() => {
  326. uni.hideLoading()
  327. location.href = jumpurl
  328. }, 0)
  329. }
  330. }
  331. },
  332. onShow () {
  333. this.handleGetIndexData()
  334. this.getLocation()
  335. const locationLocaturl = window.location.search
  336. this.code = getUrlParams(locationLocaturl, 'code')
  337. if (this.code && !this.$store.state.vuex_wxinfo.openId) { this.handleGetWXInfo(this.code) };
  338. },
  339. methods: {
  340. // 定位
  341. getLocation () {
  342. const that = this
  343. if (navigator.geolocation) {
  344. // 判断是否有这个对象
  345. navigator.geolocation.getCurrentPosition(function (pos) {
  346. that.latLongItude = { latitude: pos.coords.latitude, longitude: pos.coords.longitude }
  347. that.latitude = pos.coords.latitude
  348. that.longitude = pos.coords.longitude
  349. that.getCityNameByLonLat(that.latLongItude)
  350. }, function (err) {
  351. // 错误处理
  352. switch (err.code) {
  353. case 1:
  354. alert('位置服务被拒绝。')
  355. break
  356. case 2:
  357. alert('暂时获取不到位置信息。')
  358. break
  359. case 3:
  360. alert('获取信息超时。')
  361. break
  362. default:
  363. alert('未知错误。')
  364. break
  365. }
  366. })
  367. } else {
  368. alert('当前系统不支持GPS API')
  369. };
  370. },
  371. // 通过经纬度获取地区详细信息
  372. getCityNameByLonLat ({ longitude, latitude } = {}) {
  373. const that = this
  374. uni.showLoading({
  375. title: '加载中',
  376. mask: true
  377. })
  378. const str = `output=jsonp&key=BOGBZ-2BZ33-O4L32-Y3QJR-PGN66-RFFEL&location=${latitude},${longitude}`
  379. this.$jsonp('https://apis.map.qq.com/ws/geocoder/v1/?' + str, {}).then(res => {
  380. uni.hideLoading()
  381. if (res.status == 0) {
  382. if (res.result.ad_info) {
  383. that.city = res.result.ad_info.district
  384. }
  385. }
  386. })
  387. },
  388. // 轮播图点击
  389. swiperClick (item) {
  390. this.$u.route({
  391. url: 'pages/bannerDetails/bannerDetails',
  392. params: {
  393. id: this.bannerList[item].id
  394. }
  395. })
  396. },
  397. // 切换无感和手动
  398. orderNavclick () {
  399. uni.showLoading({
  400. title: '加载中'
  401. });
  402. console.log('this.recordList[1]',this.recordList[1]);
  403. console.log('orderNav',this.orderNav)
  404. if(!this.recordList[1]){uni.hideLoading();return}
  405. this.$u.api.feePay({ vehicleId: this.recordList[1] })
  406. .then(res => {
  407. console.log('res',res);
  408. if (res?.code == 200) {
  409. this.handleGetIndexData()
  410. } else {
  411. // this.$refs.uToast.show({
  412. // title: res?.msg,
  413. // type: 'error'
  414. // })
  415. }
  416. uni.hideLoading()
  417. }).catch(err =>{
  418. console.log('orderNavclick err',err)
  419. })
  420. },
  421. /**
  422. * 跳转页面
  423. * path 跳转路径
  424. * flag 是否存储
  425. * */
  426. openPage (path, flag) {
  427. this.$u.route({
  428. url: path
  429. })
  430. if (flag) {
  431. uni.setStorage({
  432. key: 'messageBack',
  433. data: 'pages/index/index'
  434. })
  435. }
  436. },
  437. // 搜索
  438. handleSearch () {
  439. uni.reLaunch({
  440. url: `/pages/parkingLists/parkingLists?keyword=${this.keyword}`
  441. })
  442. },
  443. // 城市选择
  444. handleCitySelect () {
  445. this.cityOpen = true
  446. },
  447. // 城市选择下拉变化
  448. cityChange (e) {
  449. if (e.area) {
  450. this.city = e.area.label
  451. } else if (e.city) {
  452. this.city = e.city.label
  453. } else {
  454. this.city = e.province.label
  455. }
  456. },
  457. // 获取首页数据
  458. handleGetIndexData () {
  459. uni.showLoading({
  460. title: '加载中'
  461. })
  462. this.$u.api.getIndexData()
  463. .then(res => {
  464. if (res.code === 200) {
  465. // 轮播
  466. const bannerList = []
  467. const banner = res.data?.advs
  468. banner.forEach(item => {
  469. const obj = {
  470. image: item.bannerUrl,
  471. id: item.id,
  472. name: item.name,
  473. content: item.content
  474. }
  475. bannerList.push(obj)
  476. })
  477. if (bannerList.length > 0) {
  478. this.bannerList = bannerList
  479. }
  480. // 是否有绑定车牌: 没有则通过弹框去绑定
  481. const vehicleList = res.data?.vehicleList ?? []
  482. if (vehicleList.length === 0) {
  483. this.bindCarShow = true
  484. }
  485. // 无感和手动
  486. const enableFeepay = []
  487. const orderList = res.data?.orderList ?? []
  488. orderList.forEach(item => {
  489. if (item.enableFeepay) {
  490. enableFeepay.push(item.enableFeepay)
  491. } else {
  492. enableFeepay.push(0)
  493. }
  494. enableFeepay.push(item.vehicleId)
  495. if (item.contractStatus) {
  496. enableFeepay.push(item.contractStatus)
  497. } else {
  498. enableFeepay.push(0)
  499. }
  500. })
  501. this.totalActualAmount = res.data?.payedInfo?.totalActualAmount
  502. this.totalCount = res.data?.payedInfo?.totalCount
  503. this.totalPayAmount = res.data?.payingInfo?.totalPayAmount
  504. this.totalPayCount = res.data?.payingInfo?.totalCount
  505. this.recordList = enableFeepay
  506. this.orderNav = enableFeepay[0]
  507. this.contractStatus = enableFeepay[2]
  508. this.orderList = res.data.orderList
  509. // 消息提示
  510. const newsList = []
  511. const news = res.data?.news ?? []
  512. news.forEach(item => {
  513. newsList.push(item.content)
  514. })
  515. this.noticeList = newsList
  516. uni.hideLoading()
  517. } else {
  518. this.$refs.uToast.show({
  519. title: res.msg,
  520. type: 'error'
  521. })
  522. uni.hideLoading()
  523. }
  524. }).catch(err => {
  525. console.log('err',err)
  526. this.$refs.uToast.show({
  527. title: '系统异常',
  528. type: 'error'
  529. })
  530. uni.hideLoading()
  531. })
  532. },
  533. // 去支付,选择支付方式
  534. goPay (orderId) {
  535. const href = location.href.split('#')
  536. this.jumpUrl = href[0] + '#/pages/center/order/orderDetails/orderDetails?orderId=' + orderId + '&type=open'
  537. this.payWayPop = true
  538. this.curOrderList = []
  539. this.curOrderList.push(orderId)
  540. },
  541. // 获取路段详情
  542. onRoadInfo (item) {
  543. this.$u.api.roadInfoById({
  544. id: item.roadId
  545. })
  546. .then(res => {
  547. this.popupOrderDetails = res.data
  548. this.showOrderDetails = true
  549. }).catch(err => {
  550. this.$refs.uToast.show({
  551. title: '系统异常',
  552. type: 'error'
  553. })
  554. })
  555. },
  556. // 关闭路段详情弹框
  557. closeOrderDetails () {
  558. this.showOrderDetails = false
  559. },
  560. // 打电话
  561. phoneCall (phone) {
  562. uni.makePhoneCall({
  563. phoneNumber: phone
  564. })
  565. },
  566. /**
  567. * 点击优惠活动的广告图
  568. * */
  569. promotionBannerClick (cur) {
  570. this.promotionBannerList.forEach((item, index) => {
  571. if (cur === index) {
  572. this.$u.route({
  573. url: 'pages/favourableActivity/favourableActivity',
  574. params: {
  575. title: item.title,
  576. id: item.id
  577. }
  578. })
  579. }
  580. })
  581. },
  582. // 关闭支付弹框
  583. closePaymentMethod () {
  584. this.payWayPop = false
  585. }
  586. }
  587. }
  588. </script>
  589. <style lang="scss" scoped>
  590. @import "./index.scss";
  591. </style>