zwzw1219 2017-10-15 17:43:54 +08:00
parent 9e5474bf28
commit 7716a7877e
2 changed files with 8 additions and 4 deletions

View File

@ -40,7 +40,7 @@
var user = loginInfo();
if (user != "") {
location.href = '/';
location.href = '/index.html';
}
function login(obj) {
@ -54,10 +54,11 @@
} else {
$.ajax({
type : 'post',
url : '/sys/login',
url : '/login',
data : $("#login-form").serialize(),
success : function() {
location.href = '/';
success : function(data) {
localStorage.setItem("token", data.token);
location.href = '/index.html';
},
error : function(xhr, textStatus, errorThrown) {
var msg = xhr.responseText;

View File

@ -1,5 +1,8 @@
$.ajaxSetup({
cache : false,
headers : {
"token" : localStorage.getItem("token")
}
error : function(xhr, textStatus, errorThrown) {
var msg = xhr.responseText;
var response = JSON.parse(msg);