Files
jshERP/erp_web/js/modules/sys/userInfo.js
2020-06-11 22:18:52 +08:00

24 lines
721 B
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//判断是否存在session如果不存在就跳到登录界面
$.ajax({
type: "get",
url: "/user/getUserSession",
dataType: "json",
async: false,
success: function (res) {
if(res && res.code === 200) {
if(res.data.user) {
var user = res.data.user;
sessionStorage.setItem("userId", user.id);
if (user.username) {
$(".main-header .user-menu .hidden-xs,.main-sidebar .info p").text(user.username);
}
}
} else {
top.location.href = '/login.html';
}
},
error: function () {
top.location.href = '/login.html';
}
});