立刻获取第一张碳身份证
让中国的每一个碳都拥有独一无二的可信数字身份
@@ -269,6 +273,9 @@ export default {
activeTab: 0,
topBannerHeight: 820,
newsLoading: true,
+ isScrolling: false,
+ scrollThreshold: 1,
+ sectionIds: ['section-hero', 'section-core', 'section-capability', 'section-overseas', 'section-news', 'section-partner', 'section-bottom'],
newsListByType: {
gjzc: [], // 国家政策
hyzx: [], // 行业资讯
@@ -372,11 +379,80 @@ export default {
this.syncBannerHeight();
window.addEventListener('resize', this.syncBannerHeight);
this.fetchNewsData();
+ window.addEventListener('wheel', this.handleWheel, { passive: false });
},
beforeDestroy() {
window.removeEventListener('resize', this.syncBannerHeight);
+ window.removeEventListener('wheel', this.handleWheel);
},
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) {
window.open(url);
},
@@ -508,7 +584,7 @@ export default {
};
-