ah_jjzhgd_webscreen/js/publics/public.js

46 lines
1.5 KiB
JavaScript

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