order.vue 9.7 KB

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