(function () { //定义页面参数 var page ={ render: function () { //垂直导航下拉 this.verticalNav(); //侧边导航栏固定 this.asideNavFix(); //手机端导航切换 this.mobileNav(); //置顶gotop this.goTop(); //拖拽移动 this.moveDrag(); }, //垂直导航下拉 verticalNav: function () { var oNav = $('#nav'); var aLi = oNav.find('li'); aLi.hover(function (){ $(this).addClass('on'); $(this).find('.v-arrow').toggleClass('icon-previewright icon-arrow3') },function (){ $(this).removeClass('on'); if($(this).children().hasClass('v-subNav')){ $(this).find('.v-arrow').toggleClass('icon-previewright icon-arrow3') } }) }, //手机端导航切换 mobileNav: function (){ $('.mobile-header-icon').click(function(){ $(this).toggleClass('icon-menu icon-guanbi') $('.mobile-main').fadeToggle(500) $('body').toggleClass('nav-open'); }) var mNav = $('.mobile-nav'); var mLi = mNav.find('li'); mLi.find('.v-arrow').click(function(){ $(this).parents('li:first').toggleClass('on'); if($(this).parents('li:first').hasClass('on')){ $(this).addClass('icon-arrow3') $(this).removeClass('icon-previewright') $(this).next('.mobile-subNav').slideDown() }else{ $(this).addClass('icon-previewright') $(this).removeClass('icon-arrow3'); $(this).next('.mobile-subNav').slideUp() } }) }, //侧边导航栏固定 asideNavFix : function (){ var asideHeight = $(".vertical-wrap-nav").height() var iWSon =document.documentElement.clientWidth; var clientHeight = document.documentElement.clientHeight; //var vLogoHeight =$('.v-logo').outerHeight(); if(iWSon >1024){ $(window).scroll(function(){ var asideHeight = $(".vertical-wrap-nav").height() var conHeight = $(".mode01").height(); var headerHeight =$('.wrap-header').height(); var wrapHeight = headerHeight + conHeight conHeight = conHeight - asideHeight; var scrollTop = $(window).scrollTop(); if(scrollTop < 163){ $('.vertical-wrap-nav').removeClass('fixTop'); }else{ $('.vertical-wrap-nav').addClass('fixTop'); } if(scrollTop > conHeight){ $('.vertical-wrap-nav').removeClass('fixTop'); $('.vertical-wrap-nav').addClass('fixBottom'); }else{ $('.vertical-wrap-nav').removeClass('fixBottom'); } }) } }, //置顶gotop goTop: function(){ $('.goTop').click(function(){ $('body,html').stop().animate({scrollTop:0}); return false; }); }, //拖拽移动 moveDrag: function() { var isMove = false; var X, Y; var left, top; $(".drag" ).bind('mousedown', function (e) { isMove = true; X = e.pageX - parseInt($(".drag").css("left")); Y = e.pageY - parseInt($(".drag").css("top")); }) $(".drag").bind('touchstart', function (e) { isMove = true; X = e.originalEvent.touches[0].clientX - parseInt($(".drag").css("left")); Y = e.originalEvent.touches[0].clientY - parseInt($(".drag").css("top")); }) $(document).bind('mousemove', function (e) { if (isMove) { left = e.pageX - X; top = e.pageY - Y; if (left < 0) { left = 1 } if (top < 0) { top = 1 } if (left > $(window).width() - $(".drag").width()) { left = $(window).width() - $(".drag").width() - 2 } if (top > $(window).height() - $(".drag").height()) { top = $(window).height() - $(".drag").height() - 2 } $(".drag").css({left: left, top: top}); } }) $(document).bind('touchmove', function (e) { if (isMove) { left = e.originalEvent.touches[0].clientX - X; top = e.originalEvent.touches[0].clientY - Y; if (left < 0) { left = 2 } if (top < 0) { top = 2 } if (left > $(window).width() - $(".drag").width()) { left = $(window).width() - $(".drag").width() - 2 } if (top > $(window).height() - $(".drag").height()) { top = $(window).height() - $(".drag").height() - 2 } $(".drag").css({left: left, top: top}); } }) $(document).bind('mouseup', 'touchend', function (e) { isMove = false; }) } } // 渲染页面 page.render(); var resizeTimer = null; $(window).bind('resize', function (){ if (resizeTimer) clearTimeout(resizeTimer); resizeTimer = setTimeout(function(){ // page.render('verticalNav'); // page.render('asideNavFix'); logoResize() } ,0); }); })(); logoResize() function logoResize(){ var sWSon = document.documentElement.clientWidth; if(sWSon<=380 ){ $('.logo_01').find('image').attr({width:150,height:35}) $('.logo_01').find('svg').attr({width:150,height:35}) $('.logo_02').find('image').attr({width:55,height:18}) $('.logo_02').find('svg').attr({width:55,height:18}) }else if(sWSon<=998 & sWSon > 380){ $('.logo_01').find('image').attr({width:200,height:46}) $('.logo_01').find('svg').attr({width:200,height:46}) $('.logo_02').find('image').attr({width:80,height:26}) $('.logo_02').find('svg').attr({width:80,height:26}) }else{ $('.logo_01').find('image').attr({width:270,height:62}) $('.logo_01').find('svg').attr({width:270,height:62}) $('.logo_02').find('image').attr({width:105,height:34}) $('.logo_02').find('svg').attr({width:105,height:34}) } } //分页下拉框跳转方法 function pageSelect(){ console.log($('.pageSelect').length) if($('.pageSelect').length!=0){ $('.pageSelect').select2({}); $("#select21").on("change",function(){ window.location.href=$(this).val() }) $("#select22").on("change",function(){ var $thval=$(this).val() if($thval=="") return false; //value 索引从0开始 $(".camel-list .list").eq($thval).find(".demo-img:first").click(); }) } } //文章页侧边栏固定 function asideFix(){ var sWSon = document.documentElement.clientWidth; if(sWSon > 998){ $(window).scroll(function(){ var scrollTop = $(window).scrollTop(); var asideHeight = $(".sub_aside2").height(); var rtHeight = $('.pageArticle .rt').height(); var lfHeight = $('.pageArticle .lf').height(); var pageArticleHeight = $(".pageArticle").height(); conHeight = pageArticleHeight - asideHeight; if(lfHeight > rtHeight && scrollTop >= rtHeight){ $('.sub_aside2').addClass('fixTop'); }else{ $('.sub_aside2').removeClass('fixTop'); } if(lfHeight > rtHeight && scrollTop > conHeight){ $('.sub_aside2').removeClass('fixTop'); $('.sub_aside2').addClass('fixBottom'); }else{ $('.sub_aside2').removeClass('fixBottom'); } }) } }