order.vue 7.4 KB

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