freezeList.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="content">
  3. <!-- <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view> -->
  6. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  9. <!-- 空白页 -->
  10. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  13. <view class="title-box">
  14. <view class="time">
  15. <text>单号:{{ item.order_id }}</text>
  16. </view>
  17. <view class="time">
  18. <text>用户:{{ item.name }}</text>
  19. </view>
  20. <view class="time">
  21. <text>支付:{{ item.price }}</text>
  22. </view>
  23. <view class="time">
  24. <text>时间:{{ item.time }}</text>
  25. </view>
  26. </view>
  27. <view class="money">
  28. <text>{{ (item.status == 0 ? '+' : '-') + item.money }}</text>
  29. </view>
  30. </view>
  31. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  32. </scroll-view>
  33. </swiper-item>
  34. </swiper>
  35. </view>
  36. </template>
  37. <script>
  38. import { rechList } from '@/api/integral.js';
  39. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  40. import empty from '@/components/empty';
  41. export default {
  42. components: {
  43. empty,
  44. uniLoadMore
  45. },
  46. onReady() {},
  47. data() {
  48. return {
  49. tabCurrentIndex: 0,
  50. navList: [
  51. {
  52. state: 0,
  53. text: '全部',
  54. loadingType: 'more',
  55. orderList: [],
  56. page: 1, //当前页数
  57. limit: 10 //每次信息条数
  58. }
  59. ]
  60. };
  61. },
  62. onShow() {
  63. // 载入积分数据
  64. this.loadData();
  65. },
  66. methods: {
  67. // 页面跳转
  68. navto(e) {
  69. uni.navigateTo({
  70. url: e
  71. });
  72. },
  73. //获取收入支出信息
  74. async loadData(source) {
  75. //这里是将订单挂载到tab列表下
  76. let index = this.tabCurrentIndex;
  77. let navItem = this.navList[index];
  78. if (source === 'tabChange' && navItem.loaded === true) {
  79. //tab切换只有第一次需要加载数据
  80. return;
  81. }
  82. if (navItem.loadingType === 'loading') {
  83. //防止重复加载
  84. return;
  85. }
  86. // 修改当前对象状态为加载中
  87. navItem.loadingType = 'loading';
  88. rechList({
  89. page: navItem.page,
  90. limit: navItem.limit
  91. })
  92. .then(({ data }) => {
  93. if (data.length > 0) {
  94. navItem.orderList = navItem.orderList.concat(data);
  95. navItem.page++;
  96. }
  97. if (navItem.limit == data.length) {
  98. //判断是否还有数据, 有改为 more, 没有改为noMore
  99. navItem.loadingType = 'more';
  100. return;
  101. } else {
  102. //判断是否还有数据, 有改为 more, 没有改为noMore
  103. navItem.loadingType = 'noMore';
  104. }
  105. uni.hideLoading();
  106. this.$set(navItem, 'loaded', true);
  107. })
  108. .catch(e => {
  109. console.log(e);
  110. });
  111. },
  112. //swiper 切换
  113. changeTab(e) {
  114. this.tabCurrentIndex = e.target.current;
  115. this.loadData('tabChange');
  116. },
  117. //顶部tab点击
  118. tabClick(index) {
  119. this.tabCurrentIndex = index;
  120. }
  121. }
  122. };
  123. </script>
  124. <style lang="scss">
  125. page {
  126. background: #ffffff;
  127. height: 100%;
  128. }
  129. .navbar {
  130. display: flex;
  131. height: 40px;
  132. padding: 0 5px;
  133. background: #fff;
  134. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  135. position: relative;
  136. z-index: 10;
  137. .nav-item {
  138. flex: 1;
  139. display: flex;
  140. justify-content: center;
  141. align-items: center;
  142. height: 100%;
  143. font-size: 15px;
  144. color: $font-color-dark;
  145. position: relative;
  146. &.current {
  147. color: $base-color;
  148. &:after {
  149. content: '';
  150. position: absolute;
  151. left: 50%;
  152. bottom: 0;
  153. transform: translateX(-50%);
  154. width: 44px;
  155. height: 0;
  156. border-bottom: 2px solid $base-color;
  157. }
  158. }
  159. }
  160. }
  161. // 列表
  162. .swiper-box {
  163. height: calc(100% - 44px);
  164. padding-top: 10rpx;
  165. .order-item {
  166. padding: 20rpx 30rpx;
  167. line-height: 1.5;
  168. .title-box {
  169. .title {
  170. font-size: $font-lg;
  171. color: $font-color-base;
  172. }
  173. .time {
  174. font-size: $font-base;
  175. color: $font-color-light;
  176. }
  177. }
  178. .money {
  179. color: #fd5b23;
  180. font-size: $font-lg;
  181. }
  182. }
  183. }
  184. .list-scroll-content {
  185. height: 100%;
  186. }
  187. .content {
  188. height: 100%;
  189. .empty-content {
  190. background-color: #ffffff;
  191. }
  192. }
  193. </style>