payLists.vue 11 KB

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