feat: 修改主页面添加交互功能

This commit is contained in:
zheng020 2026-04-30 05:52:50 +08:00
parent cce8a1c57b
commit d7406956db
2 changed files with 133 additions and 37 deletions

View File

@ -3,8 +3,9 @@
<!-- 主页面 --> <!-- 主页面 -->
<div class="container"> <div class="container">
<!-- 顶部背景轮播 --> <!-- 顶部背景轮播 -->
<div class="top-box"> <div class="top-box" id="section-hero">
<t-swiper class="top-banner-swiper" animation="fade" :height="topBannerHeight" :interval="6000" :duration="500" :loop="true" :autoplay="true" theme="dark"> <t-swiper class="top-banner-swiper" animation="fade" :height="topBannerHeight" :interval="6000" :duration="500"
:loop="true" :autoplay="true" theme="dark">
<t-swiper-item v-for="(src, idx) in topBannerImages" :key="idx"> <t-swiper-item v-for="(src, idx) in topBannerImages" :key="idx">
<div class="banner-slide" :style="{ backgroundImage: `url(${src})` }" /> <div class="banner-slide" :style="{ backgroundImage: `url(${src})` }" />
</t-swiper-item> </t-swiper-item>
@ -27,7 +28,8 @@
</div> </div>
<div class="top-search-hot"> <div class="top-search-hot">
<div class="hot-label">热门搜索: </div> <div class="hot-label">热门搜索: </div>
<div class="hot-tag" v-for="(tag, index) in hotSearchTags" :key="index" @click="handleHotSearch(tag)">{{ tag }}</div> <div class="hot-tag" v-for="(tag, index) in hotSearchTags" :key="index" @click="handleHotSearch(tag)">{{
tag }}</div>
</div> </div>
</div> </div>
@ -71,8 +73,8 @@
</div> </div>
<!-- 中间核心驱动 --> <!-- 中间核心驱动 -->
<section class="core-section"> <section class="core-section" id="section-core">
<div class="section-container"> <div class="section-container core-container">
<div class="section-title core-title"> <div class="section-title core-title">
<!-- <span class="title-bar"></span> --> <!-- <span class="title-bar"></span> -->
<span class="title-text">核心驱动</span> <span class="title-text">核心驱动</span>
@ -90,7 +92,7 @@
</section> </section>
<!-- 共性能力模块 --> <!-- 共性能力模块 -->
<section class="capability-section"> <section class="capability-section" id="section-capability">
<div class="section-container capability-container"> <div class="section-container capability-container">
<div class="capability-header"> <div class="capability-header">
<div class="capability-title-group"> <div class="capability-title-group">
@ -103,7 +105,8 @@
</div> </div>
<div class="capability-grid"> <div class="capability-grid">
<div class="capability-card" v-for="(item, index) in capabilityList" :key="index" @click="handleCapabilityClick(item)"> <div class="capability-card" v-for="(item, index) in capabilityList" :key="index"
@click="handleCapabilityClick(item)">
<div class="capability-card-content"> <div class="capability-card-content">
<img :src="item.icon" :alt="item.name" class="capability-icon" /> <img :src="item.icon" :alt="item.name" class="capability-icon" />
<span class="capability-name">{{ item.name }}</span> <span class="capability-name">{{ item.name }}</span>
@ -115,7 +118,7 @@
</section> </section>
<!-- 企业出海模块 --> <!-- 企业出海模块 -->
<section class="overseas2-section"> <section class="overseas2-section" id="section-overseas">
<div class="section-container overseas2-container"> <div class="section-container overseas2-container">
<div class="overseas2-header"> <div class="overseas2-header">
<div class="overseas2-title-group"> <div class="overseas2-title-group">
@ -144,7 +147,7 @@
</section> </section>
<!-- 行业动态 --> <!-- 行业动态 -->
<section class="news-section"> <section class="news-section" id="section-news">
<div class="section-container news-container"> <div class="section-container news-container">
<div class="news-header"> <div class="news-header">
<div class="news-title-group"> <div class="news-title-group">
@ -156,7 +159,8 @@
</div> </div>
<div class="news-tabs"> <div class="news-tabs">
<div class="news-tab" :class="{ 'news-tab-active': activeTab === index }" v-for="(tab, index) in newsTabs" :key="index" @click="activeTab = index"> <div class="news-tab" :class="{ 'news-tab-active': activeTab === index }" v-for="(tab, index) in newsTabs"
:key="index" @click="activeTab = index">
{{ tab.name }} {{ tab.name }}
</div> </div>
</div> </div>
@ -195,7 +199,7 @@
</section> </section>
<!-- 合作伙伴模块 --> <!-- 合作伙伴模块 -->
<section class="partner-section"> <section class="partner-section" id="section-partner">
<div class="section-container"> <div class="section-container">
<div class="partner-title-area"> <div class="partner-title-area">
<div class="partner-title-content"> <div class="partner-title-content">
@ -242,7 +246,7 @@
</section> </section>
<!-- 建立您的碳数字身份 --> <!-- 建立您的碳数字身份 -->
<div class="bottom-box"> <div class="bottom-box" id="section-bottom">
<div class="content"> <div class="content">
<div class="bottom-box-content-title">立刻获取第一张碳身份证</div> <div class="bottom-box-content-title">立刻获取第一张碳身份证</div>
<div class="desc">让中国的每一个碳都拥有独一无二的可信数字身份</div> <div class="desc">让中国的每一个碳都拥有独一无二的可信数字身份</div>
@ -269,6 +273,9 @@ export default {
activeTab: 0, activeTab: 0,
topBannerHeight: 820, topBannerHeight: 820,
newsLoading: true, newsLoading: true,
isScrolling: false,
scrollThreshold: 1,
sectionIds: ['section-hero', 'section-core', 'section-capability', 'section-overseas', 'section-news', 'section-partner', 'section-bottom'],
newsListByType: { newsListByType: {
gjzc: [], // gjzc: [], //
hyzx: [], // hyzx: [], //
@ -372,11 +379,80 @@ export default {
this.syncBannerHeight(); this.syncBannerHeight();
window.addEventListener('resize', this.syncBannerHeight); window.addEventListener('resize', this.syncBannerHeight);
this.fetchNewsData(); this.fetchNewsData();
window.addEventListener('wheel', this.handleWheel, { passive: false });
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener('resize', this.syncBannerHeight); window.removeEventListener('resize', this.syncBannerHeight);
window.removeEventListener('wheel', this.handleWheel);
}, },
methods: { methods: {
handleWheel(e) {
if (this.isScrolling) return;
const delta = Math.abs(e.deltaY);
if (delta < this.scrollThreshold) return;
e.preventDefault();
this.isScrolling = true;
const direction = e.deltaY > 0 ? 1 : -1;
const viewHeight = window.innerHeight;
let currentIndex = -1;
let minDistance = Infinity;
//
for (let i = 0; i < this.sectionIds.length; i++) {
const el = document.getElementById(this.sectionIds[i]);
if (el) {
const rect = el.getBoundingClientRect();
//
if (rect.top <= viewHeight && rect.bottom > 0) {
const distance = Math.abs(rect.top);
if (distance < minDistance) {
minDistance = distance;
currentIndex = i;
}
}
}
}
//
if (currentIndex === -1) {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
for (let i = 0; i < this.sectionIds.length; i++) {
const el = document.getElementById(this.sectionIds[i]);
if (el && el.offsetTop <= scrollTop) {
currentIndex = i;
}
}
}
let targetIndex;
if (direction > 0) {
//
targetIndex = currentIndex === -1 ? 0 : Math.min(currentIndex + 1, this.sectionIds.length - 1);
} else {
//
targetIndex = currentIndex === -1 ? 0 : Math.max(currentIndex - 1, 0);
}
const targetEl = document.getElementById(this.sectionIds[targetIndex]);
if (targetEl) {
const rect = targetEl.getBoundingClientRect();
const elHeight = rect.height;
if (elHeight < viewHeight) {
//
targetEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
} else {
//
targetEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
setTimeout(() => {
this.isScrolling = false;
}, 800);
},
openNewTab(url) { openNewTab(url) {
window.open(url); window.open(url);
}, },
@ -528,6 +604,7 @@ export default {
z-index: 9999; z-index: 9999;
} }
.logo-box { .logo-box {
text-align: center; text-align: center;
} }
@ -630,7 +707,8 @@ export default {
margin-top: 64px; margin-top: 64px;
width: 100%; width: 100%;
/* max-width: 1920px; */ /* max-width: 1920px; */
margin: 0 auto; /* 左右居中 */ margin: 0 auto;
/* 左右居中 */
min-height: 100vh; min-height: 100vh;
} }
@ -881,6 +959,7 @@ export default {
.cyan-card .card-header { .cyan-card .card-header {
background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.2) 100%); background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.2) 100%);
} }
.cyan-card .card-body { .cyan-card .card-body {
box-shadow: 0px 8px 12px 0px rgba(0, 185, 107, 0.1); box-shadow: 0px 8px 12px 0px rgba(0, 185, 107, 0.1);
backdrop-filter: blur(8px); backdrop-filter: blur(8px);
@ -895,6 +974,7 @@ export default {
.green-card .card-header { .green-card .card-header {
background: linear-gradient(180deg, rgba(107, 255, 204, 0.4) 0%, rgba(107, 255, 204, 0.2) 100%); background: linear-gradient(180deg, rgba(107, 255, 204, 0.4) 0%, rgba(107, 255, 204, 0.2) 100%);
} }
.green-card .card-body { .green-card .card-body {
box-shadow: 0px 8px 12px 0px rgba(0, 185, 107, 0.1); box-shadow: 0px 8px 12px 0px rgba(0, 185, 107, 0.1);
backdrop-filter: blur(8px); backdrop-filter: blur(8px);
@ -909,10 +989,17 @@ export default {
/* ==================== 核心驱动模块 ==================== */ /* ==================== 核心驱动模块 ==================== */
.core-section { .core-section {
width: 100%; width: 100%;
height: 100vh;
background: #fff; background: #fff;
padding: 80px 0; padding: 80px 0;
} }
.core-container{
position: relative;
top: 50%;
transform: translateY(-50%);
}
.section-container { .section-container {
max-width: 1400px; max-width: 1400px;
margin: 0 auto; margin: 0 auto;
@ -1022,6 +1109,7 @@ export default {
/* ==================== 共性能力模块 ==================== */ /* ==================== 共性能力模块 ==================== */
.capability-section { .capability-section {
height: 100vh;
position: relative; position: relative;
padding: 80px 0; padding: 80px 0;
overflow: hidden; overflow: hidden;
@ -1052,17 +1140,17 @@ export default {
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background: linear-gradient( background: linear-gradient(180deg,
180deg,
rgba(245, 247, 250, 1) 0%, rgba(245, 247, 250, 1) 0%,
rgba(255, 255, 255, 0.8) 50%, rgba(255, 255, 255, 0.8) 50%,
rgba(245, 247, 250, 1) 100% rgba(245, 247, 250, 1) 100%);
);
} }
.capability-container { .capability-container {
position: relative; position: relative;
z-index: 1; z-index: 1;
top: 50%;
transform: translateY(-50%);
} }
.capability-header { .capability-header {
@ -1177,9 +1265,8 @@ export default {
/* ==================== 企业出海模块(新样式) ==================== */ /* ==================== 企业出海模块(新样式) ==================== */
.overseas2-section { .overseas2-section {
/* position: relative; */ height: 100vh;
position:sticky; position: relative;
top: 64px;
padding: 80px 0; padding: 80px 0;
overflow: hidden; overflow: hidden;
background-image: url('~@/pages/index/assets/qych-bg.png'); background-image: url('~@/pages/index/assets/qych-bg.png');
@ -1191,6 +1278,8 @@ export default {
.overseas2-container { .overseas2-container {
position: relative; position: relative;
z-index: 1; z-index: 1;
top: 50%;
transform: translateY(-50%);
} }
.overseas2-header { .overseas2-header {
@ -1342,8 +1431,7 @@ export default {
z-index: 1; z-index: 1;
} }
.news-header { .news-header {}
}
.news-title-group { .news-title-group {
display: flex; display: flex;
@ -1552,6 +1640,7 @@ export default {
0% { 0% {
background-position: 200% 0; background-position: 200% 0;
} }
100% { 100% {
background-position: -200% 0; background-position: -200% 0;
} }
@ -1647,6 +1736,7 @@ export default {
/* ==================== 合作伙伴模块 ==================== */ /* ==================== 合作伙伴模块 ==================== */
.partner-section { .partner-section {
height: 100vh;
position: relative; position: relative;
background: #f5f7fa; background: #f5f7fa;
padding: 80px 0; padding: 80px 0;
@ -1686,6 +1776,7 @@ export default {
0% { 0% {
transform: translateX(0); transform: translateX(0);
} }
100% { 100% {
transform: translateX(-50%); transform: translateX(-50%);
} }
@ -1695,6 +1786,7 @@ export default {
0% { 0% {
transform: translateX(-50%); transform: translateX(-50%);
} }
100% { 100% {
transform: translateX(0); transform: translateX(0);
} }
@ -1823,9 +1915,12 @@ export default {
background-image: url(~@/pages/index/assets/home-szsf-bg.png); background-image: url(~@/pages/index/assets/home-szsf-bg.png);
background-repeat: no-repeat; /* 不重复 */ background-repeat: no-repeat;
background-size: cover; /* 不拉伸,保持原图尺寸 */ /* 不重复 */
background-position: left; /* 永远显示中间部分 */ background-size: cover;
/* 不拉伸,保持原图尺寸 */
background-position: left;
/* 永远显示中间部分 */
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -1893,6 +1988,7 @@ export default {
} }
@media (max-width: 767px) { @media (max-width: 767px) {
/* 容器调整 */ /* 容器调整 */
.container { .container {
margin-top: 64px; margin-top: 64px;

View File

@ -287,14 +287,14 @@ module.exports = {
// 会误伤 SPA 路由 /view/mhzc/...,刷新时整页请求被转发到后端导致 Proxy error。必须用 ^ 限定为路径前缀。 // 会误伤 SPA 路由 /view/mhzc/...,刷新时整页请求被转发到后端导致 Proxy error。必须用 ^ 限定为路径前缀。
proxy: { proxy: {
'^/sso': { '^/sso': {
// target: 'http://localhost:9301', target: 'http://192.168.110.29:9301',
target: 'http://carbon.liantu.tech', // target: 'http://carbon.liantu.tech',
// target: 'http://10.23.20.13:94/', // target: 'http://10.23.20.13:94/',
changeOrigin: true, changeOrigin: true,
}, },
'^/mhzc': { '^/mhzc': {
// target: 'http://localhost:9302', target: 'http://192.168.110.29:9302',
target: 'http://carbon.liantu.tech', // target: 'http://carbon.liantu.tech',
// target: 'http://10.23.20.13:94/', // target: 'http://10.23.20.13:94/',
changeOrigin: true, changeOrigin: true,
}, },