/** * Created by Administrator on 2023/6/13. */ $(function () { try { /* 页面进入动画 */ var windowWidth = $(window).width() if(windowWidth > 1300){ $('.block').smoove() } /* 页面滚动一屏 */ // $("html,body").animate({scrollTop:0}, 600); $("#dowmPage").click(function (){ var winHeight = $(window).height() - 120 $("html,body").animate({scrollTop:winHeight}, 500); }) /* 通知学术切换 */ $("#noticetabs .title").click(function(){ var _this = $(this) _this.addClass('active').siblings().removeClass('active') if(_this.index() === 0){ $(".noticeDom").css("display","block") $(".scienceDom").css("display","none") }else{ $(".scienceDom").css("display","block") $(".noticeDom").css("display","none") } }) /* banner */ new Swiper('#banner', { autoplay: { delay: 5000, disableOnInteraction: false, }, pagination: { el: '.swiper-pagination', clickable: true, }, speed: 1000, loop: true, }) /* 新闻 */ new Swiper('#newsId', { autoplay: { delay: 4000, disableOnInteraction: false, }, pagination: { el: '.swiper-pagination-news', clickable: true, }, speed: 1000, loop: true, }) var width = $(window).width() /* 新闻轮播 */ new Swiper("#newsmediaId", { slidesPerView: width < 1050 ? 2 : 3, spaceBetween: 10, loop: true, autoplay: { delay: 4000, disableOnInteraction: false, }, on: { // hs使用这个监听,唯有在浏览器窗口变化时才触发。 resize: function () { if (document.body.clientWidth < 1050) { this.params.slidesPerView = 2; } else { this.params.slidesPerView = 3; } this.update(); //窗口变化时,更新Swiper的一些属性,如宽高等 }, }, }); /* 外媒报道 */ new Swiper("#mediaId", { slidesPerView: width < 1050 ? 2 : 3, spaceBetween: 20, loop: true, autoplay: { delay: 4000, disableOnInteraction: false, }, navigation: { nextEl: ".media-button-next", prevEl: ".media-button-prev", }, on: { // hs使用这个监听,唯有在浏览器窗口变化时才触发。 resize: function () { if (document.body.clientWidth < 1050) { this.params.slidesPerView = 2; } else { this.params.slidesPerView = 3; } this.update(); //窗口变化时,更新Swiper的一些属性,如宽高等 }, }, }); /* 校园看点 */ var _video = new Swiper('#_video', { autoplay: { delay: 3000, disableOnInteraction: false, }, speed: 500, loop: true }) /* 移动段菜单打开关闭 */ var menuId = $("#menuId") var menuShade = $("#menuShade") var open = false $("#menuBtnId,#menuShade").click(function () { if (!open) { open = true menuId.addClass("active") menuShade.addClass("active") } else { open = false menuId.removeClass("active") menuShade.removeClass('active') } }) /* 滚动监听header */ // var isMain = $('body').attr('class') === 'main' // $(window).scroll(function () { // if (!isMain) return; // var top = $(document).scrollTop() // var width = $(window).width() // if (width < 1020) { // return // } // if (top >= 20) { // $("#headerId").addClass('active') // } else { // $("#headerId").removeClass('active') // } // }); // 鼠标滚动事件 // 为某个对象添加滚动监听事件(传入要监听的对象) // var width = $(window).width(); // addScrollListener(document) // // function addScrollListener(obj) { // if (obj.addEventListener) { // // Firefox // obj.addEventListener('DOMMouseScroll', wheel, false) // } // // IE/Chrome/Opera // // window.onmousewheel = document.onmousewheel = wheel // obj.onmousewheel = wheel // } // // // 统一处理滚轮滚动事件 // function wheel(event) { // event = event || window.event // 解决IE8兼容性问题 // var flag = 0 // if (event.wheelDelta) { // // IE、Chrome、Opera浏览器使用的是wheelDelta(向下为-120或-150,向上为120或150) // flag = event.wheelDelta // } else if (event.detail) { // // Firefox使用的是detail(向下为3,向上为-3,因此取反与其他浏览器保持一致) // flag = -event.detail // } // // // 调用对应处理函数 // if (flag) scrollHandle(flag) // // 阻止浏览器的默认滚动行为; 若监听的是window/document,则不阻止 // if (event.target !== document.body) { // // event.preventDefault && event.preventDefault() // // return false // 兼容IE8 // } // } // // // 分别编写向上、向下滚动时对应的处理函数 // function scrollHandle(flag) { // if (flag < 0) { // // 向下滚动 // showMain(true) // } else { // // 向上滚动 // showMain(false) // } // } // // function showMain(type) { // var scrollTop = $(window).scrollTop() // var bannerHeight = $("#banner").height() - 90 // // if (type) { // // $("#headerId").addClass('down') // // } else { // // $("#headerId").removeClass('down') // // } // if (!isMain) return; // // if (scrollTop < 10 && type) { // // $("body,html").stop().animate({ // // scrollTop: bannerHeight // // }, 500) // // } // // if (scrollTop < bannerHeight - 50 && !type) { // // $("body,html").stop().animate({ // // scrollTop: 0 // // }, 500) // // } // } // 内容列表页快速导航 /*导航显示隐藏*/ var off = true if (width < 992) { $(".navClick").slideToggle() $('#topheader').click(function () { $(".navClick").slideToggle() if (off) { off = false } else { off = true } }) } /* 折叠面板 */ $('.tag-panel .tag-title').click(function(){ var _this = $(this) var par = _this.parent() var p_height = _this.siblings().find('.p-content').height() var panelContent = _this.siblings('.panel-content') if(par.attr('class').indexOf('active')!==-1){ par.removeClass('active') panelContent.css({ height: '0px' }) }else{ par.addClass('active') panelContent.css({ height: p_height+'px' }) } }) } catch (e) { console.log(e, '--------') } })