/* ie版本 */ function versionie(){ if(navigator.appname=="microsoft internet explorer"){ var b_version=navigator.appversion, version=b_version.split(";"), trim_version=version[1].replace(/[ ]/g,""); if(trim_version=="msie8.0"){ return 'ie8'; }else if(trim_version=="msie7.0"){ return 'ie7'; }else if(trim_version=="msie6.0"){ return 'ie6'; } return true; } return false; } /* 自定义对话框 */ var msgtimer; function msgdialog(options){ if(document.getelementbyid("msgdialog")){ msgclose(); } var defaults = { text : "", time : 0, type : "success", callback : function(){} }, opts = $.extend(defaults,options), style = "display:block;float:left;font-size:40px;line-height:1;", html = ""; html += "
"; switch(opts.type){ case 'success': html += ""; break; case 'error': html += ""; break; case 'warning': html += ""; break; case 'loading': html += ""; break; case 'confirm': html += ""; break; } html += "
"+opts.text+"
"; var strstyle = "display:inline-block; *display:inline; cursor:pointer; height:26px; line-height:26px; padding:0 15px; margin-right:20px; background:#0084e9; color:#fff; border-radius:3px; border:1px solid #0078d4;"; if(opts.type == "confirm"){ html += "
确定
取消
"; }else if(opts.type != "loading" && opts.type != "success"){ html += "
确定
"; } html += "
"; $(document.body).append(html); var msgdialog = $("#msgdialog"); var divcenter = function (){ var windowwidth = $(window).width(); var windowheight = $(window).height(); var popupheight = msgdialog.height(); var popupwidth = msgdialog.width(); msgdialog.css({ "top": (windowheight*0.2)+$(document).scrolltop(), "left": (windowwidth-popupwidth)/2 }); } divcenter(); if(opts.time>0){ msgtimer = settimeout(msgclose,opts.time) ; } $(".msgbtns .msgbtn").on("click",function(){ msgclose(); if($(this).attr("rel")=="true"){ opts.callback(); } }); } /* 关闭对话框 */ function msgclose(){ cleartimeout(msgtimer); $("#msglock").remove(); $('#msgdialog').remove(); } /* 错误框 */ function msgerror(tip){ msgdialog({text:tip,type:'error'}); } /* 警告框 */ function msgalter(tip){ msgdialog({text:tip,type:'warning'}); } /* 加载,等待 */ function msgloading(tip){ msgdialog({text:tip,type:'loading'}); } /* 成功 */ function msgsuccess(tip){ msgdialog({text:tip,type:'success',time:1600}); } /* 选择对话框 */ function msgconfirm(tip,callback){ msgdialog({text:tip,type:'confirm',callback:callback}); } /* 低版本浏览器提醒 */ function lowbrowser() { var lowversion = versionie(); var lowbrowserhtml = '有部分功能您的浏览器不支持,请更换高级浏览器,建议使用firefox,chromeie10及以上'; if(lowversion == 'ie7' || lowversion == 'ie6'){ msgalter(lowbrowserhtml); } }; /* 会员注册协议 */ function protocoldialog(){ $("body").append("
"); $("body").append("
"); msgloading("数据加载中..."); $("#maincon").load("protocol.html",function(){ msgclose(); divcenter($("#divdialog")); }); var divcenter = function (obj){ var windowwidth = $(window).width(); var windowheight = $(window).height(); $("#maincon").css({"max-height":windowheight*0.9,"overflow-y":"auto"}); var popupheight = $(obj).height(); var popupwidth = $(obj).width(); var $top = (windowheight-popupheight)/2+$(document).scrolltop(); var $left = (windowwidth-popupwidth)/2; if($top < 0) $top = 0; $(obj).css({ "top": $top, "left": $left }); } $("#divclose").bind("click",function(){ $("#divdialog").remove(); $("#divdialoglock").remove(); }); } /* 会员找回密码 */ function findpassdialog(){ $("body").append("
"); $("body").append("
"); msgloading("数据加载中..."); $("#maincon").load("findpass.action",function(){ msgclose(); divcenter($("#divdialog")); }); var divcenter = function (obj){ var windowwidth = $(window).width(); var windowheight = $(window).height(); var popupheight = $(obj).height(); var popupwidth = $(obj).width(); var $top = (windowheight-popupheight)/2+$(document).scrolltop(); var $left = (windowwidth-popupwidth)/2; if($top < 0) $top = 0; $(obj).css({ "top": $top, "left": $left }); } $("#divclose").bind("click",function(){ $("#divdialog").remove(); $("#divdialoglock").remove(); }); } function checkmobile_from(name,id){ var regu =/^[1][3,5,8,7][0-9]{9}$/; var re = new regexp(regu); var val=document.getelementbyid(id).value; if(val!="" && val!=null){ if(!re.test(val)){ msgerror(name+":必须为手机格式"); document.getelementbyid(id).value=""; document.getelementbyid(id).focus(); } } } function checkemail_from(name,id){ var regu = /^[-_a-za-z0-9]+@([_a-za-z0-9]+\.)+[a-za-z0-9]{2,3}$/; var re = new regexp(regu); var val=document.getelementbyid(id).value; if(val!="" && val!=null){ if(!re.test(val)){ msgerror(name+":必须为邮箱格式"); document.getelementbyid(id).value=""; document.getelementbyid(id).focus(); } } } function checkcard_from(name,id){ var val=document.getelementbyid(id).value; if(val!="" && val!=null){ if(!/^\d{6}(18|19|20)?\d{2}(0[1-9]|10|11|12)(0[1-9]|[12]\d|3[01])\d{3}(\d|x)$/i.test(val)){ msgerror(name+":必须为身份证格式"); document.getelementbyid(id).value=""; document.getelementbyid(id).focus(); } } } function checknumber_from(name,id){ var regu = "^[0-9]+$"; var re = new regexp(regu); var val=document.getelementbyid(id).value; if (val.search(re) != -1) { return true; } else { msgerror(name+":必须为数字"); document.getelementbyid(id).value=""; document.getelementbyid(id).focus(); } } //刷新验证码 function jumpimg(){ document.getelementbyid('mycode').src='image.action?math='+math.random(); } /** * 提交反馈表单 formid:form的id属性; **/ function savefeedbackform(formid){ var fdform = $("#"+formid), options = { datatype: "json", beforesubmit: function() { msgloading('数据保存中,请稍候...'); }, success: function(data, statustext) { if(data.success==false){ msgerror("失败,原因是"+data.info+"!"); }else{ msgsuccess("数据保存成功!"); fdform[0].reset(); } fdform.data("submit",false); }, error: function(responsetext, statustext) { msgerror("保存失败,原因参考如下:"+responsetext); fdform.data("submit",false); } }; if(fdform.data("submit")){ msgalter("请不要重复提交!"); return false; } fdform.data("submit",true); fdform.ajaxsubmit(options); } // 多列下拉菜单 三级菜单 function dropmenumulticol(name){ var $box = $(name); $("li",$box).hover(function(){ var $this = $(this), dd = $box.find(".dropdown"), dc = dd.children(":eq("+$this.index()+")"); $this.children().addclass('active'); if(dc.height()>0){ dd.css({"visibility":"visible","height":(dc.height()+15)+"px"}); } dc.addclass("on"); },function(){ var $this = $(this), dd = $box.find(".dropdown"); $this.children().removeclass('active'); dd.css({"visibility":"hidden","height":0}); dd.children(":eq("+$this.index()+")").removeclass("on"); }); $(".dd-row",$box).hover(function(){ var $this = $(this); $this.addclass('on'); if($this.height()>0){ $this.parent().css({"visibility":"visible","height":($this.height()+15)+"px"}); } $box.find(".ul-one").children(":eq("+$this.index()+")").children().addclass("active"); },function(){ var $this = $(this); $this.removeclass('on'); $this.parent().css({"visibility":"hidden","height":0}); $box.find(".ul-one").children(":eq("+$this.index()+")").children().removeclass("active"); }); } function jsplaceholder(){ if(!('placeholder' in document.createelement('input'))){ var $elements = $("input[type=text],textarea"); for(var i=0,len=$elements.length;i