修改 webconfig 实现 全局 ajax请求自动载入 Token , 全局配置打开弹出层后,自动隐藏父级滚动条的功能
4个文件已修改
121 ■■■■■ 已修改文件
WebTM/layuiadmin/Scripts/webConfig.js 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/user/login.html 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/user/login_pda.html 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/生产管理/订单状态分布/Sc_OrderStateDistribution.html 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/layuiadmin/Scripts/webConfig.js
@@ -6,14 +6,14 @@
    //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: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:81/API/";            // é™ˆé•å“²æœ¬åœ°é…ç½®*/
     //var WEBURL = "http://localhost:8082/LuBaoAPI/";  //李林俊本地配置
    //var WEBURL = "http://localhost:8088/ARAPI/";      //余思杰本地配置(安瑞)
    //var WEBURL = "http://61.164.86.218:8099/ABAPI/";  //奥邦
@@ -34,6 +34,7 @@
    //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
}
@@ -41,3 +42,104 @@
    return GetWEBURL()
}
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 });
        }
    });
}
WebTM/views/user/login.html
@@ -450,6 +450,10 @@
                            sessionStorage["Organization"] = $("#Organization option:selected").text();
                            sessionStorage["HTranSlate"] = $("#HTranSlate option:selected").val();
                            //sessionStorage["IP"] = System.Configuration.ConfigurationSettings.AppSettings("name");
                             if(result.token) {
                                localStorage.setItem('token', result.token)
                            }
                            get_WriteConfigFile();
                            if (!judgeMorPCflag) {//移动端
                                window.location.href = '../../views/index_Mobile.html'
WebTM/views/user/login_pda.html
@@ -278,7 +278,9 @@
                            sessionStorage["HWorkCenter"] = result.data[0].HWorkCenterName;
                            sessionStorage["HSPID"] = result.data[0].HSPID;
                            sessionStorage["HSPName"] = result.data[0].HSPName;
                            if(result.token) {
                                localStorage.setItem('token', result.token)
                            }
                            layer.msg(result.Message, { icon: 1 });
                            //登录移动端
                            window.location.href = '../../views/index_Mobile.html'
WebTM/views/Éú²ú¹ÜÀí/¶©µ¥×´Ì¬·Ö²¼/Sc_OrderStateDistribution.html
@@ -121,21 +121,22 @@
            background-color: #007dff;
            color: #fff;
            padding: 8px 12px;
            font-size: 32px;
            font-size: 20px;
            font-weight: bold;
        }
        .param-list {
            display: flex;
            gap: 4px;
            flex-wrap: wrap;
            padding: 10px 20px;
            background-color: #f2f2f2;
        }
        .param-item {
            width: 24%;
            width: 10%;
            margin-bottom: 8px;
            font-size: 28px;
            font-size: 14px;
            color: #333;
        }