"use client"
import { useState } from "react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle, CardFooter } from "@/components/ui/card"
import { Button } from "@/components/ui/button"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Textarea } from "@/components/ui/textarea"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Switch } from "@/components/ui/switch"
import { Badge } from "@/components/ui/badge"
import { Separator } from "@/components/ui/separator"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog"
import { Sparkles, BarChart, TrendingUp, Users, Mail, Clock, Download, ChevronRight } from "lucide-react"
export default function AIAssistantPage() {
const [activeTab, setActiveTab] = useState("data-analysis")
const [selectedUserGroup, setSelectedUserGroup] = useState("")
const [isUserGroupDialogOpen, setIsUserGroupDialogOpen] = useState(false)
const [emailAddress, setEmailAddress] = useState("")
const [scheduleReport, setScheduleReport] = useState(false)
// 分析流程步骤
const [analysisStep, setAnalysisStep] = useState(1)
const [analysisType, setAnalysisType] = useState("")
// 营销策略步骤
const [strategyStep, setStrategyStep] = useState(1)
const [strategyType, setStrategyType] = useState("")
return (
AI 智能助手
利用AI技术分析数据并提供营销策略
数据分析
营销策略
AI 数据分析
使用AI分析用户数据并生成洞察报告
{/* 第1步:选择用户分群 */}
1
选择用户分群
{analysisStep > 1 ? (
) : (
)}
{selectedUserGroup && (
已选择用户分群:
{selectedUserGroup}
{analysisStep === 1 && (
)}
)}
{/* 第2步:选择分析类型 */}
2 ? "opacity-60" : "opacity-40") : ""}`}
>
2
选择分析类型
{analysisStep > 2 && (
)}
{analysisStep >= 2 && (
setAnalysisType("behavior")}
>
用户行为分析
分析用户的行为模式、偏好和习惯
{analysisType === "behavior" && 已选择}
setAnalysisType("value")}
>
用户估值分析
分析用户的价值分布和潜在价值
{analysisType === "value" && 已选择}
setAnalysisType("churn")}
>
用户流失预警
预测可能流失的用户并提供挽留建议
{analysisType === "churn" && 已选择}
)}
{analysisStep === 2 && analysisType && (
)}
{/* 第3步:分析参数设置 */}
3 ? "opacity-60" : "opacity-40") : ""}`}
>
3
分析参数设置
{analysisStep > 3 && (
)}
{analysisStep >= 3 && (
)}
{analysisStep === 3 && (
)}
{/* 第4步:报告设置 */}
{analysisStep >= 4 && (
setEmailAddress(e.target.value)}
/>
{scheduleReport && (
)}
)}
分析结果预览
AI生成的数据分析结果
{selectedUserGroup && analysisStep === 4 ? (
分析结果将在这里显示
点击"开始分析"按钮生成分析报告
) : (
请完成所有分析步骤
)}
AI 营销策略
使用AI生成针对性的营销策略和建议
{/* 第1步:选择目标用户分群 */}
1
选择目标用户分群
{strategyStep > 1 ? (
) : (
)}
{selectedUserGroup && (
已选择用户分群:
{selectedUserGroup}
{strategyStep === 1 && (
)}
)}
{/* 第2步:选择策略类型 */}
2 ? "opacity-60" : "opacity-40") : ""}`}
>
2
选择策略类型
{strategyStep > 2 && (
)}
{strategyStep >= 2 && (
setStrategyType("sales")}
>
销售预测
预测未来销售趋势并提供增长建议
{strategyType === "sales" && 已选择}
setStrategyType("reach")}
>
用户触达策略
生成针对性的用户触达和转化策略
{strategyType === "reach" && 已选择}
setStrategyType("content")}
>
内容营销策略
生成针对目标用户的内容营销策略
{strategyType === "content" && 已选择}
)}
{strategyStep === 2 && strategyType && (
)}
{/* 第3步:策略参数设置 */}
{strategyStep >= 3 && (
<>
setEmailAddress(e.target.value)}
/>
{scheduleReport && (
)}
>
)}
策略建议预览
AI生成的营销策略建议
{selectedUserGroup && strategyStep === 3 ? (
策略建议将在这里显示
点击"生成策略"按钮生成营销策略
) : (
请完成所有策略步骤
)}
)
}
// 用户分群选择对话框
function UserGroupSelectionDialog({
isOpen,
setIsOpen,
onSelect,
}: {
isOpen: boolean
setIsOpen: (open: boolean) => void
onSelect: (group: string) => void
}) {
// 模拟用户分群数据
const userGroups = [
{
id: "1",
name: "高价值用户",
description: "消费能力强,购买频率高的用户",
count: 12456,
category: "用户资产",
lastUpdated: "2023-07-20",
},
{
id: "2",
name: "活跃用户",
description: "近30天内有活动的用户",
count: 45678,
category: "用户资产",
lastUpdated: "2023-07-20",
},
{
id: "3",
name: "地摊商户",
description: "从事地摊相关业务的用户",
count: 8765,
category: "地摊相关",
lastUpdated: "2023-07-19",
},
{
id: "4",
name: "樊登读书会员",
description: "樊登读书平台的会员用户",
count: 15678,
category: "樊登读书",
lastUpdated: "2023-07-18",
},
{
id: "5",
name: "魔兽玩家",
description: "魔兽世界游戏的活跃玩家",
count: 23456,
category: "魔兽世界",
lastUpdated: "2023-07-17",
},
{
id: "6",
name: "流失风险用户",
description: "有流失风险的高价值用户",
count: 5678,
category: "用户资产",
lastUpdated: "2023-07-16",
},
]
const [searchQuery, setSearchQuery] = useState("")
const [selectedCategory, setSelectedCategory] = useState("all")
// 过滤用户分群
const filteredGroups = userGroups.filter((group) => {
const matchesSearch =
group.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
group.description.toLowerCase().includes(searchQuery.toLowerCase())
const matchesCategory = selectedCategory === "all" || group.category === selectedCategory
return matchesSearch && matchesCategory
})
// 获取所有分类
const categories = ["all", ...new Set(userGroups.map((group) => group.category))]
const handleSelect = (group: string) => {
onSelect(group)
setIsOpen(false)
}
return (
)
}