RMO-Front/src/pages/Home.tsx

200 lines
7.3 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Link } from 'react-router-dom'
import { useEffect, useRef, useState } from 'react'
import { useQuoteModal } from '../contexts/QuoteModalContext'
import './Home.css'
function Home() {
const { openQuoteModal } = useQuoteModal()
const [currentSection, setCurrentSection] = useState(0)
const sectionsRef = useRef<(HTMLElement | null)[]>([])
useEffect(() => {
const handleWheel = (e: WheelEvent) => {
e.preventDefault()
const delta = e.deltaY > 0 ? 1 : -1
const nextSection = Math.max(0, Math.min(sectionsRef.current.length - 1, currentSection + delta))
if (nextSection !== currentSection) {
setCurrentSection(nextSection)
sectionsRef.current[nextSection]?.scrollIntoView({ behavior: 'smooth' })
}
}
window.addEventListener('wheel', handleWheel, { passive: false })
return () => window.removeEventListener('wheel', handleWheel)
}, [currentSection])
useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const index = sectionsRef.current.indexOf(entry.target as HTMLElement)
if (index !== -1) {
setCurrentSection(index)
}
}
})
},
{ threshold: 0.5 }
)
sectionsRef.current.forEach((section) => {
if (section) observer.observe(section)
})
return () => observer.disconnect()
}, [])
return (
<div className="home-fullscreen">
{/* 导航指示器 */}
<div className="scroll-indicator">
{[0, 1, 2, 3, 4].map((index) => (
<button
key={index}
className={`indicator-dot ${currentSection === index ? 'active' : ''}`}
onClick={() => {
setCurrentSection(index)
sectionsRef.current[index]?.scrollIntoView({ behavior: 'smooth' })
}}
aria-label={`Section ${index + 1}`}
/>
))}
</div>
{/* Section 1: Hero - 主视觉 */}
<section
ref={(el) => (sectionsRef.current[0] = el)}
className="home-section hero-section"
style={{
backgroundImage: "url('/pic/Home_Page.png')",
backgroundPosition: 'center center',
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
backgroundAttachment: 'fixed'
}}
>
<div className="hero-content">
<h1 className="hero-title"></h1>
<p className="hero-subtitle">
</p>
<div className="hero-buttons">
<Link to="/about/overview" className="btn btn-primary"></Link>
<button type="button" className="btn btn-secondary" onClick={openQuoteModal}>
</button>
</div>
</div>
</section>
{/* Section 2: 解决方案 */}
<section
ref={(el) => (sectionsRef.current[1] = el)}
className="home-section solutions-section"
>
<div className="section-content">
<h2 className="section-title">RMO风险管理解决方案</h2>
<p className="section-subtitle"></p>
<div className="solutions-grid">
<Link to="/solutions/pharmacovigilance" className="solution-card">
<div className="solution-icon">📊</div>
<h3></h3>
<p></p>
<span className="solution-link"> </span>
</Link>
<Link to="/solutions/clinical-insurance" className="solution-card">
<div className="solution-icon">🛡</div>
<h3></h3>
<p></p>
<span className="solution-link"> </span>
</Link>
<Link to="/solutions/product-insurance" className="solution-card">
<div className="solution-icon">💼</div>
<h3></h3>
<p></p>
<span className="solution-link"> </span>
</Link>
</div>
</div>
</section>
{/* Section 3: 核心能力 */}
<section
ref={(el) => (sectionsRef.current[2] = el)}
className="home-section capabilities-section"
>
<div className="section-content">
<h2 className="section-title"></h2>
<div className="capabilities-grid">
<div className="capability-item">
<div className="capability-number">10+</div>
<div className="capability-label"></div>
</div>
<div className="capability-item">
<div className="capability-number">50+</div>
<div className="capability-label"></div>
</div>
<div className="capability-item">
<div className="capability-number">Top 5</div>
<div className="capability-label"></div>
</div>
<div className="capability-item">
<div className="capability-number">7/15</div>
<div className="capability-label"></div>
</div>
</div>
</div>
</section>
{/* Section 4: 知识资源 */}
<section
ref={(el) => (sectionsRef.current[3] = el)}
className="home-section knowledge-section"
>
<div className="section-content">
<h2 className="section-title"></h2>
<p className="section-subtitle"></p>
<div className="knowledge-grid">
<Link to="/knowledge/PVknowledge" className="knowledge-card">
<h3></h3>
<p></p>
</Link>
<Link to="/knowledge/insurance" className="knowledge-card">
<h3></h3>
<p></p>
</Link>
<Link to="/knowledge/pv-insurance" className="knowledge-card">
<h3>PV与保险</h3>
<p></p>
</Link>
<Link to="/faq" className="knowledge-card">
<h3></h3>
<p></p>
</Link>
</div>
</div>
</section>
{/* Section 5: 联系我们 */}
<section
ref={(el) => (sectionsRef.current[4] = el)}
className="home-section contact-section"
>
<div className="section-content">
<h2 className="section-title"></h2>
<p className="section-subtitle">RMO最新资讯</p>
<div className="contact-actions">
<Link to="/contact" className="btn btn-primary"></Link>
<Link to="/about/overview" className="btn btn-secondary">RMO</Link>
</div>
</div>
</section>
</div>
)
}
export default Home