This repository has been archived on 2022-06-28. You can view files and clone it, but cannot push or open issues or pull requests.
magic_box_server/html/static/js/user.js
Yutousama 11d2c15dae 2.4发版前更新
前端分离出来
工具列表新增版本控制
2020-04-01 18:00:18 +08:00

74 lines
1.6 KiB
JavaScript

window.onload=function(){
$.post("/user/test.do", '', function(data, textStatus, req) {
var json=null;
console.log("登陆测试:"+data);
try {
json=JSON.parse(data);
} catch (e) {
// TODO: handle exception
console.log(e);
}
if(json==null||json.code!=100){
var title;
var content;
var url;
var reload=false;
switch (json.code) {
case 104:
title="请登录";
content="还没登陆哦~";
url="/index.html"
break;
case 105:
title="没有访问权限";
content="您无法访问当前页面";
url="home.html"
reload=true;
break;
default:
title="异常错误";
content="未知错误,请尝试重新登录";
url="/index.html"
break;
}
var layer = layui.layer;
layer.open({
title: title,
content: content,
cancel:function(index){
return false;
},
btn: ['知道了'],
btn1: function(data){
if(reload)
window.history.go(-1);
else
window.location.replace(url);
}
});
}else{
console.log('登陆成功');
}
})
$.post("/user/udata.do",function(data, textStatus, req){
var json=JSON.parse(data);
$("#uname").text(json.uname);
})
}
function logout(){
$.post("/user/logout.do", function(data, textStatus, req) {
var layer=layui.layer;
layer.open({
title: "退出",
content: "成功退出,欢迎下次光临",
cancel:function(index){
return false;
},
btn:['了解'],
btn1:function(){
window.location.replace("/index.html");
}
})
});
}