赣州市洪水风险预警系统二维版本
xiebin
2023-03-02 b39483c96ae572121d3c619c0b9d37634e682cc4
增加token验证功能,实现统一登陆
1 files modified
52 ■■■■ changed files
index.html 52 ●●●● patch | view | raw | blame | history
index.html
@@ -143,25 +143,51 @@
    </script>
    <script>
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
        $(function () {
            var token  = getUrlParam("token")
            var login  = sessionStorage.getItem("shuiwen-token")
            //JavaScript JSON.parse()方法用于将一个 JSON 字符串转换为对象。
            var login = sessionStorage.getItem("shuiwen-token");
            // var login = sessionStorage.getItem("shuiwen-token");
            if (!login) {
                if (token) {
                    $.ajax({
                        url: "http://192.168.0.207:82/blade-ycreal/auth/jwtLogin?token=" + token,
                        type: 'get',
                        headers: {
                            'Authorization': 'Basic c2FiZXI6c2FiZXJfc2VjcmV0',
                            "Tenant-Id": "000000"
                        },
                        data: {},
                        dataType: 'JSON',
                        success: function (res) {
                            if (res.success == "true") {
                                $('#map2d').hide();
            if (login) {
                if (login.length == 0) {
                                $('.swDiv').mouseover(function(){
                                    $('.hover-box').css('display','block');
                                })
                                $('.swDiv').mouseout(function(){
                                    $('.hover-box').css('display','none');
                                })
                                return
                            } else {
                                window.location.href = "login.html";
                            }
                        },
                        error: function (res) {
                            window.location.href = "login.html";
                        },
                    })
                } else {
                    window.location.href = "login.html";
                }
            } else {
                window.location.href = "login.html";
            }
            $('#map2d').hide();
            $('.swDiv').mouseover(function(){
                $('.hover-box').css('display','block');
            })
            $('.swDiv').mouseout(function(){
                $('.hover-box').css('display','none');
            })
        });
        function map3dClick() {