order.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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" :is-scroll="false" swiperWidth="100%"></u-tabs-swiper>
  6. </view>
  7. <swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
  8. <swiper-item class="swiper-item" v-for="(item, index) in list" :key="index">
  9. <scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
  10. <view class="page-box">
  11. <view class="order" @click="goDetails(orderItem.id)" v-for="(orderItem, index) in orderList[index]" :key="orderItem.id">
  12. <view class="order-top u-flex">
  13. <view class="order-top-left u-flex-1">
  14. <view class="car">{{orderItem.vehicleNo}}</view>
  15. <view class="addr">{{orderItem.roadName}}</view>
  16. </view>
  17. <view class="order-top-right" :class="{'order-top-right-finished':orderItem.orderStatus=='4'}">{{orderItem.orderStatus | verifyStatusFilter}}</view>
  18. </view>
  19. <view class="order-center">
  20. <view class="order-center-item">订单编号:{{orderItem.orderId}}</view>
  21. <view class="order-center-item">入场时间:{{orderItem.inTime}}</view>
  22. <view class="order-center-item" v-if="orderItem.orderStatus !== 1">出场时间:{{orderItem.outTime}}</view>
  23. <view class="order-center-item" v-if="orderItem.orderStatus !== 1">停留时间:{{orderItem.duration}}</view>
  24. <view class="order-center-item">应付金额:<span class="pay-amount">{{orderItem.payAmount}}</span></view>
  25. </view>
  26. <view class="order-bottom">
  27. <u-cell-item title="收费标准" @click.native.stop="jumpChargeStandard(orderItem)"></u-cell-item>
  28. </view>
  29. </view>
  30. <u-loadmore :status="loadStatus[index]" bgColor="#F6F6FF"></u-loadmore>
  31. </view>
  32. </scroll-view>
  33. </swiper-item>
  34. </swiper>
  35. </view>
  36. <u-toast ref="uToast" />
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. orderList: [[], [], [], []],
  44. list: [
  45. {index:0,name: '全部',orderStatu:null,pageNum:1,total:null},
  46. {index:1,name: '停放中',orderStatu:1,pageNum:1,total:null},
  47. {index:2,name: '欠费未缴',orderStatu:2,pageNum:1,total:null},
  48. {index:3,name: '已完成',orderStatu:4,pageNum:1,total:null}
  49. ],
  50. current: 0,
  51. swiperCurrent: 0,
  52. tabsHeight: 0,
  53. dx: 0,
  54. loadStatus: ['loadmore','loadmore','loadmore','loadmore'],
  55. };
  56. },
  57. onLoad() {
  58. // this.getOrderList(this.list[0]);
  59. // this.getOrderList(this.list[1]);
  60. // this.getOrderList(this.list[2]);
  61. // this.getOrderList(this.list[3]);
  62. },
  63. onShow(){
  64. // onShow 刷新数据
  65. this.list[0].pageNum = 1;
  66. this.orderList=[[], [], [], []];
  67. this.getOrderList(this.list[0]);
  68. },
  69. computed: {
  70. // 价格小数
  71. priceDecimal() {
  72. return val => {
  73. if (val !== parseInt(val)) return val.slice(-2);
  74. else return '00';
  75. };
  76. },
  77. // 价格整数
  78. priceInt() {
  79. return val => {
  80. if (val !== parseInt(val)) return val.split('.')[0];
  81. else return val;
  82. };
  83. }
  84. },
  85. methods: {
  86. reachBottom() {
  87. // console.log('this.list[this.current]',this.list[this.current]);
  88. if(this.orderList[this.current].length>=this.list[this.current].total){
  89. this.loadStatus.splice(this.list[this.current].index,1,"nomore");
  90. return;
  91. };
  92. this.loadStatus.splice(this.list[this.current].index,1,"loading");
  93. this.getOrderList(this.list[this.current]);
  94. },
  95. // 页面数据
  96. getOrderList(orderType) {
  97. let param = {
  98. pageNum:orderType.pageNum,
  99. orderStatus:orderType.orderStatu,
  100. };
  101. // 未出场: orderStatu = 1-停放中
  102. // 缴费中: orderStatu = 2-出场中 && payStatus = 2-支付中
  103. // 完成: orderStatu = 4-完成
  104. this.$u.api.getOrderList(param)
  105. .then(res=>{
  106. for(let item of res.data.rows){
  107. this.orderList[orderType.index].push(item);
  108. }
  109. console.log('this.list[orderType.index]',this.list[orderType.index]);
  110. this.list[this.current].total = res.data.total;
  111. this.list[orderType.index].pageNum++;
  112. if(this.orderList[this.current].length>=this.list[this.current].total){
  113. this.loadStatus.splice(this.list[orderType.index].index,1,"nomore");
  114. };
  115. console.log(JSON.parse(JSON.stringify(this.orderList[this.swiperCurrent])));
  116. console.log('this.list[this.current]',this.list[this.current]);
  117. }).catch(err=>{
  118. this.$refs.uToast.show({
  119. title: err.msg,
  120. type: 'error',
  121. });
  122. console.log('getOrderList ',err)
  123. });
  124. this.loadStatus.splice(this.current,1,"loadmore")
  125. },
  126. // tab栏切换
  127. change(index) {
  128. // this.swiperCurrent = this.list[index].orderStatu;
  129. this.swiperCurrent = index;
  130. this.getOrderList(this.list[index]);
  131. },
  132. transition({ detail: { dx } }) {
  133. this.$refs.tabs.setDx(dx);
  134. },
  135. animationfinish({ detail: { current } }) {
  136. this.$refs.tabs.setFinishCurrent(current);
  137. this.swiperCurrent = current;
  138. this.current = current;
  139. },
  140. goDetails(id){
  141. this.$u.route({
  142. url: 'pages/center/order/orderDetails/orderDetails',
  143. params: {
  144. orderId: id
  145. }
  146. });
  147. },
  148. jumpChargeStandard(item) {
  149. console.log(item)
  150. this.$u.route({
  151. url: 'pages/chargeStandard/chargeStandard',
  152. params: {
  153. roadNo: item.roadNo
  154. }
  155. });
  156. }
  157. },
  158. filters:{
  159. verifyStatusFilter(value) {
  160. if (value === 0) {
  161. return '';
  162. } else if(value === 1){
  163. return '停放中';
  164. } else if(value === 2){
  165. return '欠费未缴';
  166. } else if(value === 4){
  167. return '已完成';
  168. } else {
  169. return '';
  170. }
  171. },
  172. }
  173. };
  174. </script>
  175. <style>
  176. /* #ifndef H5 */
  177. page {
  178. height: 100%;
  179. background-color: #F6F6FF;
  180. }
  181. /* #endif */
  182. </style>
  183. <style lang="scss" scoped>
  184. @import "./order.scss";
  185. </style>