$(function () { $('.search .search_icon').click(function () { $(this).next('.search_popup').stop(true).slideToggle(); }); $('.web_nav_btn').click(function () { $('.web_nav').animate({ 'left': 0 },500); }); $('.web_nav_close').click(function () { $('.web_nav').animate({ 'left': '100%' },500); }); $('.web_nav li').click(function () { $(this).siblings('li').find('dl').stop(true).slideUp(); $(this).find('dl').stop(true).slideToggle(); }); }); function messageBtn(obj) { var name = $(obj).parents('form').find('input[name=name]').val(), mobile = $(obj).parents('form').find('input[name=mobile]').val(), content = $(obj).parents('form').find('input[name=content]').val(); if(name == '' || mobile == ''){ layer.msg('姓名和电话不能为空!'); return false; } if(isMobilePhone(mobile) == false){ layer.msg('请正确填写手机号!'); return false; } $.ajax({ type: 'POST', url: '/mess.html', data: 'name=' + name + '&mobile=' + mobile + '&content=' + content, success: function (res) { if(res.code == 1) { setTimeout(function () { window.location.reload(); },1500); } layer.msg(res.msg); } }) } function isMobile() { var userAgentInfo = navigator.userAgent; var mobileAgents = [ "Android", "iPhone", "SymbianOS", "Windows Phone", "iPad","iPod"]; var mobile_flag = false; //根据userAgent判断是否是手机 for (var v = 0; v < mobileAgents.length; v++) { if (userAgentInfo.indexOf(mobileAgents[v]) > 0) { mobile_flag = true; break; } } var screen_width = window.screen.width; var screen_height = window.screen.height; //根据屏幕分辨率判断是否是手机 if(screen_width < 500 && screen_height < 800){ mobile_flag = true; } return mobile_flag; } function isMobilePhone(mobile) { var myreg_tel= /^((1[3|5|6|7|8|9]{1})+\d{9})$/; if(!myreg_tel.test(mobile)){ return false; } return true; }