ah_jjzhgd_webscreen/js/publics/public.js

62 lines
2.0 KiB
JavaScript

const token = sessionStorage.getItem("zhgd_token");
const us = sessionStorage.getItem("zhgd_us");
const zhgd_type = sessionStorage.getItem("zhgd_type");
/* 退出登录 */
function loginout(type) {
if (type) {
sessionStorage.removeItem("zhgd_token");
sessionStorage.removeItem("zhgd_us");
sessionStorage.removeItem("zhgd_type");
top.layer.confirm('登录已过期,请点击确定后重新登录!', {
btn: ['确认', '取消'],
move: false,
cancel: function (index, layero) {
backLoginPage();
}
}, function () {
backLoginPage();
}, function () {
backLoginPage();
});
} 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 () {
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;
}
});
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}
}, function (xhr) {
error(xhr)
});
}
}
/* 返回登录页 */
function backLoginPage() {
if (zhgd_type === "2") {
top.location.href = login_sg_page;
} else if (zhgd_type === "1") {
top.location.href = login_sc_page;
}
}