/** * 统一引入 / 页头 / 页尾 / 侧导航 / 代码, 删除以上js即可 */ // $(function () { // $('.header').load('components/header.html', function () { // headtoggle(); // headerother(); // }); // // // $('footer').load('components/footer.html', function () { // footer(); // }); // $('.sub-menu').load('components/submenu.html', function () { // submenu() // }); // }) /** * 统一引入 / 页头 / 页尾 / 侧导航 / 代码, 删除以上js即可 */ function liuyan() { $.ajax({ type:"post", url:"/index.php/addons/cms/diyform/post.html", datatype:"json", data:{ "__diyname__":"message", "row[name]":$("#liuyanname").val(), "row[gongsi]":$("#liuyangongsi").val(), "row[dianhua]":$("#liuyandianhua").val(), "row[youxiang]":$("#liuyanyouxiang").val(), "row[neirong]":$("#liuyanneirong").val() }, success:function(data){ alert(data.msg); location.reload(); }, error:function(jqxhr){ aler("发生错误:"+ jqxhr.status); } }); return false; } //--页面适配 function setfont() { var vw = $(window).width(); if (vw < 768) {//手机端 $('html').css('font-size', vw / 15) } else { $('html').css('font-size', "50px") }; } setfont(); $(window).resize(function () { setfont(); }) // 头底及公共函数 $(function () { footer(); headtoggle(); headerother(); submenu(); // 小屏去侧导航 var wow = new wow({ boxclass: 'wow', // default animateclass: 'animated', // default offset: 0, // default 0 mobile: true, // default live: true // default }); new wow().init(); $('.ani').each(function () { var txt = $(this).text(); $(this).text('') text({ str: txt, effect: $(this).attr('effect'), // normal right left down up random rightbig leftbig downbig upbig speed: $(this).attr('speed'), //显示速度 慢400 正常200 快60 极快15 数字可以自定义 conbox: $(this), }); }) }) function headerother() { $('.tabhdhv >*').hover(function () { var index = $(this).index(); var content = $(this).addclass('active').siblings().removeclass('active').parents().siblings('.tabbd'); var contentitem = content.find('>*'); contentitem.eq(index).addclass('active').siblings().removeclass('active'); // wow() }) $('#menu').menu({ 'backlabel': '返回上一级' }); $('.hd-search').click(function () { $('.hd-search-pop').toggleclass('show') $(this).find('i').toggleclass('icon-sousuo icon-guanbi1') }) $('.icon-guanbi1').click(function () { $('.hd-search-pop').removeclass('show') $('.hd-search').find('i').removeclass('icon-guanbi1').addclass('icon-sousuo') }) $(window).scroll(function () { var st = $(window).scrolltop(); if (st > 80) { $('.header').addclass('on') } else { $('.header').removeclass('on') } }) } // 统一添加返回顶部按钮 $(function () { var dom = '

