order.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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. label: '路段',
  202. value: 'road'
  203. }
  204. }
  205. },
  206. onShow() {
  207. // this.typeCurrent = this.typeList[0]
  208. // onShow 刷新数据
  209. this.list[this.current].pageNum = 1
  210. this.orderList = [
  211. [],
  212. [],
  213. [],
  214. []
  215. ]
  216. this.getOrderList(this.list[this.current],this.typeCurrent)
  217. },
  218. computed: {
  219. // 价格小数
  220. priceDecimal() {
  221. return val => {
  222. if (val !== parseInt(val)) return val.slice(-2)
  223. else return '00'
  224. }
  225. },
  226. // 价格整数
  227. priceInt() {
  228. return val => {
  229. if (val !== parseInt(val)) return val.split('.')[0]
  230. else return val
  231. }
  232. }
  233. },
  234. onBackPress(e) {
  235. // 返回主页面tabBar
  236. uni.switchTab({
  237. url: "../../center/index"
  238. })
  239. // 此处一定要return为true,否则页面不会返回到指定路径
  240. return true;
  241. },
  242. methods: {
  243. reachBottom() {
  244. if (this.orderList[this.current].length >= this.list[this.current].total) {
  245. this.loadStatus.splice(this.list[this.current].index, 1, 'nomore')
  246. return
  247. };
  248. this.loadStatus.splice(this.list[this.current].index, 1, 'loading')
  249. this.getOrderList(this.list[this.current],this.typeCurrent)
  250. },
  251. // 页面数据
  252. getOrderList(orderType,typeCurrent) {
  253. //初始化订单列表
  254. const param = {
  255. pageNum: orderType.pageNum,
  256. orderStatus: orderType.orderStatus
  257. }
  258. // 未出场: orderStatus = 1-停放中
  259. // 缴费中: orderStatus = 2-出场中 && payStatus = 2-支付中
  260. // 完成: orderStatus = 4-完成
  261. if(typeCurrent.value == 'road'){
  262. this.$u.api.getOrderList(param)
  263. .then(res => {
  264. for (const item of res.data.pageInfo.rows) {
  265. this.orderList[orderType.index].push(item)
  266. }
  267. this.list[this.current].total = res.data.pageInfo.total
  268. this.list[orderType.index].pageNum++
  269. if (this.orderList[this.current].length >= this.list[this.current].total) {
  270. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore')
  271. };
  272. }).catch(err => {
  273. this.$refs.uToast.show({
  274. title: err.msg,
  275. type: 'error'
  276. })
  277. })
  278. }else{
  279. this.$u.api.getRoomParkingApi(param)
  280. .then(res => {
  281. for (const item of res.data.pageInfo.rows) {
  282. this.orderList[orderType.index].push(item)
  283. }
  284. this.list[this.current].total = res.data.pageInfo.total
  285. this.list[orderType.index].pageNum++
  286. if (this.orderList[this.current].length >= this.list[this.current].total) {
  287. this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore')
  288. };
  289. }).catch(err => {
  290. this.$refs.uToast.show({
  291. title: err.msg,
  292. type: 'error'
  293. })
  294. })
  295. }
  296. this.loadStatus.splice(this.current, 1, 'loadmore')
  297. },
  298. // tab栏切换
  299. change(index) {
  300. this.swiperCurrent = index
  301. //重新初始化
  302. this.orderList = [
  303. [],
  304. [],
  305. [],
  306. []
  307. ]
  308. this.list[index].pageNum = 1
  309. this.getOrderList(this.list[index],this.typeCurrent)
  310. },
  311. transition({
  312. detail: {
  313. dx
  314. }
  315. }) {
  316. this.$refs.tabs.setDx(dx)
  317. },
  318. animationfinish({
  319. detail: {
  320. current
  321. }
  322. }) {
  323. this.$refs.tabs.setFinishCurrent(current)
  324. this.swiperCurrent = current
  325. this.current = current
  326. },
  327. /**
  328. * 跳转详情
  329. * 未发起退款或者未退款成功的
  330. * */
  331. goDetails(item) {
  332. this.$u.route({
  333. url: 'pages/center/order/orderDetails/orderDetails',
  334. params: {
  335. orderId: item.id,
  336. type: this.typeCurrent.value
  337. }
  338. })
  339. },
  340. jumpChargeStandard(item) {
  341. this.$u.route({
  342. url: 'pages/chargeStandard/chargeStandard',
  343. params: {
  344. roadNo: item.roadNo
  345. }
  346. })
  347. },
  348. // 申请退款
  349. applyRefund(item) {
  350. this.$u.route('pages/applyRefund/applyRefund', {
  351. orderId: item.orderId,
  352. payAmount: item.actualAmount
  353. })
  354. },
  355. /**
  356. * 申请退款详情
  357. * 只要申请退款状态等于1并且审批状态等于1跳转到退款完成详情页
  358. * 否则跳转到退款过程页
  359. * */
  360. applyRefundDetails(item) {
  361. if (item.refundStatus === 1 && item.auditStatus === 1) {
  362. this.$u.route('pages/applyRefundDetails/applyRefundAchieveDetails', {
  363. orderId: item.orderId
  364. })
  365. } else {
  366. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  367. orderId: item.orderId
  368. })
  369. }
  370. },
  371. /**
  372. * 类型切换
  373. * @param {Object} item
  374. */
  375. typeTabClick(item) {
  376. this.typeCurrent = item
  377. //重新初始化
  378. this.orderList = [
  379. [],
  380. [],
  381. [],
  382. []
  383. ]
  384. this.list[this.current].pageNum = 1
  385. this.getOrderList(this.list[this.current],this.typeCurrent)
  386. }
  387. },
  388. filters: {
  389. verifyStatusFilter(value) {
  390. if (value === 0) {
  391. return ''
  392. } else if (value === 1) {
  393. return '停放中'
  394. } else if (value === 2) {
  395. return '欠费未缴'
  396. } else if (value === 4) {
  397. return '已完成'
  398. } else {
  399. return ''
  400. }
  401. },
  402. verifyRefundStatus(item) {
  403. if (item.auditStatus === 0) {
  404. return '申请退款中'
  405. } else if (item.auditStatus === 1) {
  406. if (item.refundStatus === 0) {
  407. return '退款失败'
  408. } else if (item.refundStatus === 1) {
  409. return '退款成功'
  410. }
  411. } else if (item.auditStatus === 2) {
  412. return '已驳回'
  413. }
  414. }
  415. }
  416. }
  417. </script>
  418. <style>
  419. /* #ifndef H5 */
  420. page {
  421. height: 100%;
  422. background-color: #f6f6ff;
  423. }
  424. /* #endif */
  425. </style>
  426. <style lang="scss" scoped>
  427. @import "./order.scss";
  428. </style>