var loginType = 0; $(function () { var apiurl = "/BookCircle/Handler/CommonHandler.ashx"; $("#loginNow").click(function () { $("div[data-login-modal='true']").show(); }); $("div[data-login-tab='true']").click(function () { $("div[data-login-tab='true']").removeClass("dltdq"); $(this).addClass("dltdq"); loginType = $(this).attr("data-logintype"); $("div[data-login-div='true']").hide(); $("div[data-login-div='true'][data-logintype='"+loginType+"']").show(); }); $("#login_close").click(function () { $("div[data-login-modal='true']").hide(); }); $.fn.seconds = 120; $("#btGetVeryCode").click(function () { var phone = $("#txtPhone"); if ($.trim($(phone).val()) == "") { alert("请输入有效的手机号码"); return; } else { var isMob = /^1[3|4|5|6|7|8|9][0-9]\d{4,8}$/; if ($(phone).val().length != 11) { alert("请输入有效的手机号码"); return; } else { if (!isMob.test($(phone).val())) { alert("请输入有效的手机号码"); return; } } } var imgVeryCode = $("#txtImgVerCode_phone").val(); if ($.trim(imgVeryCode)=="") { alert("请输入图片验证码"); return; } $.get(apiurl, { methodname: "CheckImageVerCode", code: imgVeryCode }, function (result) { if (result>0) { $("#btGetVeryCode").val("获取中…"); $.ajax({ url: apiurl, type: "post", data: { methodname: "SendMobileValidateCodeUserLogin", mobile: $("#txtPhone").val(), type: 40 }, success: function (result) { result = JSON.parse(result); if (result.code == 0) { $.fn.seconds = 120; $("#btGetVeryCode").attr("disabled", "disabled"); $.timer(1000, function (timer) { $.fn.seconds--; if ($.fn.seconds >= 0) { $("#btGetVeryCode").val($.fn.seconds + "秒后重新获取"); } else { timer.stop(); $("#btGetVeryCode").removeAttr("disabled"); $("#btGetVeryCode").val("重新获取"); } }); } else { $("#btGetVeryCode").val("重新获取"); } if (result.msg == '验证码已发送,5分钟内输入有效') { alert(result.msg); } else { alert(result.msg); } } }) } else { alert("图片验证码错误!"); } }); }); $("#login").click(function () { if (loginType == 0) { var phone = $("#txtPhone"); if ($.trim($(phone).val()) == "") { alert("请输入有效的手机号码"); return false; } else { var isMob = /^1[3|4|5|6|7|8|9][0-9]\d{4,8}$/; if ($(phone).val().length != 11) { alert("请输入有效的手机号码"); return false; } else { if (!isMob.test($(phone).val())) { alert("请输入有效的手机号码"); return false; } } } var cerycode = $("#txtPhoneVerCode"); if ($(cerycode).val() == "") { alert("验证码不能为空"); return false; } else { var isVerycode = /^\d{6}$/ if (!isVerycode.test($(cerycode).val())) { alert("验证码错误,请重新输入!"); return false; } } $.ajax({ url: apiurl, type: "post", async: false, data: { methodname: "SignPhone", Mobile: $("#txtPhone").val(), ValidateCode: $("#txtPhoneVerCode").val(), type: 40 }, success: function (result) { result = JSON.parse(result); if (result.code==0) { $.fn.seconds = 0; //$("#login_r").hide(); alert("登陆成功!"); $("div[data-login-modal='true']").hide(); var html = `