// 工程案例页面脚本 $(document).ready(function() { // Tab切换 /* $('.tab-menu-item').on('click', function(e) { e.preventDefault(); $('.tab-menu-item').removeClass('active'); $(this).addClass('active'); // 这里可以添加加载不同类别工程的逻辑 console.log('切换到:' + $(this).text()); }); */ // 工程卡片点击 /* $('.project-card').on('click', function() { const projectTitle = $(this).find('.project-title').text(); console.log('查看工程详情:' + projectTitle); // 跳转到详情页 // window.location.href = 'detail.html?id=xxx'; }); */ // 分页功能 /* let currentPage = 1; const totalPages = 4; // 总页数,实际应该从后端获取 */ // 更新分页状态 /* function updatePagination(page) { currentPage = page; // 更新页码激活状态 $('.pagination-link').removeClass('active'); $(`.pagination-link[data-page="${page}"]`).addClass('active'); // 更新上一页/下一页按钮状态 if (currentPage <= 1) { $('.pagination-link.prev').addClass('disabled'); } else { $('.pagination-link.prev').removeClass('disabled'); } if (currentPage >= totalPages) { $('.pagination-link.next').addClass('disabled'); } else { $('.pagination-link.next').removeClass('disabled'); } // 滚动到列表顶部 $('html, body').animate({ scrollTop: $('.projects-grid').offset().top - 100 }, 500); // 这里应该通过AJAX加载对应页的数据 console.log('切换到第', page, '页'); } */ // 分页点击事件 /* $('.pagination-link').on('click', function(e) { e.preventDefault(); if ($(this).hasClass('disabled') || $(this).hasClass('active')) { return; } const page = $(this).data('page'); if (page === 'prev') { if (currentPage > 1) { updatePagination(currentPage - 1); } } else if (page === 'next') { if (currentPage < totalPages) { updatePagination(currentPage + 1); } } else { updatePagination(page); } }); */ // 初始化分页状态 //updatePagination(currentPage); // 返回顶部 $('#backToTop').on('click', function() { $('html, body').animate({ scrollTop: 0 }, 600); }); // 显示/隐藏返回顶部按钮 $(window).on('scroll', function() { if ($(this).scrollTop() > 300) { $('#backToTop').fadeIn(); } else { $('#backToTop').fadeOut(); } }); // 滚动动画 function checkScroll() { $('.project-card').each(function(index) { const elementTop = $(this).offset().top; const windowBottom = $(window).scrollTop() + $(window).height(); if (elementTop < windowBottom - 50) { setTimeout(() => { $(this).css({ 'opacity': '1', 'transform': 'translateY(0)' }); }, index * 50); } }); } // 初始化动画 $('.project-card').css({ 'opacity': '0', 'transform': 'translateY(20px)', 'transition': 'all 0.5s ease' }); $(window).on('scroll', checkScroll); checkScroll(); });