CJJ
2018-12-11 2078f12a6a1f870136a20d1212c50ddf88ccab7f
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="mobilCss/jquery.mobile-1.4.5.min.css"/>
<link rel="stylesheet" href="css/breadcrumb.css">
<script type="text/javascript" src="mobilJs/jquery-1.8.2.js"></script>
<script type="text/javascript" src="mobilJs/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="mobilJs/base.js"></script>
</head>
    <body>
        <!-- 三级菜单内容    -->
        <div data-role="page">
            <div data-role="header" data-position="fixed">
                <a href="selectbatt.html" class="ui-btn ui-corner-all ui-shadow ui-icon-back ui-btn-icon-left" target="_top" style="padding-top:0.7em;padding-bottom:0.7em;">返回</a>
                <h1>蓄电池组</h1>
            </div>
    
            <div data-role="content">
                <ul class="breadcrumb"></ul>
                <div id="battList2"></div>
            </div>
            <div data-role="footer" data-position="fixed">
                <!-- <h1>福光电子有限公司</h1> -->
            </div>
        </div>
    </body>
    <script type="text/javascript" src="js/battNav.js"></script>
    <script type="text/javascript">
        
        var battinlist = new Array();            //所有电池组的数组
        var temp = getCookie("battselect");
        $(document).ready(function(){
        setCookie('batt', '');
        //temp = JSON.parse(temp);
        console.info(temp);
            init();
            //searchkBattByStationid();
        });
        
        function init(){
            //var temp = getCookie("county");
            if(temp != '' || temp != undefined) {
                temp = JSON.parse(temp);
                
                var data = [
                    {url: 'javascript:JumpHomePage();', txt: '首页'},
                    {url: 'javascript:JumpFirstPage();', txt:temp.StationName1},
                    {url: 'javascript:JumpcityPage();', txt: temp.StationName2},
                    {url: 'selectcounty.html', txt: temp.StationName5 },
                    {url: 'selectbatt.html', txt: temp.StationName3},
                    {url: 'javascript:;', txt: '蓄电池组'}
                ];
                addBreadCrumb($('.breadcrumb').eq(0),data);
                            
                searchkBattByStationid();
            }else {
                window.location.href="machineroomM.html";
            }
        }
        
        
        //根据机房id查询电池组
        function searchkBattByStationid(){
            loadshow();
            var data = {
                        StationName1: temp.StationName1,
                        StationName2: temp.StationName2,
                        StationName5: temp.StationName5,
                        StationName: temp.StationName,
                        StationId: temp.StationId
                    };
            $.ajax({     
                type: "post",                 
                url: "BattInfAction!serchBattByStation",                
                async:true,                
                dataType:'text',
                data:"json = "+JSON.stringify(data),
                success: function(data){                                        
                    data = eval('('+data+')');
                    var model = eval('('+data.result+')');
                    console.info(model);
                    if(model.code == 1){
                        battinlist = model.data;
                        createUl($('#battList2'), model.data);
                    }
                    loadclose();
                },
                error:function(){
                    loadclose();
                }                 
            });
        }
        
        /*
            声明一个函数createUl,用于生成ul和li
            @param ulCon ul的容器
            @param dataList  ul的数据内容
        */
        function createUl(ulCon, dataList) {
            // 清理容器下的ul
            ulCon.find('ul').remove();
            
            // 创建ul
            var _ul = $('<ul data-role="listview" data-inset="true"></ul>');
            
            // 遍历dataList生成li和a
            for (var i = 0; i < dataList.length; i++){
                var _li = $('<li></li');
                
                var _a = $('<a href="javascript:void(0);" target="_top" data-ajax="false" value=""  data-transition="slide">'+dataList[i].BattGroupName+'</a>');
                // 将_a添加到_li,将_li添加到_ul中
                _li.append(_a);
                _ul.append(_li);
            }
            
            // 将_ul添加到容器中
            ulCon.append(_ul).trigger('create');            
            loadclose();
        }
        
        $(document).ready(function () {
            var aLi = -1;
            $('#battList2').on('click', 'ul li', function () {
                aLi = $(this).index();
                batt = getbatt(battinlist,aLi);
                var json=window.JSON.stringify(batt);
                setCookie("batt",json);
                window.location.href="testdata.html";
            });
        });
        
        
        
        //获取当前选中的batt
        function getbatt(arr,index){
            console.log(arr);
            console.log(index);
            if(arr.length>index){
                return arr[index];
            }
            return undefined;
        };
        
        $(function(){
            $('.breadcrumb').on('tap', 'a[href="#page0"]', function() {
                list=getList(battinlist,0,batt);
                //init();
            });
        });
    </script>
    
</html>