order.vue 14 KB

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