scoreAccumulate.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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: 1,
  52. text: '收入',
  53. loadingType: 'more',
  54. orderList: [],
  55. page: 1, //当前页面
  56. limit: 10 //每次信息条数
  57. },
  58. {
  59. state: 0,
  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. console.log(data)
  106. if (data.length > 0) {
  107. let list = []
  108. data.forEach((item) => {
  109. if(item.pm === state){
  110. list.push(item)
  111. }
  112. })
  113. navItem.orderList = navItem.orderList.concat(list);
  114. navItem.page++;
  115. }
  116. if (navItem.limit == data.length) {
  117. //判断是否还有数据, 有改为 more, 没有改为noMore
  118. navItem.loadingType = 'more';
  119. return;
  120. } else {
  121. //判断是否还有数据, 有改为 more, 没有改为noMore
  122. navItem.loadingType = 'noMore';
  123. }
  124. uni.hideLoading();
  125. this.$set(navItem, 'loaded', true);
  126. })
  127. .catch(e => {
  128. console.log(e);
  129. });
  130. },
  131. //swiper 切换
  132. changeTab(e) {
  133. this.tabCurrentIndex = e.target.current;
  134. this.loadData('tabChange');
  135. },
  136. //顶部tab点击
  137. tabClick(index) {
  138. this.tabCurrentIndex = index;
  139. }
  140. }
  141. };
  142. </script>
  143. <style lang="scss">
  144. page {
  145. background: #ffffff;
  146. height: 100%;
  147. }
  148. .navbar {
  149. display: flex;
  150. height: 40px;
  151. padding: 0 5px;
  152. background: #fff;
  153. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  154. position: relative;
  155. z-index: 10;
  156. .nav-item {
  157. flex: 1;
  158. display: flex;
  159. justify-content: center;
  160. align-items: center;
  161. height: 100%;
  162. font-size: 15px;
  163. color: $font-color-dark;
  164. position: relative;
  165. &.current {
  166. color: $base-color;
  167. &:after {
  168. content: '';
  169. position: absolute;
  170. left: 50%;
  171. bottom: 0;
  172. transform: translateX(-50%);
  173. width: 44px;
  174. height: 0;
  175. border-bottom: 2px solid $base-color;
  176. }
  177. }
  178. }
  179. }
  180. // 列表
  181. .swiper-box {
  182. height: calc(100% - 44px);
  183. padding-top: 10rpx;
  184. .order-item {
  185. padding: 20rpx 30rpx;
  186. line-height: 1.5;
  187. .title-box {
  188. .title {
  189. font-size: $font-lg;
  190. color: $font-color-base;
  191. }
  192. .time {
  193. font-size: $font-base;
  194. color: $font-color-light;
  195. }
  196. }
  197. .money {
  198. color: #fd5b23;
  199. font-size: $font-lg;
  200. }
  201. }
  202. }
  203. .list-scroll-content {
  204. height: 100%;
  205. }
  206. .content {
  207. height: 100%;
  208. .empty-content {
  209. background-color: #ffffff;
  210. }
  211. }
  212. .top-wrapper {
  213. width: 750rpx;
  214. height: 265rpx;
  215. background-image: url(../../static/img/wallertbg.png);
  216. background-size: 100%;
  217. background-position: bottom;
  218. // font-size: ;
  219. color: #FFFFFF;
  220. font-size: 72rpx;
  221. font-family: PingFang SC;
  222. font-weight: bold;
  223. color: #FFFFFF;
  224. line-height: 265rpx;
  225. text-align: center;
  226. }
  227. </style>