// javascript document /* $(window).scroll(function () { var top = document.documentelement.scrolltop || window.pageyoffset || document.body.scrolltop; if (top > 0) { $('.header').addclass('fixed'); } else { $('.header').removeclass('fixed'); } }); */ // javascript document $(window).scroll(function () { //banner高度 const banner = document.getelementsbyclassname('index-banner'); let height = banner[0].offsetheight; var top = document.documentelement.scrolltop || window.pageyoffset || document.body.scrolltop; var width=$(window).width(); if (window.location.pathname === '/') { const productheight = $('#index .product-box')[0].offsetheight; if(width>1044){ if (top > height && top < height + productheight) { $('.header').attr('style', 'display:none'); } else { $('.header').attr('style', 'display:block'); } } height += productheight; } if (top > height) { $('.header').addclass('fixed'); $('.header .main .logo .white').addclass('hide'); $('.header .main .logo .black').removeclass('hide'); } else { $('.header').removeclass('fixed'); $('.header .main .logo .white').removeclass('hide'); $('.header .main .logo .black').addclass('hide'); } // const banner = document.getelementsbyclassname('index-banner'); // const height = banner[0].offsetheight; // var top = document.documentelement.scrolltop || window.pageyoffset || document.body.scrolltop; // if (top > height) { // $('.header').addclass('fixed'); // $('.header .main .logo .white').addclass('hide'); // $('.header .main .logo .black').removeclass('hide'); // } else { // $('.header').removeclass('fixed'); // $('.header .main .logo .white').removeclass('hide'); // $('.header .main .logo .black').addclass('hide'); // } }); // 手机导航点击下拉 $('.school-cover').click(function () { $(this).next('.down-box').slidetoggle(); }); // 手机导航点击展示 $('.m-header .menu').click(function () { // $(this).toggleclass("active"); $('.m-cover').fadetoggle(); $('.menu-box').addclass('slideinleft'); }); $('.m-cover .mask').click(function () { $('.m-cover').fadetoggle(); }); // 回到顶部 $('.to-top').click(function () { $('html,body').animate({ scrolltop: 0 }, 1500); }); function getparam(paramname) { paramvalue = ''; isfound = false; if (this.location.search.indexof('?') == 0 && this.location.search.indexof('=') > 1) { arrsource = unescape(this.location.search).substring(1, this.location.search.length).split('&'); i = 0; while (i < arrsource.length && !isfound) { if (arrsource[i].indexof('=') > 0) { if (arrsource[i].split('=')[0].tolowercase() == paramname.tolowercase()) { paramvalue = arrsource[i].split('=')[1]; isfound = true; } } i++; } } return paramvalue; } $(function () { if (getparam('t')) { if ($(window).width() > 600) { var targetoffset = $('#' + getparam('t')).offset().top - 100; $('html,body').animate({ scrolltop: targetoffset }, 1500); } else { var targetoffset = $('#' + getparam('t')).offset().top - 44; $('html,body').animate({ scrolltop: targetoffset }, 1500); } } }); /** * 根据form表单的id获取表单下所有可提交的表单数据,封装成数组对象 */ function getformdata(formid) { var data = {}; var results = $(formid).serializearray(); $.each(results, function (index, item) { if (!data[item.name]) { data[item.name] = $.trim(item.value); } else { //name属性相同的表单,值以英文,拼接 data[item.name] = data[item.name] + ',' + $.trim(item.value); } }); var arr = new array(); $.each(data, function (i, n) { arr.push(n); }); var sign = arr.join('#dy#'); return sign; } /** * form表单的加密数据提交 */ function dyajax(dysign, url) { var form = new formdata(); form.append('dysign', dysign); $.ajax({ type: 'post', url: url, data: form, contenttype: false, processdata: false, datatype: 'json', beforesend: function () { //防止重复提交 var index = layer.load(0, { shade: 0.1, shadeclose: false }); }, success: function (data) { if (data.errcode == 0) { layer.closeall(); layer.alert(data.message, { skin: 'layui-layer-molv', closebtn: 0, title: '温馨提示:', icon: 2, anim: 2 }); } else if (data.errcode == 1) { layer.closeall(); layer.alert(data.message, { skin: 'layui-layer-molv', closebtn: 0, title: '温馨提示:', icon: 1, anim: 2 }, function () { window.parent.location.reload(); }); } }, error: function () { layer.closeall(); layer.tips('信息提交失败,请点击重试'); }, }); }