order.vue 12 KB

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