up
This commit is contained in:
@@ -0,0 +1,813 @@
|
||||
/**
|
||||
* 企业首页样式表
|
||||
* 响应式设计,支持移动端和桌面端
|
||||
*/
|
||||
|
||||
/* 基础样式 */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root {
|
||||
--primary-color: #4ade80;
|
||||
--primary-dark: #22c55e;
|
||||
--secondary-color: #86efac;
|
||||
--text-color: #1e293b;
|
||||
--text-light: #64748b;
|
||||
--bg-color: #ffffff;
|
||||
--bg-light: #f0fdf4;
|
||||
--border-color: #bbf7d0;
|
||||
--shadow: 0 4px 6px -1px rgba(74, 222, 128, 0.1);
|
||||
--shadow-lg: 0 10px 15px -3px rgba(74, 222, 128, 0.2);
|
||||
--transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
||||
line-height: 1.6;
|
||||
color: var(--text-color);
|
||||
background-color: var(--bg-color);
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
/* 导航栏 */
|
||||
.navbar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
backdrop-filter: blur(10px);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
z-index: 1000;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.navbar.scrolled {
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.navbar .container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
.nav-brand a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-decoration: none;
|
||||
color: var(--text-color);
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.nav-brand .logo {
|
||||
font-size: 2rem;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.nav-toggle {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.nav-toggle span {
|
||||
width: 25px;
|
||||
height: 3px;
|
||||
background: var(--text-color);
|
||||
margin: 3px 0;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.nav-menu {
|
||||
display: flex;
|
||||
list-style: none;
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
text-decoration: none;
|
||||
color: var(--text-color);
|
||||
font-weight: 500;
|
||||
transition: var(--transition);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nav-link:hover,
|
||||
.nav-link.active {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.nav-link::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -5px;
|
||||
left: 0;
|
||||
width: 0;
|
||||
height: 2px;
|
||||
background: var(--primary-color);
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.nav-link:hover::after,
|
||||
.nav-link.active::after {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 导航栏联系方式 */
|
||||
.nav-contact {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
.nav-phone {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
text-decoration: none;
|
||||
color: var(--primary-color);
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
padding: 10px 20px;
|
||||
border: 2px solid var(--primary-color);
|
||||
border-radius: 50px;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.nav-phone:hover {
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.nav-phone span:first-child {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
/* Hero 区域 */
|
||||
.hero {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #4ade80 0%, #22c55e 50%, #16a34a 100%);
|
||||
color: white;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.hero-content {
|
||||
max-width: 800px;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 3.5rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 20px;
|
||||
animation: fadeInUp 1s ease;
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 40px;
|
||||
opacity: 0.9;
|
||||
animation: fadeInUp 1s ease 0.2s both;
|
||||
}
|
||||
|
||||
.hero-buttons {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
justify-content: center;
|
||||
animation: fadeInUp 1s ease 0.4s both;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 15px 40px;
|
||||
border-radius: 50px;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
transition: var(--transition);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: white;
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: transparent;
|
||||
color: white;
|
||||
border: 2px solid white;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: white;
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
.hero-scroll {
|
||||
position: absolute;
|
||||
bottom: 40px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
text-align: center;
|
||||
animation: bounce 2s infinite;
|
||||
}
|
||||
|
||||
.hero-scroll span {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
font-size: 0.9rem;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.scroll-indicator {
|
||||
width: 30px;
|
||||
height: 50px;
|
||||
border: 2px solid white;
|
||||
border-radius: 25px;
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.scroll-indicator::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background: white;
|
||||
border-radius: 50%;
|
||||
animation: scrollDown 2s infinite;
|
||||
}
|
||||
|
||||
/* 解决方案区域 */
|
||||
.solutions {
|
||||
padding: 100px 0;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.solutions-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.solution-card {
|
||||
background: var(--bg-light);
|
||||
padding: 40px;
|
||||
border-radius: 20px;
|
||||
border: 2px solid var(--border-color);
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.solution-card:hover {
|
||||
transform: translateY(-5px);
|
||||
border-color: var(--primary-color);
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
|
||||
.solution-icon {
|
||||
font-size: 3.5rem;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.solution-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 15px;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.solution-description {
|
||||
color: var(--text-light);
|
||||
line-height: 1.8;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.solution-features {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.solution-features li {
|
||||
padding: 8px 0;
|
||||
color: var(--text-color);
|
||||
position: relative;
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
.solution-features li::before {
|
||||
content: '✓';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
color: var(--primary-color);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 投资者关系区域 */
|
||||
.investors {
|
||||
padding: 100px 0;
|
||||
background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
|
||||
}
|
||||
|
||||
.investors-content {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 60px;
|
||||
}
|
||||
|
||||
.investors-info h3,
|
||||
.investors-highlights h3 {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 25px;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.stock-card {
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 20px;
|
||||
box-shadow: var(--shadow);
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.stock-name {
|
||||
font-size: 1.3rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.stock-code {
|
||||
color: var(--text-light);
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.stock-price {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.stock-price .price {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.stock-price .currency {
|
||||
color: var(--text-light);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.stock-price .change {
|
||||
padding: 5px 12px;
|
||||
border-radius: 20px;
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.stock-price .change.positive {
|
||||
background: #dcfce7;
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
.stock-date {
|
||||
color: var(--text-light);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.links-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.investor-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 20px;
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
text-decoration: none;
|
||||
color: var(--text-color);
|
||||
transition: var(--transition);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.investor-link:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: var(--shadow-lg);
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
|
||||
.link-icon {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.highlights-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.highlight-item {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 15px;
|
||||
text-align: center;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.highlight-value {
|
||||
font-size: 1.8rem;
|
||||
font-weight: 700;
|
||||
color: var(--primary-dark);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.highlight-label {
|
||||
color: var(--text-color);
|
||||
font-weight: 500;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.highlight-growth {
|
||||
color: var(--primary-color);
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.investors-contact {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 15px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.investors-contact h4 {
|
||||
margin-bottom: 15px;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.investors-contact p {
|
||||
margin-bottom: 10px;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
/* 服务区域 */
|
||||
.services {
|
||||
padding: 100px 0;
|
||||
background: var(--bg-light);
|
||||
}
|
||||
|
||||
.section-header {
|
||||
text-align: center;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 15px;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.section-subtitle {
|
||||
font-size: 1.2rem;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
.services-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.service-card {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
border-radius: 20px;
|
||||
text-align: center;
|
||||
box-shadow: var(--shadow);
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.service-card:hover {
|
||||
transform: translateY(-10px);
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
|
||||
.service-icon {
|
||||
font-size: 4rem;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.service-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.service-description {
|
||||
color: var(--text-light);
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
/* 关于我们 */
|
||||
.about {
|
||||
padding: 100px 0;
|
||||
}
|
||||
|
||||
.about-content {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 60px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.about-description {
|
||||
font-size: 1.1rem;
|
||||
color: var(--text-light);
|
||||
margin-bottom: 40px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.about-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-number {
|
||||
display: block;
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
color: #22c55e;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
color: var(--text-light);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.about-image {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.image-placeholder {
|
||||
width: 400px;
|
||||
height: 300px;
|
||||
background: var(--bg-light);
|
||||
border-radius: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 8rem;
|
||||
}
|
||||
|
||||
/* 联系我们 */
|
||||
.contact {
|
||||
padding: 100px 0;
|
||||
background: var(--bg-light);
|
||||
}
|
||||
|
||||
.contact-content {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 60px;
|
||||
}
|
||||
|
||||
.contact-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.contact-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.contact-icon {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.contact-item h4 {
|
||||
font-size: 1.2rem;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.contact-item p {
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
.contact-form {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
border-radius: 20px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group input,
|
||||
.form-group textarea {
|
||||
width: 100%;
|
||||
padding: 15px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 10px;
|
||||
font-size: 1rem;
|
||||
transition: var(--transition);
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.form-group input:focus,
|
||||
.form-group textarea:focus {
|
||||
outline: none;
|
||||
border-color: #4ade80;
|
||||
box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1);
|
||||
}
|
||||
|
||||
.form-group textarea {
|
||||
resize: vertical;
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
/* 页脚 */
|
||||
.footer {
|
||||
background: var(--text-color);
|
||||
color: white;
|
||||
padding: 40px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.footer-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.footer-brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.footer-copyright {
|
||||
opacity: 0.8;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* 动画 */
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bounce {
|
||||
0%, 20%, 50%, 80%, 100% {
|
||||
transform: translateX(-50%) translateY(0);
|
||||
}
|
||||
40% {
|
||||
transform: translateX(-50%) translateY(-10px);
|
||||
}
|
||||
60% {
|
||||
transform: translateX(-50%) translateY(-5px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes scrollDown {
|
||||
0% {
|
||||
opacity: 1;
|
||||
transform: translateX(-50%) translateY(0);
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translateX(-50%) translateY(20px);
|
||||
}
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.nav-toggle {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-menu {
|
||||
position: fixed;
|
||||
top: 70px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: white;
|
||||
flex-direction: column;
|
||||
padding: 20px;
|
||||
box-shadow: var(--shadow);
|
||||
transform: translateY(-100%);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.nav-menu.active {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.nav-contact {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.hero-buttons {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.about-content,
|
||||
.contact-content,
|
||||
.investors-content {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.solutions-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.links-grid,
|
||||
.highlights-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.stock-price .price {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.about-stats {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
/**
|
||||
* 企业首页交互脚本
|
||||
* 包含导航、服务加载、表单处理等功能
|
||||
*/
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// 初始化所有功能
|
||||
initNavigation();
|
||||
initScrollEffects();
|
||||
loadServices();
|
||||
initContactForm();
|
||||
});
|
||||
|
||||
/**
|
||||
* 导航栏功能
|
||||
* - 滚动时添加阴影
|
||||
* - 移动端菜单切换
|
||||
* - 平滑滚动到锚点
|
||||
*/
|
||||
function initNavigation() {
|
||||
const navbar = document.getElementById('navbar');
|
||||
const navToggle = document.getElementById('navToggle');
|
||||
const navMenu = document.getElementById('navMenu');
|
||||
const navLinks = document.querySelectorAll('.nav-link');
|
||||
|
||||
// 滚动时添加阴影效果
|
||||
window.addEventListener('scroll', () => {
|
||||
if (window.scrollY > 50) {
|
||||
navbar.classList.add('scrolled');
|
||||
} else {
|
||||
navbar.classList.remove('scrolled');
|
||||
}
|
||||
});
|
||||
|
||||
// 移动端菜单切换
|
||||
if (navToggle) {
|
||||
navToggle.addEventListener('click', () => {
|
||||
navMenu.classList.toggle('active');
|
||||
|
||||
// 汉堡菜单动画
|
||||
const spans = navToggle.querySelectorAll('span');
|
||||
spans.forEach(span => span.classList.toggle('active'));
|
||||
});
|
||||
}
|
||||
|
||||
// 导航链接点击事件
|
||||
navLinks.forEach(link => {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
// 移除所有活动状态
|
||||
navLinks.forEach(l => l.classList.remove('active'));
|
||||
// 添加当前活动状态
|
||||
link.classList.add('active');
|
||||
|
||||
// 关闭移动端菜单
|
||||
if (navMenu.classList.contains('active')) {
|
||||
navMenu.classList.remove('active');
|
||||
}
|
||||
|
||||
// 平滑滚动到目标区域
|
||||
const targetId = link.getAttribute('href');
|
||||
const targetSection = document.querySelector(targetId);
|
||||
if (targetSection) {
|
||||
const offsetTop = targetSection.offsetTop - 70; // 减去导航栏高度
|
||||
window.scrollTo({
|
||||
top: offsetTop,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 滚动时更新导航活动状态
|
||||
window.addEventListener('scroll', () => {
|
||||
let current = '';
|
||||
const sections = document.querySelectorAll('section');
|
||||
|
||||
sections.forEach(section => {
|
||||
const sectionTop = section.offsetTop;
|
||||
const sectionHeight = section.clientHeight;
|
||||
if (scrollY >= sectionTop - 200) {
|
||||
current = section.getAttribute('id');
|
||||
}
|
||||
});
|
||||
|
||||
navLinks.forEach(link => {
|
||||
link.classList.remove('active');
|
||||
if (link.getAttribute('href') === `#${current}`) {
|
||||
link.classList.add('active');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 滚动动画效果
|
||||
* 元素进入视口时添加动画
|
||||
*/
|
||||
function initScrollEffects() {
|
||||
const observerOptions = {
|
||||
threshold: 0.1,
|
||||
rootMargin: '0px 0px -50px 0px'
|
||||
};
|
||||
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
entry.target.classList.add('animate-in');
|
||||
}
|
||||
});
|
||||
}, observerOptions);
|
||||
|
||||
// 观察所有需要动画的元素
|
||||
const animateElements = document.querySelectorAll(
|
||||
'.service-card, .stat-item, .contact-item, .about-text, .about-image'
|
||||
);
|
||||
|
||||
animateElements.forEach(el => {
|
||||
el.style.opacity = '0';
|
||||
el.style.transform = 'translateY(30px)';
|
||||
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
|
||||
observer.observe(el);
|
||||
});
|
||||
|
||||
// 添加动画样式
|
||||
const style = document.createElement('style');
|
||||
style.textContent = `
|
||||
.animate-in {
|
||||
opacity: 1 !important;
|
||||
transform: translateY(0) !important;
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从服务器加载服务数据
|
||||
* 动态生成服务卡片
|
||||
*/
|
||||
async function loadServices() {
|
||||
const servicesGrid = document.getElementById('servicesGrid');
|
||||
|
||||
if (!servicesGrid) return;
|
||||
|
||||
try {
|
||||
// 显示加载状态
|
||||
servicesGrid.innerHTML = '<div class="loading">加载中...</div>';
|
||||
|
||||
// 从 API 获取服务数据
|
||||
const response = await fetch('/api/services');
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to load services');
|
||||
}
|
||||
|
||||
const services = await response.json();
|
||||
|
||||
// 清空加载状态
|
||||
servicesGrid.innerHTML = '';
|
||||
|
||||
// 生成服务卡片
|
||||
services.forEach((service, index) => {
|
||||
const card = createServiceCard(service);
|
||||
card.style.animationDelay = `${index * 0.1}s`;
|
||||
servicesGrid.appendChild(card);
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('加载服务失败:', error);
|
||||
// 显示错误信息或使用默认数据
|
||||
servicesGrid.innerHTML = '<div class="error">加载失败,请刷新页面重试</div>';
|
||||
|
||||
// 使用默认数据作为备用
|
||||
const defaultServices = [
|
||||
{ icon: '💻', title: '软件开发', description: '提供企业级软件定制开发服务' },
|
||||
{ icon: '☁️', title: '云计算服务', description: '安全可靠的云端解决方案' },
|
||||
{ icon: '📊', title: '数据分析', description: '大数据分析与商业智能' },
|
||||
{ icon: '💡', title: '技术咨询', description: '专业的技术架构咨询服务' }
|
||||
];
|
||||
|
||||
servicesGrid.innerHTML = '';
|
||||
defaultServices.forEach((service, index) => {
|
||||
const card = createServiceCard(service);
|
||||
card.style.animationDelay = `${index * 0.1}s`;
|
||||
servicesGrid.appendChild(card);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建服务卡片元素
|
||||
*/
|
||||
function createServiceCard(service) {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'service-card';
|
||||
card.innerHTML = `
|
||||
<div class="service-icon">${service.icon}</div>
|
||||
<h3 class="service-title">${service.title}</h3>
|
||||
<p class="service-description">${service.description}</p>
|
||||
`;
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* 联系表单处理
|
||||
* 表单验证和提交
|
||||
*/
|
||||
function initContactForm() {
|
||||
const form = document.getElementById('contactForm');
|
||||
|
||||
if (!form) return;
|
||||
|
||||
form.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
// 获取表单数据
|
||||
const formData = new FormData(form);
|
||||
const data = {
|
||||
name: formData.get('name'),
|
||||
email: formData.get('email'),
|
||||
message: formData.get('message')
|
||||
};
|
||||
|
||||
// 简单验证
|
||||
if (!data.name || !data.email || !data.message) {
|
||||
showNotification('请填写所有必填项', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// 邮箱格式验证
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (!emailRegex.test(data.email)) {
|
||||
showNotification('请输入有效的邮箱地址', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示提交中状态
|
||||
const submitBtn = form.querySelector('button[type="submit"]');
|
||||
const originalText = submitBtn.textContent;
|
||||
submitBtn.textContent = '发送中...';
|
||||
submitBtn.disabled = true;
|
||||
|
||||
try {
|
||||
// 模拟提交(实际项目中应该发送到服务器)
|
||||
await simulateSubmit(data);
|
||||
|
||||
showNotification('消息已发送,我们会尽快回复您!', 'success');
|
||||
form.reset();
|
||||
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error);
|
||||
showNotification('发送失败,请稍后重试', 'error');
|
||||
} finally {
|
||||
submitBtn.textContent = originalText;
|
||||
submitBtn.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟表单提交
|
||||
* 实际项目中应该替换为真实的 API 调用
|
||||
*/
|
||||
function simulateSubmit(data) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
console.log('表单数据:', data);
|
||||
resolve({ success: true });
|
||||
}, 1500);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示通知消息
|
||||
*/
|
||||
function showNotification(message, type = 'info') {
|
||||
// 创建通知元素
|
||||
const notification = document.createElement('div');
|
||||
notification.className = `notification notification-${type}`;
|
||||
notification.textContent = message;
|
||||
|
||||
// 添加样式
|
||||
notification.style.cssText = `
|
||||
position: fixed;
|
||||
top: 90px;
|
||||
right: 20px;
|
||||
padding: 15px 25px;
|
||||
border-radius: 10px;
|
||||
color: white;
|
||||
font-weight: 500;
|
||||
z-index: 9999;
|
||||
animation: slideIn 0.3s ease;
|
||||
max-width: 300px;
|
||||
word-wrap: break-word;
|
||||
`;
|
||||
|
||||
// 根据类型设置颜色
|
||||
const colors = {
|
||||
success: '#10b981',
|
||||
error: '#ef4444',
|
||||
info: '#3b82f6',
|
||||
warning: '#f59e0b'
|
||||
};
|
||||
notification.style.backgroundColor = colors[type] || colors.info;
|
||||
|
||||
// 添加动画样式
|
||||
const style = document.createElement('style');
|
||||
style.textContent = `
|
||||
@keyframes slideIn {
|
||||
from {
|
||||
transform: translateX(100%);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes slideOut {
|
||||
from {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
transform: translateX(100%);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
|
||||
// 添加到页面
|
||||
document.body.appendChild(notification);
|
||||
|
||||
// 3秒后自动移除
|
||||
setTimeout(() => {
|
||||
notification.style.animation = 'slideOut 0.3s ease';
|
||||
setTimeout(() => {
|
||||
notification.remove();
|
||||
}, 300);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字动画效果
|
||||
* 用于统计数字的递增动画
|
||||
*/
|
||||
function animateNumber(element, target, duration = 2000) {
|
||||
const start = 0;
|
||||
const increment = target / (duration / 16);
|
||||
let current = start;
|
||||
|
||||
const timer = setInterval(() => {
|
||||
current += increment;
|
||||
if (current >= target) {
|
||||
current = target;
|
||||
clearInterval(timer);
|
||||
}
|
||||
element.textContent = Math.floor(current) + '+';
|
||||
}, 16);
|
||||
}
|
||||
|
||||
// 当关于我们区域进入视口时,启动数字动画
|
||||
const statsObserver = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
const statNumbers = entry.target.querySelectorAll('.stat-number');
|
||||
statNumbers.forEach(stat => {
|
||||
const target = parseInt(stat.textContent);
|
||||
animateNumber(stat, target);
|
||||
});
|
||||
statsObserver.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
}, { threshold: 0.5 });
|
||||
|
||||
// 观察统计区域
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const aboutSection = document.querySelector('.about-stats');
|
||||
if (aboutSection) {
|
||||
statsObserver.observe(aboutSection);
|
||||
}
|
||||
});
|
||||
|
||||
// 导出函数供测试使用
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = {
|
||||
createServiceCard,
|
||||
showNotification,
|
||||
animateNumber
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user