index.vue 18 KB

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