// 2024.01.18
$('.visible_btn').each(function(){ $(this).addClass('off') });
$('.visible_box').each(function(){ $(this).addClass('off') });
$('.visible_btn').click(function(){
var box = $(this).attr('visible');
$(this).toggleClass('on');
$('.visible_box[visible*="' + box + '"]').toggleClass('on off')
});
// 切换每个传入的参数
function toggleOn(){var args = arguments.length;for( var i = 0; i < args; i++ ){ $(arguments[i]).toggleClass('on');} }
function toggleParentOn(a){ $(a).parent().toggleClass('on'); }
// 获得页面向左、向上卷动的距离
function getScroll(){
return {
left: window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0,
top: window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
};
}
function getPosition(el) {
var xPos = 0;
var yPos = 0;
if( typeof el == 'string' ){
el = document.querySelector(el);
}
while (el) {
if (el.tagName == "BODY") {
var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
var yScroll = el.scrollTop || document.documentElement.scrollTop;
xPos += (el.offsetLeft - xScroll + el.clientLeft);
yPos += (el.offsetTop - yScroll + el.clientTop);
var transform = getComputedStyle(el,null).transform;
if(transform != 'none'){
var transformArr = transform.split(',');
xPos += parseInt(transformArr[4]);
yPos += parseInt(transformArr[5]);
}
} else {
xPos += (el.offsetLeft - el.scrollLeft + el.clientLeft);
yPos += (el.offsetTop - el.scrollTop + el.clientTop);
var transform = getComputedStyle(el,null).transform;
if(transform != 'none'){
var transformArr = transform.split(',');
xPos += parseInt(transformArr[4]);
yPos += parseInt(transformArr[5]);
}
}
el = el.offsetParent;
}
return {
x: xPos,
y: yPos
};
}
// 页面板块逐渐进入效果
setTimeout("enterEffects();","200");
$(document).ready(function(){
enterEffects();
});
$(window).resize(function(){
var resizeTimer = null;
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(function(){
enterEffects();
},50);
});
$(window).scroll(function(){
enterEffects();
});
// 逐个出现
$('.effect11,.effect21,.effect31,.effect41,.effect51,.effectChildren').each(function() {
$(this).find("li").each(function(index){
var len = $(this).parent().find("li").length;
// $( this ).css({'transition-delay': (index*0.5/len)+'s'});
$( this ).css({'transition-delay': (index*0.05)+'s'});
})
});
function enterEffects(){
var sWSon = document.documentElement.clientWidth;
if(sWSon >= 996){
$(".effect").each(function(index, element) {
var enterEffects_y = getPosition(this).y;
var transform = getComputedStyle($(this)[0],null).transform;
if(transform != 'none'){
var transformArr = transform.split(',');
enterEffects_y -= parseInt(transformArr[5]);
}
if( enterEffects_y <= $(window).height() * .85 ){
$(this).addClass("isView");
}else{
$(this).removeClass("isView");
}
});
}
$('.lazy').each(function() {
if( getPosition(this).y <= $(window).height() * 2 ){
if( $(this).attr('data-src') != undefined && $(this).attr('data-src') != '' ){
$(this).attr("src",$(this).attr("data-src"));
$(this).removeAttr('data-src').removeClass('lazy').addClass('lazyed');
}
if( $(this).attr('data-background') != undefined && $(this).attr('data-background') != '' ){
$(this).css("background-image","url(" + $(this).attr("data-background") + ")");
$(this).removeAttr('data-background').removeClass('lazy').addClass('lazyed');
}
}
});
}
function fixNav(){
var w_width = document.documentElement.clientWidth,
w_height = document.documentElement.clientHeight,
scrollHeight = document.body.scrollHeight;
if( scrollHeight > w_height + 100 && w_width > 996 ){
var scrollTop = $(window).scrollTop();
if( scrollTop >= 150 ){
$('.header').addClass('currents')
}else{
$('.header').removeClass('currents')
}
}else{
$('.header').removeClass('currents')
}
}
fixNav();
$(window).scroll(function(){
fixNav();
});
$.fn.extend({
// tab切换
tab: function (options){
var tabDefaults = { //默认参数
ev : 'mouseover', //默认事件'mouseover','click'
til : 'h2', //默认标签
box : '.tab_list', //默认列表
defaultNum : 0, //默认展示第几个
eachPage : 1, //每次切换的个数
delay : 100, //延迟时间
auto : true, //是否自动切换 true,false
speed : 4000, //自动切换间隔时间(毫秒)
init : function(){}, //首次加载时触发时间
before : function (){}, //切换前触发事件
after : function (){}, //切换后触发事件
more : true //是否有more,false,true
};
var options = $.extend(tabDefaults, options); //用户设置参数覆盖默认参数
return this.each(function (){
var o = options;
var obj = $(this);
var oTil = obj.find(o.til);
var oBox = obj.find(o.box);
var oMore = null;
var iNum = o.defaultNum;
var iLen = oTil.length;
var iBefore = o.before;
var iAfter = o.after;
var iEach = o.eachPage;
// 默认选中第一个
o.init();
if( iNum >= 0 ){
change( oTil.eq(iNum) );
}
//鼠标事件绑定
oTil.bind(o.ev , function (){
var _this = this;
if(o.ev == 'mouseover' && o.delay){
_this.timer = setTimeout(function (){
change(_this);
},o.delay);
}else{
change(_this);
};
})
oTil.bind('mouseout',function (){
var _this = this;
clearTimeout(_this.timer);
});
//自动切换效果
(function autoPlay(){
var timer2 = null;
if(o.auto){
function play(){
iNum++;
if(iNum >= iLen){
iNum =0;
};
change(oTil.eq(iNum));
};
timer2 = setInterval(play,o.speed);
obj.on('mouseover',function (){
clearInterval(timer2);
})
obj.on('mouseout',function (){
timer2 = setInterval(play,o.speed);
})
};
})();
function change(box){
iBefore(iNum,obj);
// console.log(1);
iNum = $(box).index() - obj.find(o.til).eq(0).index();
oTil.removeClass('on').addClass('off');
oBox.removeClass('on').addClass('off');
if(o.more){
oMore = obj.find('.more');
oMore.removeClass('on').addClass('off');
oMore.eq(iNum).addClass('on').removeClass('off');
};
oTil.eq(iNum).addClass('on').removeClass('off');
oBox.slice( iEach * iNum , iEach * (iNum + 1) ).addClass('on').removeClass('off');
iAfter(iNum,obj);
}
});
},
// 数字滚动
countTo: function(opts) {
var countToDefaults = {
lastSymbol:"", //显示在最后的字符,如 %、个、'个' 等
from: 0, // 开始时的数字
speed: 1000, // 总时间
refreshInterval: 100, // 刷新一次的时间
beforeSize:0, //小数点前最小显示位数,不足的话用0代替
decimals: 0, // 小数点后的位数
onUpdate: null, // 更新时回调函数
onComplete: null // 结束后回调函数
}
// 合并自定义的方法
var options = $.extend(countToDefaults, opts);
return $(this).each(function() {
// 设置总更新次数从而得到每次累加的值
var _this = this,
originalData = $(this).text(),//初始值
loops = Math.ceil(options.speed / options.refreshInterval),//总更新次数
increment = ($(this).text() - options.from) / loops,//每次累加的值
loopCount = 0,
value = options.from,
interval = setInterval(updateTimer, options.refreshInterval);
//console.log(Number(originalData).toFixed(options.decimals));
function updateTimer() {
value += increment;
loopCount++;
var str=value.toFixed(options.decimals);
//运算到此时的字符串总长度
this.sizeNum=str.length;
//运算到此时的小数点前的字符长度
this.sizeNumBefore=this.sizeNum-options.decimals-1;
//判断 此时的小数点前的字符串长度是否>=需要的字符串小数点前的长度
if(this.sizeNumBefore>=options.beforeSize) {
$(_this).html(str+options.lastSymbol);
} else{
//在<的时候 前面要补0 再显示
this._str = Array(options.beforeSize-this.sizeNumBefore + 1).join('0') + str;
$(_this).html(this._str+options.lastSymbol);
}
if (typeof(options.onUpdate) == 'function') {
options.onUpdate.call(_this, value, loopCount);
//用call方法 把 options.onUndate=='function'(是一个方法), 替换掉_this,并把value作为和这个函数的参数
}
if (loopCount >= loops) {//over
clearInterval(interval);
$(_this).html(originalData+options.lastSymbol);
value = $(_this).text();
if (typeof(options.onComplete) == 'function') {
//options.onComplete.call(_this, value, loopCount);
options.onComplete(value,loopCount,_this);
}
}
}
});
}
})
//根据参数名获得该参数 pname等于想要的参数名
function getParam(pname) {
var params = location.search.substr(1); // 获取参数 平且去掉?
var ArrParam = params.split('&');
if(ArrParam.length == 1){
//只有一个参数的情况
return params.split('=')[1]; }
else{
//多个参数参数的情况
for (var i = 0; i < ArrParam.length; i++) {
if (ArrParam[i].split('=')[0] == pname) {return ArrParam[i].split('=')[1];}
}
}
}
// 点击回到页面顶部
function gotop(){
$('body,html').stop().animate({scrollTop:0});
}
// 页面加载完成后根据链接地址滚动到指定板块
function scrollLink(){
var mao = $("#" + getParam("mao"));
if (mao.length > 0) {
var pos = mao.offset().top;
$("html,body").animate({scrollTop: pos-120}, 1000);
}
}
// scrollLink();
// 点击滚动到指定板块
function q_scrollTo(tar){
var pos = $(''+ tar).offset().top;
$("html,body").animate({scrollTop: pos-120}, 1000);
}
$('.select_link').click(function(){
$(this).find('.arrow').toggleClass('on');
$(this).find('.alert_box').toggleClass('on');
$(this).toggleClass('on');
})
$('.select_link').mouseleave(function(){
$(this).find('.arrow').removeClass('on');
$(this).find('.alert_box').removeClass('on');
$(this).removeClass('on');
})
$("#pageNumber").keydown(function(e){if(e.keyCode == 13){jumpTo()}});
$('.jumpto').click(function(){jumpTo()});
function jumpTo(){
var pageNumber = parseInt($('#pageNumber').val());
if(pageNumber>0 && pageNumber <= maxPageCount){
document.location.href = pageNumber==1?"index.htm":pageNumber > maxPageCount?"index"+(parseInt(maxPageCount)-1).toString()+".htm":"index"+(pageNumber-1).toString()+".htm";
}else{
$('.tips').text('页码需大于0小于'+maxPageCount)
}
}
// 图片延迟加载
function loadimg(imglist){
var i=0;
var run;
$(imglist).each(function(index, element) {
$(this).attr("data",$(this).attr("src"));
$(this).attr("src","");
$(this).addClass("unload");
});
run = function(img){
i++;
if($(window).scrollTop()+$(window).height()>img.offset().top){
img.load(function(){
if($("img.unload").eq(0).length > 0 && i<1000){
run($("img.unload").eq(0));
}
});
img.attr("src",img.attr("data")).removeClass("unload");
}
}
run($("img.unload").eq(0));
$(window).scroll(function(){
if($("img.unload").eq(0).length>0 && i<1000){
run($("img.unload").eq(0));
}
});
}
// 默认配置swiper
// var a = new swiperFun({
// dom: $('.外盒子'),
// // domList: $('.紧挨着列表的盒子')
// })
// function swiperFun(swiper) {
// this.dom = swiper.dom;
// this.domList = this.dom;
// this.dom.find('ul').addClass('swiper-wrapper');
// this.dom.find('li').addClass('swiper-slide');
// if(swiper.domList !== undefined){
// this.domList = this.dom.find(swiper.domList)
// }
// if(this.dom.find('.num').length > 0){
// this.dom.find('.num-total').html(this.dom.find('li').length)
// }
// this.change = function () {};
// var that = this;
// this.mySwiper = new Swiper(that.domList, {
// effect: swiper.effect !== undefined ? swiper.effect : 'slide',
// loop: swiper.loop !== undefined ? swiper.loop : true,
// autoplay: swiper.autoplay !== undefined ? swiper.autoplay : 5000,
// autoplayDisableOnInteraction: false,
// paginationClickable: true,
// speed: 600,
// slidesPerView: swiper.slidesPerView !== undefined ? swiper.slidesPerView : 1,
// slidesPerGroup: swiper.slidesPerGroup !== undefined ? swiper.slidesPerGroup : 1,
// centeredSlides: swiper.centeredSlides !== undefined ? swiper.centeredSlides : false,
// slideToClickedSlide: swiper.slideToClickedSlide !== undefined ? swiper.slideToClickedSlide : false,
// pagination: that.dom.find('.dots'),
// loopAdditionalSlides : 10,
// onSlideChangeStart: function(swiper){
// if(that.dom.find('.num').length > 0){
// that.dom.find('.num-curr').html(swiper.realIndex + 1)
// }
// that.change(swiper.realIndex);
// }
// });
// this.dom.find('.prev').click(function () {
// that.mySwiper.slidePrev();
// return false
// });
// this.dom.find('.next').click(function () {
// that.mySwiper.slideNext();
// return false
// })
// }
function play_swiper_video(swiper,controls){
$('.vv').each(function() {
$(this)[0].pause();
$(this)[0].currentTime = 0;
$(this).remove();
});
if( $(swiper).find('.swiper-slide.swiper-slide-active .gp-video-box').length > 0 ){
setTimeout(function(){
document.querySelector(swiper).swiper.autoplay.stop();
},100)
var _this = $('.swiper-slide.swiper-slide-active .gp-video-box');
var _video = _this.attr('data-video');
var _poster = _this.attr('poster-src') || '';
var videos = '';
if( controls ){
videos = '';
}
_this.append(videos);
_this.find('video').bind('ended', function() {
document.querySelector(swiper).swiper.slideNext();
document.querySelector(swiper).swiper.autoplay.start();
});
}
}
// 二级页侧栏菜单
$('.sub_menu .arrow').click(function(){
$(this).parent('.t').toggleClass('on');
$(this).parent('.t').parent('li').toggleClass('on');
$(this).parent('.t').next('ul').toggle(300);
})
$('.sub_menu_title').click(function(){
var sWSon = document.documentElement.clientWidth;
if(sWSon < 992 && $('.sub_menu').length > 0 ){
$(this).toggleClass('on');
$('.sub_left').toggleClass('on');
$('.sub_menu .lv0').toggle(300);
}
})
function initSubMenu(){
$('.sub_menu a.current').each(function(){
$(this).parent().parent('li').addClass('current');
$(this).parents('.sub_menu .lv0 ul').parent('li').addClass('on');
$(this).parents('.sub_menu .lv0 ul').slideDown(0);
$(this).parents('.sub_menu .lv0 ul').prev('.t').addClass('on');
// 当前栏目子栏目也展开
$(this).parent().addClass('on');
$(this).parent().siblings('ul').slideDown(0);
})
}
if( $(window).width() > 992 ){
initSubMenu();
}
// function linkTo(t,href){
// // window.location.href(href)
// // window.location.href=href;
// // return false;
// $(t).click(function(){
// window.open(href);
// return false;
// });
// }
// $('a').each(function(){
// var _href = $(this).attr('href');
// if( _href != undefined ){
// linkTo(this,_href);
// }
// })
// 固定在侧边
function fixedSideBar(options){
var defaults = {
wrapscroll : '.wrap_fix_scroll',
scroll : '.fix_scroll',
distance : 120, // 固定在屏幕内距离顶部的距离
showHeader : false
};
var options = $.extend(defaults,options);
if( options.showHeader ){
var _h_height = $('.header').outerHeight();
if( _h_height == null ){
_h_height = 0;
}
if( _h_height > defaults.distance ){
defaults.distance = _h_height + 10;
}
}
var oWrap = $(options.wrapscroll),
oScroll = $(options.scroll),
wrapTop = oWrap.offset().top,
wrapHeight = oWrap.outerHeight(),
scrollHeight = oScroll.outerHeight(),
scrollBottom = wrapTop + wrapHeight - scrollHeight,
start = wrapTop - options.distance,
end = scrollBottom - options.distance;
var currentStatus = 1;
function resetPosition(){
wrapTop = oWrap.offset().top;
wrapHeight = oWrap.outerHeight();
scrollHeight = oScroll.outerHeight();
scrollBottom = wrapTop + wrapHeight - scrollHeight;
start = wrapTop - options.distance;
end = scrollBottom - options.distance;
}
function checkPostion(){
var oWrap_y = getPosition(oWrap[0]).y;
if( oWrap_y > options.distance ){
var returnStatus = 1;
}else if( oWrap_y + wrapHeight - scrollHeight < options.distance ){
var returnStatus = 2;
}else{
var returnStatus = 3;
}
if( returnStatus != currentStatus ){
currentStatus = returnStatus;
if( oWrap_y > options.distance ){
oScroll.css({'position':'absolute','top':'0','bottom':'auto'});
}else if( oWrap_y + wrapHeight - scrollHeight < options.distance ){
oScroll.css({'position':'absolute','top': 'auto','bottom':'0'});
}else{
oScroll.css({'position':'fixed','top':options.distance+'px','bottom':'auto'});
}
}
}
$(document).ready(function(){
resetPosition();
checkPostion()
});
$(window).resize(function(){
var resizeTimer = null;
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(function(){
resetPosition();
checkPostion()
},50);
});
checkPostion();
$(window).scroll(function(){
// resetPosition();
checkPostion();
});
oWrap.parents().scroll(function(){
resetPosition();
checkPostion();
})
}
if( $('.wrap_fix_scroll').length > 0 ){
fixedSideBar();
}
if( $(window).width() > 996 ){
$(window).scroll(function(){
if( $(window).scrollTop() > 200 ){
$('.aside_link').addClass('on')
}else{
$('.aside_link').removeClass('on')
}
})
}