order.vue 14 KB

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