index.html
6.63 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>罗电物联网APP</title>
<link rel="stylesheet" type="text/css" href="../css/api.css" />
<link rel="stylesheet" type="text/css" href="../css/aui.css" />
<link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
<link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>
<body class="index-view">
<footer class="aui-bar aui-bar-tab" id="footer">
<div class="aui-bar-tab-item aui-active" tapmode onclick="randomSwitchBtn( this );" data-name="home">
<i class="iconfont iconyemian-copy"></i>
<div class="aui-bar-tab-label">首页</div>
</div>
<div class="aui-bar-tab-item" tapmode onclick="randomSwitchBtn( this );" data-name="warning">
<div class="aui-badge" id="totalWarn" style="display:none">0</div>
<i class="iconfont iconjinggao"></i>
<div class="aui-bar-tab-label">所有报警</div>
</div>
<div class="aui-bar-tab-item" tapmode onclick="randomSwitchBtn( this );" data-name="statistic">
<i class="iconfont icontongji"></i>
<div class="aui-bar-tab-label">统计</div>
</div>
<div class="aui-bar-tab-item" tapmode onclick="randomSwitchBtn( this );" data-name="mine">
<i class="iconfont iconwodemian2" style=" font-size: 1.1rem;margin-top: 0.18rem;margin-bottom: 0.09rem;"></i>
<div class="aui-bar-tab-label">我的</div>
</div>
</footer>
</body>
</html>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
//4个tab页记录只在登录之后第一次点击的时候进行刷新
var justLogin = [false, true, true, true];
apiready = function() {
initHeaderH();
document.getElementById("footer").style.paddingBottom = api.safeArea.bottom + 'px';
api.addEventListener({
name: 'login_user'
}, function(ret, err){
justLogin = [false, true, true, true];
});
api.addEventListener({
name:'keyback'
},function(ret,err){
api.confirm({
title:'提示',
msg:'是否退出罗电?',
buttons:['确定','取消']
},function(ret,err){
if(ret.buttonIndex==1){
api.closeWidget({
silent: true
});
}
});
});
if (!check()) {
return false;
};
//推送相关
initPush();
api.setStatusBarStyle({
style: 'dark',
color: 'rgba(0,0,0,0)'
});
api.addEventListener({
name: 'change_first'
}, function(ret, err) {
var eFootLis = $api.domAll('#footer .aui-bar-tab-item');
for (var i = 0, len = eFootLis.length; i < len; i++) {
$api.removeCls(eFootLis[i], 'aui-active');
}
$api.addCls(eFootLis[0], 'aui-active');
api.setFrameGroupIndex({
reload:true,
name: 'group',
index: 0,
scroll: false
});
});
//$api.fixStatusBar($api.dom('#main'));
funIniGroup();
api.addEventListener({
name: 'warning_count'
}, function(ret, err) {
if (ret) {
var total = ret.value.total;
if (total > 0) {
$("#totalWarn").show();
$("#totalWarn").html(total);
} else {
$("#totalWarn").hide();
$("#totalWarn").html(0);
}
}
});
api.parseTapmode();
}
function funIniGroup() {
var eHeaderLis = $api.domAll('footer .aui-bar-tab-item'),
frames = [];
for (var i = 0, len = eHeaderLis.length; i < len; i++) {
var webName = $api.attr(eHeaderLis[i], 'data-name');
frames.push({
name: webName,
url: webName + '.html',
bgColor: 'rgba(0,0,0,.2)',
bounces: true
})
}
//console.log($api.dom('#footer').offsetTop)
api.openFrameGroup({
name: 'group',
scrollEnabled: false,
rect: {
x: 0,
y: 0,
w: api.winWidth,
h: $api.dom('#footer').offsetTop
},
index: 0,
preload: 1,
frames: frames
}, function(ret, err) {
});
}
// 随意切换按钮
function randomSwitchBtn(tag) {
if (tag == $api.dom('#footer .aui-bar-tab-item.aui-active')) return;
var eFootLis = $api.domAll('#footer .aui-bar-tab-item'),
index = 0;
for (var i = 0, len = eFootLis.length; i < len; i++) {
if (tag == eFootLis[i]) {
index = i;
} else {
$api.removeCls(eFootLis[i], 'aui-active');
}
}
$api.addCls(eFootLis[index], 'aui-active');
api.setStatusBarStyle({
style: 'dark',
color: 'rgba(0,0,0,0)'
});
var needReload = false;
if(justLogin[index]){
needReload = true;
}
api.setFrameGroupIndex({
reload:needReload,
name: 'group',
index: index
});
justLogin[index] = false;
}
function randomSwitchFirst(index) {
//setTimeout(function(){
var eFootLis = $api.domAll('#footer .aui-bar-tab-item');
for (var i = 0, len = eFootLis.length; i < len; i++) {
$api.removeCls(eFootLis[i], 'aui-active');
}
//},500);
api.setStatusBarStyle({
style: 'dark',
color: 'rgba(0,0,0,0)'
});
api.setFrameGroupIndex({
//reload:true,
name: 'group',
index: 0
});
setTimeout(function(){$api.addCls(eFootLis[0], 'aui-active');},5000);
// $api.addCls(eFootLis[0], 'aui-active');
// alert($api.attr(eFootLis[0], 'class'));
// alert($api.attr(eFootLis[1], 'class'));
// alert($api.attr(eFootLis[2], 'class'));
// alert($api.attr(eFootLis[3], 'class'));
}
</script>