scoreAccumulate.vue 5.4 KB

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