$(function(){ //nav var wapnav=function(){ // $(".navbtn").click(function(){ // $(".navbtn").stop().removeclass("on"); // $(".submenu").stop().slideup(); // $(this).stop().toggleclass("on"); // $(this).stop().siblings(".submenu").slidetoggle() // }) var i=0; $(".muen").click(function(event){ $(this).toggleclass("on"); if(i==0){ $("#nav").stop().animate({"left":'0'}); i=1; }else if(i==1){ $("#nav").stop().animate({"left":'-200px'}); i=0; } event.stoppropagation(); }) $("body > *").click(function(){ $("#nav").stop().animate({"left":'-200px'}); $(".muen").removeclass("on"); i=0; }) // $(window).scroll(function() { // $("#nav").stop().animate({"left":'-200px'}); // i=0; // }) $("#nav").scroll(function(event){ event.stoppropagation(); }).click(function(event){ event.stoppropagation(); }) } //$(".homedzzxt li").hover(function(){ // $(this).find(".bg").stop().slidedown(); // $(this).find(".bgw").stop().delay(400).fadein(); // },function(){ // $(this).find(".bgw").stop().fadeout(); // $(this).find(".bg").stop().delay(300).slideup(); // // }) // $(".homenewstab a").click(function(){ var index = $(this).index(); $(this).addclass("on").siblings("a").removeclass("on"); $(".homenewsinner").eq(index).show().siblings(".homenewsinner").hide(); }) $(".aboutnav li").click(function(){ $(this).addclass("on").siblings("li").removeclass("on"); }) //生产工艺 $(".productallist li").hover(function(){ $(this).find(".bg").stop().fadein(); $(this).find(".writ").stop().animate({"bottom":'15px'}); },function(){ $(this).find(".bg").stop().fadeout(); $(this).find(".writ").stop().animate({"bottom":'-100px'}); }) var productal = function(){ var stop=$(window).scrolltop(); $(".productnext").click(function(){ var protabtop = $(this).parents(".producttab").offset().top; console.log(protabtop) $('body,html').animate({scrolltop:protabtop-90},500); }) $(".navnext ul li").click(function(){ $(".navnext ul li").removeclass("on"); $(this).addclass("on"); }) $(".navnext ul li").eq(0).click(function(){ $('body,html').animate({scrolltop:$(".productcx").offset().top-110},500); }) $(".navnext ul li").eq(1).click(function(){ $('body,html').animate({scrolltop:$(".productgy").offset().top-110},500); }) $(".navnext ul li").eq(2).click(function(){ $('body,html').animate({scrolltop:$(".productsp").offset().top-110},500); }) $(".navnext ul li").eq(3).click(function(){ $('body,html').animate({scrolltop:$(".productjg").offset().top-110},500); }) $(".navnext ul li").eq(4).click(function(){ $('body,html').animate({scrolltop:$(".productch").offset().top-110},500); }) $(".navnext ul li").eq(5).click(function(){ $('body,html').animate({scrolltop:$(".productal").offset().top-110},500); }) $(".productyflist li").eq(0).find("a").click(function(){ $('body,html').animate({scrolltop:$(".productcx").offset().top-110},500); }) $(".productyflist li").eq(1).find("a").click(function(){ $('body,html').animate({scrolltop:$(".productgy").offset().top-110},500); }) $(".productyflist li").eq(2).find("a").click(function(){ $('body,html').animate({scrolltop:$(".productsp").offset().top-110},500); }) $(".productyflist li").eq(3).find("a").click(function(){ $('body,html').animate({scrolltop:$(".productjg").offset().top-110},500); }) $(".productyflist li").eq(4).find("a").click(function(){ $('body,html').animate({scrolltop:$(".productch").offset().top-110},500); }) $(".productyflist li").eq(5).find("a").click(function(){ $('body,html').animate({scrolltop:$(".productal").offset().top-110},500); }) } //常见问题 $(".issuelist li h2").click(function(){ $(".issuelist li h2 span").stop().removeclass("on"); $(".issuelist li .issueinner").stop().slideup(); $(this).find("span").stop().addclass("on"); $(this).siblings(".issueinner").stop().slidedown(); }) //领取样品 function samplef(){ $(".formsure").click(function(){ var formname,formtel,formaddress,formmail,formreason,formyzm,num formname = $("input.formname").val(); formtel = $("input.formtel").val(); formaddress = $("input.formaddress").val(); formmail = $("input.formmail").val(); formreason = $("input.formreason").val(); formyzm = $("input.formyzm").val(); num = 0; //姓名验证 if(formname == null || formname == '' || formname == undefined){ $(".hint p").fadein().text("请输入姓名"); return false; }else{ $(".hint p").fadeout(); num = 1; } //电话验证 if(num == 1){ if(formtel == null || formtel == '' || formtel == undefined){ $(".hint p").fadein().text("请输入电话号码"); return false; }else if(!checkmobile(formtel)){ $(".hint p").fadein().text("请输入正确的电话号码"); return false; }else{ $(".hint p").fadeout(); num = 2; } } //地址验证 if(num == 2){ if(formaddress == null || formaddress == '' || formaddress == undefined){ $(".hint p").fadein().text("请输入地址"); return false; }else{ $(".hint p").fadeout(); num = 3; } } //邮箱验证 if(num == 3){ if(formmail == null || formmail == '' || formmail == undefined){ $(".hint p").fadein().text("请输入邮箱"); return false; }else if(!checkemail(formmail)){ $(".hint p").fadein().text("请输入正确的邮箱地址"); return false; }else{ $(".hint p").fadeout(); num = 4; } } //验证码 if(num == 4){ if(formyzm == null || formyzm == '' || formyzm == undefined){ $(".hint p").fadein().text("请输入验证码"); return false; }else{ $(".hint p").fadeout(); num = 5; } } if(num == 5){ $('form').submit(); }else{ return false; } }) //重置 $(".formreturn").click(function(){ $(this).parents("form").find("input").val(""); $(this).parents("form").find("textarea").val("") $(".hint p").fadeout(); }) } //wap-侧导航 $(".navbtn").click(function(){ $(".navbtn").removeclass("on"); $(".navdown").slideup(); $(this).stop().addclass("on"); $(this).siblings(".navdown").stop().slidedown(); }) //page var page=function(){ $(".page a").click(function(){ $(this).addclass("active").siblings(".page a").removeclass("active"); $(this).parent(".page").find("em").removeclass("active"); $(this).parent(".page").find("i").removeclass("active"); }) $(".page em").click(function(){ $(this).addclass("active").siblings(".page em").removeclass("active"); $(this).parent(".page").find("i").removeclass("active"); }) $(".page i").click(function(){ $(this).addclass("active").siblings(".page i").removeclass("active"); $(this).parent(".page").find("em").removeclass("active"); }) } page(); /** * 检验 用户名格式 * @param name 用户名 */ function checkusername(name){ var reg = /^[a-za-z0-9_]{6,16}$/ ; if(name.match(reg)){ return true; }else{ return false; } } /** * 验证 手机号 * @param str */ function checkmobile(str) { var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|17[015678]|18[0-9]|14[57])[0-9]{8}$/; if(str.match(reg)){ return true; } else{ return false; } } /** * 验证 邮箱地址 */ function checkemail(str){ reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; if(str.match(reg)){ return true; } else{ return false; } } wapnav(); productal(); samplef(); })