"use client" import { useState } from "react" import { useRouter } from "next/navigation" import Image from "next/image" import { ChevronLeft, Download, Share2, QrCode, Copy, BarChart4, Users } from "lucide-react" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs" import { Badge } from "@/components/ui/badge" import { Switch } from "@/components/ui/switch" import { toast } from "@/components/ui/use-toast" export default function PaymentCodeDetailPage({ params }: { params: { id: string } }) { const router = useRouter() const [activeTab, setActiveTab] = useState("detail") // 模拟数据 const paymentCode = { id: params.id, name: "社群会员付款码", amount: "19.9", description: "加入VIP社群会员", status: "active", qrCodeUrl: "/placeholder.svg?height=300&width=300&query=QR%20Code", paymentMethod: "wechat", createTime: "2023-10-26 11:00:00", totalPayments: 156, totalAmount: 3104.4, distribution: { enabled: true, type: "percentage", value: "10%", totalDistributed: 310.44, }, redPacket: { enabled: true, amount: "5", totalSent: 156, totalAmount: 780, }, autoWelcome: { enabled: true, message: "感谢您的支付,欢迎加入我们的VIP社群!", }, tags: ["付款客户", "社群会员", "已成交"], } const recentPayments = [ { id: 1, user: "用户1", amount: "19.9", time: "2023-10-26 15:30:00", status: "success" }, { id: 2, user: "用户2", amount: "19.9", time: "2023-10-26 14:45:00", status: "success" }, { id: 3, user: "用户3", amount: "19.9", time: "2023-10-26 13:20:00", status: "success" }, { id: 4, user: "用户4", amount: "19.9", time: "2023-10-26 12:10:00", status: "success" }, { id: 5, user: "用户5", amount: "19.9", time: "2023-10-26 11:05:00", status: "success" }, ] const handleStatusChange = (checked: boolean) => { toast({ title: checked ? "付款码已启用" : "付款码已停用", description: checked ? "客户现在可以通过此付款码支付" : "客户将无法通过此付款码支付", }) } const handleCopy = (text: string) => { navigator.clipboard.writeText(text) toast({ title: "复制成功", description: "内容已复制到剪贴板", }) } const handleDownload = () => { toast({ title: "下载成功", description: "付款码已保存到相册", }) } const handleShare = () => { toast({ title: "分享成功", description: "付款码已分享", }) } return (
{/* 头部 */}

付款码详情

{paymentCode.status === "active" ? "启用中" : "已停用"}
{/* 标签页 */}
付款码 支付记录 高级设置 {/* 付款码详情 */}

{paymentCode.name}

{paymentCode.description}

付款码
¥{paymentCode.amount}

付款码信息

付款码ID {paymentCode.id}
支付方式 {paymentCode.paymentMethod === "wechat" ? "微信支付" : paymentCode.paymentMethod === "alipay" ? "支付宝" : "微信和支付宝"}
创建时间 {paymentCode.createTime}
支付笔数 {paymentCode.totalPayments}
支付金额 ¥{paymentCode.totalAmount}
{/* 支付记录 */}

最近支付记录

{recentPayments.map((payment) => (

{payment.user}

{payment.time}

¥{payment.amount}

支付成功
))}

支付统计

总支付笔数 {paymentCode.totalPayments}
总支付金额 ¥{paymentCode.totalAmount}
平均客单价 ¥{(paymentCode.totalAmount / paymentCode.totalPayments).toFixed(2)}
新增客户数 {Math.floor(paymentCode.totalPayments * 0.9)}
{/* 高级设置 */}

分销返利设置

启用分销返利
{paymentCode.distribution.enabled && (
返利类型 {paymentCode.distribution.type === "percentage" ? "比例返利" : "固定金额"}
返利值 {paymentCode.distribution.value}
已发放金额 ¥{paymentCode.distribution.totalDistributed}
)}

红包奖励设置

启用红包奖励
{paymentCode.redPacket.enabled && (
红包金额 ¥{paymentCode.redPacket.amount}
已发放数量 {paymentCode.redPacket.totalSent}
已发放金额 ¥{paymentCode.redPacket.totalAmount}
)}

自动欢迎语设置

启用自动欢迎语
{paymentCode.autoWelcome.enabled && (
欢迎语内容
{paymentCode.autoWelcome.message}
)}

客户标签设置

{paymentCode.tags.map((tag, index) => ( {tag} ))}
) }