payLists.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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"> 免费时长:{{ payItem.freeDuration || 0 }} </view>
  41. <!-- 计费时长=停车时长-免费时长 -->
  42. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 计费时长:{{ payItem.calcDuration || 0 }} </view>
  43. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 累计停车时长:{{ payItem.duration || 0 }} </view>
  44. <view class="pay-center-item" v-if="payItem.orderStatus == 1"
  45. >预计金额:<span class="pay-amount">{{ payItem.payAmount || 0 }}</span>
  46. </view>
  47. <view class="pay-center-item" v-else
  48. >应付金额:<span class="pay-amount">{{ payItem.payAmount || 0 }}</span>
  49. </view>
  50. <view
  51. class="pay-center-item"
  52. v-if="(payItem.actualAmount || payItem.actualAmount === 0) && payItem.orderStatus !== 2 && payItem.orderStatus !== 1"
  53. >
  54. 实缴金额:<span class="pay-amount">{{ payItem.actualAmount || 0 }}</span>
  55. </view>
  56. <view class="pay-center-item">泊位号:{{ payItem.spaceName }}</view>
  57. <view class="pay-center-item" v-if="payItem.deviceType && payItem.deviceType != 1"> 车位锁设备号:{{ payItem.deviceNo }} </view>
  58. </view>
  59. <view class="pay-bottom">
  60. <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId)" style="color: #008cff"> </u-cell-item>
  61. </view>
  62. </view>
  63. <view v-if="item.index == 1">
  64. <view class="pay-top u-flex">
  65. <view class="pay-top-left u-flex-1">
  66. <view class="car">{{ payItem.vehicleNo }}</view>
  67. <view class="addr">{{ payItem.parkingName }}</view>
  68. </view>
  69. <view class="pay-top-right">{{ payItem.orderStatus | filterOrderStatus }} </view>
  70. </view>
  71. <view class="pay-center">
  72. <view class="pay-center-item">订单编号:{{ payItem.orderId }}</view>
  73. <view class="pay-center-item">入场通道:{{ payItem.entranceName }}</view>
  74. <view class="pay-center-item">入场时间:{{ payItem.inTime || 0 }}</view>
  75. <view class="pay-center-item">出场通道:{{ payItem.outEntranceName }}</view>
  76. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 出场时间:{{ payItem.outTime || 0 }} </view>
  77. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 免费时长:{{ payItem.freeDuration || 0 }} </view>
  78. <!-- 计费时长=停车时长-免费时长 -->
  79. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 计费时长:{{ payItem.calcDuration || 0 }} </view>
  80. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 累计停车时长:{{ payItem.duration || 0 }} </view>
  81. <view class="pay-center-item"
  82. >应付金额:<span class="pay-amount">{{ payItem.payAmount || 0 }}</span>
  83. </view>
  84. <view class="pay-center-item" v-if="payItem.deviceType && payItem.deviceType != 1"> 车位锁设备号:{{ payItem.deviceNo }} </view>
  85. </view>
  86. <view class="pay-bottom">
  87. <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId)" style="color: #008cff"> </u-cell-item>
  88. </view>
  89. </view>
  90. </view>
  91. <u-loadmore :status="loadStatus[index]" bg-color="#F6F6FF"></u-loadmore>
  92. </view>
  93. </scroll-view>
  94. </swiper-item>
  95. </swiper>
  96. </view>
  97. <view class="bottom">
  98. <view class="bottom-total">
  99. 累计欠费<span class="total">{{ totalCount }}</span
  100. >笔,合计<span class="total">{{ totalPayAmount }}</span
  101. >元
  102. </view>
  103. <view class="button-wrap" v-if="payList.length && payList.length >= 1">
  104. <button class="button" type="primary" @click="confirmPrice()">全部缴费</button>
  105. </view>
  106. </view>
  107. <!-- 缴费提示-->
  108. <u-modal
  109. v-model="payTipsPop"
  110. :title-style="{ color: '#404040' }"
  111. title="缴费提示"
  112. :show-confirm-button="true"
  113. confirm-text="立即缴费"
  114. :confirm-style="{ backgroundColor: '#3397FA', color: '#fff' }"
  115. :show-cancel-button="true"
  116. cancel-text="取消"
  117. :cancel-style="{ backgroundColor: '#EBF1FF', color: '#3397FA' }"
  118. @confirm="payTipsPopConfirm"
  119. >
  120. <view class="slot-content">
  121. <view class="pay-tips">
  122. <text>{{ payTipsItem.num || 0 }}</text
  123. >场停车欠费,共 <text>{{ payTipsItem.price || 0 }}</text
  124. >元
  125. </view>
  126. </view>
  127. </u-modal>
  128. <!-- 支付方式 -->
  129. <PaymentMethod
  130. :payWayPop="payWayPop"
  131. :exportFlag="exportFlag"
  132. :curOrderList="currentItem"
  133. :jumpUrl="jumpUrl"
  134. @closePaymentMethod="closePaymentMethod"
  135. ></PaymentMethod>
  136. <u-toast ref="uToast" />
  137. </view>
  138. </template>
  139. <script>
  140. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue';
  141. export default {
  142. components: {
  143. PaymentMethod
  144. },
  145. data() {
  146. return {
  147. totalPayAmount: '',
  148. totalCount: '',
  149. currentPayUrl: '',
  150. payList: [[], []],
  151. list: [
  152. {
  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. this.list[this.current].pageNum = 1;
  210. this.payList = [[], []];
  211. this.orderListArr(this.list[this.current], this.swiperCurrent);
  212. },
  213. methods: {
  214. reachBottom() {
  215. if (this.payList[this.current].length >= this.list[this.current].total) {
  216. this.loadStatus.splice(this.list[this.current].index, 1, 'nomore');
  217. return;
  218. }
  219. this.loadStatus.splice(this.list[this.current].index, 1, 'loading');
  220. this.orderListArr(this.list[this.current], this.swiperCurrent);
  221. },
  222. // tab栏切换
  223. change(index) {
  224. this.swiperCurrent = index;
  225. this.current = index;
  226. //重新初始化
  227. this.payList = [[], [], [], []];
  228. this.list[index].pageNum = 1;
  229. if (index == 1) {
  230. this.exportFlag = true;
  231. } else {
  232. this.exportFlag = false;
  233. }
  234. this.orderListArr(this.list[index], index);
  235. },
  236. transition({ detail: { dx } }) {
  237. this.$refs.tabs.setDx(dx);
  238. },
  239. animationfinish({ detail: { current } }) {
  240. this.$refs.tabs.setFinishCurrent(current);
  241. this.swiperCurrent = current;
  242. this.current = current;
  243. },
  244. customBack() {
  245. this.$u.route({
  246. type: 'switchTab',
  247. url: 'pages/index/index'
  248. });
  249. },
  250. orderListArr(orderType, index) {
  251. let pageNum = orderType.pageNum; // 页码, 默认从1开始
  252. let pageSize = orderType.total; // 页长, 默认每页10条
  253. if (index == 0) {
  254. this.$u.api
  255. .getOrderList({
  256. // pageSize: pageSize,
  257. pageNum: pageNum,
  258. paying: true
  259. })
  260. .then((res) => {
  261. for (const item of res.data.pageInfo.rows) {
  262. this.payList[orderType.index].push(item);
  263. }
  264. this.list[this.current].total = res.data.pageInfo.total;
  265. this.list[orderType.index].pageNum++;
  266. if (this.payList[this.current].length >= this.list[this.current].total) {
  267. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore');
  268. }
  269. this.totalCount = res.data.costInfo.totalCount;
  270. this.totalPayAmount = res.data.costInfo.totalPayAmount;
  271. })
  272. .catch((err) => {
  273. this.$refs.uToast.show({
  274. title: err.msg,
  275. type: 'error'
  276. });
  277. });
  278. } else {
  279. this.$u.api
  280. .getRoomParkingApi({
  281. pageNum: pageNum,
  282. paying: true
  283. })
  284. .then((res) => {
  285. for (const item of res.data.pageInfo.rows) {
  286. this.payList[orderType.index].push(item);
  287. }
  288. this.list[this.current].total = res.data.pageInfo.total;
  289. this.list[orderType.index].pageNum++;
  290. if (this.payList[this.current].length >= this.list[this.current].total) {
  291. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore');
  292. }
  293. this.totalCount = res.data.costInfo.totalCount;
  294. this.totalPayAmount = res.data.costInfo.totalPayAmount;
  295. });
  296. }
  297. },
  298. all() {
  299. this.payList.forEach((item, index, arr) => {
  300. if (item.orderId) {
  301. this.orderList.push(item.orderId);
  302. }
  303. });
  304. this.$u.api
  305. .payGzbank({
  306. orderList: this.orderList
  307. })
  308. .then((res) => {
  309. let payUrl = res.data.url;
  310. this.currentPayUrl = encodeURIComponent(res.data.url);
  311. // console.log('this.currentPayUrl',this.currentPayUrl);
  312. // return;
  313. this.$u.route({
  314. url: 'pages/payLists/pay',
  315. params: {
  316. currentPayUrl: this.currentPayUrl
  317. }
  318. });
  319. })
  320. .catch((err) => {
  321. this.$refs.uToast.show({
  322. title: err.msg,
  323. type: 'error'
  324. });
  325. });
  326. },
  327. // 去支付,选择支付方式
  328. choosePayWay(item) {
  329. this.currentItem = [];
  330. this.currentItem.push(item);
  331. this.payWayPop = true;
  332. },
  333. // 全部缴费确认
  334. confirmPrice() {
  335. let orderNum = 0,
  336. price = 0;
  337. this.currentItem = [];
  338. this.payList[this.current].forEach((item) => {
  339. if (item.orderStatus !== 4 && item.payStatus !== 1) {
  340. price += Number(item.payAmount);
  341. orderNum++;
  342. this.currentItem.push(item.orderId);
  343. }
  344. });
  345. this.payTipsItem.num = orderNum;
  346. this.payTipsItem.price = price.toFixed(2);
  347. if (orderNum !== 0 && price !== 0) {
  348. this.payTipsPop = true;
  349. } else {
  350. this.$refs.uToast.show({
  351. title: '没有需要支付的订单',
  352. type: 'warning'
  353. });
  354. }
  355. },
  356. // 缴费提示弹框确认
  357. payTipsPopConfirm() {
  358. this.payWayPop = true;
  359. },
  360. handleGetOrderinfo(orderId) {
  361. this.$u.api
  362. .getOrderinfo({
  363. id: orderId
  364. })
  365. .then((res) => {
  366. this.orderInfo = res.data;
  367. console.log('handleGetOrderinfo', JSON.parse(JSON.stringify(res)));
  368. })
  369. .catch((err) => {
  370. this.$refs.uToast.show({
  371. title: err.msg,
  372. type: 'error'
  373. });
  374. });
  375. },
  376. closePaymentMethod() {
  377. this.payWayPop = false;
  378. }
  379. }
  380. };
  381. </script>
  382. <style>
  383. /* #ifndef H5 */
  384. page {
  385. height: 100%;
  386. background-color: #f6f6ff;
  387. }
  388. /* #endif */
  389. </style>
  390. <style lang="scss" scoped>
  391. @import './payLists.scss';
  392. </style>