myfans.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="content">
  3. <image class="banner" src="@/static/user/myfans/banner.png" mode="widthFix"></image>
  4. <view class="tabItem flex">
  5. <view class="list" :class="{action:acTab==0}" @click="tabChange(0)">
  6. 我的好友
  7. </view>
  8. <view class="list" :class="{action:acTab==1}" @click="tabChange(1)">
  9. 间接好友
  10. </view>
  11. <view class="list" :class="{action:acTab==2}" @click="tabChange(2)">
  12. 其他好友
  13. </view>
  14. </view>
  15. <scroll-view scroll-y="true" class="swiper-box" :style="{'height':height}" @scrolltolower="getMyfans()">
  16. <view class="fans-list-val flex" v-for="(item,index) in itemList[acTab].list"
  17. :style="{'background':index%2 ==0 ? '#F9F9F9':'#fff'}">
  18. <view class="list-item clamp">
  19. {{item.real_name||item.nickname}}
  20. </view>
  21. <view class="list-item">
  22. {{item.uid}}
  23. </view>
  24. <view class="list-item">
  25. {{item.money}}
  26. </view>
  27. <view class="list-item">
  28. {{item.count}}
  29. </view>
  30. </view>
  31. <uni-load-more :status="itemList[acTab].loadingType"></uni-load-more>
  32. </scroll-view>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. getMyfans
  38. } from '@/api/user.js'
  39. export default {
  40. data() {
  41. return {
  42. // 选中的对象
  43. acTab:0,
  44. height: '',
  45. itemList: [{
  46. list: [{
  47. }],
  48. page: 1,
  49. limit: 10,
  50. loadingType: 'more',
  51. load:false
  52. }, {
  53. list: [],
  54. page: 1,
  55. limit: 10,
  56. loadingType: 'more',
  57. load:false
  58. },{
  59. list: [],
  60. page: 1,
  61. limit: 10,
  62. loadingType: 'more',
  63. load:false
  64. }]
  65. }
  66. },
  67. onLoad() {
  68. this.getMyfans();
  69. },
  70. onReady(res) {
  71. var _this = this;
  72. uni.getSystemInfo({
  73. success: resu => {
  74. const query = uni.createSelectorQuery();
  75. query.select('.swiper-box').boundingClientRect();
  76. query.exec(function(res) {
  77. // console.log(res, 'ddddddddddddd');
  78. _this.height = resu.windowHeight - res[0].top + 'px';
  79. // console.log('打印页面的剩余高度', _this.height);
  80. });
  81. },
  82. fail: res => {}
  83. });
  84. },
  85. methods: {
  86. // 切换
  87. tabChange(index){
  88. this.acTab=index;
  89. if(!this.itemList(index).load){
  90. this.getMyfans();
  91. }
  92. },
  93. getMyfans() {
  94. let that = this
  95. let obj = that.itemList[that.acTab];
  96. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  97. return
  98. }
  99. obj.loadingType = 'loading'
  100. getMyfans({
  101. page: obj.page,
  102. limit: obj.limit
  103. }).then(res => {
  104. console.log(res)
  105. let ar = res.data.user.map((item) => {
  106. if (item.real_name.length > 2) {
  107. let str = item.real_name.slice(1, item.real_name.length - 1);
  108. let str2 = str.replace(/.*/g, '*');
  109. item.real_name = item.real_name.slice(0, 1) + str2 + item.real_name.slice(item.real_name.length - 1);
  110. } else if (item.real_name.length == 2) {
  111. item.real_name = item.real_name.slice(0, 1) + "*";
  112. }
  113. return item
  114. })
  115. obj.list = obj.list.concat(res.data.user)
  116. obj.page++
  117. if(!obj.load){
  118. obj.load = true;
  119. }
  120. if (res.data.user.length == obj.limit) {
  121. obj.loadingType = 'more'
  122. } else {
  123. obj.loadingType = 'noMore'
  124. }
  125. })
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. page {
  132. background-color: #FFF;
  133. height: 100%;
  134. }
  135. .banner {
  136. width: 750rpx;
  137. }
  138. .content {
  139. // background-color: #f3f5f4;
  140. }
  141. .fans-list-val {
  142. width: 710rpx;
  143. height: 100rpx;
  144. margin: auto;
  145. text-align: center;
  146. font-size: 30rpx;
  147. font-weight: bold;
  148. color: #0C1732;
  149. .list-item {
  150. width: 25%;
  151. flex-shrink: 0;
  152. }
  153. }
  154. .tabItem{
  155. font-weight: bold;
  156. font-size: 31rpx;
  157. color: #FFFFFF;
  158. margin-top: -40rpx;
  159. .list{
  160. background: rgba(51, 51, 51, .44s);
  161. border-radius: 20rpx 20rpx 0px 0px;
  162. padding: 30rpx;
  163. width: 240rpx;
  164. text-align: center;
  165. flex-grow: 0;
  166. &.action{
  167. background-color:rgba(51, 51, 51, 1) ;
  168. }
  169. }
  170. }
  171. </style>