scoreAccumulate.vue 5.2 KB

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