order.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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)" 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
  18. class="order-top-right apply-refund"
  19. v-show="current === 3 && orderItem.allowRefund == 1 && (orderItem.refundStatus === 2 || !orderItem.refundStatus && orderItem.refundStatus !== 0)"
  20. @click.stop="applyRefund(orderItem)"
  21. >申请退款</view>
  22. <view
  23. class="order-top-right apply-refund"
  24. @click.stop="applyRefundDetails(orderItem)"
  25. v-show="current === 3 && (orderItem.refundStatus || orderItem.refundStatus == 0)">
  26. {{orderItem.refundStatus | verifyRefundStatus}}
  27. </view>
  28. <view
  29. class="order-top-right"
  30. v-show="!orderItem.refundStatus && orderItem.refundStatus != 0"
  31. :class="{'order-top-right-finished': orderItem.orderStatus == '4'}">
  32. {{orderItem.orderStatus | verifyStatusFilter}}
  33. </view>
  34. </view>
  35. <view class="order-center">
  36. <view class="order-center-item">订单编号:{{orderItem.orderId}}</view>
  37. <view class="order-center-item">入场时间:{{orderItem.inTime}}</view>
  38. <view class="order-center-item" v-if="orderItem.orderStatus !== 1">出场时间:{{orderItem.outTime}}</view>
  39. <view class="order-center-item" v-if="orderItem.orderStatus !== 1">停留时间:{{orderItem.duration}}</view>
  40. <view class="order-center-item">应付金额:<span class="pay-amount">{{orderItem.payAmount}}</span></view>
  41. </view>
  42. <view class="order-bottom">
  43. <u-cell-item title="收费标准" @click.native.stop="jumpChargeStandard(orderItem)"></u-cell-item>
  44. </view>
  45. </view>
  46. <u-loadmore :status="loadStatus[index]" bgColor="#F6F6FF"></u-loadmore>
  47. </view>
  48. </scroll-view>
  49. </swiper-item>
  50. </swiper>
  51. </view>
  52. <u-toast ref="uToast" />
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. orderList: [[], [], [], []],
  60. list: [
  61. {index:0,name: '全部',orderStatu:null,pageNum:1,total:null},
  62. {index:1,name: '停放中',orderStatu:1,pageNum:1,total:null},
  63. {index:2,name: '欠费未缴',orderStatu:2,pageNum:1,total:null},
  64. {index:3,name: '已完成',orderStatu:4,pageNum:1,total:null}
  65. ],
  66. current: 0,
  67. swiperCurrent: 0,
  68. tabsHeight: 0,
  69. dx: 0,
  70. loadStatus: ['loadmore','loadmore','loadmore','loadmore'],
  71. };
  72. },
  73. onLoad() {
  74. // this.getOrderList(this.list[0]);
  75. // this.getOrderList(this.list[1]);
  76. // this.getOrderList(this.list[2]);
  77. // this.getOrderList(this.list[3]);
  78. },
  79. onShow(){
  80. // onShow 刷新数据
  81. this.list[this.current].pageNum = 1;
  82. this.orderList=[[], [], [], []];
  83. this.getOrderList(this.list[this.current]);
  84. },
  85. computed: {
  86. // 价格小数
  87. priceDecimal() {
  88. return val => {
  89. if (val !== parseInt(val)) return val.slice(-2);
  90. else return '00';
  91. };
  92. },
  93. // 价格整数
  94. priceInt() {
  95. return val => {
  96. if (val !== parseInt(val)) return val.split('.')[0];
  97. else return val;
  98. };
  99. }
  100. },
  101. methods: {
  102. reachBottom() {
  103. // console.log('this.list[this.current]',this.list[this.current]);
  104. if(this.orderList[this.current].length>=this.list[this.current].total){
  105. this.loadStatus.splice(this.list[this.current].index,1,"nomore");
  106. return;
  107. };
  108. this.loadStatus.splice(this.list[this.current].index,1,"loading");
  109. this.getOrderList(this.list[this.current]);
  110. },
  111. // 页面数据
  112. getOrderList(orderType) {
  113. let param = {
  114. pageNum:orderType.pageNum,
  115. orderStatus:orderType.orderStatu,
  116. };
  117. // 未出场: orderStatu = 1-停放中
  118. // 缴费中: orderStatu = 2-出场中 && payStatus = 2-支付中
  119. // 完成: orderStatu = 4-完成
  120. this.$u.api.getOrderList(param)
  121. .then(res=>{
  122. for(let item of res.data.rows){
  123. this.orderList[orderType.index].push(item);
  124. }
  125. console.log('this.list[orderType.index]',this.list[orderType.index]);
  126. this.list[this.current].total = res.data.total;
  127. this.list[orderType.index].pageNum++;
  128. if(this.orderList[this.current].length>=this.list[this.current].total){
  129. this.loadStatus.splice(this.list[orderType.index].index,1,"nomore");
  130. };
  131. console.log(JSON.parse(JSON.stringify(this.orderList[this.swiperCurrent])));
  132. console.log('this.list[this.current]',this.list[this.current]);
  133. }).catch(err=>{
  134. this.$refs.uToast.show({
  135. title: err.msg,
  136. type: 'error',
  137. });
  138. console.log('getOrderList ',err)
  139. });
  140. this.loadStatus.splice(this.current,1,"loadmore")
  141. },
  142. // tab栏切换
  143. change(index) {
  144. // this.swiperCurrent = this.list[index].orderStatu;
  145. this.swiperCurrent = index;
  146. this.getOrderList(this.list[index]);
  147. },
  148. transition({ detail: { dx } }) {
  149. this.$refs.tabs.setDx(dx);
  150. },
  151. animationfinish({ detail: { current } }) {
  152. this.$refs.tabs.setFinishCurrent(current);
  153. this.swiperCurrent = current;
  154. this.current = current;
  155. },
  156. goDetails(item){
  157. if (item.refundStatus === 1) { // 退款完成
  158. this.$u.route('pages/applyRefundDetails/applyRefundAchieveDetails', {
  159. orderId: item.orderId
  160. })
  161. } else {
  162. this.$u.route({ // 未发起退款或者未退款成功的
  163. url: 'pages/center/order/orderDetails/orderDetails',
  164. params: {
  165. orderId: item.id
  166. }
  167. });
  168. }
  169. },
  170. jumpChargeStandard(item) {
  171. this.$u.route({
  172. url: 'pages/chargeStandard/chargeStandard',
  173. params: {
  174. roadNo: item.roadNo
  175. }
  176. });
  177. },
  178. // 申请退款
  179. applyRefund(item) {
  180. this.$u.route('pages/applyRefund/applyRefund', {
  181. orderId: item.orderId,
  182. payAmount: item.payAmount
  183. })
  184. },
  185. // 申请退款详情
  186. applyRefundDetails(item) {
  187. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  188. orderId: item.orderId
  189. })
  190. }
  191. },
  192. filters:{
  193. verifyStatusFilter(value) {
  194. if (value === 0) {
  195. return '';
  196. } else if(value === 1){
  197. return '停放中';
  198. } else if(value === 2){
  199. return '欠费未缴';
  200. } else if(value === 4){
  201. return '已完成';
  202. } else {
  203. return '';
  204. }
  205. },
  206. verifyRefundStatus(value) {
  207. switch(value) {
  208. case 0:
  209. return '申请退款中';
  210. break;
  211. case 1:
  212. return '已通过';
  213. break;
  214. case 2:
  215. return '已驳回';
  216. break;
  217. case 3:
  218. return '退款失败';
  219. break;
  220. default:
  221. return null;
  222. break;
  223. }
  224. }
  225. }
  226. };
  227. </script>
  228. <style>
  229. /* #ifndef H5 */
  230. page {
  231. height: 100%;
  232. background-color: #F6F6FF;
  233. }
  234. /* #endif */
  235. </style>
  236. <style lang="scss" scoped>
  237. @import "./order.scss";
  238. </style>