scoreAccumulate.vue 5.7 KB

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