File: /www/wwwroot/m.wfehn.com/static/js/mt-tabpage2.js
$(function () {
$("[js-tab=2]").tab({
curDisplay: 1,
changeMethod: "horizontal",
});
});
(function ($, window, document, undefined) {
var Plugin = function (elem, options) {
this.$wrapper = elem;
this.$tab_list = this.$wrapper
.find(".mt-tabpage-title")
.find(".mt-tabpage-item");
this.$tabCont_wrap = this.$wrapper.find(".mt-tabpage-cont__wrap");
this.$tab_cont = this.$tabCont_wrap.find(".mt-tabpage-item");
this.timer = null;
this.playTimer = null;
this.iNow = 0;
this.defaults = {
curDisplay: 1,
mouse: "click",
changeMethod: "default",
autoPlay: false,
};
this.opts = $.extend({}, this.defaults, options);
};
Plugin.prototype = {
inital: function () {
var self = this;
this.setData();
this.tabInital();
if (this.opts.mouse === "click") {
this.$tab_list.click(function () {
self.changeTab($(this).index());
self.iNow = $(this).index();
});
} else if (this.opts.mouse === "over") {
this.$tab_list.hover(
function () {
var cur_obj = this;
clearTimeout(self.timer);
self.timer = setTimeout(function () {
self.changeTab($(cur_obj).index());
}, 30);
self.iNow = $(this).index();
},
function () {
clearTimeout(self.timer);
}
);
} else {
this.$tab_list.click(function () {
self.changeTab($(this).index());
self.iNow = $(this).index();
});
}
if (this.opts.autoPlay) {
clearInterval(this.playTimer);
this.playTimer = setInterval(function () {
self.autoPlay();
}, 1000);
this.$wrapper.hover(
function () {
clearInterval(self.playTimer);
},
function () {
self.playTimer = setInterval(function () {
self.autoPlay();
}, 1000);
}
);
}
},
setData: function () {
var tabCont_w = this.$tab_cont.width();
var tabCont_h = this.$tab_cont.height();
var tabCont_len = this.$tab_cont.length;
switch (this.opts.changeMethod) {
case "default":
this.$tab_cont.css({
display: "none",
});
break;
case "horizontal":
this.$tabCont_wrap.css({
width: tabCont_w * tabCont_len,
});
this.$tab_cont.css({
float: "left",
});
break;
case "vertical":
this.$tabCont_wrap.css({
height: tabCont_h * tabCont_len,
});
break;
case "opacity":
this.$tab_cont.css({
display: "none",
});
break;
default:
this.$tab_cont.css({
display: "none",
});
break;
}
},
tabInital: function () {
var curNum = this.opts.curDisplay - 1;
this.$tab_list.removeClass("mt-tabpage-item-cur");
this.$tab_list.eq(curNum).addClass("mt-tabpage-item-cur");
if (
this.opts.changeMethod === "default" ||
this.opts.changeMethod === "opacity"
) {
this.$tab_cont.eq(curNum).css({
display: "block",
});
} else if (this.opts.changeMethod === "horizontal") {
this.$tabCont_wrap.css({
left: -curNum * this.$tab_cont.width(),
});
} else if (this.opts.changeMethod === "vertical") {
this.$tabCont_wrap.css({
top: -curNum * this.$tab_cont.height(),
});
} else {
this.$tab_cont.eq(curNum).css({
display: "block",
});
}
this.iNow = this.opts.curDisplay - 1;
},
changeTab: function (index) {
this.$tab_list.removeClass("mt-tabpage-item-cur");
this.$tab_list.eq(index).addClass("mt-tabpage-item-cur");
switch (this.opts.changeMethod) {
case "default":
this.$tab_cont.css({
display: "none",
});
this.$tab_cont.eq(index).css({
display: "block",
});
break;
case "horizontal":
this.$tabCont_wrap.stop().animate({
left: this.$tab_cont.width() * -index,
});
break;
case "vertical":
this.$tabCont_wrap.stop().animate({
top: this.$tab_cont.height() * -index,
});
break;
case "opacity":
this.$tab_cont.stop().fadeOut();
this.$tab_cont.eq(index).stop().fadeIn();
break;
default:
this.$tab_cont.css({
display: "none",
});
this.$tab_cont.eq(index).css({
display: "block",
});
break;
}
},
autoPlay: function () {
if (this.iNow === this.$tab_list.length - 1) {
this.iNow = 0;
} else {
this.iNow++;
}
this.changeTab(this.iNow);
},
constructor: Plugin,
};
$.fn.tab = function (options) {
var plugin = new Plugin(this, options);
return plugin.inital();
};
})(window.jQuery, window, document);
$(function () {
var height = $("#main-page .right").height();
$(".mt-tabpage-count").css("height", height + 64);
$("#main-page .nav").css("height", height - 64);
});
$(function () {
var height3 = $("#main-page2 .right").height();
$(".mt-tabpage-count").css("height", height3 + 64);
// $("#main-page2 .nav").css("height", height3 - 64);
// $("#main-page2 .nav").css("height", '666');
});
$(function () {
var height4 = $("#main-page3 .right").height();
$(".mt-tabpage-count").css("height", height4 + 64);
$("#main-page3 .nav").css("height", height4 - 64);
});
$(function () {
var height2 = $("#main-page1 .right").height();
console.log(height2);
$(".mt-tabpage-count").css("height", height2 + 64);
$("#main-page .nav").css("height", height2 - 64);
$(".img_box").click(function () {
$(".bigImg").show();
document.body.style.overflow = "hidden";
});
$("#button").click(function () {
$(".bigImg").hide();
document.body.style.position = "static";
document.body.style.overflow = "";
});
$(".bigImg .box").click(function () {
$(".bigImg").hide();
document.body.style.position = "static";
document.body.style.overflow = "";
});
$(".jzyb").on("click", ".pic", function () {
var img = $(this).find("img").attr("src");
var tit = $(this).parent().find(".txt").text();
var des = $(this).parent().find(".desT").text();
var str = "";
str += '<div class="img_box"><img src="' + img + '"></div>';
str += '<p class="text1">' + tit + "</p>";
str += '<p class="text2">' + des + "</p>";
$(".bigImg .box .insideBox").html(str);
$(".bigImg").show();
document.body.style.overflow = "hidden";
});
});
// var swiper = new Swiper(".aquaculture02 .mySwiper", {
// slidesPerView: 3,
// speed:200,
// // spaceBetween: 64,
// initialSlide: 0,
// // centeredSlides: false,
// centeredSlidesBounds: true,
// freeMode: true,
// // autoplayDisableOnInteraction : false,
// observer:true,
// observeParents:true,
// autoplay: { //匀速滚动
// delay: 2000, //间隔时间毫秒
// stopOnLastSlide: false,
// disableOnInteraction: true, //触摸后仍然执行
// },
// navigation: {
// nextEl: ".aquaculture02 .swiper-button-next",
// prevEl: ".aquaculture02 .swiper-button-prev",
// },
// // 分页索引
// // pagination: {
// // el: ".swiper-pagination",
// // clickable: true,
// // },
// scrollbar: {
// el: ".swiper-scrollbar",
// },
// // on: {
// // setTranslate: function () {
// // this.$wrapperEl.transition("");
// // TweenMax.to(this.$wrapperEl, 1.2, {
// // x: this.translate,
// // ease: Power4.easeOut,
// // });
// // },
// // },
// });
if (document.documentElement.clientWidth<=1024) {
//这里执行的是移动端的代码;
var swiper = new Swiper('.swiper2', {
slidesPerView: 1,
loop:true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
autoplay: { //匀速滚动
delay: 2000, //间隔时间毫秒
stopOnLastSlide: false,
disableOnInteraction: false, //触摸后仍然执行
},
});
} else{
//这里执行的是PC端的代码;
var swiper = new Swiper('.swiper2', {
slidesPerView: 3,
spaceBetween: 30,
loop:true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
autoplay: { //匀速滚动
delay: 2000, //间隔时间毫秒
stopOnLastSlide: false,
disableOnInteraction: false, //触摸后仍然执行
},
});
}