// JavaScript Document layui.use('form', function(){ var form = layui.form; //监听提交 form.on('submit(formDemo)', function(data){ layer.msg(JSON.stringify(data.field)); return false; }); }); layui.use('laydate', function(){ var laydate = layui.laydate; laydate.render({ elem: '#ycqi' //指定元素 }); }); //手机导航 $("#menu-button").click(function(){ if($(this).hasClass('off')){ $(this).removeAttr('class').addClass('menu-button open'); $("#wap-nav").width('100%'); $("#mask").show(); }else{ $('#menu-button').css('right','17px').removeAttr('class').addClass('menu-button off'); $("#wap-nav").width('0%'); $("#mask").hide(); }}); $("#mask").click(function(){ $('#menu-button').removeClass('cross'); $("#wap-nav").width('0%'); $("#mask").hide(); }); $('.wap-nav li dl a').click(function(){ $('#menu-button').removeClass('cross'); $("#wap-nav").width('0%'); $("#mask").hide(); }) $('.wap-nav li > a').click(function(){ var len=$(this).next().find('dd').length; var othis=$(this).next(); $('.wap-nav li dl').not(this).height(0); len=len*51; if(othis.height()==0){ $(this).next().css({'height':len+'px'}); }else{ $(this).next().css({'height':'0px'}); } }) //结束手机导航 var scrollt = document.documentElement.scrollTop + document.body.scrollTop; $('.header').mousemove(function(){ if(scrollt<200){ $('.header').addClass('ohit'); $('.header').css({'background':'rgba(255,255,255,0.9)'}); } }); $('.header').mouseout(function(){ if(scrollt<200){ $('.header').removeClass('ohit'); $('.header').css({'background':'rgba(255,255,255,1)'}); } }); $(window).scroll(function(){ scrollt = document.documentElement.scrollTop + document.body.scrollTop; if(scrollt>50){ $('.top').addClass('hit').removeAttr('style'); }else{ $('.top').removeClass('hit').removeAttr('style'); } //console.log(scrollt); });//end scroll var idxarray = Array ; window.onload=function(){ // topv=$('.main-header').height()+$('.top-header').height(); // $('.idx').each(function(index, element) { // idxarray[index]=$(element).offset().top-topv; // //$('html,body').animate({scrollTop:idxarray[index]}, 300); // $('#wap-nav li').eq(index).find('a').attr('data-go',idxarray[index]); // $('.nav li').eq(index).find('a').attr('data-go',idxarray[index]); // console.log(idxarray[index]); // }); $('.pcNav .layui-nav-child').each(function(index, element) { $(this).show(); $(this).css('margin-left',-$(this)[0].offsetWidth/2); $(this).hide(); }); } //当前时间 getDate() function getDate() { var timezone = 8; var offset_GMT = new Date().getTimezoneOffset(); var nowDate = new Date().getTime(); var today = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000); var date = today.getFullYear() + "-" + twoDigits(today.getMonth() + 1) + "-" + twoDigits(today.getDate()); var time = twoDigits(today.getHours()) + ":" + twoDigits(today.getMinutes()) + ":" + twoDigits(today.getSeconds()); $(".getDate").html(date + ' ' + time); //$(".getDate").html(time); } function twoDigits(val) { if (val < 10) return "0" + val; return val; } $(function() { setInterval(getDate, 1000); });