order.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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" v-if="orderItem.deviceType == 1">
  68. 免费时长:{{ orderItem.freeDuration || 0 }}</view>
  69. <view class="order-center-item" v-if="orderItem.deviceType == 2">
  70. 免费时长:0天0时15分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. }
  160. },
  161. onShow() {
  162. // onShow 刷新数据
  163. this.list[this.current].pageNum = 1
  164. this.orderList = [
  165. [],
  166. [],
  167. [],
  168. []
  169. ]
  170. this.getOrderList(this.list[this.current])
  171. },
  172. computed: {
  173. // 价格小数
  174. priceDecimal() {
  175. return val => {
  176. if (val !== parseInt(val)) return val.slice(-2)
  177. else return '00'
  178. }
  179. },
  180. // 价格整数
  181. priceInt() {
  182. return val => {
  183. if (val !== parseInt(val)) return val.split('.')[0]
  184. else return val
  185. }
  186. }
  187. },
  188. onBackPress(e) {
  189. // 返回主页面tabBar
  190. uni.switchTab({
  191. url: "../../center/index"
  192. })
  193. // 此处一定要return为true,否则页面不会返回到指定路径
  194. return true;
  195. },
  196. methods: {
  197. reachBottom() {
  198. if (this.orderList[this.current].length >= this.list[this.current].total) {
  199. this.loadStatus.splice(this.list[this.current].index, 1, 'nomore')
  200. return
  201. };
  202. this.loadStatus.splice(this.list[this.current].index, 1, 'loading')
  203. this.getOrderList(this.list[this.current])
  204. },
  205. // 页面数据
  206. getOrderList(orderType) {
  207. const param = {
  208. pageNum: orderType.pageNum,
  209. orderStatus: orderType.orderStatu
  210. }
  211. // 未出场: orderStatu = 1-停放中
  212. // 缴费中: orderStatu = 2-出场中 && payStatus = 2-支付中
  213. // 完成: orderStatu = 4-完成
  214. this.$u.api.getOrderList(param)
  215. .then(res => {
  216. for (const item of res.data.pageInfo.rows) {
  217. this.orderList[orderType.index].push(item)
  218. }
  219. this.list[this.current].total = res.data.pageInfo.total
  220. this.list[orderType.index].pageNum++
  221. if (this.orderList[this.current].length >= this.list[this.current].total) {
  222. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore')
  223. };
  224. }).catch(err => {
  225. this.$refs.uToast.show({
  226. title: err.msg,
  227. type: 'error'
  228. })
  229. })
  230. this.loadStatus.splice(this.current, 1, 'loadmore')
  231. },
  232. // tab栏切换
  233. change(index) {
  234. // this.swiperCurrent = this.list[index].orderStatu;
  235. this.swiperCurrent = index
  236. this.getOrderList(this.list[index])
  237. },
  238. transition({
  239. detail: {
  240. dx
  241. }
  242. }) {
  243. this.$refs.tabs.setDx(dx)
  244. },
  245. animationfinish({
  246. detail: {
  247. current
  248. }
  249. }) {
  250. this.$refs.tabs.setFinishCurrent(current)
  251. this.swiperCurrent = current
  252. this.current = current
  253. },
  254. /**
  255. * 跳转详情
  256. * 未发起退款或者未退款成功的
  257. * */
  258. goDetails(item) {
  259. this.$u.route({
  260. url: 'pages/center/order/orderDetails/orderDetails',
  261. params: {
  262. orderId: item.id
  263. }
  264. })
  265. },
  266. jumpChargeStandard(item) {
  267. this.$u.route({
  268. url: 'pages/chargeStandard/chargeStandard',
  269. params: {
  270. roadNo: item.roadNo
  271. }
  272. })
  273. },
  274. // 申请退款
  275. applyRefund(item) {
  276. this.$u.route('pages/applyRefund/applyRefund', {
  277. orderId: item.orderId,
  278. payAmount: item.actualAmount
  279. })
  280. },
  281. /**
  282. * 申请退款详情
  283. * 只要申请退款状态等于1并且审批状态等于1跳转到退款完成详情页
  284. * 否则跳转到退款过程页
  285. * */
  286. applyRefundDetails(item) {
  287. if (item.refundStatus === 1 && item.auditStatus === 1) {
  288. this.$u.route('pages/applyRefundDetails/applyRefundAchieveDetails', {
  289. orderId: item.orderId
  290. })
  291. } else {
  292. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  293. orderId: item.orderId
  294. })
  295. }
  296. }
  297. },
  298. filters: {
  299. verifyStatusFilter(value) {
  300. if (value === 0) {
  301. return ''
  302. } else if (value === 1) {
  303. return '停放中'
  304. } else if (value === 2) {
  305. return '欠费未缴'
  306. } else if (value === 4) {
  307. return '已完成'
  308. } else {
  309. return ''
  310. }
  311. },
  312. verifyRefundStatus(item) {
  313. if (item.auditStatus === 0) {
  314. return '申请退款中'
  315. } else if (item.auditStatus === 1) {
  316. if (item.refundStatus === 0) {
  317. return '退款失败'
  318. } else if (item.refundStatus === 1) {
  319. return '退款成功'
  320. }
  321. } else if (item.auditStatus === 2) {
  322. return '已驳回'
  323. }
  324. }
  325. }
  326. }
  327. </script>
  328. <style>
  329. /* #ifndef H5 */
  330. page {
  331. height: 100%;
  332. background-color: #f6f6ff;
  333. }
  334. /* #endif */
  335. </style>
  336. <style lang="scss" scoped>
  337. @import "./order.scss";
  338. </style>