followList.vue 4.0 KB

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