//登录 $("#btnlogin").click(function () { var btnText = $('#btnlogin').html(); $("#btnlogin").attr("disabled", "true"); //设置禁用按钮 $('#btnlogin').text('登录中...'); //显示提交中 $("#loginForm").ajaxSubmit({ url: "/APP/login/login", type: "post", success: function (res) { if (res.Status == 200) { save_cookies(); $.toastr.success('登录成功', { position: 'top-center', time: 350, location.href = "/APP/Home/Index"; }); $('#btnlogin').text(btnText); //还原显示 $('#btnlogin').removeAttr('disabled')//重置按钮 } else { $.toastr.error('登录失败!
' + res.Message, { time: 3000, position: 'top-center' }); $('#btnlogin').text(btnText); //还原显示 $('#btnlogin').removeAttr('disabled')//重置按钮 //toastr.options = { // closebutton: false, // progressbar: true, // showmethod: 'slidedown', // timeout: 2000, // positionclass: "toast-top-center", //}; //toastr.error("登录失败:" + res.message); } }, error: function (error) { $('#btnlogin').removeAttr('disabled')//重置按钮 alert(error); } }); }); function save_cookies() { if ($("#remember").prop("checked")) { var username = $("#username").val(); var password = $("#password").val(); $.cookie("remember", "true", { expires: 7 }); $.cookie("username", username, { expires: 7 }); $.cookie("password", password, { expires: 7 }); } else { $.cookie("remember", "false", { expires: -1 }); $.cookie("username", "", { expires: -1 }); $.cookie("password", "", { expires: -1 }); } };