将 admin 模块化拆分
This commit is contained in:
42
static/src/js/app/oj/account/login.js
Normal file
42
static/src/js/app/oj/account/login.js
Normal file
@@ -0,0 +1,42 @@
|
||||
define("login", ["jquery", "bs_alert", "validation"], function($, bs_alert){
|
||||
$("#login-form")
|
||||
.formValidation({
|
||||
framework: "bootstrap",
|
||||
fields: {
|
||||
username: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写用户名"
|
||||
}
|
||||
}
|
||||
},
|
||||
password: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写密码"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
).on('success.form.fv', function(e) {
|
||||
e.preventDefault();
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
$.ajax({
|
||||
url: "/api/login/",
|
||||
data: {username: username, password: password},
|
||||
dataType: "json",
|
||||
method: "post",
|
||||
success: function (data) {
|
||||
if(!data.code){
|
||||
window.location.href="/";
|
||||
}
|
||||
else{
|
||||
bs_alert(data.data);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user