"use client" import { useState, useEffect } from "react" import { useRouter } from "next/navigation" import { Card } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { ChevronLeft, Search, Filter, RefreshCw, Plus } from "lucide-react" import { Badge } from "@/components/ui/badge" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Pagination, PaginationContent, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, } from "@/components/ui/pagination" interface TrafficUser { id: string avatar: string nickname: string wechatId: string phone: string region: string note: string status: "pending" | "added" | "failed" addTime: string source: string tags: string[] } export default function ChannelTrafficPage({ params, searchParams, }: { params: { channel: string } searchParams: { type?: string } }) { const router = useRouter() const [users, setUsers] = useState([]) const [searchQuery, setSearchQuery] = useState("") const [statusFilter, setStatusFilter] = useState(searchParams.type || "all") const [currentPage, setCurrentPage] = useState(1) const itemsPerPage = 10 const getChannelName = (channel: string) => { const channelMap: Record = { douyin: "抖音", kuaishou: "快手", xiaohongshu: "小红书", weibo: "微博", } return channelMap[channel] || channel } const channelName = getChannelName(params.channel) useEffect(() => { const fetchUsers = async () => { // 模拟API调用 const mockUsers = Array.from({ length: 50 }, (_, i) => ({ id: `user-${i + 1}`, avatar: "/placeholder.svg?height=40&width=40", nickname: `用户${i + 1}`, wechatId: `wxid_${Math.random().toString(36).substr(2, 8)}`, phone: `1${["3", "5", "7", "8", "9"][Math.floor(Math.random() * 5)]}${Array.from({ length: 9 }, () => Math.floor(Math.random() * 10), ).join("")}`, region: ["广东", "浙江", "江苏", "北京", "上海"][Math.floor(Math.random() * 5)], note: ["感兴趣", "需要了解", "想购买", "咨询价格"][Math.floor(Math.random() * 4)], status: searchParams.type === "added" ? "added" : ["pending", "added", "failed"][Math.floor(Math.random() * 3)], addTime: new Date(Date.now() - Math.random() * 86400000 * 7).toLocaleString(), source: params.channel, tags: ["意向客户", "高活跃度", "新用户"][Math.floor(Math.random() * 3)].split(" "), })) setUsers(mockUsers) } fetchUsers() }, [params.channel, searchParams.type]) const filteredUsers = users.filter((user) => { const matchesSearch = user.nickname.toLowerCase().includes(searchQuery.toLowerCase()) || user.wechatId.toLowerCase().includes(searchQuery.toLowerCase()) || user.phone.includes(searchQuery) const matchesStatus = statusFilter === "all" || user.status === statusFilter return matchesSearch && matchesStatus }) const paginatedUsers = filteredUsers.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage) const totalPages = Math.ceil(filteredUsers.length / itemsPerPage) return (

{channelName}流量池

setSearchQuery(e.target.value)} className="pl-9" />
{paginatedUsers.map((user) => (
{user.nickname}
{user.nickname}
{user.status === "added" ? "已添加" : user.status === "failed" ? "已失败" : "待处理"}
微信号: {user.wechatId}
手机号: {user.phone}
地区: {user.region}
添加时间: {user.addTime}
{user.tags.map((tag, index) => ( {tag} ))}
))}
{totalPages > 1 && ( { e.preventDefault() setCurrentPage((prev) => Math.max(1, prev - 1)) }} /> {Array.from({ length: totalPages }, (_, i) => i + 1).map((page) => ( { e.preventDefault() setCurrentPage(page) }} > {page} ))} { e.preventDefault() setCurrentPage((prev) => Math.min(totalPages, prev + 1)) }} /> )}
) }