-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
133 lines (129 loc) · 3.13 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="js/mui.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet"/>
<link href="css/hope.css" rel="stylesheet"/>
<script type="text/javascript" charset="utf-8">
mui.init();
</script>
</head>
<body>
<nav class="mui-bar mui-bar-tab">
<a class="mui-tab-item mui-active" href="indexSub.html">
<span class="mui-icon mui-icon-home"></span>
<span class="mui-tab-label">发布</span>
</a>
<a class="mui-tab-item" href="tel.html">
<span class="mui-icon mui-icon-phone"></span>
<span class="mui-tab-label">浏览</span>
</a>
<a class="mui-tab-item" href="user.html">
<span class="mui-icon mui-icon-email"></span>
<span class="mui-tab-label">我的</span>
</a>
</nav>
</body>
<script src="js/ajax.js"></script>
<script type="text/jscript">
mui.init({
subpages: [{
url: 'tel.html',
id: 'tel.html',
styles: {
bottom: '45px'
}
},{
url: 'user.html',
id: 'user.html',
styles: {
bottom: '45px'
}
}]
});
mui.plusReady(function() {
checkLogin();
var item = document.getElementsByClassName('mui-tab-item');
var subIds = Array.prototype.slice.apply(item).map(function(ele) {
return ele.getAttribute('href');
});
var subPages = [];
subIds.forEach(function(ele, i) {
subPages[i] = mui.preload({
url: ele,
id: ele,
styles: {
top: '0px',
bottom: '45px'
}
})
});
mui.preload({
url:'indexSub.html',
id: 'indexSub.html'
})
console.log(subIds);
subPages[0].show();
changeView();
var backButtonPress = 0;
mui.back = function(event) {
backButtonPress++;
if (backButtonPress > 1) {
plus.runtime.quit();
} else {
plus.nativeUI.toast('再按一次退出应用');
}
setTimeout(function() {
backButtonPress = 0;
}, 1000);
return false;
};
})
function changeView() {
console.log(111111111111);
var item = document.getElementsByClassName('mui-tab-item');
Array.prototype.slice.apply(item).forEach(function(ele) {
ele.addEventListener('tap', function() {
var id = ele.getAttribute('href');
var view = plus.webview.getWebviewById(id);
view.reload();
setTimeout(function() {
view.show();
},10)
})
})
}
function checkLogin() {
function showLogin() {
var loginPage = mui.preload({
url: 'login.html',
id: 'login.html'
})
setTimeout(function() {
mui.openWindow({
id: 'login.html',
})
}, 0)
}
if(!localStorage.getItem('name') || !localStorage.getItem('avatar')) {
showLogin();
return;
}
var checkLoginUrl = 'http://ce.sysu.edu.cn/hopeapi/checklogin';
get(checkLoginUrl).then(function(data) {
if(data.code !== 200) {
localStorage.clear();
plus.nativeUI.toast('未登录,请先登录!');
showLogin();
return;
} else {
localStorage.setItem('name', data.name);
localStorage.setItem('avatar', data.avatar);
}
})
}
</script>
</html>