"use client" import { useState } from "react" import { ChevronLeft, Copy, Link, HelpCircle } from "lucide-react" import { Button } from "@/components/ui/button" import { useRouter } from "next/navigation" import { toast } from "@/components/ui/use-toast" import { ScenarioAcquisitionCard } from "@/app/components/acquisition/ScenarioAcquisitionCard" import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, } from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip" // 获取渠道中文名称 const getChannelName = (channel: string) => { const channelMap: Record = { douyin: "抖音", kuaishou: "快手", xiaohongshu: "小红书", weibo: "微博", haibao: "海报", phone: "电话", gongzhonghao: "公众号", weixinqun: "微信群", payment: "付款码", api: "API", } return channelMap[channel] || channel } interface Task { id: string name: string status: "running" | "paused" | "completed" stats: { devices: number acquired: number added: number } lastUpdated: string executionTime: string nextExecutionTime: string trend: { date: string; customers: number }[] } interface DeviceStats { active: number } // API文档提示组件 function ApiDocumentationTooltip() { return (

计划接口允许您通过API将外部系统的客户数据直接导入到存客宝。支持多种编程语言和第三方平台集成。

) } export default function ChannelPage({ params }: { params: { channel: string } }) { const router = useRouter() const channel = params.channel const channelName = getChannelName(params.channel) const initialTasks = [ { id: "1", name: `${channelName}直播获客计划`, status: "running", stats: { devices: 5, acquired: 31, added: 25, }, lastUpdated: "2024-02-09 15:30", executionTime: "2024-02-09 17:24:10", nextExecutionTime: "2024-02-09 17:25:36", trend: Array.from({ length: 7 }, (_, i) => ({ date: `2月${String(i + 1)}日`, customers: Math.floor(Math.random() * 30) + 30, })), }, { id: "2", name: `${channelName}评论区获客计划`, status: "paused", stats: { devices: 3, acquired: 15, added: 12, }, lastUpdated: "2024-02-09 14:00", executionTime: "2024-02-09 16:30:00", nextExecutionTime: "2024-02-09 16:45:00", trend: Array.from({ length: 7 }, (_, i) => ({ date: `2月${String(i + 1)}日`, customers: Math.floor(Math.random() * 20) + 20, })), }, ] const [tasks, setTasks] = useState(initialTasks) const [deviceStats, setDeviceStats] = useState({ active: 5, }) const [showApiDialog, setShowApiDialog] = useState(false) const [currentApiSettings, setCurrentApiSettings] = useState({ apiKey: "", webhookUrl: "", taskId: "", }) const handleEditPlan = (taskId: string) => { router.push(`/scenarios/${channel}/edit/${taskId}`) } const handleCopyPlan = (taskId: string) => { const taskToCopy = tasks.find((task) => task.id === taskId) if (taskToCopy) { const newTask = { ...taskToCopy, id: `${Date.now()}`, name: `${taskToCopy.name} (副本)`, status: "paused" as const, } setTasks([...tasks, newTask]) toast({ title: "计划已复制", description: `已成功复制"${taskToCopy.name}"`, variant: "success", }) } } const handleDeletePlan = (taskId: string) => { const taskToDelete = tasks.find((t) => t.id === taskId) if (taskToDelete) { setTasks(tasks.filter((t) => t.id !== taskId)) toast({ title: "计划已删除", description: `已成功删除"${taskToDelete.name}"`, variant: "success", }) } } const handleStatusChange = (taskId: string, newStatus: "running" | "paused") => { setTasks(tasks.map((task) => (task.id === taskId ? { ...task, status: newStatus } : task))) toast({ title: newStatus === "running" ? "计划已启动" : "计划已暂停", description: `已${newStatus === "running" ? "启动" : "暂停"}获客计划`, variant: "success", }) } const handleOpenApiSettings = (taskId: string) => { const task = tasks.find((t) => t.id === taskId) if (task) { setCurrentApiSettings({ apiKey: `api_${taskId}_${Math.random().toString(36).substring(2, 10)}`, webhookUrl: `${window.location.origin}/api/scenarios/${channel}/${taskId}/webhook`, taskId, }) setShowApiDialog(true) } } const handleCopyApiUrl = (url: string, withParams = false) => { let copyUrl = url if (withParams) { copyUrl = `${url}?name=张三&phone=13800138000&source=外部系统&remark=测试数据` } navigator.clipboard.writeText(copyUrl) toast({ title: "已复制", description: withParams ? "接口地址(含示例参数)已复制到剪贴板" : "接口地址已复制到剪贴板", variant: "success", }) } return (

{channelName}获客

{tasks.length > 0 ? ( tasks.map((task) => (
handleEditPlan(task.id)} onCopy={handleCopyPlan} onDelete={handleDeletePlan} onStatusChange={handleStatusChange} onOpenSettings={handleOpenApiSettings} />
)) ) : (
暂无获客计划
)}
{/* API接口设置对话框 */}
计划接口
使用此接口直接导入客资到该获客计划,支持多种编程语言。

支持GET/POST请求,必要参数:name(姓名)、phone(电话)

查看Python、Java等多语言示例代码

) }