order.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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
  16. class="swiper-box"
  17. :current="swiperCurrent"
  18. @transition="transition"
  19. @animationfinish="animationfinish"
  20. >
  21. <swiper-item class="swiper-item" v-for="(item, index) in list" :key="index">
  22. <scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
  23. <view class="page-box">
  24. <view
  25. class="order"
  26. @click="goDetails(orderItem)"
  27. v-for="(orderItem, index) in orderList[index]"
  28. :key="'o-' + index"
  29. >
  30. <view class="order-top u-flex">
  31. <view class="order-top-left u-flex-1">
  32. <view class="car">{{ orderItem.vehicleNo }}</view>
  33. <view class="addr">{{ orderItem.roadName }}</view>
  34. </view>
  35. <!--
  36. 显示申请退款按钮满足一下条件:
  37. 1.允许退款allowRefund等于1 并且
  38. 2.退款状态auditStatus等于2 已驳回 或者
  39. 3.退款状态auditStatus不能为空 并且不能等于0
  40. -->
  41. <view
  42. class="order-top-right apply-refund"
  43. v-show="orderItem.allowRefund == 1 &&
  44. (orderItem.auditStatus == 2 || !orderItem.auditStatus && orderItem.auditStatus != 0)"
  45. @click.stop="applyRefund(orderItem)"
  46. >申请退款</view>
  47. <!--
  48. 显示申请状态满足以下条件
  49. 申请状态存在或者审核状态存在(由于0比较特殊,所以单独拉出来判断)
  50. -->
  51. <view
  52. class="order-top-right apply-refund"
  53. @click.stop="applyRefundDetails(orderItem)"
  54. v-if="orderItem.refundStatus ||
  55. orderItem.refundStatus == 0 ||
  56. orderItem.auditStatus ||
  57. orderItem.auditStatus == 0"
  58. >{{ orderItem | verifyRefundStatus }}</view>
  59. <view
  60. class="order-top-right"
  61. v-else
  62. :class="{ 'order-top-right-finished': orderItem.orderStatus == '4' }"
  63. >{{ orderItem.orderStatus | verifyStatusFilter }}</view>
  64. </view>
  65. <view class="order-center">
  66. <view class="order-center-item">订单编号:{{ orderItem.orderId }}</view>
  67. <view class="order-center-item">入场时间:{{ orderItem.inTime }}</view>
  68. <view
  69. class="order-center-item"
  70. v-if="orderItem.orderStatus == 1 && orderItem.outTime"
  71. >预计出场时间:{{orderItem.outTime}}</view>
  72. <view
  73. class="order-center-item"
  74. v-if="orderItem.orderStatus !== 1"
  75. >出场时间:{{ orderItem.outTime }}</view>
  76. <view
  77. class="order-center-item"
  78. v-if="orderItem.orderStatus !== 1"
  79. >停留时间:{{ orderItem.duration }}</view>
  80. <view
  81. class="order-center-item"
  82. v-if="orderItem.orderStatus == 1"
  83. >
  84. 预计金额:
  85. <span class="pay-amount">{{ orderItem.payAmount }}</span>
  86. </view>
  87. <view class="order-center-item" v-else>
  88. 应付金额:
  89. <span class="pay-amount">{{ orderItem.payAmount }}</span>
  90. </view>
  91. <view
  92. class="order-center-item"
  93. v-if="(orderItem.actualAmount || orderItem.actualAmount === 0) && orderItem.orderStatus !== 2"
  94. >
  95. 实缴金额:
  96. <span class="pay-amount">{{ orderItem.actualAmount }}</span>
  97. </view>
  98. </view>
  99. <view class="order-bottom">
  100. <u-cell-item title="收费标准" @click.native.stop="jumpChargeStandard(orderItem)"></u-cell-item>
  101. </view>
  102. </view>
  103. <u-loadmore :status="loadStatus[index]" bg-color="#F6F6FF"></u-loadmore>
  104. </view>
  105. </scroll-view>
  106. </swiper-item>
  107. </swiper>
  108. </view>
  109. <u-toast ref="uToast" />
  110. </view>
  111. </template>
  112. <script>
  113. export default {
  114. data () {
  115. return {
  116. orderList: [[], [], [], []],
  117. list: [
  118. { index: 0, name: '全部', orderStatu: null, pageNum: 1, total: null },
  119. { index: 1, name: '停放中', orderStatu: 1, pageNum: 1, total: null },
  120. { index: 2, name: '欠费未缴', orderStatu: 2, pageNum: 1, total: null },
  121. { index: 3, name: '已完成', orderStatu: 4, pageNum: 1, total: null }
  122. ],
  123. current: 0,
  124. swiperCurrent: 0,
  125. tabsHeight: 0,
  126. dx: 0,
  127. loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore']
  128. }
  129. },
  130. onShow () {
  131. // onShow 刷新数据
  132. this.list[this.current].pageNum = 1
  133. this.orderList = [[], [], [], []]
  134. this.getOrderList(this.list[this.current])
  135. },
  136. computed: {
  137. // 价格小数
  138. priceDecimal () {
  139. return val => {
  140. if (val !== parseInt(val)) return val.slice(-2)
  141. else return '00'
  142. }
  143. },
  144. // 价格整数
  145. priceInt () {
  146. return val => {
  147. if (val !== parseInt(val)) return val.split('.')[0]
  148. else return val
  149. }
  150. }
  151. },
  152. methods: {
  153. reachBottom () {
  154. // console.log('this.list[this.current]',this.list[this.current]);
  155. if (this.orderList[this.current].length >= this.list[this.current].total) {
  156. this.loadStatus.splice(this.list[this.current].index, 1, 'nomore')
  157. return
  158. };
  159. this.loadStatus.splice(this.list[this.current].index, 1, 'loading')
  160. this.getOrderList(this.list[this.current])
  161. },
  162. // 页面数据
  163. getOrderList (orderType) {
  164. const param = {
  165. pageNum: orderType.pageNum,
  166. orderStatus: orderType.orderStatu
  167. }
  168. // 未出场: orderStatu = 1-停放中
  169. // 缴费中: orderStatu = 2-出场中 && payStatus = 2-支付中
  170. // 完成: orderStatu = 4-完成
  171. this.$u.api.getOrderList(param)
  172. .then(res => {
  173. for (const item of res.data.rows) {
  174. this.orderList[orderType.index].push(item)
  175. }
  176. this.list[this.current].total = res.data.total
  177. this.list[orderType.index].pageNum++
  178. if (this.orderList[this.current].length >= this.list[this.current].total) {
  179. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore')
  180. };
  181. }).catch(err => {
  182. this.$refs.uToast.show({
  183. title: err.msg,
  184. type: 'error'
  185. })
  186. // console.log('getOrderList ',err)
  187. })
  188. this.loadStatus.splice(this.current, 1, 'loadmore')
  189. },
  190. // tab栏切换
  191. change (index) {
  192. // this.swiperCurrent = this.list[index].orderStatu;
  193. this.swiperCurrent = index
  194. this.getOrderList(this.list[index])
  195. },
  196. transition ({ detail: { dx } }) {
  197. this.$refs.tabs.setDx(dx)
  198. },
  199. animationfinish ({ detail: { current } }) {
  200. this.$refs.tabs.setFinishCurrent(current)
  201. this.swiperCurrent = current
  202. this.current = current
  203. },
  204. /**
  205. * 跳转详情
  206. * 未发起退款或者未退款成功的
  207. * */
  208. goDetails (item) {
  209. this.$u.route({
  210. url: 'pages/center/order/orderDetails/orderDetails',
  211. params: {
  212. orderId: item.id
  213. }
  214. })
  215. },
  216. jumpChargeStandard (item) {
  217. this.$u.route({
  218. url: 'pages/chargeStandard/chargeStandard',
  219. params: {
  220. roadNo: item.roadNo
  221. }
  222. })
  223. },
  224. // 申请退款
  225. applyRefund (item) {
  226. this.$u.route('pages/applyRefund/applyRefund', {
  227. orderId: item.orderId,
  228. payAmount: item.actualAmount
  229. })
  230. },
  231. /**
  232. * 申请退款详情
  233. * 只要申请退款状态等于1并且审批状态等于1跳转到退款完成详情页
  234. * 否则跳转到退款过程页
  235. * */
  236. applyRefundDetails (item) {
  237. if (item.refundStatus === 1 && item.auditStatus === 1) {
  238. this.$u.route('pages/applyRefundDetails/applyRefundAchieveDetails', {
  239. orderId: item.orderId
  240. })
  241. } else {
  242. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  243. orderId: item.orderId
  244. })
  245. }
  246. }
  247. },
  248. filters: {
  249. verifyStatusFilter (value) {
  250. if (value === 0) {
  251. return ''
  252. } else if (value === 1) {
  253. return '停放中'
  254. } else if (value === 2) {
  255. return '欠费未缴'
  256. } else if (value === 4) {
  257. return '已完成'
  258. } else {
  259. return ''
  260. }
  261. },
  262. verifyRefundStatus (item) {
  263. if (item.auditStatus === 0) {
  264. return '申请退款中'
  265. } else if (item.auditStatus === 1) {
  266. if (item.refundStatus === 0) {
  267. return '退款失败'
  268. } else if (item.refundStatus === 1) {
  269. return '退款成功'
  270. }
  271. } else if (item.auditStatus === 2) {
  272. return '已驳回'
  273. }
  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 "./order.scss";
  288. </style>