payLists.vue 15 KB

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