order.vue 14 KB

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