2025-04-21 17:35:54 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="wrap">
|
|
|
|
|
<view v-if="flowList.length">
|
|
|
|
|
<view
|
|
|
|
|
class="flex-box"
|
|
|
|
|
v-for="i in flowList"
|
|
|
|
|
v-if="i.id != id"
|
|
|
|
|
:key="i.id"
|
|
|
|
|
>
|
|
|
|
|
<u-image
|
2025-05-07 17:45:16 +08:00
|
|
|
|
@click="tozuozhe(i.id)"
|
2025-04-21 17:35:54 +08:00
|
|
|
|
:src="i.face"
|
|
|
|
|
class="flxleft"
|
|
|
|
|
width="120"
|
|
|
|
|
height="120"
|
|
|
|
|
shape="circle"
|
|
|
|
|
loading-icon="/static/missing-face.png"
|
|
|
|
|
error-icon="/static/missing-face.png"
|
|
|
|
|
style="display: flex; align-items: center"
|
|
|
|
|
></u-image>
|
|
|
|
|
|
2025-05-07 17:45:16 +08:00
|
|
|
|
<view
|
|
|
|
|
class="flxcenter"
|
|
|
|
|
@click="tozuozhe(i.id)"
|
|
|
|
|
>
|
2025-04-21 17:35:54 +08:00
|
|
|
|
<view class="nkname">{{ i.nickname }}</view>
|
2025-05-07 17:45:16 +08:00
|
|
|
|
<view
|
|
|
|
|
class="fans"
|
|
|
|
|
v-if="i.myFansCounts"
|
|
|
|
|
>
|
|
|
|
|
粉丝:{{ getGraceNumber(i.myFansCounts || 0) }}
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="fans"
|
|
|
|
|
v-if="i.totalLikeMeCounts"
|
|
|
|
|
>
|
|
|
|
|
获赞:{{ getGraceNumber(i.totalLikeMeCounts || 0) }}
|
|
|
|
|
</view>
|
2025-04-21 17:35:54 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="flxright">
|
|
|
|
|
<u-button
|
|
|
|
|
type="error"
|
|
|
|
|
@click="follow(i)"
|
|
|
|
|
v-if="i.followStatus == '未关注'"
|
|
|
|
|
>
|
|
|
|
|
关注
|
|
|
|
|
</u-button>
|
|
|
|
|
<u-button
|
|
|
|
|
v-else
|
|
|
|
|
type="plain"
|
|
|
|
|
@click="cancelFollow(i)"
|
|
|
|
|
>
|
|
|
|
|
{{ i.followStatus }}
|
|
|
|
|
</u-button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<u-loadmore
|
|
|
|
|
style="padding: 10px 0"
|
|
|
|
|
bg-color="#f8f8f8"
|
|
|
|
|
:status="loadStatus"
|
|
|
|
|
@loadmore="getData"
|
|
|
|
|
></u-loadmore>
|
|
|
|
|
</view>
|
|
|
|
|
<u-empty
|
|
|
|
|
v-else
|
|
|
|
|
style="margin-top: 20%"
|
|
|
|
|
text="暂无数据"
|
|
|
|
|
mode="data"
|
|
|
|
|
></u-empty>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import storage from '@/utils/storage.js'; //缓存
|
2025-05-07 17:45:16 +08:00
|
|
|
|
import { vlogSearchUser, vlogFansFollow, vlogFansCancel, vlogQueryDoIFollowVloger } from '@/api/vlog';
|
|
|
|
|
import { clickFeedBack, graceNumber } from '@/utils/tools.js';
|
2025-04-21 17:35:54 +08:00
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
keywords: {
|
|
|
|
|
default: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
flag: 2, // 在tabs中的索引
|
|
|
|
|
loadStatus: 'loadmore',
|
|
|
|
|
flowList: [],
|
|
|
|
|
page: 0,
|
|
|
|
|
totalPage: 0,
|
|
|
|
|
search: '',
|
2025-05-07 17:45:16 +08:00
|
|
|
|
id: '',
|
|
|
|
|
channelComment: null
|
2025-04-21 17:35:54 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
2025-05-07 17:45:16 +08:00
|
|
|
|
destroyed() {
|
|
|
|
|
console.log('查询用户组件销毁');
|
|
|
|
|
// 销毁时关闭 BroadcastChannel
|
|
|
|
|
if (this.channelComment) {
|
|
|
|
|
this.channelComment.close();
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-04-21 17:35:54 +08:00
|
|
|
|
created() {
|
|
|
|
|
this.initData();
|
2025-05-07 17:45:16 +08:00
|
|
|
|
this.channelComment = new BroadcastChannel('comment-counts');
|
2025-04-21 17:35:54 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2025-05-07 17:45:16 +08:00
|
|
|
|
// 把超过1000或10000的数字调整, 比如1.3k/6.8w
|
|
|
|
|
getGraceNumber(num) {
|
|
|
|
|
return graceNumber(num);
|
|
|
|
|
},
|
|
|
|
|
tozuozhe(userId) {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/me/vlogerInfo?userPageId=' + userId
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-04-21 17:35:54 +08:00
|
|
|
|
async getData() {
|
|
|
|
|
if (this.loadStatus !== 'loadmore') return;
|
|
|
|
|
var info = storage.getVlogUserInfo();
|
|
|
|
|
var id = '';
|
|
|
|
|
if (info != null) {
|
|
|
|
|
id = info.id;
|
|
|
|
|
}
|
|
|
|
|
this.id = id;
|
|
|
|
|
this.loadStatus = 'loading';
|
|
|
|
|
this.page += 1;
|
|
|
|
|
console.log('加载用户数据');
|
|
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
|
id: id,
|
|
|
|
|
nickname: this.search,
|
|
|
|
|
page: this.page,
|
|
|
|
|
pageSize: 10
|
|
|
|
|
};
|
|
|
|
|
console.log(params);
|
|
|
|
|
var result = await vlogSearchUser(params);
|
|
|
|
|
console.log(result);
|
|
|
|
|
if (result.data.status == 200) {
|
|
|
|
|
var data = result.data.data || [];
|
|
|
|
|
if (!data.length) {
|
|
|
|
|
this.loadStatus = 'nomore';
|
|
|
|
|
} else {
|
|
|
|
|
if (data.length < 10) {
|
|
|
|
|
this.loadStatus = 'nomore';
|
|
|
|
|
} else {
|
|
|
|
|
this.loadStatus = 'loadmore';
|
|
|
|
|
}
|
|
|
|
|
data.forEach((i) => {
|
|
|
|
|
i.doIflow = false;
|
2025-04-30 14:28:07 +08:00
|
|
|
|
if (i.followStatus == null) {
|
|
|
|
|
// 处理未登录时的状态
|
|
|
|
|
i.followStatus = '未关注';
|
|
|
|
|
}
|
2025-04-21 17:35:54 +08:00
|
|
|
|
this.flowList.push(i);
|
|
|
|
|
});
|
|
|
|
|
// this.flowList.push(...data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
initData() {
|
|
|
|
|
this.search = this.keywords;
|
|
|
|
|
this.page = 0;
|
|
|
|
|
this.totalPage = 0;
|
|
|
|
|
this.flowList = [];
|
|
|
|
|
this.loadStatus = 'loadmore';
|
|
|
|
|
console.log('初始化用户数据');
|
|
|
|
|
this.getData();
|
|
|
|
|
},
|
|
|
|
|
async follow(item) {
|
2025-05-07 17:45:16 +08:00
|
|
|
|
clickFeedBack();
|
2025-04-21 17:35:54 +08:00
|
|
|
|
let userInfo = storage.getVlogUserInfo();
|
|
|
|
|
if (userInfo == null) {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/passport/login',
|
|
|
|
|
animationType: 'slide-in-bottom'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let data = {
|
|
|
|
|
myId: userInfo.id,
|
|
|
|
|
vlogerId: item.id
|
|
|
|
|
};
|
|
|
|
|
var result = await vlogFansFollow(data);
|
|
|
|
|
console.log(result);
|
|
|
|
|
if (result.data.status == 200) {
|
2025-05-07 17:45:16 +08:00
|
|
|
|
var bothFrd = await vlogQueryDoIFollowVloger({ myId: item.id, vlogerId: userInfo.id });
|
|
|
|
|
if (bothFrd.data.data) {
|
|
|
|
|
item.followStatus = '互相关注';
|
|
|
|
|
} else {
|
|
|
|
|
item.followStatus = '已关注';
|
|
|
|
|
}
|
|
|
|
|
console.log(bothFrd);
|
|
|
|
|
this.channelComment.postMessage({
|
|
|
|
|
type: 'comment-counts',
|
|
|
|
|
data: { flag: true, from: 'refresh', vlogerId: item.id, vlogId: item.vlogId }
|
|
|
|
|
});
|
|
|
|
|
item.myFansCounts++;
|
2025-04-21 17:35:54 +08:00
|
|
|
|
} else {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: result.data.msg,
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 3000
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async cancelFollow(item) {
|
2025-05-07 17:45:16 +08:00
|
|
|
|
clickFeedBack();
|
2025-04-21 17:35:54 +08:00
|
|
|
|
let userInfo = storage.getVlogUserInfo();
|
|
|
|
|
if (userInfo == null) {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/passport/login',
|
|
|
|
|
animationType: 'slide-in-bottom'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let data = {
|
|
|
|
|
myId: userInfo.id,
|
|
|
|
|
vlogerId: item.id
|
|
|
|
|
};
|
|
|
|
|
var result = await vlogFansCancel(data);
|
|
|
|
|
console.log(result);
|
|
|
|
|
if (result.data.status == 200) {
|
2025-05-07 17:45:16 +08:00
|
|
|
|
item.followStatus = '未关注';
|
|
|
|
|
this.channelComment.postMessage({
|
|
|
|
|
type: 'comment-counts',
|
|
|
|
|
data: { flag: false, from: 'refresh', vlogerId: item.id, vlogId: item.vlogId }
|
|
|
|
|
});
|
|
|
|
|
item.myFansCounts--;
|
2025-04-21 17:35:54 +08:00
|
|
|
|
} else {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: result.data.msg,
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 3000
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.flex-box {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-bottom: 10rpx;
|
|
|
|
|
padding: 10rpx 20rpx;
|
|
|
|
|
}
|
|
|
|
|
.flxleft {
|
|
|
|
|
width: 120rpx;
|
|
|
|
|
height: 120rpx;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
}
|
|
|
|
|
.flxcenter {
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
.nkname {
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
-webkit-line-clamp: 1;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
font-weight: 500;
|
2025-05-07 17:45:16 +08:00
|
|
|
|
font-size: 32rpx;
|
2025-04-21 17:35:54 +08:00
|
|
|
|
}
|
|
|
|
|
.fans {
|
2025-05-07 17:45:16 +08:00
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
color: #000;
|
2025-04-21 17:35:54 +08:00
|
|
|
|
}
|
|
|
|
|
.flxright {
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|