follow.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="page">
  3. <PageHeader title="" style="border: 1px solid #F2F6F2;">
  4. <template slot="center">
  5. <view class="tabs">
  6. <view class="tab" :class="{ active: activeTab === 'follow' }" @click="switchTab('follow')">关注</view>
  7. <view class="tab" :class="{ active: activeTab === 'fans' }" @click="switchTab('fans')">粉丝</view>
  8. </view>
  9. </template>
  10. </PageHeader>
  11. <view style="height: 90rpx;"></view>
  12. <view class="follow-list">
  13. <view class="follow-item" v-for="(item, index) in currentList" :key="index">
  14. <CircleAvatar class="avator" :src="item.avator"></CircleAvatar>
  15. <view class="info">
  16. <view class="top-box">
  17. <view class="name">{{ item.name }}</view>
  18. <image src="../../static/icon/wd_icon_nan.png" mode="widthFix" v-if="item.sex_id == 1" />
  19. <image src="../../static/icon/wd_icon_nv.png" mode="widthFix" v-else-if="item.sex_id == 2" />
  20. <view class="level">Lv{{ item.my_level }}</view>
  21. </view>
  22. <view class="desc">{{ item.description }}</view>
  23. </view>
  24. <view :class=" item.isFollowing ? 'unfollow-btn' : 'unfollow-btn active' " @click="toggleFollow(item)">
  25. <image src="../../static/me/wd_icon_guanzhu.png"></image>
  26. {{ item.isFollowing ? '取消关注' : '关注' }}
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import PageHeader from '@/components/PageHeader/PageHeader.vue';
  34. import CircleAvatar from "@/components/CircleAvatar/CircleAvatar.vue";
  35. export default {
  36. components: {
  37. PageHeader,
  38. CircleAvatar
  39. },
  40. data() {
  41. return {
  42. activeTab: 'follow', // 当前激活的标签
  43. followList: [
  44. {
  45. avatar: 'http://e.zhichao.art/upload/2025-03/a6e7f16b074da870527bf49b3c337555_new.png',
  46. name: '冷落',
  47. description: 'AI设计师',
  48. isFollowing: true,
  49. sex_id: 1,
  50. my_level: 10
  51. },
  52. {
  53. avatar: 'http://e.zhichao.art/upload/2025-03/a6e7f16b074da870527bf49b3c337555_new.png',
  54. name: '雾里',
  55. description: '感谢你的关注,远方的陌生人',
  56. isFollowing: true,
  57. sex_id: 2,
  58. my_level: 210
  59. }
  60. ],
  61. fansList: [
  62. {
  63. avatar: 'http://e.zhichao.art/upload/2025-03/a6e7f16b074da870527bf49b3c337555_new.png',
  64. name: '小明',
  65. description: '热爱生活的人',
  66. isFollowing: false,
  67. sex_id: 1,
  68. my_level: 20
  69. },
  70. {
  71. avatar: 'http://e.zhichao.art/upload/2025-03/a6e7f16b074da870527bf49b3c337555_new.png',
  72. name: '阳光',
  73. description: '摄影师',
  74. isFollowing: true,
  75. sex_id: 2,
  76. my_level: 30
  77. }
  78. ]
  79. }
  80. },
  81. computed: {
  82. // 根据当前标签返回对应的列表数据
  83. currentList() {
  84. return this.activeTab === 'follow' ? this.followList : this.fansList;
  85. }
  86. },
  87. methods: {
  88. // 切换标签
  89. switchTab(tab) {
  90. this.activeTab = tab;
  91. },
  92. toggleFollow(item) {
  93. item.isFollowing = !item.isFollowing;
  94. // 这里可以添加调用后端API的逻辑
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped lang="scss">
  100. @import 'follow.scss';
  101. </style>