添加红点

This commit is contained in:
张成
2025-11-21 08:42:58 +08:00
parent 35b9d07a91
commit fe523ac2bc
10 changed files with 814 additions and 25 deletions

View File

@@ -3,6 +3,7 @@ import { View, Text, ScrollView, Image } from "@tarojs/components";
import { withAuth, EmptyState, GeneralNavbar } from "@/components";
import { useGlobalState } from "@/store/global";
import FollowService from "@/services/followService";
import messageService from "@/services/messageService";
import { formatShortRelativeTime } from "@/utils/timeUtils";
import Taro from "@tarojs/taro";
import "./index.scss";
@@ -34,11 +35,11 @@ const NewFollow = () => {
// 获取新增关注列表
const getFollowList = async () => {
if (loading) return;
setLoading(true);
try {
const res = await FollowService.get_new_fans_list(1, 20);
if (res.list && res.list.length > 0) {
// 映射数据
const mappedList = res.list.map((item: any) => ({
@@ -52,8 +53,20 @@ const NewFollow = () => {
time: item.follow_time,
is_mutual: item.is_mutual || false,
}));
setFollowList(mappedList);
// 获取未读关注ID并标记已读
const unreadFanIds = res.list
.filter((item: any) => item.is_read === 0)
.map((item: any) => item.id);
if (unreadFanIds.length > 0) {
// 使用统一接口标记已读
messageService.markAsRead('follow', unreadFanIds).catch(e => {
console.error("标记关注已读失败:", e);
});
}
} else {
// 如果没有数据,设置为空数组以显示空状态
setFollowList([]);