payLists.vue 13 KB

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