admin
2020-07-14 0866694119bd92a1786172d77a43ed1d6a8e7924
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
var load = {
    init: function() {
        if ($(".loading-more").length <= 0) {
            return;
        }
        $(".loading-more").css("visibility", "hidden");
        $(".loading-more").empty();
        $(".loading-more").css("display", "flex");
        $(".loading-more").css("justify-content", "center");
        $(".loading-more").css("align-items", "center");
        $(".loading-more").css("height", "0.8rem");
        $(".loading-more").css("font-size", "0");
        $(".loading-more").append("<div class='loading'>");
        for (var i = 1; i < 13; i++) {
            // alert('2');
            $(".loading").append("<div><span class='k'></span><span class='s'></span></div>");
        }
        $(".loading-more").append(
            "<div class='notifyContent' style='display:inline;font-size:0.3rem;margin-left:0.2rem;color:#999999'>正在加载更多数据</div>"
        )
    },
    show: function(msg) {
        if (msg != null && msg.length > 0)
            $(".loading-more").find("div").eq(1).html(msg);
        $(".loading-more").css("visibility", "visible");
    },
    hidden: function() {
        $(".loading-more").css("visibility", "hidden");
    },
    isLoading: function() {
        var visibility = $(".loading-more").css("visibility");
        if ("hidden" == visibility)
            return false;
        else
            return true;
    },
    noMore: function() {
        $(".loading-more .notifyContent").html("没有更多了");
        $(".loading-more").find(".loading").css("display", "none");
        $(".loading-more").css("visibility", "visible");
    },
    showMore: function(element, callBack) {
        if (Math.abs(load.getScrollHeight() - load.getDocumentTop() - load.getWindowHeight()) < 10) {
            if (load.isLoading())
                return;
            load.show();
            setTimeout(function() {
                callBack();
            }, 300);
        }
    },
    getDocumentTop: function() {
        var scrollTop = 0,
            bodyScrollTop = 0,
            documentScrollTop = 0;
        if (document.body) {
            bodyScrollTop = document.body.scrollTop;
        }
        if (document.documentElement) {
            documentScrollTop = document.documentElement.scrollTop;
        }
        scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
        console.log("scrollTop:" + scrollTop);
        return scrollTop;
    },
    getWindowHeight: function() {
        var windowHeight = 0;
        if (document.compatMode == "CSS1Compat") {
            windowHeight = document.documentElement.clientHeight;
        } else {
            windowHeight = document.body.clientHeight;
        }
        console.log("windowHeight:" + windowHeight);
        return windowHeight;
    },
    getScrollHeight: function() {
        var scrollHeight = 0,
            bodyScrollHeight = 0,
            documentScrollHeight = 0;
        if (document.body) {
            bodyScrollHeight = document.body.scrollHeight;
        }
        if (document.documentElement) {
            documentScrollHeight = document.documentElement.scrollHeight;
        }
        scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
        console.log("scrollHeight:" + scrollHeight);
        return scrollHeight;
    }
};
load.init();