scoreAccumulate.vue 4.6 KB

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