'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { useAuth } from '@/contexts/AuthContext' import { ShieldCheck, AlertCircle, ArrowLeft, Mail, Lock, User, Phone } from 'lucide-react' import Link from 'next/link' import type { UserRole } from '@/lib/api' const roleOptions: { value: UserRole; label: string; desc: string }[] = [ { value: 'brand', label: '品牌方', desc: '创建项目、管理代理商、配置审核规则' }, { value: 'agency', label: '代理商', desc: '管理达人、分配任务、审核内容' }, { value: 'creator', label: '达人', desc: '上传脚本和视频、查看审核结果' }, ] export default function RegisterPage() { const router = useRouter() const { register } = useAuth() const [name, setName] = useState('') const [email, setEmail] = useState('') const [phone, setPhone] = useState('') const [password, setPassword] = useState('') const [confirmPassword, setConfirmPassword] = useState('') const [role, setRole] = useState('creator') const [error, setError] = useState('') const [isLoading, setIsLoading] = useState(false) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError('') if (!name.trim()) { setError('请输入用户名') return } if (!email && !phone) { setError('请填写邮箱或手机号') return } if (password.length < 6) { setError('密码至少 6 位') return } if (password !== confirmPassword) { setError('两次密码不一致') return } setIsLoading(true) const result = await register({ name: name.trim(), email: email || undefined, phone: phone || undefined, password, role, }) if (result.success) { switch (role) { case 'creator': router.push('/creator') break case 'agency': router.push('/agency') break case 'brand': router.push('/brand') break } } else { setError(result.error || '注册失败') } setIsLoading(false) } return (
{/* 返回 */} 返回登录 {/* Logo */}
注册账号

加入秒思智能审核平台

{/* 注册表单 */}
{error && (
{error}
)} {/* 角色选择 */}
{roleOptions.map((opt) => ( ))}

{roleOptions.find((o) => o.value === role)?.desc}

{/* 用户名 */}
setName(e.target.value)} className="w-full pl-12 pr-4 py-3.5 bg-bg-elevated border border-border-subtle rounded-xl text-text-primary placeholder-text-tertiary focus:outline-none focus:ring-2 focus:ring-accent-indigo focus:border-transparent transition-all" required />
{/* 邮箱 */}
setEmail(e.target.value)} className="w-full pl-12 pr-4 py-3.5 bg-bg-elevated border border-border-subtle rounded-xl text-text-primary placeholder-text-tertiary focus:outline-none focus:ring-2 focus:ring-accent-indigo focus:border-transparent transition-all" />
{/* 手机号 */}
setPhone(e.target.value)} className="w-full pl-12 pr-4 py-3.5 bg-bg-elevated border border-border-subtle rounded-xl text-text-primary placeholder-text-tertiary focus:outline-none focus:ring-2 focus:ring-accent-indigo focus:border-transparent transition-all" />
{/* 密码 */}
setPassword(e.target.value)} className="w-full pl-12 pr-4 py-3.5 bg-bg-elevated border border-border-subtle rounded-xl text-text-primary placeholder-text-tertiary focus:outline-none focus:ring-2 focus:ring-accent-indigo focus:border-transparent transition-all" required />
{/* 确认密码 */}
setConfirmPassword(e.target.value)} className="w-full pl-12 pr-4 py-3.5 bg-bg-elevated border border-border-subtle rounded-xl text-text-primary placeholder-text-tertiary focus:outline-none focus:ring-2 focus:ring-accent-indigo focus:border-transparent transition-all" required />
{/* 底部链接 */}

已有账号?{' '} 立即登录

) }