//头部、底部加载
(function (win) {
resizeRoot();
function resizeRoot() {
var wWidth = document.documentElement.clientWidth;
if (wWidth > 640) wWidth = 640;
else if (wWidth <320) wWidth = 320;
document.documentElement.style.fontSize = wWidth / 7.5 + 'px';
}
window.onresize = resizeRoot;
})(window);
// 轮播
$(function(){
// 以防冲突
if($(".c_slide").length){
$(".c_slide").each(function(){
var p_first="
"+$(this).find(".txtBox .txt:first").text()+"
";
var p_last=""+$(this).find(".txtBox .txt:last").text()+"
";
$(this).find(".txtBox").prepend(p_last);
$(this).find(".txtBox").append(p_first);
var present=$(this);
setSlide(present);
});
}
if($(".c_slide2").length){
setSlide2(".c_slide2");
}
sub_column();
});
function setSlide(obj){
var mySwiper = new Swiper(obj, {
autoplay: 5000,//可选选项,自动滑动
observer:true,
observeParents:true,
// 前进后退按钮
nextButton: '.c_next',
prevButton: '.c_prev',
loop:true,
onSlideChangeStart: function(swiper){
obj.find(".txtBox .txt").hide();
obj.find(".txtBox .txt").eq(swiper.activeIndex).stop().fadeIn();
}
});
}
function setSlide2(obj2){
var mySwiper = new Swiper(obj2, {
autoplay: 5000,//可选选项,自动滑动
observer:true,
loop:true,
observeParents:true,
// 前进后退按钮
nextButton: '.c_next2',
prevButton: '.c_prev2'
});
}
$(function(){
// var url = window.location.href;
// if (url.indexOf('aspx') < 0 && url.indexOf('html') > 0) {
// $("#header").load("header.html");
// $("#footer").load("footer.html");
// $("#sidenav").load("sidenav.html");
// }
// 文本多了隐藏,点击展开
$(".c_ny_top .unfold").click(function(){
$(this).parents(".c_ny_top").find(".p_box").toggleClass("on");
});
// 展开关闭切换
if($(".c_hide_box").length){
$(".c_hide_box").on("click",".cut_btn",function(){
$(this).siblings(".hid").slideToggle();
$(this).toggleClass("on");
});
}
if($(".c_tab_wr").length){
tab();
}
if($(".c_tab_wr2").length){
tab2();
}
$("table").each(function(){
$(this).find("th:odd").addClass("col");
});
//自定义滚动条
if($(".user-defined").length){
$(".user-defined").mCustomScrollbar({
horizontalScroll: true,
theme: "minimal-dark",
autoHideScrollbar: false
});
}
});
// unfoldTxt(按钮,外盒子,内盒子,初始高度);
function unfoldTxt(btn,obj_big,obj,hei){
$("body").on("click",btn,function(){
var $p_box = $(this).siblings(obj_big).eq(0); //当按钮是外盒子兄弟级时开启
// var $p_box = $(this).parents(obj_big); 当按钮是外盒子子级时开启
var i_switch = $(this).hasClass("on");
$(btn).removeClass("on");
$(obj_big).stop().animate({"height":hei}, 300);
if(i_switch){
$(this).removeClass("on");
$p_box.stop().animate({"height":hei}, 300);
}else{
$(this).addClass("on");
$p_box.stop().animate({"height":$p_box.find(obj).innerHeight()}, 300);
}
});
}
function tab(){
$(".c_tab_wr .bd .item").hide();
if($(".c_tab_wr .hd .on").length){
$(".c_tab_wr .bd .item").eq($(".c_tab_wr .hd .on").index()).show();
}else{
$(".c_tab_wr .hd li").eq(0).addClass("on");
$(".c_tab_wr .bd .item").eq(0).show();
}
$(".c_tab_wr .hd").on("click","li",function(){
$(this).addClass("on").siblings('li').removeClass("on");
$(".c_tab_wr .bd .item").eq($(this).index()).stop().fadeIn().siblings('.item').hide();
});
}
function tab2(){
$(".c_tab_wr2 .bd .item").hide();
if($(".c_tab_wr2 .hd .on").length){
$(".c_tab_wr2 .bd .item").eq($(".c_tab_wr2 .hd .on").index()).show();
}else{
$(".c_tab_wr2 .hd li").eq(0).addClass("on");
$(".c_tab_wr2 .bd .item").eq(0).show();
}
$(".c_tab_wr2 .hd").on("click","li",function(){
$(this).addClass("on").siblings('li').removeClass("on");
$(".c_tab_wr2 .bd .item").eq($(this).index()).stop().fadeIn().siblings('.item').hide();
});
}
//下拉
$(".c_down").each(function(){
$(this).hover(function(){
$(this).addClass("on");
},function(){
$(this).removeClass("on");
});
var s=$(this);
var z=parseInt(s.css("z-index"));
var dt=$(this).children("span");
var dd=$(this).children("ul");
var _show=function(){dd.slideDown(200);s.css("z-index",z+1);dt.addClass("on")}; //展开效果
var _hide=function(){dd.slideUp(200);s.css("z-index",z);dt.removeClass("on")}; //关闭效果
dt.click(function(){dd.is(":hidden")?_show():_hide();});
dd.find("li").click(function(){dt.html($(this).html());_hide();}); //选择效果(如需要传值,可自定义参数,在此处返回对应的“value”值 )
$("body").click(function(i){ !$(i.target).parents(".c_down").first().is(s) ? _hide():"";});
});
// wow动画
$(function(){
if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))){
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 0,
mobile: true,
live: true
});
wow.init();
};
});
function sub_column(){
if($(".sub_nav").length){
$(".curr").click(function(){
$(this).siblings('.sub_nav').stop().fadeIn();
$("html,body").scrollTop(0);
$("html").addClass("ovfHiden");
});
$(".sub_nav .bg,.sub_nav .this").click(function(e){
$('.sub_nav').stop().fadeOut();
$("html").removeClass("ovfHiden");
e.stopPropagation();
});
}
}
// a标签的伪类兼容ios移动端的方法
// document.body.addEventListener('touchstart',function(){});