From ecd9d731c0970ea9abc764afad5432477ecc23ef Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期四, 26 三月 2026 10:57:31 +0800
Subject: [PATCH] 修改 webconfig 实现 全局 ajax请求自动载入 Token , 全局配置打开弹出层后,自动隐藏父级滚动条的功能
---
WebTM/layuiadmin/Scripts/webConfig.js | 146 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 116 insertions(+), 30 deletions(-)
diff --git a/WebTM/layuiadmin/Scripts/webConfig.js b/WebTM/layuiadmin/Scripts/webConfig.js
index b7a74a2..6db8126 100644
--- a/WebTM/layuiadmin/Scripts/webConfig.js
+++ b/WebTM/layuiadmin/Scripts/webConfig.js
@@ -1,30 +1,20 @@
锘�
function GetWEBURL() {
- //var WEBURL = "http://192.168.16.80:8011/"; //鍔炲叕瀹ゆ湇鍔″櫒
- //var WEBURL = "http://localhost:8081/SWEAPI/"; //ch鏈湴*/
+ //var WEBURL = "http://192.168.16.80:8011/"; //鍔炲叕瀹ゆ湇鍔″櫒
//var WEBURL = "http://61.164.86.218:8099/ABAPI/";
- /*var WEBURL = "http://localhost/API/"; //棰滄檽鍐涙湰鍦伴厤缃�*/
- //var WEBURL = "http://localhost:8082/LuBaoAPI/"; //鏉ㄤ箰鏈湴閰嶇疆
- /* var WEBURL = "http://localhost:8082/API/"; //鏉滆春鏈湴閰嶇疆*/
- //var WEBURL = "http://localhost:8082/API/"; //寮犵憺骞挎湰鍦伴厤缃�
-<<<<<<< HEAD
- var WEBURL = "http://localhost:8080/API/"; //鐜嬩华鏈湴閰嶇疆
- //var WEBURL = "http://localhost:81/API/" //缈佹稕娑涙湰鍦伴厤缃�
-
- //var WEBURL = "http://localhost:8080/API/"; //鐜嬩华鏈湴閰嶇疆
-// var WEBURL = "http://localhost:81/API/" //缈佹稕娑涙湰鍦伴厤缃�
- //var WEBURL = "http://localhost:81/API/" //缈佹稕娑涙湰鍦伴厤缃�
- //var WEBURL = "http://localhost:81/API/" //缈佹稕娑涙湰鍦伴厤缃�
- //var WEBURL = "http://localhost:8082/LuBaoAPI/"; //鏉ㄤ箰鏈湴閰嶇疆
-=======
- var WEBURL = "http://localhost:81/API/" //缈佹稕娑涙湰鍦伴厤缃�
- /* var WEBURL = "http://localhost:8080/API/"; //鐜嬩华鏈湴閰嶇疆*/
- //var WEBURL = "http://localhost:8082/LuBaoAPI/"; //鏉ㄤ箰鏈湴閰嶇疆
->>>>>>> 2ed130171719a0848e8356d28055eb1bdf649d01
+ //var WEBURL = "http://localhost/API/"; //棰滄檽鍐涙湰鍦伴厤缃�
+ //var WEBURL = "http://localhost:8082/API/"; //鏉滆春鏈湴閰嶇疆
+ //var WEBURL = "http://localhost:81/API/" //缈佹稕娑涙湰鍦伴厤缃�
+ // var WEBURL = "http://localhost:8082/API/"; //寮犵憺骞挎湰鍦伴厤缃�
+ var WEBURL = "http://localhost:81/API/"; //闄堥晲鍝叉湰鍦伴厤缃�
+ //var WEBURL = "http://localhost:8082/LuBaoAPI/"; //鏉庢灄淇婃湰鍦伴厤缃�
+ //var WEBURL = "http://localhost:8080/API/"; //鐜嬩华鏈湴閰嶇疆
+ //var WEBURL = "http://localhost:8082/LuBaoAPI/"; //浣欐�濇澃鏈湴閰嶇疆
+ //var WEBURL = "http://localhost:8088/ARAPI/"; //浣欐�濇澃鏈湴閰嶇疆(瀹夌憺)
//var WEBURL = "http://47.96.97.237/API/"; //鏅轰簯鏈嶅姟鍣�
- /*var WEBURL = "http://localhost:8082/LuBaoAPI/";*/ //浣欐�濇澃鏈湴閰嶇疆
- //var WEBURL = "http://localhost:81/API/"; // 闄堥晲鍝叉湰鍦伴厤缃�*/
- var WEBURL = "http://localhost:8082/LuBaoAPI/"; //鏉庢灄淇婃湰鍦伴厤缃�
+ /* var WEBURL = "http://localhost:8082/LuBaoAPI/"; //浣欐�濇澃鏈湴閰嶇疆*/
+ // var WEBURL = "http://localhost:81/API/"; // 闄堥晲鍝叉湰鍦伴厤缃�*/
+ //var WEBURL = "http://localhost:8082/LuBaoAPI/"; //鏉庢灄淇婃湰鍦伴厤缃�
//var WEBURL = "http://localhost:8088/ARAPI/"; //浣欐�濇澃鏈湴閰嶇疆(瀹夌憺)
//var WEBURL = "http://61.164.86.218:8099/ABAPI/"; //濂ラ偊
//var WEBURL = "http://10.1.4.155/API/"; //姹熶赴瀹㈡埛NEW
@@ -40,10 +30,11 @@
//var WEBURL = "http://192.168.1.237:9003/API"; //澶忓疂鍐呯綉
//var WEBURL = "http://60.190.4.42:9003/API"; //澶忓疂澶栫綉
//var WEBURL = "http://192.168.60.12/API"; //涓帶
- //var WEBURL = "http://192.168.6.5:8082/API/"; //鑸滄垚
- /*var WEBURL = "http://121.36.199.126:8181/API/"; //涓夊崌*/
+ //var WEBURL = "http://192.168.6.5:8082/API/"; //鑸滄垚
+ //var WEBURL = "http://121.36.199.126:8181/API/"; //涓夊崌
//var WEBURL = "http://36.134.2.30:200/WEBS-API/"; //閲戝竻
//var WEBURL = "http://172.16.1.85/API/"; //杩﹀崡
+ // var WEBURL = "http://61.164.64.222:8082/API_WW/"
return WEBURL
}
@@ -52,8 +43,103 @@
}
-//function GetWEBURL1() {
-// //var WEBURL = 'http://192.168.16.80:8011/'; //鍔炲叕瀹ゆ湇鍔″櫒
-// var WEBURL = 'http://localhost:9011/WebAPI';
-// return WEBURL
-//}
\ No newline at end of file
+layui.use(['jquery', 'layer'], function () {
+ var $ = layui.jquery,
+ layer = layui.layer;
+
+ // 鍏ㄥ眬閰嶇疆
+ layer.config({
+ scrollbar: false
+ });
+
+ // 鍏ㄥ眬閰嶇疆 榛樿涓嶆樉绀虹埗绾ф粴鍔ㄦ
+ var _open = layer.open;
+ layer.open = function (opts) {
+ // 鍚堝苟榛樿閰嶇疆
+ var options = $.extend({}, layer.config, opts);
+
+ var oldSuccess = options.success;
+ var oldEnd = options.end;
+ var needHideScroll = options.scrollbar === false;
+
+ // 鎵撳紑寮圭獥鏃�
+ options.success = function (layero, index) {
+ if (needHideScroll) {
+ $('body').css('overflow', 'hidden');
+ }
+ if (oldSuccess) oldSuccess.call(this, layero, index);
+ };
+
+ // 鍏抽棴寮圭獥鏃�
+ options.end = function () {
+ if (needHideScroll) {
+ // 鍙湁鏈�鍚庝竴涓脊绐楀叧闂墠鎭㈠
+ if ($('.layui-layer:visible').length <= 1) {
+ $('body').css('overflow', '');
+ }
+ }
+ if (oldEnd) oldEnd.call(this);
+ };
+
+ return _open.call(this, options);
+ };
+
+ // 鍏ㄥ眬鎷︽埅鎵�鏈� layui ajax 璇锋眰
+ $(document).ajaxSend(function (event, jqxhr, settings) {
+ var token = localStorage.getItem('token');
+ if (token) {
+ // 鑷姩甯︿笂 token
+ jqxhr.setRequestHeader('Authorization', 'Bearer ' + token);
+ }
+
+ });
+
+
+ // 缁熶竴澶勭悊 鏈璇�/鏈巿鏉冭姹�
+ $(document).ajaxComplete(function (event, jqxhr, settings) {
+ // HTTP 鐘舵�佺爜
+ var status = jqxhr.status;
+
+ if (status === 401) {
+ // 鏈櫥褰� / token 杩囨湡
+ layer.confirm('鐧诲綍宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�', { icon: 7, title: '鎻愮ず' }, function () {
+ localStorage.removeItem('token');
+ window.top.location.href = '../../views/user/login.html'; // 璺冲埌鐧诲綍椤�
+
+ });
+ } else if (status === 403) {
+ // 鏃犳潈闄�
+ layer.msg('鎮ㄦ病鏈夎妯″潡鐨勬搷浣滄潈闄�', { icon: 2, time: 2000 });
+ }
+ });
+});
+
+if (typeof $ != 'undefined') {
+ $(document).ajaxSend(function (event, jqxhr, settings) {
+ var token = localStorage.getItem('token');
+ if (token) {
+ // 鑷姩甯︿笂 token
+ jqxhr.setRequestHeader('Authorization', 'Bearer ' + token);
+ }
+
+ });
+
+
+ // 缁熶竴澶勭悊 鏈璇�/鏈巿鏉冭姹�
+ $(document).ajaxComplete(function (event, jqxhr, settings) {
+ // HTTP 鐘舵�佺爜
+ var status = jqxhr.status;
+
+ if (status === 401) {
+ // 鏈櫥褰� / token 杩囨湡
+ layer.confirm('鐧诲綍宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�', { icon: 7, title: '鎻愮ず' }, function () {
+ localStorage.removeItem('token');
+ window.top.location.href = '../../views/user/login.html'; // 璺冲埌鐧诲綍椤�
+
+ });
+ } else if (status === 403) {
+ // 鏃犳潈闄�
+ layui.layer.msg('鎮ㄦ病鏈夎妯″潡鐨勬搷浣滄潈闄�', { icon: 2, time: 2000 });
+ }
+ });
+}
--
Gitblit v1.9.1