"use client" import { useState, useEffect } from "react" import { Button } from "@/components/ui/button" import { Zap, BookOpen } from "lucide-react" import { getFullBookPrice, getAllSections } from "@/lib/book-data" import { useStore } from "@/lib/store" import { AuthModal } from "./modules/auth/auth-modal" import { PaymentModal } from "./modules/payment/payment-modal" export function PurchaseSection() { const [fullBookPrice, setFullBookPrice] = useState(9.9) const [sectionsCount, setSectionsCount] = useState(55) const [isAuthOpen, setIsAuthOpen] = useState(false) const [isPaymentOpen, setIsPaymentOpen] = useState(false) const { isLoggedIn } = useStore() useEffect(() => { const sections = getAllSections() setSectionsCount(sections.length) setFullBookPrice(getFullBookPrice(sections.length)) }, []) const handlePurchase = () => { if (!isLoggedIn) { setIsAuthOpen(true) return } setIsPaymentOpen(true) } return (
{/* Pricing cards - stacked on mobile */}
{/* Single section */}

单节购买

按兴趣选择

¥1 /节
{/* Full book - highlighted */}
推荐

整本购买

全部{sectionsCount}节 · 后续更新免费

¥{fullBookPrice.toFixed(1)}
{/* Dynamic pricing note */}

动态定价: 每新增一章节,整本价格+¥1

setIsAuthOpen(false)} /> setIsPaymentOpen(false)} type="fullbook" amount={fullBookPrice} onSuccess={() => window.location.reload()} />
) }