scoreAccumulate.vue 4.2 KB

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