order.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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[current]" :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 }}
  41. </view>
  42. </view>
  43. <view class="order-center">
  44. <view class="order-center-item">订单编号:{{ orderItem.orderId }}</view>
  45. <!-- <view class="order-center-item">入场时间:{{ orderItem.inTime }}</view> -->
  46. <view class="order-center-item" v-if="orderItem.deviceType == 1">
  47. 入场时间:{{ orderItem.inTime }}</view>
  48. <view class="order-center-item" v-else>开始计费:{{ orderItem.inTime }}</view>
  49. <template v-if="orderItem.deviceType == 1">
  50. <view class="order-center-item"
  51. v-if="orderItem.orderStatus == 1 && orderItem.outTime">
  52. 出场时间:{{ `未出场` }}</view>
  53. <view class="order-center-item" v-if="orderItem.orderStatus !== 1">
  54. 出场时间:{{ orderItem.outTime }}</view>
  55. </template>
  56. <template v-else>
  57. <view class="order-center-item"
  58. v-if="orderItem.orderStatus == 1 && orderItem.outTime">
  59. 结束计费:{{ `未出场` }}</view>
  60. <view class="order-center-item" v-if="orderItem.orderStatus !== 1">
  61. 结束计费:{{ orderItem.outTime }}</view>
  62. </template>
  63. <!-- <view class="order-center-item">
  64. 停车时长:{{ orderItem.duration || 0 }}</view> -->
  65. <!-- <view class="order-center-item" v-if="orderItem.orderStatus !== 1">
  66. 免费时长:{{ orderItem.freeDuration || 0 }}</view> -->
  67. <view class="order-center-item">
  68. 免费时长:{{ orderItem.freeDuration || 0 }}</view>
  69. <!-- <view class="order-center-item" v-if="orderItem.deviceType == 2">
  70. 免费时长:{{ new Date(orderItem.createTime).valueOf() < new Date('2022-06-20 00:00:00').valueOf() ? '0天0时15分0秒' : '0天0时30分0秒' }}</view> -->
  71. <!-- <view class="order-center-item" v-if="orderItem.orderStatus !== 1">
  72. 计费时长:{{ orderItem.calcDuration || 0 }}</view> -->
  73. <view class="order-center-item">
  74. 计费时长:{{ orderItem.calcDuration || 0 }}</view>
  75. <view class="order-center-item">
  76. 累计停车时长:{{ orderItem.duration || 0 }}</view>
  77. <view class="order-center-item" v-if="orderItem.orderStatus == 1">
  78. 预计金额:
  79. <span class="pay-amount">{{ orderItem.payAmount || 0 }}</span>
  80. </view>
  81. <view class="order-center-item" v-else>
  82. 应付金额:
  83. <span class="pay-amount">{{ orderItem.payAmount || 0 }}</span>
  84. </view>
  85. <view class="order-center-item"
  86. v-if="(orderItem.actualAmount || orderItem.actualAmount === 0) && orderItem.orderStatus !== 2 && orderItem.orderStatus !== 1">
  87. 实缴金额:
  88. <span class="pay-amount">{{ orderItem.actualAmount || 0 }}</span>
  89. </view>
  90. <view class="order-center-item">泊位号:{{ orderItem.spaceName }}</view>
  91. <view class="order-center-item" v-if="Number(orderItem.deviceType) !== 1">
  92. 车位锁设备号:{{ orderItem.deviceNo }}</view>
  93. </view>
  94. <view class="order-bottom">
  95. <u-cell-item title="收费标准" @click.native.stop="jumpChargeStandard(orderItem)">
  96. </u-cell-item>
  97. </view>
  98. </view>
  99. <u-loadmore :status="loadStatus[index]" bg-color="#F6F6FF"></u-loadmore>
  100. </view>
  101. </scroll-view>
  102. </swiper-item>
  103. </swiper>
  104. </view>
  105. <u-toast ref="uToast" />
  106. </view>
  107. </template>
  108. <script>
  109. // 订单状态orderStatus: 1-停放中 2-出场中 3-欠费 4-完成
  110. export default {
  111. data() {
  112. return {
  113. orderList: [
  114. [],
  115. [],
  116. [],
  117. []
  118. ],
  119. list: [{
  120. index: 0,
  121. name: '全部',
  122. orderStatu: null,
  123. pageNum: 1,
  124. total: null
  125. },
  126. {
  127. index: 1,
  128. name: '停放中',
  129. orderStatu: 1,
  130. pageNum: 1,
  131. total: null
  132. },
  133. {
  134. index: 2,
  135. name: '欠费未缴',
  136. orderStatu: 2,
  137. pageNum: 1,
  138. total: null
  139. },
  140. {
  141. index: 3,
  142. name: '已完成',
  143. orderStatu: 4,
  144. pageNum: 1,
  145. total: null
  146. }
  147. ],
  148. current: 0,
  149. swiperCurrent: 0,
  150. tabsHeight: 0,
  151. dx: 0,
  152. loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore']
  153. }
  154. },
  155. onLoad(options) {
  156. let questCurrent = options.swiperIndex
  157. if (questCurrent) {
  158. this.current = questCurrent
  159. this.swiperCurrent = questCurrent
  160. }
  161. },
  162. onShow() {
  163. // onShow 刷新数据
  164. this.list[this.current].pageNum = 1
  165. this.orderList = [
  166. [],
  167. [],
  168. [],
  169. []
  170. ]
  171. this.getOrderList(this.list[this.current])
  172. },
  173. computed: {
  174. // 价格小数
  175. priceDecimal() {
  176. return val => {
  177. if (val !== parseInt(val)) return val.slice(-2)
  178. else return '00'
  179. }
  180. },
  181. // 价格整数
  182. priceInt() {
  183. return val => {
  184. if (val !== parseInt(val)) return val.split('.')[0]
  185. else return val
  186. }
  187. }
  188. },
  189. onBackPress(e) {
  190. // 返回主页面tabBar
  191. uni.switchTab({
  192. url: "../../center/index"
  193. })
  194. // 此处一定要return为true,否则页面不会返回到指定路径
  195. return true;
  196. },
  197. methods: {
  198. reachBottom() {
  199. if (this.orderList[this.current].length >= this.list[this.current].total) {
  200. this.loadStatus.splice(this.list[this.current].index, 1, 'nomore')
  201. return
  202. };
  203. this.loadStatus.splice(this.list[this.current].index, 1, 'loading')
  204. this.getOrderList(this.list[this.current])
  205. },
  206. // 页面数据
  207. getOrderList(orderType) {
  208. const param = {
  209. pageNum: orderType.pageNum,
  210. orderStatus: orderType.orderStatu
  211. }
  212. // 未出场: orderStatu = 1-停放中
  213. // 缴费中: orderStatu = 2-出场中 && payStatus = 2-支付中
  214. // 完成: orderStatu = 4-完成
  215. this.$u.api.getOrderList(param)
  216. .then(res => {
  217. for (const item of res.data.pageInfo.rows) {
  218. this.orderList[orderType.index].push(item)
  219. }
  220. this.list[this.current].total = res.data.pageInfo.total
  221. this.list[orderType.index].pageNum++
  222. if (this.orderList[this.current].length >= this.list[this.current].total) {
  223. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore')
  224. };
  225. })
  226. this.loadStatus.splice(this.current, 1, 'loadmore')
  227. },
  228. // tab栏切换
  229. change(index) {
  230. // this.swiperCurrent = this.list[index].orderStatu;
  231. this.swiperCurrent = index
  232. this.getOrderList(this.list[index])
  233. },
  234. transition({
  235. detail: {
  236. dx
  237. }
  238. }) {
  239. this.$refs.tabs.setDx(dx)
  240. },
  241. animationfinish({
  242. detail: {
  243. current
  244. }
  245. }) {
  246. this.$refs.tabs.setFinishCurrent(current)
  247. this.swiperCurrent = current
  248. this.current = current
  249. },
  250. /**
  251. * 跳转详情
  252. * 未发起退款或者未退款成功的
  253. * */
  254. goDetails(item) {
  255. this.$u.route({
  256. url: 'pages/center/order/orderDetails/orderDetails',
  257. params: {
  258. orderId: item.id
  259. }
  260. })
  261. },
  262. jumpChargeStandard(item) {
  263. this.$u.route({
  264. url: 'pages/chargeStandard/chargeStandard',
  265. params: {
  266. roadNo: item.roadNo
  267. }
  268. })
  269. },
  270. // 申请退款
  271. applyRefund(item) {
  272. this.$u.route('pages/applyRefund/applyRefund', {
  273. orderId: item.orderId,
  274. payAmount: item.actualAmount
  275. })
  276. },
  277. /**
  278. * 申请退款详情
  279. * 只要申请退款状态等于1并且审批状态等于1跳转到退款完成详情页
  280. * 否则跳转到退款过程页
  281. * */
  282. applyRefundDetails(item) {
  283. if (item.refundStatus === 1 && item.auditStatus === 1) {
  284. this.$u.route('pages/applyRefundDetails/applyRefundAchieveDetails', {
  285. orderId: item.orderId
  286. })
  287. } else {
  288. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  289. orderId: item.orderId
  290. })
  291. }
  292. }
  293. },
  294. filters: {
  295. verifyStatusFilter(value) {
  296. if (value === 0) {
  297. return ''
  298. } else if (value === 1) {
  299. return '停放中'
  300. } else if (value === 2) {
  301. return '欠费未缴'
  302. } else if (value === 4) {
  303. return '已完成'
  304. } else {
  305. return ''
  306. }
  307. },
  308. verifyRefundStatus(item) {
  309. if (item.auditStatus === 0) {
  310. return '申请退款中'
  311. } else if (item.auditStatus === 1) {
  312. if (item.refundStatus === 0) {
  313. return '退款失败'
  314. } else if (item.refundStatus === 1) {
  315. return '退款成功'
  316. }
  317. } else if (item.auditStatus === 2) {
  318. return '已驳回'
  319. }
  320. }
  321. }
  322. }
  323. </script>
  324. <style>
  325. /* #ifndef H5 */
  326. page {
  327. height: 100%;
  328. background-color: #f6f6ff;
  329. }
  330. /* #endif */
  331. </style>
  332. <style lang="scss" scoped>
  333. @import "./order.scss";
  334. </style>