index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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. <u-toast ref="uToast" />
  162. </view>
  163. </template>
  164. <script>
  165. import getUrlParams from '../../utils/getUrlParams.js'
  166. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue'
  167. export default {
  168. components: {
  169. PaymentMethod
  170. },
  171. data() {
  172. return {
  173. // 城市选择框
  174. cityOpen: false,
  175. // 选中城市
  176. city: '贵州省',
  177. // 搜索框值
  178. keyword: '',
  179. // 轮播图
  180. bannerList: [{
  181. image: require('@/static/img/index-banner01.png')
  182. }],
  183. // 订单列表
  184. orderList: [],
  185. // 微信code
  186. code: null,
  187. // 手动,无感
  188. orderNav: '',
  189. // 绑定车询问弹窗
  190. bindCarShow: false,
  191. // 是否线上订单细节
  192. showOrderDetails: false,
  193. // 订单详情
  194. popupOrderDetails: [],
  195. // 消息列表
  196. noticeList: [],
  197. // 优惠活动广告图
  198. promotionBannerList: [{
  199. id: 1,
  200. image: '/static/img/promotion-banner-1.png',
  201. title: '1分钱停车'
  202. },
  203. {
  204. id: 2,
  205. image: '/static/img/promotion-banner-2.png',
  206. title: '八折停车'
  207. }
  208. ],
  209. // 签约状态
  210. contractStatus: '',
  211. vehicleId: '',
  212. recordList: [],
  213. // 支付方式弹框
  214. payWayPop: false,
  215. // 订单号
  216. curOrderList: [],
  217. // 当前位置经纬度
  218. latLongItude: {},
  219. // 跳转地址
  220. jumpUrl: '',
  221. // 宫格菜单列表
  222. gridList: [{
  223. url: 'pages/payLists/payLists',
  224. imageUrl: '../../static/img/index-content-nav-01.png',
  225. title: '停车缴费'
  226. },
  227. {
  228. url: 'pages/favourableActivity/favourableActivity',
  229. imageUrl: '../../static/img/index-content-nav-02.png',
  230. title: '优惠活动'
  231. },
  232. {
  233. url: 'pages/myCars/myCars',
  234. imageUrl: '../../static/img/index-content-nav-03.png',
  235. title: '车辆管理'
  236. },
  237. {
  238. url: 'pages/searchparking/searchparking',
  239. imageUrl: '../../static/img/index-content-nav-04.png',
  240. title: '我的停车'
  241. }
  242. ],
  243. totalActualAmount: '', //缴费总额
  244. totalPayAmount: '', //应支付总额
  245. totalCount: '', //缴费总笔数
  246. totalPayCount: '' //应支付总笔数
  247. }
  248. },
  249. onLoad(page) {
  250. const locationLocaturl = window.location.search
  251. const type = getUrlParams(locationLocaturl, 'type')
  252. if (type && type === 'jumpurl') {
  253. const jumpurl = localStorage.getItem('jumpUrl')
  254. if (jumpurl) {
  255. uni.showLoading({
  256. title: '正在跳转中...'
  257. })
  258. setTimeout(() => {
  259. uni.hideLoading()
  260. location.href = jumpurl
  261. }, 0)
  262. }
  263. }
  264. },
  265. onShow() {
  266. this.handleGetIndexData()
  267. this.getLocation()
  268. const locationLocaturl = window.location.search
  269. this.code = getUrlParams(locationLocaturl, 'code')
  270. if (this.code && !this.$store.state.vuex_wxinfo.openId) {
  271. this.handleGetWXInfo(this.code)
  272. };
  273. },
  274. methods: {
  275. // 定位
  276. getLocation() {
  277. const that = this
  278. if (navigator.geolocation) {
  279. // 判断是否有这个对象
  280. navigator.geolocation.getCurrentPosition(function(pos) {
  281. that.latLongItude = {
  282. latitude: pos.coords.latitude,
  283. longitude: pos.coords.longitude
  284. }
  285. that.latitude = pos.coords.latitude
  286. that.longitude = pos.coords.longitude
  287. that.getCityNameByLonLat(that.latLongItude)
  288. }, function(err) {
  289. // 错误处理
  290. switch (err.code) {
  291. case 1:
  292. alert('位置服务被拒绝。')
  293. break
  294. case 2:
  295. alert('暂时获取不到位置信息。')
  296. break
  297. case 3:
  298. alert('获取信息超时。')
  299. break
  300. default:
  301. alert('未知错误。')
  302. break
  303. }
  304. })
  305. } else {
  306. alert('当前系统不支持GPS API')
  307. };
  308. },
  309. // 通过经纬度获取地区详细信息
  310. getCityNameByLonLat({
  311. longitude,
  312. latitude
  313. } = {}) {
  314. const that = this
  315. uni.showLoading({
  316. title: '加载中',
  317. mask: true
  318. })
  319. const str = `output=jsonp&key=BOGBZ-2BZ33-O4L32-Y3QJR-PGN66-RFFEL&location=${latitude},${longitude}`
  320. this.$jsonp('https://apis.map.qq.com/ws/geocoder/v1/?' + str, {}).then(res => {
  321. uni.hideLoading()
  322. if (res.status == 0) {
  323. if (res.result.ad_info) {
  324. that.city = res.result.ad_info.district
  325. }
  326. }
  327. })
  328. },
  329. // 轮播图点击
  330. swiperClick(item) {
  331. this.$u.route({
  332. url: 'pages/bannerDetails/bannerDetails',
  333. params: {
  334. id: this.bannerList[item].id
  335. }
  336. })
  337. },
  338. // 切换无感和手动
  339. orderNavclick() {
  340. uni.showLoading({
  341. title: '加载中'
  342. });
  343. console.log('this.recordList[1]', this.recordList[1]);
  344. console.log('orderNav', this.orderNav)
  345. if (!this.recordList[1]) {
  346. uni.hideLoading();
  347. return
  348. }
  349. this.$u.api.feePay({
  350. vehicleId: this.recordList[1]
  351. })
  352. .then(res => {
  353. console.log('res', res);
  354. if (res?.code == 200) {
  355. this.handleGetIndexData()
  356. } else {
  357. // this.$refs.uToast.show({
  358. // title: res?.msg,
  359. // type: 'error'
  360. // })
  361. }
  362. uni.hideLoading()
  363. }).catch(err => {
  364. console.log('orderNavclick err', err)
  365. })
  366. },
  367. /**
  368. * 跳转页面
  369. * path 跳转路径
  370. * flag 是否存储
  371. * */
  372. openPage(path, flag) {
  373. this.$u.route({
  374. url: path
  375. })
  376. if (flag) {
  377. uni.setStorage({
  378. key: 'messageBack',
  379. data: 'pages/index/index'
  380. })
  381. }
  382. },
  383. // 搜索
  384. handleSearch() {
  385. uni.reLaunch({
  386. url: `/pages/parkingLists/parkingLists?keyword=${this.keyword}`
  387. })
  388. },
  389. // 城市选择
  390. handleCitySelect() {
  391. this.cityOpen = true
  392. },
  393. // 城市选择下拉变化
  394. cityChange(e) {
  395. if (e.area) {
  396. this.city = e.area.label
  397. } else if (e.city) {
  398. this.city = e.city.label
  399. } else {
  400. this.city = e.province.label
  401. }
  402. },
  403. // 获取首页数据
  404. handleGetIndexData() {
  405. uni.showLoading({
  406. title: '加载中'
  407. })
  408. this.$u.api.getIndexData()
  409. .then(res => {
  410. if (res.code === 200) {
  411. // 轮播
  412. const bannerList = []
  413. const banner = res.data?.advs
  414. banner.forEach(item => {
  415. const obj = {
  416. image: item.bannerUrl,
  417. id: item.id,
  418. name: item.name,
  419. content: item.content
  420. }
  421. bannerList.push(obj)
  422. })
  423. if (bannerList.length > 0) {
  424. this.bannerList = bannerList
  425. }
  426. // 是否有绑定车牌: 没有则通过弹框去绑定
  427. const vehicleList = res.data?.vehicleList ?? []
  428. if (vehicleList.length === 0) {
  429. this.bindCarShow = true
  430. }
  431. // 无感和手动
  432. const enableFeepay = []
  433. const orderList = res.data?.orderList ?? []
  434. orderList.forEach(item => {
  435. if (item.enableFeepay) {
  436. enableFeepay.push(item.enableFeepay)
  437. } else {
  438. enableFeepay.push(0)
  439. }
  440. enableFeepay.push(item.vehicleId)
  441. if (item.contractStatus) {
  442. enableFeepay.push(item.contractStatus)
  443. } else {
  444. enableFeepay.push(0)
  445. }
  446. })
  447. this.totalActualAmount = res.data?.payedInfo?.totalActualAmount
  448. this.totalCount = res.data?.payedInfo?.totalCount
  449. this.totalPayAmount = res.data?.payingInfo?.totalPayAmount
  450. this.totalPayCount = res.data?.payingInfo?.totalCount
  451. this.recordList = enableFeepay
  452. this.orderNav = enableFeepay[0]
  453. this.contractStatus = enableFeepay[2]
  454. this.orderList = res.data.orderList
  455. // 消息提示
  456. const newsList = []
  457. const news = res.data?.news ?? []
  458. news.forEach(item => {
  459. newsList.push(item.content)
  460. })
  461. this.noticeList = newsList
  462. uni.hideLoading()
  463. } else {
  464. this.$refs.uToast.show({
  465. title: res.msg,
  466. type: 'error'
  467. })
  468. uni.hideLoading()
  469. }
  470. }).catch(err => {
  471. console.log('err', err)
  472. this.$refs.uToast.show({
  473. title: '系统异常',
  474. type: 'error'
  475. })
  476. uni.hideLoading()
  477. })
  478. },
  479. // 去支付,选择支付方式
  480. goPay(orderId) {
  481. const href = location.href.split('#')
  482. this.jumpUrl = href[0] + '#/pages/center/order/orderDetails/orderDetails?orderId=' + orderId + '&type=open'
  483. this.payWayPop = true
  484. this.curOrderList = []
  485. this.curOrderList.push(orderId)
  486. },
  487. // 获取路段详情
  488. onRoadInfo(item) {
  489. this.$u.api.roadInfoById({
  490. id: item.roadId
  491. })
  492. .then(res => {
  493. this.popupOrderDetails = res.data
  494. this.showOrderDetails = true
  495. }).catch(err => {
  496. this.$refs.uToast.show({
  497. title: '系统异常',
  498. type: 'error'
  499. })
  500. })
  501. },
  502. // 关闭路段详情弹框
  503. closeOrderDetails() {
  504. this.showOrderDetails = false
  505. },
  506. // 打电话
  507. phoneCall(phone) {
  508. uni.makePhoneCall({
  509. phoneNumber: phone
  510. })
  511. },
  512. /**
  513. * 点击优惠活动的广告图
  514. * */
  515. promotionBannerClick(cur) {
  516. this.promotionBannerList.forEach((item, index) => {
  517. if (cur === index) {
  518. this.$u.route({
  519. url: 'pages/favourableActivity/favourableActivity',
  520. params: {
  521. title: item.title,
  522. id: item.id
  523. }
  524. })
  525. }
  526. })
  527. },
  528. // 关闭支付弹框
  529. closePaymentMethod() {
  530. this.payWayPop = false
  531. }
  532. }
  533. }
  534. </script>
  535. <style lang="scss" scoped>
  536. @import "./index.scss";
  537. </style>