初始化项目
This commit is contained in:
64
AUTS.Web/Plugin/login.js
Normal file
64
AUTS.Web/Plugin/login.js
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
//登录
|
||||
$("#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,
|
||||
callback: function () {
|
||||
location.href = "/APP/Home/index";
|
||||
}
|
||||
});
|
||||
$('#btnlogin').text(btnText); //还原显示
|
||||
$('#btnlogin').removeAttr('disabled')//重置按钮
|
||||
} else {
|
||||
|
||||
$.toastr.error('登录失败! <br />' + 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 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user