wangrong
2021-11-24 130b72d6c5734f8acaac0214b6dfe5c8bfa319c3
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
var layer_load ;
function resetWin(){
    $("body").height($(window).height());
}
$(function(){
    resetWin();
});
var bList = {
        batch_ind : "第一批次",
        page_num : 0
}
//更改批次
function pici_tab(me,ind){
    bList.page_num = 0;
    $("#piciList").html("");
    $(me).addClass("self-active").siblings().removeClass("self-active");
    bList.batch_ind = ind;
    request();
}
 
function roomMsg(id,data){
    localStorage.setItem("data",JSON.stringify(data));
    window.location.href="houseDetail.html?id_="+id;
}
//请求
function request(){
    bList.page_num += 1;
    layer_load = layer.open({
        type: 2,
        shade: 'background-color: rgba(0,0,0,.2)',
        content: '加载中'
    });
    $.get(basePath + "buildingList",bList,function(data){
        buildingList(data);
    },"json");
}
//随机边框色
function RandomNum(Min,Max){
    var Range = Max - Min;
    var Rand = Math.random();  
    var num = Min + Math.round(Rand * Range);
    return num;
}
function split_str(a){
    if(a == "null" || a == null){
        return "无";
    }else if(a.split("(")[0] != ""){
        return a.split("(")[0];
    }else{
        return a;
    }
}
function buildingList(data){
    if(data.length != 0){
        var str = "";
        for(var i = 0;i<data.length;i++){
            str += '<div class="card boder_l'+RandomNum(0,4)+'" onclick=\'roomMsg("'+data[i].id+'",'+JSON.stringify(data[i])+')\'>';
            str += '<ul class="buildBox"><li class="buildName">'+split_str(data[i].name)+'</li><li class="buildAdd">'+split_str(data[i].address)+'</li></ul>';
            str += '</div>';
        }
        $("#piciList").append(str);
    }else{
        layer.open({
            content: '已加载全部',
            skin: 'msg',
            time: 2 //2秒后自动关闭
          });
    }
    
    layer.close(layer_load);
}
window.onload = function(){
    request();
}