class Base { constructor() { } load() { this.footer(); this.header(); $('#searchOpen').click(function () { $('#search').slideDown(100) if ($('#menuBtn').hasClass('active')) { $('#menuBtn').removeClass("active"); $('#nav').removeClass("active"); $('.header').removeClass("active"); } }) $('#searchClose').click(function () { $('#search').slideUp(100) }) if($('.counter').length){ $('.counter').countUp(); } } headToggle() { $('#menuBtn').click(function () { var flag = $(this).hasClass('active'); if (!flag) { $(this).addClass("active"); $('#nav').addClass("active"); $('header').addClass("active"); } else { $(this).removeClass("active"); $('#nav').removeClass("active"); $('header').removeClass("active"); } }) } mobileMenuToggle() { $('#menus .xsdrop .tit').click(function () { if ($(this).parent('.item').hasClass('open')) { $(this).parents('.item').removeClass('open') $(this).siblings('.xs-menu').slideUp() } else { $('#menus .open').removeClass('open').find('.xs-menu').slideUp(); $(this).parents('.item').addClass('open') $(this).siblings('.xs-menu').slideDown() } }) } tab() { $('.tabNav >*').click(function () { var index = $(this).index(); var content = $(this).addClass('active').siblings().removeClass('active').parents().siblings('.tabInfo'); var contentItem = content.find('>*'); contentItem.eq(index).addClass('active').siblings().removeClass('active'); }) $('.tabNavHv >*').hover(function () { var index = $(this).index(); var content = $(this).addClass('active').siblings().removeClass('active').parents().siblings('.tabInfo'); var contentItem = content.find('>*'); contentItem.eq(index).addClass('active').siblings().removeClass('active'); }) } wow() { var wow = new WOW({ boxClass: 'wow', animateClass: 'animated', offset: 200, mobile: false, live: true }); new WOW().init(); } totop() { $('#totop').on('click', function () { $('html,body').animate({ scrollTop: 0 }, 300) }) $(window).scroll(function () { var st = $(window).scrollTop(); if (st >= $(window).height() / 2) { $('#totop').addClass('show'); } else { $('#totop').removeClass('show'); } }) } header() { this.headToggle(); this.mobileMenuToggle() } footer(){ fn(); $(window).resize(fn) function fn() { $('#ftNavs').off('click', '.navitem h4'); var flag = $('#ftNavs .icon-jia').eq(0).css('display') == 'block'; if (flag) { $('#ftNavs .navitem .info').hide() $('#ftNavs').on('click', '.navitem h4', toggle); } else { $('#ftNavs .navitem .info').show() } } function toggle() { var item = $(this).parent('.navitem'); item.toggleClass('active') $(this).siblings('.info').slideToggle(100); item.siblings('.navitem').removeClass('active').each(function () { $(this).find('.icon-jia').removeClass('active') $(this).find('.info').slideUp(100) }) } } mobileUrl(){ $('.mobileUrl').click(function () { let url = $(this).attr('data-url'); if ($(window).width() <= 768) { location.href = url; } }) } /** * 璺ㄩ〉闈㈣烦杞 */ navLink(obj) { obj.on('click', function () { var id = $(this).attr('data-id'); var link = $(this).attr('href'); if (id) { localStorage.setItem('__todom__', id); } location.href = link; return false; }) window.onload = function () { var getobj = localStorage.getItem('__todom__'); setTimeout(function () { if (getobj) { var obj = $('#' + getobj); if(obj.length==0){ localStorage.removeItem('__todom__'); return }; var headheight = 0; if($(window).width()<1200){ headheight = $('header').height(); headheight = Math.max(60, headheight); } var top = obj.offset().top - headheight; $('html,body').scrollTop(top); localStorage.removeItem('__todom__'); } }); } } /** * 鍦ㄦ湰椤甸潰椤佃烦杞 * */ pageToDom(obj) { obj.click(function () { var href = $(this).attr('href'); var dom = $(href); var headheight = 0; if($(window).width()<1200){ headheight = $("header").height(); } var top = dom.offset().top - headheight; $('html,body').animate({ scrollTop: top }, 300); return false; }) } } $(function () { let doc = new Base(); doc.load(); doc.tab(); doc.totop(); doc.wow() doc.mobileUrl() doc.navLink($(".navLink")) doc.pageToDom($(".pageToDom")) // layui.use(['layer','form'],function(){ // var layer = layui.layer; // var form = layui.form; // }) }) function submitForm(filter){ layui.use('form', function () { var form = layui.form; var layer = layui.layer; let issubmit = false; form.on("submit("+filter+")", function (data) { if(issubmit) return false; issubmit = true; $.post("/addons/cms/diyform/post",data.field,function(res){ if (res.code == 1) { layer.alert(res.msg, function () { location.href = '/'; }); } else { layer.msg(res.msg); issubmit = false; } }) return false; }) }); }