2025-04-25 18:10:54 +08:00
|
|
|
<template>
|
|
|
|
<view class="mpage">
|
|
|
|
<view class="line"></view>
|
|
|
|
<scroll-view
|
|
|
|
scroll-y="true"
|
|
|
|
@scrolltolower="pagingFansList()"
|
|
|
|
>
|
|
|
|
<view
|
|
|
|
class="user-wrapper"
|
|
|
|
v-for="(f, index) in fansList"
|
|
|
|
:key="f.fanId"
|
|
|
|
>
|
|
|
|
<view
|
|
|
|
class="user-info"
|
|
|
|
@click="goTovlogerInfo(f.fanId)"
|
|
|
|
>
|
|
|
|
<image
|
|
|
|
class="face"
|
|
|
|
:src="f.face"
|
|
|
|
/>
|
|
|
|
<text class="user-name">
|
|
|
|
{{ f.nickname }}
|
|
|
|
</text>
|
|
|
|
</view>
|
|
|
|
|
2025-04-12 17:11:06 +08:00
|
|
|
<view v-if="!from">
|
2025-04-25 18:10:54 +08:00
|
|
|
<view
|
|
|
|
v-if="f.bothFriend == 0"
|
|
|
|
class="operator-wrapper"
|
|
|
|
>
|
|
|
|
<text
|
|
|
|
class="operator-words"
|
|
|
|
style="color: #ef274d"
|
2025-05-07 17:45:16 +08:00
|
|
|
@click="followMe(f)"
|
2025-04-25 18:10:54 +08:00
|
|
|
>
|
2025-04-12 17:11:06 +08:00
|
|
|
回粉
|
|
|
|
</text>
|
|
|
|
</view>
|
2025-04-25 18:10:54 +08:00
|
|
|
<view
|
|
|
|
v-if="f.bothFriend == 1"
|
|
|
|
class="operator-wrapper"
|
|
|
|
>
|
|
|
|
<text
|
|
|
|
class="operator-words"
|
|
|
|
style="color: #ffffff"
|
2025-05-07 17:45:16 +08:00
|
|
|
@click="cancelFollow(f)"
|
2025-04-25 18:10:54 +08:00
|
|
|
>
|
2025-04-12 17:11:06 +08:00
|
|
|
互粉
|
|
|
|
</text>
|
|
|
|
</view>
|
2025-04-25 18:10:54 +08:00
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</scroll-view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
let system = uni.getSystemInfoSync();
|
|
|
|
import storage from '@/utils/storage.js'; //缓存
|
|
|
|
import { vlogFansCancel, vlogFansFollow, vlogQueryMyFans } from '@/api/vlog';
|
2025-05-07 17:45:16 +08:00
|
|
|
import { isStrEmpty, clickFeedBack } from '@/utils/tools.js';
|
2025-04-25 18:10:54 +08:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
userId: '',
|
|
|
|
screenHeight: 0,
|
|
|
|
page: 0,
|
|
|
|
totalPage: 0,
|
|
|
|
fansList: [],
|
|
|
|
from: false
|
|
|
|
};
|
|
|
|
},
|
2025-05-07 17:45:16 +08:00
|
|
|
destroyed() {
|
|
|
|
console.log('组件销毁');
|
|
|
|
// 销毁时关闭 BroadcastChannel
|
|
|
|
if (this.channelComment) {
|
|
|
|
this.channelComment.close();
|
|
|
|
}
|
|
|
|
},
|
2025-04-25 18:10:54 +08:00
|
|
|
onLoad(param) {
|
2025-05-07 17:45:16 +08:00
|
|
|
this.channelComment = new BroadcastChannel('comment-counts');
|
2025-04-25 18:10:54 +08:00
|
|
|
if (!isStrEmpty(param.userId)) {
|
|
|
|
this.from = true;
|
|
|
|
this.userId = param.userId;
|
|
|
|
} else {
|
|
|
|
var uinfo = storage.getVlogUserInfo();
|
|
|
|
this.userId = uinfo.id;
|
|
|
|
}
|
|
|
|
this.queryMyFansList(0);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
goTovlogerInfo(vlogerId) {
|
|
|
|
var id = storage.getVlogUserInfo().id;
|
|
|
|
// 是否是当前登录的用户
|
|
|
|
if (id == vlogerId) {
|
|
|
|
uni.switchTab({
|
|
|
|
url: 'me'
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
uni.navigateTo({
|
|
|
|
url: 'vlogerInfo?userPageId=' + vlogerId
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 关注/取关后的list重新状态刷新设置
|
|
|
|
reFreshList(vlogerId, status) {
|
|
|
|
let me = this;
|
|
|
|
let fansList = me.fansList;
|
|
|
|
for (let i = 0; i < fansList.length; i++) {
|
|
|
|
let fan = fansList[i];
|
|
|
|
if (fan.fanId == vlogerId) {
|
|
|
|
fan.bothFriend = status;
|
|
|
|
// fansList.splice(i, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
me.fansList = fansList;
|
|
|
|
},
|
2025-05-07 17:45:16 +08:00
|
|
|
async cancelFollow(item) {
|
|
|
|
clickFeedBack();
|
2025-04-25 18:10:54 +08:00
|
|
|
let me = this;
|
|
|
|
let userId = me.userId;
|
|
|
|
let data = {
|
|
|
|
myId: userId,
|
2025-05-07 17:45:16 +08:00
|
|
|
vlogerId: item.fanId
|
2025-04-25 18:10:54 +08:00
|
|
|
};
|
|
|
|
var result = await vlogFansCancel(data);
|
|
|
|
console.log(result);
|
|
|
|
if (result.data.status == 200) {
|
2025-05-07 17:45:16 +08:00
|
|
|
me.reFreshList(item.fanId, 0);
|
|
|
|
this.channelComment.postMessage({
|
|
|
|
type: 'comment-counts',
|
|
|
|
data: { flag: false, from: 'refresh', vlogerId: item.fanId }
|
|
|
|
});
|
|
|
|
this.channelComment.postMessage({
|
|
|
|
type: 'comment-counts',
|
|
|
|
data: { from: 'initGuanzhu' }
|
|
|
|
});
|
2025-04-25 18:10:54 +08:00
|
|
|
} else {
|
|
|
|
uni.showToast({
|
|
|
|
title: result.data.msg,
|
|
|
|
icon: 'none',
|
|
|
|
duration: 3000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2025-05-07 17:45:16 +08:00
|
|
|
async followMe(item) {
|
|
|
|
clickFeedBack();
|
2025-04-25 18:10:54 +08:00
|
|
|
let me = this;
|
|
|
|
let userId = me.userId;
|
|
|
|
let data = {
|
|
|
|
myId: userId,
|
2025-05-07 17:45:16 +08:00
|
|
|
vlogerId: item.fanId
|
2025-04-25 18:10:54 +08:00
|
|
|
};
|
|
|
|
var result = await vlogFansFollow(data);
|
|
|
|
console.log(result);
|
|
|
|
if (result.data.status == 200) {
|
2025-05-07 17:45:16 +08:00
|
|
|
me.reFreshList(item.fanId, 1);
|
|
|
|
this.channelComment.postMessage({
|
|
|
|
type: 'comment-counts',
|
|
|
|
data: { flag: true, from: 'refresh', vlogerId: item.fanId }
|
|
|
|
});
|
|
|
|
this.channelComment.postMessage({
|
|
|
|
type: 'comment-counts',
|
|
|
|
data: { from: 'initGuanzhu' }
|
|
|
|
});
|
2025-04-25 18:10:54 +08:00
|
|
|
} else {
|
|
|
|
uni.showToast({
|
|
|
|
title: result.data.msg,
|
|
|
|
icon: 'none',
|
|
|
|
duration: 3000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async queryMyFansList(page) {
|
|
|
|
let me = this;
|
|
|
|
page = page + 1;
|
|
|
|
let userId = me.userId;
|
|
|
|
let currentUserId = this.currentUserId;
|
|
|
|
var data = {
|
|
|
|
myId: userId,
|
|
|
|
// vlogerId: userId,
|
|
|
|
// currentUserId: currentUserId,
|
|
|
|
page: page,
|
|
|
|
pageSize: 10
|
|
|
|
};
|
|
|
|
var result = await vlogQueryMyFans(data);
|
|
|
|
console.log(result);
|
|
|
|
if (result.data.status == 200) {
|
|
|
|
let fansList = result.data.data.rows;
|
|
|
|
let totalPage = result.data.data.total;
|
|
|
|
me.fansList = me.fansList.concat(fansList);
|
|
|
|
me.page = page;
|
|
|
|
me.totalPage = totalPage;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// 上滑分页粉丝列表
|
|
|
|
pagingFansList() {
|
|
|
|
if (this.page >= this.totalPage) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.queryMyFansList(this.page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.user-info {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-start;
|
|
|
|
}
|
|
|
|
|
|
|
|
.face {
|
|
|
|
align-items: center;
|
|
|
|
width: 110rpx;
|
|
|
|
height: 110rpx;
|
|
|
|
border-radius: 100rpx;
|
|
|
|
border-width: 2rpx;
|
|
|
|
border-color: #f1f1f1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.user-name {
|
|
|
|
align-items: center;
|
|
|
|
color: #ffffff;
|
|
|
|
font-size: 30rpx;
|
|
|
|
margin-left: 20rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.line {
|
|
|
|
height: 1rpx;
|
|
|
|
background-color: #393a41;
|
|
|
|
width: 750rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.mpage {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
background-color: #181b27;
|
|
|
|
}
|
|
|
|
|
|
|
|
.user-wrapper {
|
|
|
|
padding-left: 30rpx;
|
|
|
|
padding-right: 30rpx;
|
|
|
|
width: 750rpx;
|
|
|
|
height: 120rpx;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 20rpx;
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.operator-wrapper {
|
|
|
|
width: 140rpx;
|
|
|
|
height: 60rpx;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: center;
|
|
|
|
background-color: #ef274d;
|
|
|
|
border-radius: 20rpx;
|
|
|
|
align-items: center;
|
|
|
|
border-width: 2rpx;
|
|
|
|
border-color: #ef274d;
|
|
|
|
background-color: #181b27;
|
|
|
|
}
|
|
|
|
|
|
|
|
.operator-words {
|
|
|
|
align-items: center;
|
|
|
|
font-size: 28rpx;
|
|
|
|
}
|
|
|
|
</style>
|