sz.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="getList()">
  9. <!-- 空白页 -->
  10. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  13. <view class="title-box">
  14. <view class="title">
  15. <text>{{ item.title }}</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>
  30. </template>
  31. <script>
  32. import empty from '@/components/empty';
  33. import { spreadCommission,getIntegralList } from '@/api/wallet.js';
  34. export default {
  35. components: {
  36. empty
  37. },
  38. data() {
  39. return {
  40. maxheight: '',
  41. tabCurrentIndex: 0,
  42. navList: [
  43. {
  44. loaded: false,
  45. state: 1,
  46. text: '收入',
  47. loadingType: 'more',
  48. orderList: [],
  49. page: 1, //当前页面
  50. limit: 10 //每次信息条数
  51. },
  52. {
  53. loaded: false,
  54. state: 0,
  55. text: '支出',
  56. loadingType: 'more',
  57. orderList: [],
  58. page: 1, //当前页面
  59. limit: 10 //每次信息条数
  60. }
  61. ],
  62. type: 0,//1-复投积分 2-佣金 3-分红额度 4-消费积分
  63. }
  64. },
  65. onLoad(opt) {
  66. this.type = opt.type
  67. },
  68. onShow() {
  69. this.getList()
  70. },
  71. onReady(res) {
  72. var _this = this;
  73. uni.getSystemInfo({
  74. success: resu => {
  75. const query = uni.createSelectorQuery();
  76. query.select('.swiper-box').boundingClientRect();
  77. query.exec(function(res) {
  78. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  79. console.log('打印页面的剩余高度', _this.maxheight);
  80. });
  81. },
  82. fail: res => {}
  83. });
  84. },
  85. methods:{
  86. //顶部tab点击
  87. tabClick(index) {
  88. this.tabCurrentIndex = index;
  89. },
  90. changeTab(res) {
  91. console.log(res);
  92. let that = this
  93. that.tabCurrentIndex = res.detail.current
  94. that.getList('tab')
  95. },
  96. getList(type) {
  97. let that = this
  98. let item = that.navList[that.tabCurrentIndex]
  99. let status = 0
  100. let qdata = {
  101. page: item.page,
  102. limit: item.limit,
  103. pm: item.state
  104. }
  105. if(type == 'tab' && item.loaded) {
  106. return
  107. }
  108. if(item.loadingType == 'noMore' || item.loadingType == 'loading') {
  109. return
  110. }
  111. item.loadingType = 'loading'
  112. getIntegralList(qdata).then(res => {
  113. // console.log(res)
  114. let arr = res.data
  115. item.orderList = item.orderList.concat(arr)
  116. if(item.limit == arr.length) {
  117. item.loadingType = 'more'
  118. }else {
  119. item.loadingType = 'noMore'
  120. }
  121. item.loaded = true
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .navbar {
  129. display: flex;
  130. height: 40px;
  131. padding: 0 5px;
  132. background: #fff;
  133. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  134. position: relative;
  135. z-index: 10;
  136. .nav-item {
  137. flex: 1;
  138. display: flex;
  139. justify-content: center;
  140. align-items: center;
  141. height: 100%;
  142. font-size: 15px;
  143. color: $font-color-dark;
  144. position: relative;
  145. &.current {
  146. color: #000;
  147. font-weight: bold;
  148. &:after {
  149. content: '';
  150. position: absolute;
  151. left: 50%;
  152. bottom: 0;
  153. transform: translateX(-50%);
  154. width: 44px;
  155. height: 0;
  156. border-bottom: 2px solid #FF4C4C;
  157. }
  158. }
  159. }
  160. }
  161. .swiper-box {
  162. .order-item {
  163. padding: 20rpx 30rpx;
  164. line-height: 1.5;
  165. .title-box {
  166. .title {
  167. font-size: $font-lg;
  168. color: $font-color-base;
  169. }
  170. .time {
  171. font-size: $font-base;
  172. color: $font-color-light;
  173. }
  174. }
  175. .money {
  176. color: rgba(239, 58, 85, 1);
  177. font-size: $font-lg;
  178. }
  179. }
  180. }
  181. .list-scroll-content {
  182. background-color: #ffffff;
  183. height: 100%;
  184. }
  185. </style>