payLists.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view>
  3. <u-navbar
  4. title-color="#fff"
  5. :custom-back="customBack"
  6. :bpay-bottom="false"
  7. back-icon-color="#CCE8FF"
  8. :background="{ background: '#008CFF' }"
  9. title="停车缴费"
  10. ></u-navbar>
  11. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  12. <scroll-view scroll-y style="height: 100%; width: 100%">
  13. <view class="page-box">
  14. <view class="pay" v-for="(payItem, index) in payList" :key="payItem.id">
  15. <view class="pay-top u-flex">
  16. <view class="pay-top-left u-flex-1">
  17. <view class="car">{{ payItem.vehicleNo }}</view>
  18. <view class="addr">{{ payItem.roadName }}</view>
  19. </view>
  20. <view class="pay-top-right">{{ payItem.orderStatus | filterOrderStatus }}</view>
  21. </view>
  22. <view class="pay-center">
  23. <view class="pay-center-item">订单编号:{{ payItem.orderId }}</view>
  24. <view class="pay-center-item" v-if="payItem.deviceType == 1">入场时间:{{ payItem.inTime || '' }} </view>
  25. <view class="pay-center-item" v-else>开始计费:{{ payItem.inTime || '' }}</view>
  26. <template v-if="payItem.deviceType == 1">
  27. <view class="pay-center-item" v-if="payItem.orderStatus == 1 && payItem.outTime"> 出场时间:{{ `未出场` }}</view>
  28. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 出场时间:{{ payItem.outTime }}</view>
  29. </template>
  30. <template v-else>
  31. <view class="pay-center-item" v-if="payItem.orderStatus == 1 && payItem.outTime"> 结束计费:{{ `未出场` }}</view>
  32. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 结束计费:{{ payItem.outTime }}</view>
  33. </template>
  34. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 免费时长:{{ payItem.freeDuration }} </view>
  35. <!-- 计费时长=停车时长-免费时长 -->
  36. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 计费时长:{{ payItem.calcDuration || 0 }} </view>
  37. <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 累计停车时长:{{ payItem.duration || 0 }} </view>
  38. <view class="pay-center-item" v-if="payItem.orderStatus == 1"
  39. >预计金额:<span class="pay-amount">{{ payItem.payAmount || 0 }}</span>
  40. </view>
  41. <view class="pay-center-item" v-else
  42. >应付金额:<span class="pay-amount">{{ payItem.payAmount || 0 }}</span>
  43. </view>
  44. <view
  45. class="pay-center-item"
  46. v-if="(payItem.actualAmount || payItem.actualAmount === 0) && payItem.orderStatus !== 2 && payItem.orderStatus !== 1"
  47. >
  48. 实缴金额:<span class="pay-amount">{{ payItem.actualAmount || 0 }}</span>
  49. </view>
  50. <view class="pay-center-item">泊位号:{{ payItem.spaceName }}</view>
  51. <view class="pay-center-item" v-if="payItem.deviceType && payItem.deviceType != 1"> 车位锁设备号:{{ payItem.deviceNo }} </view>
  52. </view>
  53. <view class="pay-bottom">
  54. <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId)" style="color: #008cff"> </u-cell-item>
  55. </view>
  56. </view>
  57. </view>
  58. </scroll-view>
  59. </mescroll-body>
  60. <view class="bottom">
  61. <view class="bottom-total">
  62. 累计欠费<span class="total">{{ totalCount }}</span
  63. >笔,合计<span class="total">{{ totalPayAmount }}</span
  64. >元
  65. </view>
  66. <view class="button-wrap" v-if="payList.length && payList.length >= 1">
  67. <!-- <button class="button" type="primary" @click="all()">全部缴费</button> -->
  68. <button class="button" type="primary" @click="confirmPrice()">全部缴费</button>
  69. </view>
  70. </view>
  71. <!-- 缴费提示-->
  72. <u-modal
  73. v-model="payTipsPop"
  74. :title-style="{ color: '#404040' }"
  75. title="缴费提示"
  76. :show-confirm-button="true"
  77. confirm-text="立即缴费"
  78. :confirm-style="{ backgroundColor: '#3397FA', color: '#fff' }"
  79. :show-cancel-button="true"
  80. cancel-text="取消"
  81. :cancel-style="{ backgroundColor: '#EBF1FF', color: '#3397FA' }"
  82. @confirm="payTipsPopConfirm"
  83. >
  84. <view class="slot-content">
  85. <view class="pay-tips">
  86. <text>{{ payTipsItem.num || 0 }}</text
  87. >场停车欠费,共 <text>{{ payTipsItem.price || 0 }}</text
  88. >元
  89. </view>
  90. </view>
  91. </u-modal>
  92. <!-- 支付方式 -->
  93. <PaymentMethod :payWayPop="payWayPop" :curOrderList="currentItem" :jumpUrl="jumpUrl" @closePaymentMethod="closePaymentMethod"></PaymentMethod>
  94. <u-toast ref="uToast" />
  95. </view>
  96. </template>
  97. <script>
  98. import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
  99. import getUrlParams from '../../utils/getUrlParams.js';
  100. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue';
  101. export default {
  102. mixins: [MescrollMixin], // 使用mixin
  103. components: {
  104. PaymentMethod
  105. },
  106. data() {
  107. return {
  108. totalPayAmount: '',
  109. totalCount: '',
  110. currentPayUrl: '',
  111. payList: [],
  112. list: [],
  113. orderList: [],
  114. PayUrl: '',
  115. payTipsPop: false,
  116. payWayPop: false,
  117. // 选中去支付的单条条目
  118. currentItem: [],
  119. // 缴费提示类目
  120. payTipsItem: {
  121. num: '',
  122. price: ''
  123. },
  124. code: null,
  125. jumpUrl: ''
  126. };
  127. },
  128. computed: {
  129. // 价格小数
  130. priceDecimal() {
  131. return (val) => {
  132. if (val !== parseInt(val)) return val.slice(-2);
  133. else return '00';
  134. };
  135. },
  136. // 价格整数
  137. priceInt() {
  138. return (val) => {
  139. if (val !== parseInt(val)) return val.split('.')[0];
  140. else return val;
  141. };
  142. }
  143. },
  144. onLoad() {
  145. const href = location.href.split('#');
  146. this.jumpUrl = href[0] + '#/pages/center/order/order';
  147. },
  148. onShow() {
  149. // onShow 刷新数据
  150. if (this.mescroll) {
  151. this.mescroll.triggerDownScroll();
  152. }
  153. },
  154. methods: {
  155. customBack() {
  156. this.$u.route({
  157. type: 'switchTab',
  158. url: 'pages/index/index'
  159. });
  160. },
  161. /*下拉刷新的回调*/
  162. downCallback() {
  163. // 第2种: 下拉刷新和上拉加载调同样的接口, 则不用第1种, 直接mescroll.resetUpScroll()即可
  164. this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  165. },
  166. /*上拉加载的回调*/
  167. upCallback(page) {
  168. let pageNum = page.num; // 页码, 默认从1开始
  169. let pageSize = page.size; // 页长, 默认每页10条
  170. // this.getMessageList()
  171. this.$u.api
  172. .getOrderList({
  173. pageSize: pageSize,
  174. pageNum: pageNum,
  175. paying: true
  176. })
  177. .then((res) => {
  178. // 接口返回的当前页数据列表 (数组)
  179. let curPageData = res.data.pageInfo.rows;
  180. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  181. let curPageLen = curPageData.length;
  182. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  183. let totalPage = res.data.pageInfo.pages;
  184. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  185. let totalSize = res.data.pageInfo.total;
  186. // 接口返回的是否有下一页 (true/false)
  187. // let hasNext = data.pages;
  188. //设置列表数据
  189. if (page.num == 1) this.payList = []; //如果是第一页需手动置空列表
  190. this.payList = this.payList.concat(curPageData); //追加新数据
  191. this.totalCount = res.data.costInfo.totalCount;
  192. this.totalPayAmount = res.data.costInfo.totalPayAmount;
  193. // 请求成功,隐藏加载状态
  194. //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  195. this.mescroll.endByPage(curPageLen, totalPage);
  196. setTimeout(() => {
  197. this.mescroll.endSuccess(curPageLen);
  198. }, 20);
  199. })
  200. .catch((err) => {
  201. this.$refs.uToast.show({
  202. title: err.msg,
  203. type: 'error'
  204. });
  205. });
  206. },
  207. paythis(orderId) {
  208. let orderList = [];
  209. orderList.push(orderId);
  210. this.$u.api
  211. .payGzbank({
  212. orderList: orderList
  213. })
  214. .then((res) => {
  215. let payUrl = res.data.url;
  216. this.currentPayUrl = encodeURIComponent(res.data.url);
  217. // return;
  218. this.$u.route({
  219. url: 'pages/payLists/pay',
  220. params: {
  221. currentPayUrl: this.currentPayUrl
  222. }
  223. });
  224. })
  225. .catch((err) => {
  226. this.$refs.uToast.show({
  227. title: err.msg,
  228. type: 'error'
  229. });
  230. });
  231. },
  232. all() {
  233. this.payList.forEach((item, index, arr) => {
  234. console.log(item);
  235. if (item.orderId) {
  236. this.orderList.push(item.orderId);
  237. }
  238. });
  239. this.$u.api
  240. .payGzbank({
  241. orderList: this.orderList
  242. })
  243. .then((res) => {
  244. let payUrl = res.data.url;
  245. this.currentPayUrl = encodeURIComponent(res.data.url);
  246. // console.log('this.currentPayUrl',this.currentPayUrl);
  247. // return;
  248. this.$u.route({
  249. url: 'pages/payLists/pay',
  250. params: {
  251. currentPayUrl: this.currentPayUrl
  252. }
  253. });
  254. })
  255. .catch((err) => {
  256. this.$refs.uToast.show({
  257. title: err.msg,
  258. type: 'error'
  259. });
  260. });
  261. },
  262. // 去支付,选择支付方式
  263. choosePayWay(item) {
  264. this.currentItem = [];
  265. this.currentItem.push(item);
  266. this.payWayPop = true;
  267. },
  268. // 全部缴费确认
  269. confirmPrice() {
  270. let orderNum = 0,
  271. price = 0;
  272. this.currentItem = [];
  273. this.payList.forEach((item) => {
  274. if (item.orderStatus !== 4 && item.payStatus !== 1) {
  275. price += Number(item.payAmount);
  276. orderNum++;
  277. this.currentItem.push(item.orderId);
  278. }
  279. });
  280. this.payTipsItem.num = orderNum;
  281. this.payTipsItem.price = price.toFixed(2);
  282. if (orderNum !== 0 && price !== 0) {
  283. this.payTipsPop = true;
  284. } else {
  285. this.$refs.uToast.show({
  286. title: '没有需要支付的订单',
  287. type: 'warning'
  288. });
  289. }
  290. },
  291. // 缴费提示弹框确认
  292. payTipsPopConfirm() {
  293. this.payWayPop = true;
  294. },
  295. handleGetOrderinfo(orderId) {
  296. this.$u.api
  297. .getOrderinfo({
  298. id: orderId
  299. })
  300. .then((res) => {
  301. this.orderInfo = res.data;
  302. console.log('handleGetOrderinfo', JSON.parse(JSON.stringify(res)));
  303. })
  304. .catch((err) => {
  305. this.$refs.uToast.show({
  306. title: err.msg,
  307. type: 'error'
  308. });
  309. });
  310. },
  311. closePaymentMethod() {
  312. this.payWayPop = false;
  313. }
  314. }
  315. };
  316. </script>
  317. <style>
  318. /* #ifndef H5 */
  319. page {
  320. height: 100%;
  321. background-color: #f6f6ff;
  322. }
  323. /* #endif */
  324. </style>
  325. <style lang="scss" scoped>
  326. @import './payLists.scss';
  327. </style>