admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
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
function gotoLogin() {
    window.location.href = "login.html";
}
 
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if(r != null) return unescape(r[2]);
    return null;
}
 
function doResponse(data, successEvent) {
    if(data.code == 0)
        successEvent;
    else if(data.code == 2)
        gotoLogin();
    else
        layer.msg(data.msg);
}
 
function getCommonTime(timestamp) {
    var newDate = new Date();
    newDate.setTime(timestamp);
    return newDate.getFullYear() + "-" + (newDate.getMonth() + 1) + "-" + (newDate.getDay() + 1) + " " + newDate.getHours() + ":" + newDate.getMinutes();
}
 
function bindCheck() {
    $(".check-all").bind("change", function() {
        if($(this).is(':checked')) {
            $(".check-item").prop("checked", true);
        } else {
            $(".check-item").prop("checked", false);
        }
    });
}
 
$(function() {
    bindCheck();
 
    function getVideoType(pid, $parentselectitem) {
        console.log("开始获取分类");
        $.post('../new/api/class/getnextclass', {
            "pid": pid
        }, function(data) {
            console.log("返回结果:" + JSON.stringify(data));
            if(data.data.length > 0) {
                if($parentselectitem == undefined) { //第一级
                    $(".videotypes .roottype").empty();
                    $(".videotypes .roottype").append("<option value='0'>全部</option>");
                    for(var i = 0; i < data.data.length; i++) {
                        $(".videotypes .roottype").append("<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>");
                    }
                    $(".videotypes .roottype").bind("change", function() {
                        getVideoType($(this).val(), $(this));
                    });
 
                } else { //下面几级
                    $parentselectitem.nextAll().remove();
                    if(pid > 0) {
 
                        var html = "";
 
                        html += "<select class='form-control search'>";
                        html += "<option value='" + pid + "'>全部</option>";
                        for(var i = 0; i < data.data.length; i++) {
                            html += "<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>";
                        }
                        html += "</select>";
                        $parentselectitem.parent().append(html);
                        $parentselectitem.next().bind("change", function() {
                            getVideoType($(this).val(), $(this));
                        });
                    }
                }
            }
 
        }, 'json');
    }
    if($(".videotypes .roottype"))
        getVideoType(0, undefined);
 
    if($(".select-detailsystem"))
        $.post('../new/api/common/detailsystemlist', function(data) {
            if(data.code == 0) {
                $(".select-detailsystem").empty();
                $(".select-detailsystem").append("<option value='0'>" + '全部' + "</option>>");
                for(var i = 0; i < data.data.length; i++) {
                    $(".select-detailsystem").append("<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>>");
                }
            }
        }, 'json');
});