'use client'; import { useState, useEffect, useRef } from 'react'; import { ChevronLeft, ChevronRight, Play, Pause, Star, Clock, Gift, Zap } from 'lucide-react'; interface BannerSlide { id: string; type: 'hero' | 'product' | 'promotion'; title: string; subtitle?: string; description: string; image?: string; gradient: string; cta: { primary: { text: string; href: string }; secondary?: { text: string; href: string }; }; badge?: { text: string; type: 'new' | 'hot' | 'discount' | 'limited'; }; features?: string[]; price?: { original?: string; current: string; discount?: string; }; } interface HeroBannerProps { currentLang: string; translations: any; } export function HeroBanner({ currentLang, translations }: HeroBannerProps) { const [currentSlide, setCurrentSlide] = useState(0); const [isPlaying, setIsPlaying] = useState(true); const [isHovered, setIsHovered] = useState(false); const intervalRef = useRef(null); const t = translations[currentLang]; // Banner slides data const slides: BannerSlide[] = [ { id: 'hero-main', type: 'hero', title: currentLang === 'zh' ? '专业云服务器解决方案' : 'Professional Cloud Server Solutions', subtitle: currentLang === 'zh' ? '为您的业务提供稳定、高效、安全的云计算服务' : 'Stable, Efficient, and Secure Cloud Computing Services', description: currentLang === 'zh' ? '我们是领先的云服务器代理商,提供全球顶级云服务商的产品与服务,助力企业数字化转型' : 'Leading cloud server reseller providing top-tier global cloud services to accelerate your digital transformation', gradient: 'from-amber-900 via-yellow-800 to-orange-700', cta: { primary: { text: t.hero.cta, href: '/contact' }, secondary: { text: t.hero.demo, href: '/demo' }, }, features: [ currentLang === 'zh' ? '99.9% 可用性保证' : '99.9% Uptime Guarantee', currentLang === 'zh' ? '24/7 技术支持' : '24/7 Technical Support', currentLang === 'zh' ? '全球数据中心' : 'Global Data Centers', ], }, { id: 'product-ecs', type: 'product', title: currentLang === 'zh' ? '云服务器 ECS - 弹性计算' : 'Cloud Server ECS - Elastic Computing', description: currentLang === 'zh' ? '高性能云服务器,支持弹性扩展,按需付费,助力业务快速发展' : 'High-performance cloud servers with elastic scaling and pay-as-you-go pricing', gradient: 'from-blue-900 via-indigo-800 to-purple-700', badge: { text: currentLang === 'zh' ? '热销' : 'Hot', type: 'hot' }, cta: { primary: { text: currentLang === 'zh' ? '立即购买' : 'Buy Now', href: '/products/ecs', }, secondary: { text: currentLang === 'zh' ? '免费试用' : 'Free Trial', href: '/trial/ecs', }, }, price: { original: currentLang === 'zh' ? '¥199/月' : '$29/month', current: currentLang === 'zh' ? '¥99/月' : '$15/month', discount: '50%', }, features: [ currentLang === 'zh' ? '2-64核 CPU' : '2-64 Core CPU', currentLang === 'zh' ? '1GB-256GB 内存' : '1GB-256GB RAM', currentLang === 'zh' ? 'SSD 高速存储' : 'SSD High-Speed Storage', ], }, { id: 'promotion-new-year', type: 'promotion', title: currentLang === 'zh' ? '新年特惠 - 云服务大促销' : 'New Year Special - Cloud Services Sale', description: currentLang === 'zh' ? '限时优惠!所有云产品享受超低折扣,新用户更有专属礼包' : 'Limited time offer! All cloud products at super low prices, exclusive packages for new users', gradient: 'from-red-900 via-pink-800 to-rose-700', badge: { text: currentLang === 'zh' ? '限时' : 'Limited', type: 'limited' }, cta: { primary: { text: currentLang === 'zh' ? '抢购优惠' : 'Grab Deal', href: '/promotions/new-year', }, secondary: { text: currentLang === 'zh' ? '查看详情' : 'View Details', href: '/promotions', }, }, features: [ currentLang === 'zh' ? '最高7折优惠' : 'Up to 30% Off', currentLang === 'zh' ? '免费迁移服务' : 'Free Migration Service', currentLang === 'zh' ? '专属技术支持' : 'Dedicated Support', ], }, { id: 'product-database', type: 'product', title: currentLang === 'zh' ? '云数据库 RDS - 高可用数据库' : 'Cloud Database RDS - High Availability', description: currentLang === 'zh' ? '企业级云数据库服务,支持MySQL、PostgreSQL等多种数据库引擎' : 'Enterprise-grade cloud database service supporting MySQL, PostgreSQL and more', gradient: 'from-green-900 via-emerald-800 to-teal-700', badge: { text: currentLang === 'zh' ? '新品' : 'New', type: 'new' }, cta: { primary: { text: currentLang === 'zh' ? '立即体验' : 'Try Now', href: '/products/rds', }, secondary: { text: currentLang === 'zh' ? '技术咨询' : 'Consultation', href: '/support', }, }, price: { current: currentLang === 'zh' ? '¥199/月起' : 'From $29/month', }, features: [ currentLang === 'zh' ? '自动备份恢复' : 'Auto Backup & Recovery', currentLang === 'zh' ? '读写分离' : 'Read-Write Splitting', currentLang === 'zh' ? '监控告警' : 'Monitoring & Alerts', ], }, ]; // Auto-play functionality useEffect(() => { if (isPlaying && !isHovered) { intervalRef.current = setInterval(() => { setCurrentSlide((prev) => (prev + 1) % slides.length); }, 5000); } else { if (intervalRef.current) { clearInterval(intervalRef.current); } } return () => { if (intervalRef.current) { clearInterval(intervalRef.current); } }; }, [isPlaying, isHovered, slides.length]); const goToSlide = (index: number) => { setCurrentSlide(index); }; const nextSlide = () => { setCurrentSlide((prev) => (prev + 1) % slides.length); }; const prevSlide = () => { setCurrentSlide((prev) => (prev - 1 + slides.length) % slides.length); }; const togglePlayPause = () => { setIsPlaying(!isPlaying); }; const getBadgeIcon = (type: string) => { switch (type) { case 'new': return ; case 'hot': return ; case 'discount': return ; case 'limited': return ; default: return null; } }; const getBadgeColor = (type: string) => { switch (type) { case 'new': return 'bg-green-500 text-white'; case 'hot': return 'bg-red-500 text-white'; case 'discount': return 'bg-purple-500 text-white'; case 'limited': return 'bg-orange-500 text-white'; default: return 'bg-gray-500 text-white'; } }; const currentSlideData = slides[currentSlide]; return (
setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} role="banner" aria-label="Hero banner carousel" > {/* Background with gradient */}
{/* Background pattern */}
{/* Content */}
{/* Left Content */}
{/* Badge */} {currentSlideData.badge && (
{getBadgeIcon(currentSlideData.badge.type)} {currentSlideData.badge.text}
)} {/* Title */}

