$(function () { //导航栏状态变化 $(".nav-item").hover(function () { var tthis = $(this), others = $(this).siblings(); tthis.find(".dropdown-menu").addClass("show"); others.find(".dropdown-menu").removeClass("show"); }, function () { var tthis = $(this); // tthis.find(".dropdown-menu").removeClass("show"); }) $("#header_fixed").hover(function () { }, function () { $(this).find(".dropdown-menu").removeClass("show"); }) $("#header_lang").hover(function () { var tthis = $(this), others = $(this).siblings(); tthis.find(".dropdown-menu").addClass("show"); others.find(".dropdown-menu").removeClass("show"); }, function () { var tthis = $(this); // tthis.find(".dropdown-menu").removeClass("show"); }) //pc中头部搜索栏 $("body").on("click", "#pc_heads_search", function () { $("#pc_search").toggle(); }) //大屏中,右侧提示栏显示 $("#tips").hover(function () { $(this).addClass("show"); }, function () { $(this).removeClass("show"); }) //大屏中,右侧提示栏显示,移动里面的栏位状态变化 $("#tips .tips_cell").hover(function () { $(this).addClass("active"); }, function () { $(this).removeClass("active"); }) //图片懒加载 $("img.lazyload").lazyload(); //导航在PC端点击,直接打开链接 var screenWidth = $(window).width(); // if(screenWidth<992){ // $("#pc_heads .dropdown-menu").each(function (index,item){ // $(item).addClass("show"); // }) // } // $("#pc_heads").on("click",".nav-link",function (e){ // var navHref = $(this).attr("href"); // location.href = navHref; // return false; // }) if (screenWidth >= 768) { $("#pc_heads").on("click", ".nav-link", function () { var navHref = $(this).attr("href"); // console.log(navHref); location.href = navHref; }) } //大屏中,右侧提示栏显示 $("body").on("click", "#tips_xuqiu .tips_title", function () { var tips_xuqiu = $("#tips_xuqiu"); tips_xuqiu.toggleClass("show"); }) $("body").on("click", "#tips_xuqiu .tips_close", function () { var tips_xuqiu = $("#tips_xuqiu"); tips_xuqiu.toggleClass("show"); }) // Fetch all the forms we want to apply custom Bootstrap validation styles to var forms = document.querySelectorAll('.needs-validation') // Loop over them and prevent submission Array.prototype.slice.call(forms) .forEach(function (form) { form.addEventListener('submit', function (event) { if (!form.checkValidity()) { event.preventDefault(); event.stopPropagation(); } form.classList.add('was-validated'); return false; }, false) }) //页脚需求 $("body").on("submit","#tips_xuqiu",function (event){ event.preventDefault(); event.stopPropagation(); var telReg =/^1[0-9]{10}$/; if(!telReg.test($("#tel").val())){ $("#tel").addClass("is-invalid"); // $("#xuqiu_form").addClass("was-validated"); return; }else{ $("#tel").removeClass("is-invalid").addClass("is-valid"); } var fields = $("#xuqiu_form").serializeArray(); $.post("/index/sy/message",fields,function (result){ let res = JSON.parse(result); alert(res.msg); if(res.code==200){ $("#tips_xuqiu").removeClass("show"); setTimeout(function (){ location.reload(); },1500) } }) return; }) $("#tips_xuqiu #tel").on("blur",function (){ var telReg =/^1[0-9]{10}$/; if(!telReg.test($("#tel").val())){ $("#tel").addClass("is-invalid"); // $("#xuqiu_form").addClass("was-validated"); return; }else{ $("#tel").removeClass("is-invalid").addClass("is-valid"); } }) })