payLists.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <view>
  3. <!-- <u-navbar title-color="#fff" :custom-back="customBack" :bpay-bottom="false" back-icon-color="#CCE8FF"
  4. :background="{background: '#008CFF' }" title="停车缴费"></u-navbar> -->
  5. <view class="swiper-wrap">
  6. <view class="u-tabs-box">
  7. <u-tabs-swiper activeColor="#008CFF" ref="tabs" :list="list" :current="current" @change="change"
  8. :is-scroll="false" swiperWidth="100%"></u-tabs-swiper>
  9. </view>
  10. <swiper class="swiper-box" :current="swiperCurrent" @transition="transition"
  11. @animationfinish="animationfinish" disable-touch>
  12. <swiper-item class="swiper-item" v-for="(item, index) in list" :key="index">
  13. <!-- <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"> -->
  14. <scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
  15. <view class="page-box">
  16. <view class="pay" v-for="(payItem, index) in payList[index]"
  17. :key="payItem.id">
  18. <view v-if="item.index==0">
  19. <view class="pay-top u-flex">
  20. <view class="pay-top-left u-flex-1">
  21. <view class="car">{{payItem.vehicleNo}}</view>
  22. <view class="addr">{{payItem.roadName}}</view>
  23. </view>
  24. <view class="pay-top-right">{{payItem.orderStatus | filterOrderStatus}}
  25. </view>
  26. </view>
  27. <view class="pay-center">
  28. <view class="pay-center-item">订单编号:{{payItem.orderId}}</view>
  29. <view class="pay-center-item">停车泊位:{{payItem.spaceName}}</view>
  30. <view class="pay-center-item">入场时间:{{payItem.inTime || 0}}</view>
  31. <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
  32. 出场时间:{{payItem.outTime || 0}}
  33. </view>
  34. <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
  35. 免费时长:{{payItem.freeDuration || 0}}
  36. </view>
  37. <!-- 计费时长=停车时长-免费时长 -->
  38. <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
  39. 计费时长:{{payItem.calcDuration || 0}}
  40. </view>
  41. <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
  42. 累计停车时长:{{payItem.duration || 0}}
  43. </view>
  44. <view class="pay-center-item">应付金额:<span
  45. class="pay-amount">{{payItem.payAmount || 0}}</span>
  46. </view>
  47. <view class="pay-center-item" v-if="payItem.deviceType && payItem.deviceType != 1">
  48. 车位锁设备号:{{payItem.deviceNo}}
  49. </view>
  50. </view>
  51. <view class="pay-bottom">
  52. <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId)"
  53. style="color: #008CFF;">
  54. </u-cell-item>
  55. </view>
  56. </view>
  57. <view v-if="item.index==1">
  58. <view class="pay-top u-flex">
  59. <view class="pay-top-left u-flex-1">
  60. <view class="car">{{payItem.vehicleNo}}</view>
  61. <view class="addr">{{payItem.parkingName}}</view>
  62. </view>
  63. <view class="pay-top-right">{{payItem.orderStatus | filterOrderStatus}}
  64. </view>
  65. </view>
  66. <view class="pay-center">
  67. <view class="pay-center-item">订单编号:{{payItem.orderId}}</view>
  68. <view class="pay-center-item">入场通道:{{payItem.entranceName}}</view>
  69. <view class="pay-center-item">入场时间:{{payItem.inTime || 0}}</view>
  70. <view class="pay-center-item">出场通道:{{payItem.outEntranceName}}</view>
  71. <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
  72. 出场时间:{{payItem.outTime || 0}}
  73. </view>
  74. <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
  75. 免费时长:{{payItem.freeDuration || 0}}
  76. </view>
  77. <!-- 计费时长=停车时长-免费时长 -->
  78. <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
  79. 计费时长:{{payItem.calcDuration || 0}}
  80. </view>
  81. <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
  82. 累计停车时长:{{payItem.duration || 0}}
  83. </view>
  84. <view class="pay-center-item">应付金额:<span
  85. class="pay-amount">{{payItem.payAmount || 0}}</span>
  86. </view>
  87. <view class="pay-center-item" v-if="payItem.deviceType && payItem.deviceType != 1">
  88. 车位锁设备号:{{payItem.deviceNo}}
  89. </view>
  90. </view>
  91. <view class="pay-bottom">
  92. <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId)"
  93. style="color: #008CFF;">
  94. </u-cell-item>
  95. </view>
  96. </view>
  97. </view>
  98. <u-loadmore :status="loadStatus[index]" bg-color="#F6F6FF"></u-loadmore>
  99. </view>
  100. </scroll-view>
  101. <!-- </mescroll-body> -->
  102. </swiper-item>
  103. </swiper>
  104. </view>
  105. <view class="bottom">
  106. <view class="bottom-total">
  107. 累计欠费<span class="total">{{totalCount}}</span>笔,合计<span class="total">{{totalPayAmount}}</span>元
  108. </view>
  109. <view class="button-wrap" v-if="payList.length&&payList.length>=1">
  110. <!-- <button class="button" type="primary" @click="all()">全部缴费</button> -->
  111. <button class="button" type="primary" @click="confirmPrice()">全部缴费</button>
  112. </view>
  113. </view>
  114. <!-- 缴费提示-->
  115. <u-modal v-model="payTipsPop" :title-style="{color: '#404040'}" title="缴费提示" :show-confirm-button="true"
  116. confirm-text="立即缴费" :confirm-style="{backgroundColor: '#3397FA', color: '#fff'}" :show-cancel-button="true"
  117. cancel-text="取消" :cancel-style="{backgroundColor: '#EBF1FF', color: '#3397FA'}"
  118. @confirm="payTipsPopConfirm">
  119. <view class="slot-content">
  120. <view class="pay-tips">
  121. <text>{{payTipsItem.num || 0}}</text>场停车欠费,共
  122. <text>{{payTipsItem.price || 0}}</text>元
  123. </view>
  124. </view>
  125. </u-modal>
  126. <!-- 支付方式 -->
  127. <PaymentMethod :payWayPop="payWayPop" :exportFlag="exportFlag" :curOrderList="currentItem" :jumpUrl="jumpUrl"
  128. @closePaymentMethod="closePaymentMethod"></PaymentMethod>
  129. <u-toast ref="uToast" />
  130. </view>
  131. </template>
  132. <script>
  133. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  134. import getUrlParams from "../../utils/getUrlParams.js";
  135. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue'
  136. export default {
  137. mixins: [MescrollMixin], // 使用mixin
  138. components: {
  139. PaymentMethod
  140. },
  141. data() {
  142. return {
  143. totalPayAmount: '',
  144. totalCount: '',
  145. currentPayUrl: "",
  146. payList: [
  147. [],
  148. [],
  149. [],
  150. []
  151. ],
  152. list: [{
  153. index: 0,
  154. name: '路段',
  155. orderStatus: null,
  156. pageNum: 1,
  157. total: null
  158. },
  159. {
  160. index: 1,
  161. name: '停车场',
  162. orderStatus: 1,
  163. pageNum: 1,
  164. total: null
  165. },
  166. ],
  167. current: 0,
  168. swiperCurrent: 0,
  169. dx: 0,
  170. loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore'],
  171. isLoadMore: false, //是否加载中
  172. orderList: [],
  173. exportFlag: false,
  174. PayUrl: "",
  175. payTipsPop: false,
  176. payWayPop: false,
  177. // 选中去支付的单条条目
  178. currentItem: [],
  179. // 缴费提示类目
  180. payTipsItem: {
  181. num: '',
  182. price: ''
  183. },
  184. code: null,
  185. jumpUrl: ''
  186. };
  187. },
  188. computed: {
  189. // 价格小数
  190. priceDecimal() {
  191. return val => {
  192. if (val !== parseInt(val)) return val.slice(-2);
  193. else return '00';
  194. };
  195. },
  196. // 价格整数
  197. priceInt() {
  198. return val => {
  199. if (val !== parseInt(val)) return val.split('.')[0];
  200. else return val;
  201. };
  202. }
  203. },
  204. onLoad() {
  205. const href = location.href.split('#')
  206. this.jumpUrl = href[0] + '#/pages/center/order/order'
  207. },
  208. onShow() {
  209. // onShow 刷新数据
  210. if (this.mescroll) {
  211. this.mescroll.triggerDownScroll();
  212. }
  213. this.list[this.current].pageNum = 1
  214. this.orderList = [
  215. [],
  216. [],
  217. [],
  218. []
  219. ]
  220. this.orderListArr(this.list[this.current], this.swiperCurrent)
  221. },
  222. methods: {
  223. reachBottom() {
  224. if (this.payList[this.current].length >= this.list[this.current].total) {
  225. this.loadStatus.splice(this.list[this.current].index, 1, 'nomore')
  226. return
  227. };
  228. this.loadStatus.splice(this.list[this.current].index, 1, 'loading')
  229. this.orderListArr(this.list[this.current], this.swiperCurrent)
  230. },
  231. // tab栏切换
  232. change(index) {
  233. this.swiperCurrent = index
  234. this.current = index
  235. //重新初始化
  236. this.payList = [
  237. [],
  238. [],
  239. [],
  240. []
  241. ]
  242. this.list[index].pageNum = 1
  243. if (index == 1) {
  244. this.exportFlag = true
  245. } else {
  246. this.exportFlag = false
  247. }
  248. this.orderListArr(this.list[index], index)
  249. },
  250. transition({
  251. detail: {
  252. dx
  253. }
  254. }) {
  255. this.$refs.tabs.setDx(dx)
  256. },
  257. animationfinish({
  258. detail: {
  259. current
  260. }
  261. }) {
  262. this.$refs.tabs.setFinishCurrent(current)
  263. this.swiperCurrent = current
  264. this.current = current
  265. },
  266. customBack() {
  267. this.$u.route({
  268. type: 'switchTab',
  269. url: 'pages/index/index'
  270. });
  271. },
  272. orderListArr(orderType, index) {
  273. let pageNum = orderType.pageNum; // 页码, 默认从1开始
  274. let pageSize = orderType.total; // 页长, 默认每页10条
  275. if (index == 0) {
  276. this.$u.api.getOrderList({
  277. // pageSize: pageSize,
  278. pageNum: pageNum,
  279. paying: true
  280. })
  281. .then(res => {
  282. for (const item of res.data.pageInfo.rows) {
  283. this.payList[orderType.index].push(item)
  284. }
  285. this.list[this.current].total = res.data.pageInfo.total
  286. this.list[orderType.index].pageNum++
  287. if (this.payList[this.current].length >= this.list[this.current].total) {
  288. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore')
  289. };
  290. this.totalCount = res.data.costInfo.totalCount;
  291. this.totalPayAmount = res.data.costInfo.totalPayAmount;
  292. }).catch(err => {
  293. this.$refs.uToast.show({
  294. title: err.msg,
  295. type: 'error',
  296. });
  297. });
  298. } else {
  299. this.$u.api.getRoomParkingApi({
  300. pageNum: pageNum,
  301. paying: true
  302. })
  303. .then(res => {
  304. for (const item of res.data.pageInfo.rows) {
  305. this.payList[orderType.index].push(item)
  306. }
  307. this.list[this.current].total = res.data.pageInfo.total
  308. this.list[orderType.index].pageNum++
  309. if (this.payList[this.current].length >= this.list[this.current].total) {
  310. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore')
  311. };
  312. this.totalCount = res.data.costInfo.totalCount;
  313. this.totalPayAmount = res.data.costInfo.totalPayAmount;
  314. })
  315. }
  316. },
  317. /*下拉刷新的回调*/
  318. // downCallback() {
  319. // // 第2种: 下拉刷新和上拉加载调同样的接口, 则不用第1种, 直接mescroll.resetUpScroll()即可
  320. // this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  321. // },
  322. /*上拉加载的回调*/
  323. // upCallback(page) {
  324. // console.log(page)
  325. // let pageNum = page.num; // 页码, 默认从1开始
  326. // let pageSize = page.size; // 页长, 默认每页10条
  327. // // this.getMessageList()
  328. // this.$u.api.getOrderList({
  329. // pageSize: pageSize,
  330. // pageNum: pageNum,
  331. // paying: true
  332. // })
  333. // .then(res => {
  334. // // 接口返回的当前页数据列表 (数组)
  335. // let curPageData = res.data.pageInfo.rows;
  336. // // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  337. // let curPageLen = curPageData.length;
  338. // // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  339. // let totalPage = res.data.pageInfo.pages;
  340. // // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  341. // let totalSize = res.data.pageInfo.total;
  342. // // 接口返回的是否有下一页 (true/false)
  343. // // let hasNext = data.pages;
  344. // //设置列表数据
  345. // if (page.num == 1) this.payList = []; //如果是第一页需手动置空列表
  346. // this.payList = this.payList.concat(curPageData); //追加新数据
  347. // this.totalCount = res.data.costInfo.totalCount;
  348. // this.totalPayAmount = res.data.costInfo.totalPayAmount;
  349. // // 请求成功,隐藏加载状态
  350. // //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  351. // this.mescroll.endByPage(curPageLen, totalPage);
  352. // setTimeout(() => {
  353. // this.mescroll.endSuccess(curPageLen)
  354. // }, 20)
  355. // }).catch(err => {
  356. // this.$refs.uToast.show({
  357. // title: err.msg,
  358. // type: 'error',
  359. // });
  360. // });
  361. // },
  362. paythis(orderId) {
  363. let orderList = [];
  364. orderList.push(orderId);
  365. this.$u.api.payGzbank({
  366. orderList: orderList
  367. }).then(res => {
  368. let payUrl = res.data.url;
  369. this.currentPayUrl = encodeURIComponent(res.data.url);
  370. // return;
  371. this.$u.route({
  372. url: 'pages/payLists/pay',
  373. params: {
  374. currentPayUrl: this.currentPayUrl
  375. }
  376. });
  377. }).catch(err => {
  378. this.$refs.uToast.show({
  379. title: err.msg,
  380. type: 'error',
  381. });
  382. });
  383. },
  384. all() {
  385. this.payList.forEach((item, index, arr) => {
  386. console.log(item)
  387. if (item.orderId) {
  388. this.orderList.push(item.orderId)
  389. }
  390. });
  391. this.$u.api.payGzbank({
  392. orderList: this.orderList
  393. }).then(res => {
  394. let payUrl = res.data.url;
  395. this.currentPayUrl = encodeURIComponent(res.data.url);
  396. // console.log('this.currentPayUrl',this.currentPayUrl);
  397. // return;
  398. this.$u.route({
  399. url: 'pages/payLists/pay',
  400. params: {
  401. currentPayUrl: this.currentPayUrl
  402. }
  403. });
  404. }).catch(err => {
  405. this.$refs.uToast.show({
  406. title: err.msg,
  407. type: 'error',
  408. });
  409. });
  410. },
  411. // 去支付,选择支付方式
  412. choosePayWay(item) {
  413. this.currentItem = []
  414. this.currentItem.push(item)
  415. this.payWayPop = true
  416. },
  417. // 全部缴费确认
  418. confirmPrice() {
  419. let orderNum = 0,
  420. price = 0
  421. this.currentItem = []
  422. this.payList.forEach(item => {
  423. if (item.orderStatus !== 4 && item.payStatus !== 1) {
  424. price += Number(item.payAmount)
  425. orderNum++
  426. this.currentItem.push(item.orderId)
  427. }
  428. })
  429. this.payTipsItem.num = orderNum
  430. this.payTipsItem.price = price.toFixed(2)
  431. if (orderNum !== 0 && price !== 0) {
  432. this.payTipsPop = true
  433. } else {
  434. this.$refs.uToast.show({
  435. title: '没有需要支付的订单',
  436. type: 'warning'
  437. })
  438. }
  439. },
  440. // 缴费提示弹框确认
  441. payTipsPopConfirm() {
  442. this.payWayPop = true
  443. },
  444. handleGetOrderinfo(orderId) {
  445. this.$u.api.getOrderinfo({
  446. id: orderId
  447. })
  448. .then(res => {
  449. this.orderInfo = res.data;
  450. console.log('handleGetOrderinfo', JSON.parse(JSON.stringify(res)));
  451. }).catch(err => {
  452. this.$refs.uToast.show({
  453. title: err.msg,
  454. type: 'error',
  455. });
  456. });
  457. },
  458. closePaymentMethod() {
  459. this.payWayPop = false
  460. }
  461. }
  462. };
  463. </script>
  464. <style>
  465. /* #ifndef H5 */
  466. page {
  467. height: 100%;
  468. background-color: #F6F6FF;
  469. }
  470. /* #endif */
  471. </style>
  472. <style lang="scss" scoped>
  473. @import "./payLists.scss";
  474. </style>