添加粉丝关注页面

This commit is contained in:
张成
2025-10-01 01:48:36 +08:00
parent 78d8ec659e
commit a5539bd219
7 changed files with 187 additions and 62 deletions

View File

@@ -2,20 +2,21 @@ import { useState, useEffect } from "react";
import { View, Text, ScrollView } from "@tarojs/components";
import { Avatar } from "@nutui/nutui-react-taro";
import { withAuth, EmptyState } from "@/components";
import noticeService from "@/services/noticeService";
import FollowService from "@/services/followService";
import Taro from "@tarojs/taro";
import "./index.scss";
// 关注项类型定义
interface FollowItem {
id: string;
user_id: string;
id: number;
user_id: number;
user_avatar: string;
user_nickname: string;
user_signature?: string;
city?: string;
ntrp_level?: string;
time: string;
is_mutual: boolean; // 是否互相关注
is_read: number;
}
const NewFollow = () => {
@@ -32,21 +33,20 @@ const NewFollow = () => {
setLoading(true);
try {
const res = await noticeService.getNotificationList({
notification_type: "follow", // 筛选关注类型
});
const res = await FollowService.get_new_fans_list(1, 20);
if (res.code === 0) {
if (res.list) {
// 映射数据
const mappedList = res.data.list.map((item: any) => ({
const mappedList = res.list.map((item: any) => ({
id: item.id,
user_id: item.related_user_id || "",
user_avatar: item.related_user_avatar || "",
user_nickname: item.related_user_nickname || "匿名用户",
user_signature: item.related_user_signature || "",
time: item.created_at,
is_mutual: item.is_mutual_follow || false,
is_read: item.is_read,
user_id: item.id,
user_avatar: item.avatar_url || "",
user_nickname: item.nickname || "匿名用户",
user_signature: item.personal_profile || "",
city: item.city || "",
ntrp_level: item.ntrp_level || "",
time: item.follow_time,
is_mutual: item.is_mutual || false,
}));
setFollowList(mappedList);
@@ -93,8 +93,7 @@ const NewFollow = () => {
}
try {
// TODO: 调用关注接口
// await userService.followUser({ user_id: item.user_id });
await FollowService.follow_back(item.user_id);
Taro.showToast({
title: "关注成功",
@@ -125,7 +124,7 @@ const NewFollow = () => {
};
// 处理点击用户
const handleUserClick = (userId: string) => {
const handleUserClick = (userId: number) => {
Taro.navigateTo({
url: `/user_pages/other/index?user_id=${userId}`,
});