绿满眶商城微信小程序-uniapp
peng
2025-07-09 c22e91296d532873b70cb51bf5510bf7738f3f1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template>
  <view class="container">
 
    <view class="user-list">
      <view class="user-item" v-for="(user, index) in followList" :key="user.id">
        <image class="avatar" :src="user.subscribeUserAvatar" @click="jumpToHome(user.subscribeUserId)" mode="aspectFill"></image>
        <text class="nickname">{{user.subscribeUserNickname}}</text>
        <button class="unfollow-btn" @click="handleUnfollow(user.subscribeUserId)">取消关注</button>
      </view>
      
      <view v-if="followList.length === 0" class="empty-tip">
        <text>您还没有关注任何用户</text>
      </view>
    </view>
  </view>
</template>
 
<script>
    import {mySubscribePage} from "@/api/user.js"
    import {unSubscribe} from "@/api/video.js"
export default {
  data() {
    return {
      followList: [],
      query: {
          pageNumber: 1,
          pageSize: 10
      }
    }
  },
  onPullDownRefresh() {
      this.query.pageNumber = 1
    this.getFollowList()
  },
  onLoad() {
    // 页面加载时获取关注列表
    this.getFollowList();
  },
  methods: {
    // 获取关注列表
    getFollowList() {
      mySubscribePage(this.query).then(res => {
          this.followList = res.data.data
      })
    },
    // 取消关注
    handleUnfollow(userId) {
      unSubscribe(userId).then(res => {
          this.getFollowList()
      })
    },
    // 跳转TA的主页
    jumpToHome(authorId) {
        uni.navigateTo({
            url: `/pages/video/home-page?authorId=${authorId}`
        })
    }
  }
}
</script>
 
<style lang="scss">
.container {
  padding: 20rpx;
  background-color: #f7f7f7;
  min-height: 100vh;
}
 
.header {
  padding: 30rpx 0;
  text-align: center;
  
  .title {
    font-size: 36rpx;
    font-weight: bold;
    color: #333;
  }
}
 
.user-list {
  background-color: #fff;
  border-radius: 12rpx;
  overflow: hidden;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  
  .user-item {
    display: flex;
    align-items: center;
    padding: 20rpx 30rpx;
    border-bottom: 1rpx solid #f0f0f0;
    
    &:last-child {
      border-bottom: none;
    }
  }
  
  .avatar {
    width: 80rpx;
    height: 80rpx;
    border-radius: 50%;
    margin-right: 20rpx;
  }
  
  .nickname {
    flex: 1;
    font-size: 32rpx;
    color: #333;
  }
  
  .unfollow-btn {
    margin: 0;
    padding: 0 20rpx;
    height: 60rpx;
    line-height: 60rpx;
    font-size: 26rpx;
    color: #666;
    background-color: #f5f5f5;
    border-radius: 30rpx;
    
    &::after {
      border: none;
    }
  }
  
  .empty-tip {
    padding: 40rpx 0;
    text-align: center;
    font-size: 28rpx;
    color: #999;
  }
}
</style>