order.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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"
  71. >出场时间:{{ orderItem.outTime }}</view>
  72. <view
  73. class="order-center-item"
  74. v-if="orderItem.orderStatus !== 1"
  75. >停留时间:{{ orderItem.duration }}</view>
  76. <view class="order-center-item">
  77. 应付金额:
  78. <span class="pay-amount">{{ orderItem.payAmount }}</span>
  79. </view>
  80. <view
  81. class="order-center-item"
  82. v-if="(orderItem.actualAmount || orderItem.actualAmount === 0) && orderItem.orderStatus !== 2"
  83. >
  84. 实缴金额:
  85. <span class="pay-amount">{{ orderItem.actualAmount }}</span>
  86. </view>
  87. </view>
  88. <view class="order-bottom">
  89. <u-cell-item title="收费标准" @click.native.stop="jumpChargeStandard(orderItem)"></u-cell-item>
  90. </view>
  91. </view>
  92. <u-loadmore :status="loadStatus[index]" bg-color="#F6F6FF"></u-loadmore>
  93. </view>
  94. </scroll-view>
  95. </swiper-item>
  96. </swiper>
  97. </view>
  98. <u-toast ref="uToast" />
  99. </view>
  100. </template>
  101. <script>
  102. export default {
  103. data () {
  104. return {
  105. orderList: [[], [], [], []],
  106. list: [
  107. { index: 0, name: '全部', orderStatu: null, pageNum: 1, total: null },
  108. { index: 1, name: '停放中', orderStatu: 1, pageNum: 1, total: null },
  109. { index: 2, name: '欠费未缴', orderStatu: 2, pageNum: 1, total: null },
  110. { index: 3, name: '已完成', orderStatu: 4, pageNum: 1, total: null }
  111. ],
  112. current: 0,
  113. swiperCurrent: 0,
  114. tabsHeight: 0,
  115. dx: 0,
  116. loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore']
  117. }
  118. },
  119. onShow () {
  120. // onShow 刷新数据
  121. this.list[this.current].pageNum = 1
  122. this.orderList = [[], [], [], []]
  123. this.getOrderList(this.list[this.current])
  124. },
  125. onLoad(options) {
  126. let questCurrent = options.swiperIndex
  127. console.log(questCurrent)
  128. if(questCurrent){
  129. this.current = questCurrent
  130. // this.getOrderList(this.list[questCurrent])
  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. methods: {
  150. reachBottom () {
  151. // console.log('this.list[this.current]',this.list[this.current]);
  152. if (this.orderList[this.current].length >= this.list[this.current].total) {
  153. this.loadStatus.splice(this.list[this.current].index, 1, 'nomore')
  154. return
  155. };
  156. this.loadStatus.splice(this.list[this.current].index, 1, 'loading')
  157. this.getOrderList(this.list[this.current])
  158. },
  159. // 页面数据
  160. getOrderList (orderType) {
  161. const param = {
  162. pageNum: orderType.pageNum,
  163. orderStatus: orderType.orderStatu
  164. }
  165. // 未出场: orderStatu = 1-停放中
  166. // 缴费中: orderStatu = 2-出场中 && payStatus = 2-支付中
  167. // 完成: orderStatu = 4-完成
  168. this.$u.api.getOrderList(param)
  169. .then(res => {
  170. for (const item of res.data.rows) {
  171. this.orderList[orderType.index].push(item)
  172. }
  173. this.list[this.current].total = res.data.total
  174. this.list[orderType.index].pageNum++
  175. if (this.orderList[this.current].length >= this.list[this.current].total) {
  176. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore')
  177. };
  178. }).catch(err => {
  179. this.$refs.uToast.show({
  180. title: err.msg,
  181. type: 'error'
  182. })
  183. // console.log('getOrderList ',err)
  184. })
  185. this.loadStatus.splice(this.current, 1, 'loadmore')
  186. },
  187. // tab栏切换
  188. change (index) {
  189. // this.swiperCurrent = this.list[index].orderStatu;
  190. this.swiperCurrent = index
  191. this.getOrderList(this.list[index])
  192. },
  193. transition ({ detail: { dx } }) {
  194. this.$refs.tabs.setDx(dx)
  195. },
  196. animationfinish ({ detail: { current } }) {
  197. this.$refs.tabs.setFinishCurrent(current)
  198. this.swiperCurrent = current
  199. this.current = current
  200. },
  201. /**
  202. * 跳转详情
  203. * 未发起退款或者未退款成功的
  204. * */
  205. goDetails (item) {
  206. this.$u.route({
  207. url: 'pages/center/order/orderDetails/orderDetails',
  208. params: {
  209. orderId: item.id
  210. }
  211. })
  212. },
  213. jumpChargeStandard (item) {
  214. this.$u.route({
  215. url: 'pages/chargeStandard/chargeStandard',
  216. params: {
  217. roadNo: item.roadNo
  218. }
  219. })
  220. },
  221. // 申请退款
  222. applyRefund (item) {
  223. this.$u.route('pages/applyRefund/applyRefund', {
  224. orderId: item.orderId,
  225. payAmount: item.actualAmount
  226. })
  227. },
  228. /**
  229. * 申请退款详情
  230. * 只要申请退款状态等于1并且审批状态等于1跳转到退款完成详情页
  231. * 否则跳转到退款过程页
  232. * */
  233. applyRefundDetails (item) {
  234. if (item.refundStatus === 1 && item.auditStatus === 1) {
  235. this.$u.route('pages/applyRefundDetails/applyRefundAchieveDetails', {
  236. orderId: item.orderId
  237. })
  238. } else {
  239. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  240. orderId: item.orderId
  241. })
  242. }
  243. }
  244. },
  245. filters: {
  246. verifyStatusFilter (value) {
  247. if (value === 0) {
  248. return ''
  249. } else if (value === 1) {
  250. return '停放中'
  251. } else if (value === 2) {
  252. return '欠费未缴'
  253. } else if (value === 4) {
  254. return '已完成'
  255. } else {
  256. return ''
  257. }
  258. },
  259. verifyRefundStatus (item) {
  260. if (item.auditStatus === 0) {
  261. return '申请退款中'
  262. } else if (item.auditStatus === 1) {
  263. if (item.refundStatus === 0) {
  264. return '退款失败'
  265. } else if (item.refundStatus === 1) {
  266. return '退款成功'
  267. }
  268. } else if (item.auditStatus === 2) {
  269. return '已驳回'
  270. }
  271. }
  272. }
  273. }
  274. </script>
  275. <style>
  276. /* #ifndef H5 */
  277. page {
  278. height: 100%;
  279. background-color: #f6f6ff;
  280. }
  281. /* #endif */
  282. </style>
  283. <style lang="scss" scoped>
  284. @import "./order.scss";
  285. </style>