payLists.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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 }}</span
  104. >笔,合计<span class="total">{{ totalPayAmount }}</span
  105. >元
  106. </view>
  107. <view class="button-wrap" v-if="payList.length && payList.length >= 1">
  108. <button class="button" type="primary" @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>{{ payTipsItem.num || 0 }}</text
  127. >场停车欠费,共 <text>{{ payTipsItem.price || 0 }}</text
  128. >元
  129. </view>
  130. </view>
  131. </u-modal>
  132. <!-- 支付方式 -->
  133. <PaymentMethod
  134. :payWayPop="payWayPop"
  135. :exportFlag="exportFlag"
  136. :curOrderList="currentItem"
  137. :jumpUrl="jumpUrl"
  138. @closePaymentMethod="closePaymentMethod"
  139. ></PaymentMethod>
  140. <!-- <ChoosePayment
  141. ref="choosePayment"
  142. :exportFlag="exportFlag"
  143. :curOrderList="currentItem"
  144. :jumpUrl="jumpUrl"
  145. @closePaymentMethod="closePaymentMethod"
  146. /> -->
  147. <u-toast ref="uToast" />
  148. </view>
  149. </template>
  150. <script>
  151. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue';
  152. import ChoosePayment from '@/pages/choosePayment/choosePayment.vue';
  153. export default {
  154. components: {
  155. PaymentMethod,
  156. ChoosePayment
  157. },
  158. data() {
  159. return {
  160. totalPayAmount: '',
  161. totalCount: '',
  162. currentPayUrl: '',
  163. payList: [[], []],
  164. list: [
  165. {
  166. index: 0,
  167. name: '路段',
  168. orderStatus: null,
  169. pageNum: 1,
  170. total: null
  171. },
  172. {
  173. index: 1,
  174. name: '停车场',
  175. orderStatus: 1,
  176. pageNum: 1,
  177. total: null
  178. }
  179. ],
  180. current: 0,
  181. swiperCurrent: 0,
  182. dx: 0,
  183. loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore'],
  184. isLoadMore: false, //是否加载中
  185. orderList: [],
  186. exportFlag: false,
  187. PayUrl: '',
  188. payTipsPop: false,
  189. payWayPop: false,
  190. // 选中去支付的单条条目
  191. currentItem: [],
  192. // 缴费提示类目
  193. payTipsItem: {
  194. num: '',
  195. price: ''
  196. },
  197. code: null,
  198. jumpUrl: ''
  199. };
  200. },
  201. computed: {
  202. // 价格小数
  203. priceDecimal() {
  204. return (val) => {
  205. if (val !== parseInt(val)) return val.slice(-2);
  206. else return '00';
  207. };
  208. },
  209. // 价格整数
  210. priceInt() {
  211. return (val) => {
  212. if (val !== parseInt(val)) return val.split('.')[0];
  213. else return val;
  214. };
  215. }
  216. },
  217. onLoad() {
  218. const href = location.href.split('#');
  219. this.jumpUrl = href[0] + '#/pages/center/order/order?';
  220. },
  221. onShow() {
  222. this.list[this.current].pageNum = 1;
  223. this.payList = [[], []];
  224. this.orderListArr(this.list[this.current], this.swiperCurrent);
  225. },
  226. methods: {
  227. reachBottom() {
  228. if (this.payList[this.current].length >= this.list[this.current].total) {
  229. this.loadStatus.splice(this.list[this.current].index, 1, 'nomore');
  230. return;
  231. }
  232. this.loadStatus.splice(this.list[this.current].index, 1, 'loading');
  233. this.orderListArr(this.list[this.current], this.swiperCurrent);
  234. },
  235. // tab栏切换
  236. change(index) {
  237. this.swiperCurrent = index;
  238. this.current = index;
  239. //重新初始化
  240. this.payList = [[], [], [], []];
  241. this.list[index].pageNum = 1;
  242. if (index == 1) {
  243. this.exportFlag = true;
  244. } else {
  245. this.exportFlag = false;
  246. }
  247. this.orderListArr(this.list[index], index);
  248. },
  249. transition({ detail: { dx } }) {
  250. this.$refs.tabs.setDx(dx);
  251. },
  252. animationfinish({ detail: { current } }) {
  253. this.$refs.tabs.setFinishCurrent(current);
  254. this.swiperCurrent = current;
  255. this.current = current;
  256. },
  257. customBack() {
  258. this.$u.route({
  259. type: 'switchTab',
  260. url: 'pages/index/index'
  261. });
  262. },
  263. orderListArr(orderType, index) {
  264. let pageNum = orderType.pageNum; // 页码, 默认从1开始
  265. let pageSize = orderType.total; // 页长, 默认每页10条
  266. if (index == 0) {
  267. this.$u.api
  268. .getOrderList({
  269. // pageSize: pageSize,
  270. pageNum: pageNum,
  271. paying: true
  272. })
  273. .then((res) => {
  274. for (const item of res.data.pageInfo.rows) {
  275. this.payList[orderType.index].push(item);
  276. }
  277. this.list[this.current].total = res.data.pageInfo.total;
  278. this.list[orderType.index].pageNum++;
  279. if (this.payList[this.current].length >= this.list[this.current].total) {
  280. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore');
  281. }
  282. this.totalCount = res.data.costInfo.totalCount;
  283. this.totalPayAmount = res.data.costInfo.totalPayAmount;
  284. })
  285. .catch((err) => {
  286. this.$refs.uToast.show({
  287. title: err.msg,
  288. type: 'error'
  289. });
  290. });
  291. } else {
  292. this.$u.api
  293. .getRoomParkingApi({
  294. pageNum: pageNum,
  295. paying: true
  296. })
  297. .then((res) => {
  298. for (const item of res.data.pageInfo.rows) {
  299. this.payList[orderType.index].push(item);
  300. }
  301. this.list[this.current].total = res.data.pageInfo.total;
  302. this.list[orderType.index].pageNum++;
  303. if (this.payList[this.current].length >= this.list[this.current].total) {
  304. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore');
  305. }
  306. this.totalCount = res.data.costInfo.totalCount;
  307. this.totalPayAmount = res.data.costInfo.totalPayAmount;
  308. });
  309. }
  310. },
  311. all() {
  312. this.payList.forEach((item, index, arr) => {
  313. if (item.orderId) {
  314. this.orderList.push(item.orderId);
  315. }
  316. });
  317. this.$u.api
  318. .payGzbank({
  319. orderList: this.orderList
  320. })
  321. .then((res) => {
  322. let payUrl = res.data.url;
  323. this.currentPayUrl = encodeURIComponent(res.data.url);
  324. // console.log('this.currentPayUrl',this.currentPayUrl);
  325. // return;
  326. this.$u.route({
  327. url: 'pages/payLists/pay',
  328. params: {
  329. currentPayUrl: this.currentPayUrl
  330. }
  331. });
  332. })
  333. .catch((err) => {
  334. this.$refs.uToast.show({
  335. title: err.msg,
  336. type: 'error'
  337. });
  338. });
  339. },
  340. // 去支付,选择支付方式
  341. choosePayWay(orderId, item) {
  342. this.currentItem = [];
  343. this.currentItem.push(orderId);
  344. this.payWayPop = true;
  345. // this.$nextTick(() => {
  346. // this.$refs['choosePayment'].openPopup(item, 'single', this.current === 0 ? 'road' : 'parking');
  347. // });
  348. },
  349. // 全部缴费确认
  350. confirmPrice() {
  351. let orderNum = 0,
  352. price = 0;
  353. this.currentItem = [];
  354. this.payList[this.current].forEach((item) => {
  355. if (item.orderStatus !== 4 && item.payStatus !== 1) {
  356. price += Number(item.payAmount);
  357. orderNum++;
  358. this.currentItem.push(item.orderId);
  359. }
  360. });
  361. this.payTipsItem.num = orderNum;
  362. this.payTipsItem.price = price.toFixed(2);
  363. if (orderNum !== 0 && price !== 0) {
  364. this.payTipsPop = true;
  365. } else {
  366. this.$refs.uToast.show({
  367. title: '没有需要支付的订单',
  368. type: 'warning'
  369. });
  370. }
  371. },
  372. // 缴费提示弹框确认
  373. payTipsPopConfirm() {
  374. this.payWayPop = true;
  375. // this.$nextTick(() => {
  376. // this.$refs['choosePayment'].openPopup({ totalAmount: Number(this.payTipsItem.price) }, 'multiple', this.current === 0 ? 'road' : 'parking');
  377. // });
  378. },
  379. handleGetOrderinfo(orderId) {
  380. this.$u.api
  381. .getOrderinfo({
  382. id: orderId
  383. })
  384. .then((res) => {
  385. this.orderInfo = res.data;
  386. console.log('handleGetOrderinfo', JSON.parse(JSON.stringify(res)));
  387. })
  388. .catch((err) => {
  389. this.$refs.uToast.show({
  390. title: err.msg,
  391. type: 'error'
  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>