关闭
用户登录
返回顶部
// 添加新的交互脚本 $(document).ready(function() { // 页面加载完成后隐藏加载动画 setTimeout(function() { $('.loading-overlay').fadeOut(); }, 500); // 图片懒加载 $('.txtitem img').each(function() { $(this).attr('data-src', $(this).attr('src')); $(this).attr('src', ''); }); function lazyLoad() { $('.txtitem img').each(function() { if ($(this).offset().top < $(window).height() + $(window).scrollTop()) { $(this).attr('src', $(this).attr('data-src')); } }); } lazyLoad(); $(window).on('scroll', lazyLoad); // 平滑滚动 $('a[href*="#"]').on('click', function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: $($(this).attr('href')).offset().top }, 500); }); // 返回顶部按钮动画 $(window).scroll(function() { if ($(window).scrollTop() > 600) { $('#backtop').addClass('visible'); } else { $('#backtop').removeClass('visible'); } }); // 修改 showpdf 函数添加动画 window.showpdf = function(pdf) { if(!userinfo) { window.location.href ='https://cas.sntcm.edu.cn/lyuapServer/login?service=http://szjx.sntcm.edu.cn/userinfo.html'; return; } $.ajax({ url: baseurl + "/course/view/"+$(pdf).attr("data-cid"), type: 'GET', contentType: "application/json", headers: { "Authorization": sessionStorage.getItem("header") }, dataType: 'json', success: (res) => {} }); $.ajax({ url: baseurl + "/course/meta/"+$(pdf).attr("data-id"), type: 'GET', contentType: "application/json", headers: { "Authorization": sessionStorage.getItem("header") }, dataType: 'json', success: (res) => { if (res.code == '200') { $("#pdfname").html(res.data.cmsResourcesCourseMetaList[0].attachName); $("#tcbox").addClass('active').show(); $("#pdf").attr("href", baseurl + res.data.cmsResourcesCourseMetaList[0].attachPath); $('a.media').media(); time1 = Date.now(); xkid = res.data.projectId; infoid = $(pdf).attr("data-id"); } } }); }; // 修改关闭函数添加动画 window.closetc = function() { $("#tcbox").removeClass('active').fadeOut(300); tiaozhuan(); }; // 内容加载动画 function animateContent() { $('.txtitem').each(function(index) { $(this).css({ 'animation': `fadeInUp 0.5s ease forwards ${index * 0.1}s`, 'opacity': '0' }); }); } // 监听内容变化并触发动画 const observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.addedNodes.length) { animateContent(); } }); }); observer.observe(document.getElementById('htmlbox'), { childList: true, subtree: true }); });