attention.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="attention">
  3. <uv-tabs :list="tabList" @click="clickTab" :scrollable="false"></uv-tabs>
  4. <mescroll-body top="120" bottom="40" @init="mescrollInit" @down="downCallback" @up="upCallback" :option="{}">
  5. <view class="fans-list" v-if="type === 1">
  6. <view class="fans-item" v-for="(item,index) in list" :key="item.id"
  7. @click="$navigateTo('/pages/person/person?userId='+item.userId)">
  8. <image class="fans-avatar" :src="item.fansUserPortrait" mode="">
  9. </image>
  10. <view class="fans-content">
  11. <view class="fans-name">{{item.fansUserName}}</view>
  12. <view class="fans-organization">{{item.date}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="house-list" v-else-if="type === 2">
  17. <house-item v-for="(item,index) in list" :house="item" :key="item.id"></house-item>
  18. </view>
  19. </mescroll-body>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. getFansAttentionListByPage
  25. } from '@/request/api/my.js'
  26. import {
  27. getCollectionHouseListByPage
  28. } from '@/request/api/house.js'
  29. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  30. import houseItem from "@/components/house/houseItem.vue";
  31. export default {
  32. mixins: [MescrollMixin], // 使用mixin
  33. data() {
  34. return {
  35. list: [],
  36. tabList: [{
  37. id: 1,
  38. name: '关注用户',
  39. }, {
  40. id: 2,
  41. name: '关注房源',
  42. }],
  43. type: 1
  44. }
  45. },
  46. onLoad() {
  47. },
  48. methods: {
  49. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  50. upCallback(page) {
  51. if (this.type === 1) {
  52. getFansAttentionListByPage(page.num, 10).then(res => {
  53. if (res.code === 200) {
  54. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  55. if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
  56. let data = res.data.dataList;
  57. this.list = this.list.concat(data); //追加新数据
  58. } else {
  59. this.mescroll.endErr();
  60. }
  61. }).catch(() => {
  62. //联网失败, 结束加载
  63. this.mescroll.endErr();
  64. })
  65. } else {
  66. getCollectionHouseListByPage(page.num, 10).then(res => {
  67. if (res.code === 200) {
  68. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  69. if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
  70. let data = res.data.dataList;
  71. this.list = this.list.concat(data); //追加新数据
  72. } else {
  73. this.mescroll.endErr();
  74. }
  75. }).catch(() => {
  76. //联网失败, 结束加载
  77. this.mescroll.endErr();
  78. })
  79. }
  80. },
  81. clickTab(item) {
  82. this.type = item.id;
  83. this.list = [];
  84. this.mescroll.resetUpScroll();
  85. }
  86. },
  87. components: {
  88. houseItem
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. .attention {
  94. .uv-tabs {
  95. position: fixed;
  96. top: 0;
  97. width: 100%;
  98. background: #ffffff;
  99. border-top: 2rpx solid $uni-border-1;
  100. z-index: 99999;
  101. }
  102. .house-list {
  103. padding: 0 30rpx;
  104. }
  105. }
  106. .fans-list {
  107. padding: 0 30rpx;
  108. box-sizing: border-box;
  109. .fans-item {
  110. height: 140rpx;
  111. background-color: #ffffff;
  112. border-radius: 8px;
  113. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
  114. display: flex;
  115. align-items: center;
  116. padding: 0 30rpx;
  117. margin-bottom: 20rpx;
  118. }
  119. .fans-avatar {
  120. width: 100rpx;
  121. height: 100rpx;
  122. border-radius: 100rpx;
  123. }
  124. .fans-content {
  125. flex: 1;
  126. width: 0;
  127. margin-left: 20rpx;
  128. }
  129. .fans-name {
  130. font-size: 32rpx;
  131. }
  132. .fans-organization {
  133. color: $uni-secondary-color;
  134. font-weight: 300;
  135. margin-top: 4rpx;
  136. font-size: 24rpx;
  137. }
  138. .fans-icon {
  139. width: 80rpx;
  140. height: 80rpx;
  141. border-radius: 50%;
  142. background: $uni-primary;
  143. text-align: center;
  144. line-height: 80rpx;
  145. }
  146. }
  147. </style>