"use client" import { useState } from "react" import { X, Wallet, CheckCircle } from "lucide-react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { useStore } from "@/lib/store" interface WithdrawalModalProps { isOpen: boolean onClose: () => void availableAmount: number } export function WithdrawalModal({ isOpen, onClose, availableAmount }: WithdrawalModalProps) { const { requestWithdrawal } = useStore() const [amount, setAmount] = useState("") const [method, setMethod] = useState<"wechat" | "alipay">("wechat") const [account, setAccount] = useState("") const [name, setName] = useState("") const [isSubmitting, setIsSubmitting] = useState(false) const [isSuccess, setIsSuccess] = useState(false) if (!isOpen) return null const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() const amountNum = parseFloat(amount) if (isNaN(amountNum) || amountNum <= 0 || amountNum > availableAmount) { alert("请输入有效的提现金额") return } if (!account || !name) { alert("请填写完整的提现信息") return } setIsSubmitting(true) // Simulate API delay await new Promise(resolve => setTimeout(resolve, 1000)) requestWithdrawal(amountNum, method, account, name) setIsSubmitting(false) setIsSuccess(true) } const handleClose = () => { setIsSuccess(false) setAmount("") setAccount("") setName("") onClose() } return (
{isSuccess ? (

申请提交成功

您的提现申请已提交,预计1-3个工作日内到账。

) : (

申请提现

¥ setAmount(e.target.value)} className="pl-7" placeholder="最低10元" />
setAccount(e.target.value)} placeholder={method === "wechat" ? "请输入微信号" : "请输入支付宝账号"} />
setName(e.target.value)} placeholder="请输入收款人真实姓名" />
)}
) }