绑定后可用于提现和找伙伴功能
提示:绑定至少一个支付方式(微信或支付宝)才能使用提现功能
"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 (
绑定后可用于提现和找伙伴功能
提示:绑定至少一个支付方式(微信或支付宝)才能使用提现功能
{bindError}
)}