payLists.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. paythis(orderId) {
  323. let orderList = [];
  324. orderList.push(orderId);
  325. this.$u.api.payGzbank({
  326. orderList: orderList
  327. }).then(res => {
  328. let payUrl = res.data.url;
  329. this.currentPayUrl = encodeURIComponent(res.data.url);
  330. // return;
  331. this.$u.route({
  332. url: 'pages/payLists/pay',
  333. params: {
  334. currentPayUrl: this.currentPayUrl
  335. }
  336. });
  337. }).catch(err => {
  338. this.$refs.uToast.show({
  339. title: err.msg,
  340. type: 'error',
  341. });
  342. });
  343. },
  344. all() {
  345. this.payList.forEach((item, index, arr) => {
  346. console.log(item)
  347. if (item.orderId) {
  348. this.orderList.push(item.orderId)
  349. }
  350. });
  351. this.$u.api.payGzbank({
  352. orderList: this.orderList
  353. }).then(res => {
  354. let payUrl = res.data.url;
  355. this.currentPayUrl = encodeURIComponent(res.data.url);
  356. // console.log('this.currentPayUrl',this.currentPayUrl);
  357. // return;
  358. this.$u.route({
  359. url: 'pages/payLists/pay',
  360. params: {
  361. currentPayUrl: this.currentPayUrl
  362. }
  363. });
  364. }).catch(err => {
  365. this.$refs.uToast.show({
  366. title: err.msg,
  367. type: 'error',
  368. });
  369. });
  370. },
  371. // 去支付,选择支付方式
  372. choosePayWay(item) {
  373. this.currentItem = []
  374. this.currentItem.push(item)
  375. this.payWayPop = true
  376. },
  377. // 全部缴费确认
  378. confirmPrice() {
  379. let orderNum = 0,
  380. price = 0
  381. this.currentItem = []
  382. this.payList[this.current].forEach(item => {
  383. if (item.orderStatus !== 4 && item.payStatus !== 1) {
  384. price += Number(item.payAmount)
  385. orderNum++
  386. this.currentItem.push(item.orderId)
  387. }
  388. })
  389. this.payTipsItem.num = orderNum
  390. this.payTipsItem.price = price.toFixed(2)
  391. if (orderNum !== 0 && price !== 0) {
  392. this.payTipsPop = true
  393. } else {
  394. this.$refs.uToast.show({
  395. title: '没有需要支付的订单',
  396. type: 'warning'
  397. })
  398. }
  399. },
  400. // 缴费提示弹框确认
  401. payTipsPopConfirm() {
  402. this.payWayPop = true
  403. },
  404. handleGetOrderinfo(orderId) {
  405. this.$u.api.getOrderinfo({
  406. id: orderId
  407. })
  408. .then(res => {
  409. this.orderInfo = res.data;
  410. console.log('handleGetOrderinfo', JSON.parse(JSON.stringify(res)));
  411. }).catch(err => {
  412. this.$refs.uToast.show({
  413. title: err.msg,
  414. type: 'error',
  415. });
  416. });
  417. },
  418. closePaymentMethod() {
  419. this.payWayPop = false
  420. }
  421. }
  422. };
  423. </script>
  424. <style>
  425. /* #ifndef H5 */
  426. page {
  427. height: 100%;
  428. background-color: #F6F6FF;
  429. }
  430. /* #endif */
  431. </style>
  432. <style lang="scss" scoped>
  433. @import "./payLists.scss";
  434. </style>