$(function () { setTimeout(function () { new WOW().init(); headerNav($(".header")) banner() // productTab('.index.product', '.tabControl a', '.product-content') mobileNav() toolbar() indexDSwiper(".indexD", 4, 2, 4, 20) // indexDBgimg() contentWayPoint() number() indexCSwiper() productSwiper() $("img").on("contextmenu", function () { return false; }); $("img").on("dragstart", function () { return false; }); }, 300) }) $(window).scroll(function () { headerNav($(".header")) }) // 产品列表滚动 function productSwiper() { new Swiper('.productSwiper', { slidesPerView: 3, spaceBetween: -100, centeredSlides: true, loop: true, autoplay: { delay: 2000, stopOnLastSlide: false, disableOnInteraction: false, }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, }); } // 数字滚动 var b = false if ($(".indexD .indexD-title").length > 0) { $(window).scroll(function () { if ($(".indexD .indexD-title").offset().top - $(window).scrollTop() - $(window).height() < -10 && $(".indexD .indexD-title").offset().top - $(window).scrollTop() > -10) { if (b) { b = false number() } } else { b = true } }) } function number() { $("*[data-number]").each(function () { $(this).width($(this).width() + 1).numberRock({ lastNumber: $(this).data('number'), //终止数字 duration: 2000, easing: 'swing', //慢快慢 }) }); } $.fn.numberRock = function (options) { var defaults = { lastNumber: 100, duration: 2000, easing: 'swing' //swing(默认 : 缓冲 : 慢快慢) linear(匀速的) }; var opts = $.extend({}, defaults, options); $(this).animate({ num: "numberRock", }, { duration: opts.duration, easing: opts.easing, complete: function () { // console.log("success"); }, step: function (a, b) { //可以检测我们定时器的每一次变化 $(this).html(parseInt(b.pos * opts.lastNumber)); } }); } // 专属设计 function indexCSwiper() { new Swiper('.indexC .swiper-container', { effect: 'fade', loop: true, autoplay: true, autoplay: { delay: 2000, disableOnInteraction: false, }, pagination: { el: '.swiper-pagination', clickable: true, }, slidesPerView: 1, }) } // 专属设计 function hoverImg(a) { $(".indexC-list-box").eq(a).hover(function () { // $(this).find("img").attr('src', "images/indexC-" + (a + 4) + "w.png"); if ($(".indexC-img").hasClass("hover")) { $(".indexC-img").removeClass("hover") $(".indexC-img .a img").attr('src', "images/indexC" + (a + 1) + ".jpg"); } else { $(".indexC-img").addClass("hover") $(".indexC-img .b img").attr('src', "images/indexC" + (a + 1) + ".jpg"); } }, function () { // $(this).find("img").attr('src', "images/indexC-" + (a + 4) + ".png"); if ($(".indexC-img").hasClass("hover")) { $(".indexC-img .a img").attr('src', "images/indexC" + (a + 1) + ".jpg"); } else { $(".indexC-img .b img").attr('src', "images/indexC" + (a + 1) + ".jpg"); } }) } // 客户案例-校徽 function indexDBgimg() { $(".indexD-bgimg-img .content-img").eq(0).addClass("active"); $(".indexD-bgimg-list").eq(0).addClass("active"); $(".indexD-bgimg-list").mouseenter(function () { if ($(this).attr("data-id") != $(".indexD-bgimg-list.active").attr("data-id")) { $(".indexD-bgimg-list").removeClass("active"); $(this).addClass("active"); $(".indexD-bgimg-img .content-img").removeClass("active"); $(".indexD-bgimg-img .content-img" + "[data-id='" + $(this).attr("data-id") + "']").addClass("active"); } }) } // 客户案例-校徽 function indexDSwiper(a, b, c, d, e) { $(a + " .swiper-wrapper").html(function () { var a = ""; var b = ["南京师范大学附属小学六合双语方洲校区", "安徽全椒中学", "北大附属即墨实验小学", "北外附属贵阳学校", "玛利娅·蒙特梭利幼儿园", "扬州市汶河小学", "苏州相城实验小学", "徐州张集矿校", "长沙博雅卫生学校", "苏州天成中学", "镇江索普初级中学", "江苏省亭湖高级中学", "丹阳新桥初级中学", "重庆市九龙坡区华梁学校", "常州龙城小学", "黑龙江大庆靓湖学校", "大庆市第五十一中学", "大庆市铁人学校", "大庆外国语学校", "大庆一中附属机关小学", "岳阳市云梦教育集团", "浙江省岱山中学", "浙江岱山职业技术学校", "丹阳市实验学校", "丹阳市建山学校", "丹阳市云阳学校", "哈尔滨师范大学附属中学", "杭州娃哈哈双语学校", "呼和浩特市第三职业中专", "华师大苏州湾实验小学", "淮安市第一中学", "淮安市浦东实验学校", "江苏科技大学附属中学", "昆山市秀峰中学", "南京溧水经济开发区小学", "南京市溧水区实验小学", "北师大常州附属学校", "江苏省南菁高级中学", "淮安清江浦中学", "圣奥本国际双语学校", "扬州树人国际部", "扬州中学教育集团树人学校", "北美国际学校", "江苏省运河中学", "盐城市大丰外国语学校", "苏州工业园区莲花学校", "江苏省盐城中学", "苏州国际外语学校", "北大附属嘉兴实验学校", "江苏大学", "华师大苏州实验中学", "上海浦东明珠小学", "上海市临港第一中学", "上海万科实验小学"] for (var i = 01; i <= 54; i++) { a += '
' a += '
' a += '

' + b[i - 1] + '

' a += '
' } return a }) new Swiper(a + ' .swiper-container', { effect: 'slide', speed: 1000, // loop: true, // autoplay: true, // autoplay: { // delay: 3000, // disableOnInteraction: false, // }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, slidesPerView: 4, slidesPerColumn: 2, slidesPerColumnFill: 'row', slidesPerGroup: 2, spaceBetween: 5, breakpoints: { 768: { slidesPerView: b, slidesPerColumn: c, slidesPerGroup: d, spaceBetween: e, }, 426: { slidesPerView: 5, slidesPerColumn: 2, slidesPerGroup: 3, spaceBetween: 5, } } }) // $(".indexD-swiper img").hover(function () { // console.log($(this).data("id")) // $(".index.indexD").css("background-image","url(images/indexC3.jpg)") // },function(){ // console.log(1) // $(".index.indexD").css("background-image","url()") // }) } // 导航栏 function headerNav(obj) { if ($(window).scrollTop() > $(".header").height()) { obj.addClass("fixed") } else if ($(window).scrollTop() <= $(".header").height()) { obj.removeClass("fixed") } } // banner function banner() { if ($(window).width() > 576) { $(".banner .swiper-wrapper .swiper-slide[data-id='2']").remove(); } else { $(".banner .swiper-wrapper .swiper-slide[data-id='1']").remove(); } new Swiper('.banner .swiper-container', { effect: 'slide', speed: 1000, loop: true, autoplay: true, autoplay: { delay: 3000, disableOnInteraction: false, }, slidesPerView: 1, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, pagination: { el: '.swiper-pagination', clickable: true, }, }) } // 产品选项卡 function productTab(a, b, c) { $(a + " " + b).eq(0).addClass("active"); $(a + " " + c).eq(0).addClass("active"); $(a + " " + b).mouseenter(function () { if ($(this).attr("data-id") != $(a + " " + b + ".active").attr("data-id")) { $(a + " " + b).removeClass("active"); $(a + " " + c).removeClass("active"); $(this).addClass("active"); $(a + " " + c + "[data-id='" + $(this).attr("data-id") + "']").addClass("active"); } }) } // 手机版导航菜单 function mobileNav() { var navbtnH = Number($(".nav>li").height()) * Number($(".nav>li").length); var navbtnI = 0; $(".navbtn").click(function () { navbtnI++ $(this).addClass("animated") $("ul.nav").css("height", navbtnH + "px") if (navbtnI == 2) { navbtnI -= 2 $(this).removeClass("animated") $("ul.nav").css("height", "0") } }).mouseout(function () { $(this).removeClass("animated") $("ul.nav").css("height", "0") }) } // 右侧工具栏 function toolbar() { $(window).scroll(function () { if ($(this).scrollTop() > 300) { $('#toolbar .top').fadeIn(); } else { $('#toolbar .top').fadeOut(); } }); $('#toolbar .top').click(function () { $('html ,body').animate({ scrollTop: 0 }, 1000); return false; }); } // 滚屏动画 function contentWayPoint() { var i = 0; $('.animate-box').waypoint(function (direction) { if (direction === 'down' && !$(this.element).hasClass('animated')) { i++; $(this.element).addClass('item-animate'); setTimeout(function () { $('body .animate-box.item-animate').each(function (k) { var el = $(this); setTimeout(function () { el.addClass('fadeInUp animated'); el.removeClass('item-animate'); }, k * 200, 'easeInOutExpo'); }); }, 100); } }, { offset: '85%' }); }; /** * setCookie 设置cookie的函数 * @param {1} key 设置的cookie的键 * @param {2} value 设置的cookie的值 * @param {3} seconds 设置cookie在多少秒之后失效 - 单位:秒 * @param {4} path 设置cookie的路径 - 默认是 / 根目录 */ function setCookie(key, value, seconds = 86400, path = window.location.host) { //console.log(key, value, seconds) var date = new Date(); date.setTime(date.getTime() - 8 * 3600 * 1000 + seconds * 1000) document.cookie = key + '=' + value + ';expires=' + date + ";path=" + path; //console.log(key + '=' + value + ';expires=' + date + ";path=" + path) } /** * getCookie 获取cookie的函数 * @param {1} key 要获取的cookie的键 * return 返回想要的键对应的值 */ function getCookie(key) { var cookies = document.cookie; if (key == undefined) return cookies var arr = cookies.split("; "); for (var i = 0; i < arr.length; i++) { if (arr[i].split("=")[0] == key) { return arr[i].split("=")[1]; } } } /** * removeCookie 删除cookie的函数 * @param {1} key 要删除的cookie的键 * @param {2} path 要删除的cookie的路径 - 默认为 / 根目录 */ function removeCookie(key, path = window.location.host) { setCookie(key, null, -1, path); } /**************************************时间格式化处理************************************/ function dateFtt(fmt, date) { //author: meizz var o = { "M+": date.getMonth() + 1, //月份 "d+": date.getDate(), //日 "h+": date.getHours(), //小时 "m+": date.getMinutes(), //分 "s+": date.getSeconds(), //秒 "q+": Math.floor((date.getMonth() + 3) / 3), //季度 "S": date.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } /* 去除html标签以及空格 */ function deleteHtml(str) { str = str.replace(/<[^>]+>|&[^>]+;/g, "").trim(); //去掉所有的html标签和 之类的特殊符合 return str; } var varHref = window.location.href; // if (varHref.indexOf('index') > 0) { // setSiteNav(0); // } else if (varHref.indexOf('aboutpage') > 0) { // setSiteNav(1); // } else if (varHref.indexOf('product') > 0) { // setSiteNav(2); // } else if (varHref.indexOf('news') > 0) { // setSiteNav(3); // } else if (varHref.indexOf('cases') > 0) { // setSiteNav(4); // } else if (varHref.indexOf('contactus') > 0) { // setSiteNav(5); // } else { // setSiteNav(0); // } function setSiteNav(navIndex) { $('.nav>li').removeClass('active'); $('.nav>li').eq(navIndex).addClass('active'); } /* 获取Url参数的值 */ function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return (false); } function GetStrByLength(str, length, isdot) { var i = str.length; if (i > length) { if (isdot) { return str.substring(0, length) + "..."; } else { return str.substring(0, length); } } else { return str; } }