function isphone() { let mobile = navigator.useragent.match( /(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone)/i ) return mobile != null } function getquerystring(name) { var reg = new regexp('(^|&)' + name + '=([^&]*)(&|$)', 'i') var r = window.location.search.substr(1).match(reg) if (r != null) return decodeuri(r[2]) return null } $(function () { /** * 初始化wow.js * * */ wow = new wow({ boxclass: 'wow', // default animateclass: 'animated', // default offset: 0, // default mobile: true, // default live: true, // default }) wow.init() /** * 初始化导航栏选中select * * */ let locationfile = '/' + location.href.split('/')[location.href.split('/').length - 1] $('.nav-list .nav-item').each(function (index, item) { let thispageurl = $(this).children('a').attr('href') if (thispageurl === locationfile) { $('.nav-item').removeclass('active') $(this).addclass('active') return false } else { $(this) .children('.item-list') .children('.item-a') .each(function () { let childurl = $(this).children('a').attr('href') if (locationfile === childurl) { $('.nav-item').removeclass('active') $(this).parent().parent().addclass('active') return false } else if (locationfile.indexof('videodetail.html') > 0) { $('.nav-list .nav-item:eq(5)').addclass('active') } else if (locationfile.indexof('newsdetail.html') > 0) { $('.nav-list .nav-item:eq(3)').addclass('active') } else if (locationfile.indexof('productdetail.html') > 0) { $('.nav-list .nav-item:eq(2)').addclass('active') } }) } }) /** * 初始化点击回到顶部 * * */ $('body').append( '
' ) $(window).scroll(function () { if ($(window).scrolltop() > 300) { $('.fixtop').show() } else { $('.fixtop').hide() } }) $('.fixtop').on('click', function () { $('body,html').animate({ scrolltop: 0 }, 500) }) /** * 表单提交验证 * * */ if ($('#form1')[0] !== undefined) { $("#form1").validate({ ignore: "", rules: { name: { required: true }, phone: { required: true, isphone: true }, email: { required: true, email: true }, remark: { required: true }, }, messages: { name: { required: '*' }, phone: { required: '*' }, email: { required: '*' }, remark: { required: '*' }, } }); //提交表单 $("#btnsendform1").click(function () { var b = $("#form1").valid(); if (b) { var data = $("#form1").serializearray(); $.post("/viewsiteapi/handle/saveform", { data: json.stringify(data) }, function (res) { if (res.result == 1) { alert("提交成功!"); location.href = location.href.replace(/#/g, ""); } else { alert("提交失败!" + (res.message != "" ? ("\n" + res.message) : "")); } }); } }); } /** * 移动端导航点击 * */ $('.right-icon').on('click', function () { $(this).hasclass('active') ? $('body,.right-icon,.m-modal').removeclass('active') : $('body,.right-icon,.m-modal').addclass('active') }) var myswiper = new swiper('.banner', { autoplay: true, //可选选项,自动滑动 pagination: { el: '.swiper-pagination', bulletclass: 'my-bullet', }, }) /** * 初始化导航栏选中select * * */ $('.sc-nav-list .sc-nav-item').each(function (index, item) { let parentname = $(".sc-nav-list").attr("data-name") let _childname = $(item).children().text() if (parentname == '' && $('.sc-nav-list .sc-nav-item').eq(0).children().text() !== '新闻中心') { $('.sc-nav-list .sc-nav-item').eq(0).addclass('active') return false } if (parentname == _childname) { $(item).addclass('active') } }) /** * 初始化产品详情detail */ var myswiper = new swiper('.prod-images', { autoplay: true, //可选选项,自动滑动 pagination: true }) /** * 产品展示初始化 */ $('.pd-type-list .type-item').eq(0).addclass('active') $('.pd-list .pd-li-item').eq(0).addclass('active') // $('.pd-type-list .type-item').on('click', function () { // let _index = $(this).index() // $('.pd-list .pd-li-item').removeclass('active') // $('.pd-type-list .type-item').removeclass('active') // $('.pd-type-list .type-item').eq(_index).addclass('active') // $('.pd-list .pd-li-item').eq(_index).addclass('active') // }) /** * prod-m初始化 */ if ($(".prod-m").length > 0) { var myswiper = new swiper('.product-swiper', { autoheight: true, }) let _flagnum = null $(`.prod-pagi .swiper-wrapper .swiper-slide`).removeclass('select').eq(0).addclass('select'); var pagiswiper = new swiper('.prod-pagi', { slidesperview: 3.5, //重要的 autoplaydisableoninteraction: false, noswiping: true, on: { tap: function (swiper, event) { $(`.prod-pagi .swiper-wrapper .swiper-slide`).removeclass('select').eq(swiper.clickedindex).addclass('select'); swiper.clickedindex > _flagnum ? pagiswiper.slideto(swiper.clickedindex, 300, false) : pagiswiper.slideto(swiper.clickedindex - 1, 300, false) myswiper.slideto(swiper.clickedindex, 300, false) $('.prod-pagi .swiper-wrapper .swiper-slide') .removeclass('swiper-slide-active') .eq(swiper.clickedindex) .addclass('swiper-slide-active') _flagnum = swiper.clickedindex }, }, }) } })