sz.vue 5.0 KB

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