'; $('body').append(dom); $('#totop').click(function () { $('html,body').animate({ scrolltop: 0 }, 300) }) _showtotop() $(window).scroll(_showtotop); function _showtotop() { var winh = $(window).height(); if ($(window).scrolltop() > winh / 3) { $('#totop').fadein() } else { $('#totop').fadeout() } } }) function wow() { var wow = new wow({ boxclass: 'wow', // default animateclass: 'animated', // default offset: 0, // default 0 mobile: true, // default live: true // default }); new wow().init(); } $(function () { $('.ani').each(function () { var txt = $(this).text(); $(this).text('') text({ str: txt, effect: $(this).attr('effect'), speed: $(this).attr('speed'), //显示速度 慢400 正常200 快60 极快15 数字可以自定义 conbox: $(this), }); }) // tab $('.tabhd >*').click(function () { var index = $(this).index(); var content = $(this).addclass('active').siblings().removeclass('active').parents().siblings('.tabbd'); var contentitem = content.find('>*'); contentitem.eq(index).addclass('active').siblings().removeclass('active'); }) $('.tabhdhv >*').hover(function () { var index = $(this).index(); var content = $(this).addclass('active').siblings().removeclass('active').parents().siblings('.tabbd'); var contentitem = content.find('>*'); contentitem.eq(index).addclass('active').siblings().removeclass('active'); // wow() }) }) function changetab() { if ($('.tabnav').length > 0) { var t = parseint($('.tabnav').offset().top); $('.tabnav .item').click(function () { var wint = parseint($('.tabnav').offset().top); $('html,body').animate({ scrolltop: t },0) wow(); }) } } // 悬浮导航 $(function () { if ($('.fixed-nav').length > 0) { var offset = parseint($('.tab-nav').offset().top); fn($(window).scrolltop()); $(window).scroll(function () { var wint = $(window).scrolltop(); fn(wint); }) function fn(wint) { if (wint > 100) { $('.header').addclass('default') } else { $('.header').removeclass('default') } if ($(window).scrolltop() >= offset) { $('.tab-nav').addclass('fixed') } else { $('.tab-nav').removeclass('fixed') } } } }) //产品页swiper $(function () { if ($('.scene-swiper').length > 0) { var myswiper = new swiper('.scene-swiper', { slidesperview: 'auto', // 如果需要分页器 pagination: { el: '.swiper-pagination', }, // 如果需要前进后退按钮 navigation: { nextel: '.pro-scene .swiper-button-next', prevel: '.pro-scene .swiper-button-prev', }, }) } }) // 数字跳动累加 function datas() { var topheight = $('#datas').offset().top; var windowheight = $(window).height(); var flag = false; var vals = []; $('#datas b span').each(function () { vals.push($(this).text()) $(this).text(0); }) $(window).scroll(function () { var srcrollheight = $(window).scrolltop(); if (srcrollheight >= (topheight - windowheight) && !flag) { change(); } if (srcrollheight < 100) { flag = false } }) function change() { $('#datas b span').each(function () { var index = $(this).parents('li').index(); setvals($(this), vals[index]); }) flag = true; } function setvals(obj, val) { var count = 0; var spend = 1; if (val > 20) { spend = 2 } var timer = setinterval(function () { count += spend; if (count >= val) { obj.text(val); clearinterval(timer); } else { obj.text(count); } }, 100) } } function footer() { fn(); $(window).resize(fn) function fn() { $('#ftnavs').off('click', '.item-nav h4'); var flag = $('#ftnavs .icon-jia').eq(0).css('display') == 'block'; if (flag) { $('#ftnavs .item-nav .info').hide() $('#ftnavs').on('click', '.item-nav h4', toggle) } else { $('#ftnavs .item-nav .info').show() } } function toggle() { var item = $(this).parent('.item-nav'); item.toggleclass('active') $(this).siblings('.info').slidetoggle(300); item.siblings('.item-nav').removeclass('active').each(function () { $(this).find('.icon-jia').removeclass('active') $(this).find('.info').slideup(300) }) } } function headtoggle() { var btn = $('#menubtn'); $('#nav .item').each(function () { var index = $(this).index() ; index = index < 10 ? '0' + index : index; $(this).addclass('delay' + index); }) btn.click(function () { btn.toggleclass("active"); $('#nav').toggleclass("active"); $('body').toggleclass('add') $('#nav .item').toggleclass('animate') }) } // 滚动导航 $(window).load(function () { if ($('.fixed-navs').length > 0) { setnav(); $(window).resize(setnav); function setnav() { settimeout(function () { var top = $('.crumbs').offset().top; var hdheight = $('.header').height(); $(window).scroll(function () { var st = $(window).scrolltop(); if (st >= top) { $('.fixed-navs').addclass('fixed'); $('.header').css('top', -hdheight); } else { $('.header').css('top', 0); $('.fixed-navs').removeclass('fixed'); } }) }, 400) } } }) function submenu() { var $width = '664px'; fn(); $(window).resize(fn); $('#popservice,.popservice').on('click', function () { layer.open({ closebtn: 0, title: false, type: 1, content: $('.pop-service'), area: [$width], }) }) $('.icon-guanbi1').on('click', function () { layer.closeall() }) function fn() { $width = ($(window).width() < 992) ? '90%' : '664px'; } }