orderList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="container">
  3. <view class="order-tab">
  4. <u-tabs :list="tabList" :is-scroll="false" :current="tabIndex" @change="changeTabs" font-size="30" active-color="#52A63A"
  5. inactive-color="#666666" :bold="false" height="90"></u-tabs>
  6. </view>
  7. <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(1)" v-if="tabIndex==0">
  8. <orderItem v-for="(item, index) in orderList1" :key="index" :orderData="item" :tabIndex="tabIndex + 1"></orderItem>
  9. <view style="padding: 10px 0" v-if="!orderList1.length || isOver1">
  10. <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
  11. </view>
  12. </scroll-view>
  13. <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(2)" v-else-if="tabIndex==1">
  14. <orderItem v-for="(item, index) in orderList2" :key="index" :orderData="item" :tabIndex="tabIndex + 1" @reasetList="reasetList()"></orderItem>
  15. <view style="padding: 10px 0" v-if="!orderList2.length || isOver2">
  16. <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
  17. </view>
  18. </scroll-view>
  19. <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(3)" v-else-if="tabIndex==2">
  20. <orderItem v-for="(item, index) in orderList3" :key="index" :orderData="item" :tabIndex="tabIndex + 1" @reasetList="reasetList()"></orderItem>
  21. <view style="padding: 10px 0" v-if="!orderList3.length || isOver3">
  22. <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
  23. </view>
  24. </scroll-view>
  25. <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(4)" v-else-if="tabIndex==3">
  26. <orderItem v-for="(item, index) in orderList4" :key="index" :orderData="item" :tabIndex="tabIndex + 1" @reasetList="reasetList()"></orderItem>
  27. <view style="padding: 10px 0" v-if="!orderList4.length || isOver4">
  28. <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
  29. </view>
  30. </scroll-view>
  31. <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(5)" v-else-if="tabIndex==4">
  32. <orderItem v-for="(item, index) in orderList5" :key="index" :orderData="item" :tabIndex="tabIndex + 1" @reasetList="reasetList()"></orderItem>
  33. <view style="padding: 10px 0" v-if="!orderList5.length || isOver5">
  34. <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
  35. </view>
  36. </scroll-view>
  37. <u-top-tips ref="uTips"></u-top-tips>
  38. </view>
  39. </template>
  40. <script>
  41. const NET = require('@/utils/request')
  42. const API = require('@/config/api')
  43. import orderItem from '@/pagesMain/orderItem.vue'
  44. export default {
  45. components: {
  46. orderItem
  47. },
  48. data() {
  49. return {
  50. tabIndex: 0,
  51. tabList: [{
  52. name: '全部'
  53. }, {
  54. name: '待付款'
  55. }, {
  56. name: '待发货'
  57. }, {
  58. name: '待收货'
  59. }, {
  60. name: '待评价'
  61. }, ],
  62. pageIndex1: 1,
  63. isOver1: false,
  64. orderList1: [],
  65. pageIndex2: 1,
  66. isOver2: false,
  67. orderList2: [],
  68. pageIndex3: 1,
  69. isOver3: false,
  70. orderList3: [],
  71. pageIndex4: 1,
  72. isOver4: false,
  73. orderList4: [],
  74. pageIndex5: 1,
  75. isOver5: false,
  76. orderList5: [],
  77. }
  78. },
  79. onLoad(options) {
  80. this.tabIndex = options.type - 1
  81. this.getOrderList(options.type)
  82. },
  83. onShow() {
  84. },
  85. onReady(options) {},
  86. onPullDownRefresh() {
  87. this['isOver' + (this.tabIndex + 1)] = false
  88. this['pageIndex' + (this.tabIndex + 1)] = 1
  89. this['orderList' + (this.tabIndex + 1)] = []
  90. this.getOrderList(this.tabIndex + 1, 'refresh')
  91. },
  92. methods: {
  93. // 切换tab
  94. changeTabs(index) {
  95. this.tabIndex = index;
  96. this.reasetList()
  97. },
  98. // 刷新数据
  99. reasetList() {
  100. this['isOver' + (this.tabIndex + 1)] = false
  101. this['pageIndex' + (this.tabIndex + 1)] = 1
  102. this['orderList' + (this.tabIndex + 1)] = []
  103. this.getOrderList(this.tabIndex + 1)
  104. },
  105. // 懒加载
  106. handleLoadMore(type) {
  107. if (!this['isOver' + type]) {
  108. this['pageIndex' + type]++
  109. this.getOrderList(type)
  110. }
  111. },
  112. // 获取全部商品
  113. getOrderList(type, refresh) {
  114. NET.request(API.getOrderList + this['pageIndex' + type] + '/10', {
  115. flag: type,
  116. }, 'GET').then(res => {
  117. if (refresh == 'refresh') {
  118. uni.stopPullDownRefresh();
  119. }
  120. this['isOver' + type] = res.data.list.length != 10
  121. this['orderList' + type] = this['orderList' + type].concat(res.data.list)
  122. }).catch(error => {
  123. this.$refs.uTips.show({
  124. title: error.data.msg,
  125. type: 'warning',
  126. })
  127. })
  128. },
  129. }
  130. }
  131. </script>
  132. <style>
  133. page {
  134. background-color: #f7f7f7;
  135. }
  136. </style>
  137. <style lang="less" scoped>
  138. page {
  139. width: 100%;
  140. height: 100%;
  141. }
  142. .container {
  143. width: 100%;
  144. // height: 100%;
  145. float: left;
  146. padding-top: 45px;
  147. background-color: #f7f7f7;
  148. position: relative;
  149. .order-tab {
  150. width: 100%;
  151. height: 45px;
  152. float: left;
  153. position: fixed;
  154. top: 0;
  155. }
  156. .order-list {
  157. width: calc(100% - 30px);
  158. height: calc(100% - 46px);
  159. float: left;
  160. margin: 0 15px;
  161. box-sizing: border-box;
  162. padding-top: 10px;
  163. }
  164. }
  165. </style>