From 23ffc2ee97c99eb6a7305b7c61e660d0d0d84b89 Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期二, 09 七月 2024 08:06:52 +0800
Subject: [PATCH] 获取储位号
---
HTML/js/public.js | 46 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/HTML/js/public.js b/HTML/js/public.js
index 27b625e..879c061 100644
--- a/HTML/js/public.js
+++ b/HTML/js/public.js
@@ -13,7 +13,7 @@
{
sendData(IP + "/Basis/GetFunSettingByNo?funSetNo="+"Fun013", {}, 'get', function (res) {
console.log(res.data.SetValue)
- if (res.code == 0) { //鎴愬姛
+ if (res.code == 200) { //鎴愬姛
if(res.data.IsEnable == 'NO')
{
pageCnt = parseInt(res.data.SetValue);
@@ -39,6 +39,15 @@
if (!$.cookie('token')) {
callbackFun("鐧诲綍浜轰俊鎭凡澶辨晥");
}
+ if(isExpired = isTokenExpired($.cookie('token'))){
+ try{
+ parent.window.location.href = '/views/Login.html';
+ }
+ catch(error){
+ window.location.href = '/views/Login.html';
+ }
+ return;
+ }
}
$.ajax({
url: url,
@@ -55,19 +64,33 @@
success: function (res, status, xhr) {
// console.log(res);
// console.log(status);
-
callbackFun(res);
},
- error: function (res, status, error) {
- // console.log(res);
- // console.log(status);
- callbackFun(res, status, error);
+ error: function (res, status, error) {
+ callbackFun(res.responseJSON, status, error);
// layer.msg(res.statusText, {
// icon: 2,
// time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
// }, function() {});
},
});
+}
+function isTokenExpired(token) {
+ const tokenParts = token.split('.');
+ if (tokenParts.length !== 3) {
+ return true; // JWT 鏍煎紡涓嶆纭�
+ }
+ const payloadBase64 = tokenParts[1];
+ const payload = JSON.parse(atob(payloadBase64));
+
+ if (!payload || !payload.exp) {
+ return true; // 娌℃湁鏈夋晥杞借嵎鎴栬�呮病鏈夎繃鏈熸椂闂�
+ }
+
+ const now = Date.now() / 1000; // 褰撳墠鏃堕棿鎴筹紙绉掞級
+ const expiration = payload.exp;
+
+ return now >= expiration;
}
function synData(url, data, type, callbackFun) {
var deferred = $.Deferred();
@@ -245,7 +268,7 @@
function GetIsSetColW()
{
sendData(IP + "/Basis/GetFunSettingByNo?funSetNo="+"Fun014", {}, 'get', function (res) {
- if (res.code == 0) { //鎴愬姛
+ if (res.code == 200) { //鎴愬姛
if(res.data.IsEnable == 'NO')
{
isSetColW=true;
@@ -333,4 +356,13 @@
}
}
});
+}
+
+var FnParseData = function (res) {
+ return {
+ "code": res.code == 200 ? 0 : res.code, // 瑙f瀽鎺ュ彛鐘舵��
+ "msg": res.msg, // 瑙f瀽鎻愮ず鏂囨湰
+ "count": res.data.Total, // 瑙f瀽鏁版嵁闀垮害
+ "data": res.data.Items // 瑙f瀽鏁版嵁鍒楄〃
+ };
}
\ No newline at end of file
--
Gitblit v1.8.0