"use client" import { useState } from "react" import { useRouter } from "next/navigation" import { ChevronLeft, Phone, MessageCircle, CreditCard, Check, X, Loader2, Shield } from "lucide-react" import { useStore } from "@/lib/store" export default function SettingsPage() { const router = useRouter() const { user, updateUser, logout } = useStore() // 绑定弹窗状态 const [showBindModal, setShowBindModal] = useState(false) const [bindType, setBindType] = useState<"phone" | "wechat" | "alipay">("phone") const [bindValue, setBindValue] = useState("") const [isBinding, setIsBinding] = useState(false) const [bindError, setBindError] = useState("") // 绑定账号 const handleBind = async () => { if (!bindValue.trim()) { setBindError("请输入内容") return } if (bindType === "phone" && !/^1[3-9]\d{9}$/.test(bindValue)) { setBindError("请输入正确的手机号") return } if (bindType === "wechat" && bindValue.length < 6) { setBindError("微信号至少6位") return } if (bindType === "alipay" && !bindValue.includes("@") && !/^1[3-9]\d{9}$/.test(bindValue)) { setBindError("请输入正确的支付宝账号") return } setIsBinding(true) setBindError("") try { await new Promise(resolve => setTimeout(resolve, 1000)) if (updateUser && user) { const updates: any = {} if (bindType === "phone") updates.phone = bindValue if (bindType === "wechat") updates.wechat = bindValue if (bindType === "alipay") updates.alipay = bindValue updateUser(user.id, updates) } setShowBindModal(false) setBindValue("") alert("绑定成功!") } catch (error) { setBindError("绑定失败,请重试") } finally { setIsBinding(false) } } const openBindModal = (type: "phone" | "wechat" | "alipay") => { setBindType(type) setBindValue("") setBindError("") setShowBindModal(true) } // 检查是否有绑定任何支付方式 const hasAnyPaymentBound = user?.wechat || user?.alipay return (
{/* Header */}

设置

{/* 账号绑定 */}
账号绑定

绑定后可用于提现和找伙伴功能

{/* 手机号 */} {/* 微信号 */} {/* 支付宝 */}
{/* 绑定提示 */} {!hasAnyPaymentBound && (

提示:绑定至少一个支付方式(微信或支付宝)才能使用提现功能

)} {/* 退出登录 */}
{/* 绑定弹窗 */} {showBindModal && (
!isBinding && setShowBindModal(false)} />

绑定{bindType === "phone" ? "手机号" : bindType === "wechat" ? "微信号" : "支付宝"}

setBindValue(e.target.value)} placeholder={ bindType === "phone" ? "请输入11位手机号" : bindType === "wechat" ? "请输入微信号" : "请输入支付宝账号" } className="w-full px-4 py-3 rounded-xl bg-black/30 border border-white/10 text-white placeholder-white/30 focus:outline-none focus:border-[#00CED1]/50" disabled={isBinding} />
{bindError && (

{bindError}

)}
)}
) }