ah_jjzhgd_webscreen/js/publics/public.js

79 lines
2.5 KiB
JavaScript
Raw Normal View History

2024-03-26 19:52:42 +08:00
const token = sessionStorage.getItem("zhgd_token");
const us = sessionStorage.getItem("zhgd_us");
const zhgd_type = sessionStorage.getItem("zhgd_type");
2024-03-27 09:46:09 +08:00
const roleCode = JSON.parse(us).roleCode;
const orgId = JSON.parse(us).orgId;
const userId = JSON.parse(us).userId;
2024-03-29 15:25:34 +08:00
2024-03-25 20:20:02 +08:00
/* 退出登录 */
function loginout(type) {
if (type) {
2024-03-26 19:52:42 +08:00
sessionStorage.removeItem("zhgd_token");
sessionStorage.removeItem("zhgd_us");
sessionStorage.removeItem("zhgd_type");
2024-03-25 20:20:02 +08:00
top.layer.confirm('登录已过期,请点击确定后重新登录!', {
btn: ['确认', '取消'],
move: false,
cancel: function (index, layero) {
2024-03-26 19:52:42 +08:00
backLoginPage();
2024-03-25 20:20:02 +08:00
}
}, function () {
2024-03-26 19:52:42 +08:00
backLoginPage();
2024-03-25 20:20:02 +08:00
}, function () {
2024-03-26 19:52:42 +08:00
backLoginPage();
2024-03-25 20:20:02 +08:00
});
} else {
top.layer.confirm('请您确定注销?', {
btn: ['确认', '取消'],
move: false,
}, function () {
loginOutAjax();
}, function () {
});
}
// 登出请求
function loginOutAjax() {
ajaxRequest(login_out, "POST", null, true, function () {
}, function (result) {
if (result.code === 200) {
top.layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
2024-03-26 19:52:42 +08:00
sessionStorage.removeItem("zhgd_token");
sessionStorage.removeItem("zhgd_us");
sessionStorage.removeItem("zhgd_type");
if (zhgd_type === "2") {
top.location.href = login_sg_page;
} else if (zhgd_type === "1") {
top.location.href = login_sc_page;
}
2024-03-25 20:20:02 +08:00
});
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}
}, function (xhr) {
error(xhr)
});
}
2024-03-26 19:52:42 +08:00
}
2024-03-29 15:25:34 +08:00
/* 请求错误 */
function error(xhr, status, error) {
if (xhr.status === 0) {
// 网络连接失败
console.error("网络连接失败,请检查网络是否正常");
} else {
// 请求出现其他错误
console.error("ajax请求错误" + error);
}
}
2024-03-26 19:52:42 +08:00
/* 返回登录页 */
function backLoginPage() {
if (zhgd_type === "2") {
top.location.href = login_sg_page;
} else if (zhgd_type === "1") {
top.location.href = login_sc_page;
}
2024-03-30 20:51:14 +08:00
}
//判断字符是否为空的方法
function isEmpty(obj) {
return typeof obj == "undefined" || obj == null || obj == "" || obj == '00';
2024-03-25 20:20:02 +08:00
}