{currentSlideData.title}

{/* Subtitle */} {currentSlideData.subtitle && (

{currentSlideData.subtitle}

)} {/* Description */}

{currentSlideData.description}

{/* Features */} {currentSlideData.features && (
{currentSlideData.features.map((feature, index) => (
{feature}
))}
)} {/* Price */} {currentSlideData.price && (
{currentSlideData.price.current}
{currentSlideData.price.original && (
{currentSlideData.price.original} {currentSlideData.price.discount && ( -{currentSlideData.price.discount} )}
)}
)} {/* CTA Buttons */}
{/* Right Content - Visual Element */}
{/* Floating Cards */}
{currentLang === 'zh' ? '服务状态:正常' : 'Service Status: Normal'}
99.9%
{currentLang === 'zh' ? '可用性保证' : 'Uptime Guarantee'}
{currentLang === 'zh' ? '全球节点' : 'Global Nodes'}
50+
{currentLang === 'zh' ? '数据中心' : 'Data Centers'}
{currentLang === 'zh' ? '客户满意度' : 'Customer Satisfaction'}
4.9/5
{currentLang === 'zh' ? '用户评分' : 'User Rating'}
{/* Navigation Controls */}
{/* Slide Indicators */}
{slides.map((_, index) => (
{/* Play/Pause Button */}
{/* Navigation Arrows */} {/* Progress Bar */}
); }