$(function(){
/*产品目录第一个默认展开*/
/*$(".menu_li>p>span").first().addClass('on');
$(".menu_li>ul").first().show();*/
var h_mulu_li=$('.ly_show_in .hd .h_mulu ul li').length*125-120+68;
$('.ly_show_in .hd .h_mulu ul').width(h_mulu_li);
});
function goTop(){
$('html,body').animate({'scrollTop':0},300);
}
var windowWidth = $(window).width();
/*if(windowWidth < 767){
var top_nav=0;
$('.navigation li i').click(function(event){
if(top_nav==0){
$(this).parent('li').toggleClass('on');
$(this).parent('li').children('.nav2').slideToggle(300);
top_nav=1;
}else{
$(this).parent('li').toggleClass('on');
$(this).parent('li').children('.nav2').slideToggle(300);
top_nav=0;
}
event.stopPropagation();
});
}*/
if(windowWidth >= 767){
/*网站导航二级目录*/
$(".navigation li").hover(function(){
$(this).children('.nav2').show();
},function(){
$(this).children('.nav2').hide();
});
}
var menu_tit_flag3=0;
$(".navigation li i").on('click',function(){
if ( matchMedia( 'only screen and (max-width:767px)' ).matches ) {
if(menu_tit_flag3==0){
$(this).parents('li').children('.nav2').stop(true).slideDown(300);
menu_tit_flag3=1;
}else{
$(this).parents('li').children('.nav2').stop(true).slideUp(300);
menu_tit_flag3=0;
}
}
event.stopPropagation();
});
/*网站导航点击事件*/
var menu_flag=0;
$('.btn-menu').click(function(event){
if(menu_flag==0){
$(this).toggleClass('active');
$('.navigation').slideToggle(300);
menu_flag=1;
}else{
$(this).toggleClass('active');
$('.navigation').slideToggle(300);
menu_flag=0;
}
event.stopPropagation();
});
var menu_tit_flag=0;
$('.menu_tit').on('click',function(){
if ( matchMedia( 'only screen and (max-width:991px)' ).matches ) {
if(menu_tit_flag==0){
$('.menu_list').stop(true).slideToggle(300);
$(this).children('em').html('点击收起 -');
menu_tit_flag=1;
}else{
$('.menu_list').stop(true).slideToggle(300);
$(this).children('em').html('点击展开+');
menu_tit_flag=0;
}
}
});
/*产品目录收缩*/
$(".menu_li>p>span").on('click',function(){
$(this).parents('p').next('ul').stop(true).slideToggle(300);
$(this).stop(true).toggleClass('on');
});
/*联系方式tab切换*/
$(".contact .tags_title .one").hover(function(){
$(this).removeClass('ron');
$(".contact .tags_title .two").addClass('ron');
$(".contact .content2").hide();
$(".contact .content1").show();
},function(){
});
$(".contact .tags_title .two").hover(function(){
$(this).removeClass('ron');
$(".contact .tags_title .one").addClass('ron');
$(".contact .content1").hide();
$(".contact .content2").show();
},function(){
});
/*产品目录收缩*/
$(".pro_mulu>ul>li").hover(function() {
$(".pro_mulu>ul>li>div").hide();
$(".pro_mulu>ul>li").removeClass('on');
$(this).addClass('on');
$(this).children('div').show();
}, function() {
});
/*在线漂浮关闭按钮*/
$('.oline_zxzx .hd i.close').click(function(){
$('.oline_zxzx').fadeOut(500);
});
/*详情页表格 开始*/
$(function() {
var fuji = $('#c_detail_wrap table').parent();
if(fuji.length>0) {
$('#c_detail_wrap table').wrap("");
$('#new-div').prepend("");
}
var h_table;
var flag_table=0;
function setTable() {
var lxl=1;
$('section#new-div').removeClass('on');
$('section#new-div').scrollTop(0,0);
$("section#new-div table,section#new-div table td").removeAttr("width");
$("section#new-div table,section#new-div table td").removeAttr("height");
$("section#new-div table").css('width','initial');
$("section#new-div table td").css('width','initial');
/*$("section#new-div table td").css('height','initial');*/
$('#c_detail_wrap table').each(function() {
if ( matchMedia( 'only screen and (max-width:1199px)' ).matches ) {
var zclientWidth=$(document).outerWidth();
var ztableWidth=$(this).outerWidth();
var zscale=zclientWidth/ztableWidth*0.871546673799;
lxl=zscale;
if(lxl>1){lxl=1;}
}
$(this).css("transform","scale(" + lxl + ")");
var h_table=$(this).height();
$(this).parent('section#new-div').height(h_table*lxl+10);
});
}
$("#c_detail_wrap table").on('click',function(){
if ( matchMedia( 'only screen and (max-width:1199px)' ).matches ) {
if(flag_table==0){
$(this).parent('section#new-div').addClass('on');
$(this).parent('section#new-div').children('table').css("transform","scale(" + 1 + ")");
$(this).parent('section#new-div').height(h_table);
flag_table=1;
}else{
setTable();
flag_table=0;
}
}
});
$("#c_detail_wrap #new-div .zoom-caret").on('click',function(){
if ( matchMedia( 'only screen and (max-width:1199px)' ).matches ) {
if(flag_table==0){
$(this).parent('section#new-div').addClass('on');
$(this).parent('section#new-div').children('table').css("transform","scale(" + 1 + ")");
$(this).parent('section#new-div').height(h_table);
flag_table=1;
}else{
setTable();
flag_table=0;
}
}
});
/*调用方法*/
setTable();
$(window).resize(function() {
/*调用方法*/
setTable();
});
/*产品详情页点击tab切换*/
$(".nyprodetail2 .hd span").on('click',function(){
var num1=$(this).index();
$(".nyprodetail2 .bd>section").eq(num1).show().siblings('.nyprodetail2 .bd>section').hide();
$(this).addClass('on').siblings('.nyprodetail2 .hd span').removeClass('on');
/*调用方法*/
setTable()
});
});
/*详情页表格 结束*/
//图片滚动 调用方法 imgscroll({speed: 30,amount: 1,dir: "up"});
$.fn.imgscroll = function(o){
var defaults = {
speed: 40,
amount: 0,
width: 1,
dir: "left"
};
o = $.extend(defaults, o);
return this.each(function(){
var _li = $("li", this);
_li.parent().parent().css({overflow: "hidden", position: "relative"}); //div
_li.parent().css({margin: "0", padding: "0", overflow: "hidden", position: "relative", "list-style": "none"}); //ul
_li.css({position: "relative", overflow: "hidden"}); //li
if(o.dir == "left") _li.css({float: "left"});
//初始大小
var _li_size = 0;
for(var i=0; i<_li.size(); i++)
_li_size += o.dir == "left" ? _li.eq(i).outerWidth(true) : _li.eq(i).outerHeight(true);
//循环所需要的元素
if(o.dir == "left") _li.parent().css({width: (_li_size*3)+"px"});
_li.parent().empty().append(_li.clone()).append(_li.clone()).append(_li.clone());
_li = $("li", this);
//滚动
var _li_scroll = 0;
function goto(){
_li_scroll += o.width;
if(_li_scroll > _li_size)
{
_li_scroll = 0;
_li.parent().css(o.dir == "left" ? { left : -_li_scroll } : { top : -_li_scroll });
_li_scroll += o.width;
}
_li.parent().animate(o.dir == "left" ? { left : -_li_scroll } : { top : -_li_scroll }, o.amount);
}
//开始
var move = setInterval(function(){ goto(); }, o.speed);
_li.parent().hover(function(){
clearInterval(move);
},function(){
clearInterval(move);
move = setInterval(function(){ goto(); }, o.speed);
});
});
};
$(document).ready(function(){
$(".ly_scroll").imgscroll({
speed: 20, //图片滚动速度
amount: 0, //图片滚动过渡时间
width: 1, //图片滚动步数
dir: "left" // "left" 或 "up" 向左或向上滚动
});
});