fansList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="container-body">
  3. <view id='topbox2' class="fans x-f desc es-pl-30 es-pr-30 es-pt-24 es-pb-24">
  4. 共<text class="es-ml-10 es-mr-10" style="color: #333333;">{{total||0}}</text>个粉丝
  5. </view>
  6. <mescroll-body :height="height+'px'" @init="mescrollInit" top="0" bottom="0" :down="downOption" @down="downCallback" :up="upOption"
  7. @up="upCallback">
  8. <view>
  9. <listItem type="fans" :isFollow="item.isFollow" :item="item" v-for="item in dataList" :key="item.talentId" @resetData="resetUpScroll"></listItem>
  10. </view>
  11. </mescroll-body>
  12. </view>
  13. </template>
  14. <script>
  15. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  16. import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js";
  17. import listItem from "./listItem.vue"
  18. import { getTalentFansByUserId} from "@/api/expert.js"
  19. export default {
  20. mixins: [MescrollMixin,MescrollMoreItemMixin],
  21. props: {
  22. cataType:Number,
  23. i:Number,
  24. index:Number,
  25. itemData: {
  26. type: Object,
  27. default() {
  28. return { };
  29. }
  30. },
  31. },
  32. components: {
  33. listItem
  34. },
  35. data() {
  36. return {
  37. height: 0,
  38. downOption: {
  39. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  40. },
  41. upOption: {
  42. auto: false, // 不自动加载
  43. page: {
  44. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  45. size: 10 // 每页数据的数量
  46. },
  47. noMoreSize: 10, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  48. textNoMore:"",
  49. toTop:{
  50. width:0,
  51. }
  52. },
  53. keyword:"",
  54. dataList: [], //列表数据
  55. userId:"",
  56. total: 0
  57. }
  58. },
  59. methods: {
  60. initHeight() {
  61. const query = uni.createSelectorQuery().in(this);
  62. query
  63. .select("#topbox2")
  64. .boundingClientRect((data) => {
  65. console.log(JSON.stringify(data))
  66. if(data) {
  67. this.height = uni.getSystemInfoSync().windowHeight - data.height - data.top
  68. console.log(this.height)
  69. }
  70. })
  71. .exec();
  72. },
  73. click(item) {
  74. console.log('item', item);
  75. },
  76. resetUpScroll() {
  77. this.mescroll.resetUpScroll()
  78. },
  79. // /*下拉刷新的回调 */
  80. // downCallback(mescroll) {
  81. // mescroll.resetUpScroll()
  82. // },
  83. /*上拉加载的回调 */
  84. upCallback(page) {
  85. //联网加载数据
  86. var that = this;
  87. var params = {"keyword":this.keyword,talentId:this.userId};
  88. if(!this.userId){
  89. this.mescroll.endByPage(0, 0);
  90. return
  91. }
  92. getTalentFansByUserId(params,page.num).then(res => {
  93. if(res.code==200){
  94. //设置列表数据
  95. if (page.num == 1) {
  96. that.dataList = res.rows;
  97. } else {
  98. that.dataList = that.dataList.concat(res.rows);
  99. }
  100. that.total = res.total
  101. that.mescroll.endBySize(res.rows.length, res.total);
  102. }else{
  103. uni.showToast({
  104. icon:'none',
  105. title: "请求失败",
  106. });
  107. that.dataList = null;
  108. that.mescroll.endErr();
  109. }
  110. });
  111. },
  112. }
  113. }
  114. </script>
  115. <style scoped lang="scss">
  116. .container-body {
  117. position: relative;
  118. background-color: #fff;
  119. font-family: MiSans;
  120. font-weight: 400;
  121. font-size: 28rpx;
  122. color: #333333;
  123. .title {
  124. font-weight: 600;
  125. }
  126. .desc {
  127. font-size: 24rpx;
  128. color: #999999;
  129. }
  130. }
  131. .fans {
  132. border-bottom: 1rpx solid #EEEEEE;
  133. }
  134. </style>