payLists.vue 11 KB

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