payLists.vue 9.0 KB

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