自动化立体仓库 - WCS系统
pang.jiabao
2025-04-14 13f3721a678782cfa042acca5208644e8f32dcfb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>NEWS</title>
    <style>
        /** {*/
        /*    padding: 0;*/
        /*    margin: 0;*/
        /*}*/
        .container {
            height: 100%;
            width: 100%;
        }
        /*=============== SCROLL UP ===============*/
        .scrollup {
            text-decoration: none;
            text-align: center;
            width: 25px;
            height: 18px;
            position: fixed;
            right: 1rem;
            bottom: -55%;
            background-color: rgb(108,167,168);
            box-shadow: 0 8px 12px hsla(228, 66%, 45%, .1);
            display: inline-flex;
            padding: .35rem;
            border-radius: .25rem;
            color: #ffffff;
            z-index: 10;
            transition: .3s;
            font-size: 8px;
        }
        .scrollup:hover {
            transform: translateY(-.25rem);
        }
        /* Show Scroll Up*/
        .show-scroll {
            bottom: 5%;
        }
 
        .news-desc {
            font-size: 14px;
        }
        .level-1 {
            color: #333333;
        }
        .level-2 {
            color: #0087ec;
        }
        .level-3 {
            color: red;
        }
    </style>
</head>
<body>
<div class="container">
 
</div>
<a class="scrollup" id="scroll-up">
    <span>顶部</span>
</a>
</body>
<script src="../static/js/jquery/jquery-3.3.1.min.js"></script>
<script src="../static/js/handlebars/handlebars-v4.5.3.js"></script>
<script src="../static/js/common.js"></script>
<script>
    var autoScroll = true;
 
    function scrollUp(){
        const scrollUp = document.getElementById('scroll-up');
        if(this.scrollY >= 100) scrollUp.classList.add('show-scroll'); else scrollUp.classList.remove('show-scroll')
    }
    window.addEventListener('scroll', scrollUp)
 
    $(document).on('click ','#scroll-up', function () {
        window.scrollTo(0, 0);
        autoScroll = false;
    })
 
    $(document).on('click ','body', function () {
        autoScroll = false;
    })
 
    setInterval(()=>{
        $.ajax({
            url: baseUrl + "/news/print",
            // headers: {'token': localStorage.getItem('token')},
            method: 'GET',
            success: function (res) {
                if (res.code === 200) {
                    let template = Handlebars.compile($('#newsTpl').html());
                    $('.container').html(template({list: res.data}));
                    if (autoScroll) {
                        window.scrollTo(0, document.body.scrollHeight)
                    }
                } else if (res.code === 403) {
                    window.location.href = baseUrl + "/login";
                } else {
                    console.error(res.msg);
                }
            }
        })
    }, 1000)
 
</script>
<script type="text/template" id="newsTpl">
    {{#each list}}
    <div class="news-desc level-{{l}}">
        <span>{{t}}</span>&nbsp;-&nbsp;<span>{{v}}</span>
    </div>
    {{/each}}
</script>
</html>