-
Notifications
You must be signed in to change notification settings - Fork 1
/
index-menu.html
206 lines (197 loc) · 5.89 KB
/
index-menu.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
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
201
202
203
204
205
206
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello MUI</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.min.css">
<link rel="stylesheet" type="text/css" href="css/iconfont.css" />
<style type="text/css">
body,
.mui-content {
background-color: #333;
color: #fff;
}
.title {
margin: 35px 15px 10px;
}
.title+.content {
margin: 10px 15px 35px;
color: #bbb;
text-indent: 1em;
font-size: 14px;
line-height: 24px;
}
.mui-table-view {
margin-bottom: 35px;
}
</style>
</head>
<body>
<div class="mui-content">
<div class="title"><img src="images/Icon/cheshibanglogo.png" /></div>
<div class="content">
</div>
<ul class="mui-table-view mui-table-view-chevron mui-table-view-inverted" style="color: #ddd;">
<li class="mui-table-view-cell">
<a class="mui-navigate-right" login='true' href="templates/My/Order.html">
<span class="mui-icon iconfont icon-dingdan"></span> 我的订单
</a>
</li>
<li class="mui-table-view-cell">
<a class="mui-navigate-right" login='true' href="templates/My/MyVouchers.html">
<span class="mui-icon iconfont icon-daijinquan mui-icon-settings"></span> 我的代金券
</a>
</li>
<li class="mui-table-view-cell">
<a class="mui-navigate-right" href="templates/VehicleModel/index.html">
<span class="mui-icon iconfont icon-chexingxuanze"></span> 我的车型
</a>
</li>
<li class="mui-table-view-cell">
<!--根据登录状态判断跳到哪个页面(未写)-->
<a class="mui-navigate-right" href="templates/settings/Jump.html">
<span class="mui-icon mui-icon-settings"></span> 设置
</a>
</li>
</ul>
</div>
<script src="js/mui.min.js"></script>
<script src="js/CarMaid.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var aniShow = "slide-in-right";
//关于backbutton和menubutton两个按键的说明,在iOS平台不存在,故需隐藏
if (!mui.os.android) {
var span = document.getElementById("android-only")
if (span) {
span.style.display = "none";
}
aniShow = "pop-in";
}
var subWebview = null,
template = null,
index = null;
mui.plusReady(function() {
//获得主页面webview引用;
index = plus.webview.currentWebview().opener();
})
mui('.mui-table-view').on('tap', 'a', function() {
var id = this.getAttribute("href");
var type = this.getAttribute("open-type");
var href = this.href;
if (type == "common" || mui.os.ios) {
console.log('type:' + type + ';Is IOS:' + mui.os.ios);
var webview_style = {
popGesture: "close"
};
// 判断打开该页面是否需要登录。 不需要 则 直接打开页面。
var login = this.getAttribute('login');
if (login) {
console.log('登录后继续。');
// 判断是否已经登录 ,已登录 直接打开页面,反之则打开登录页面。
if (CarMaid.UserInfo.Has_login()) {
ShowTemplateForISO(id, href, webview_style, aniShow);
} else {
ShowLoginPage();
}
} else {
ShowTemplateForISO(id, href, webview_style, aniShow);
}
} else {
var href = this.href;
var title = this.innerText;
var login = this.getAttribute('login');
if (login) {
// 判断 是否已经登录
if (CarMaid.UserInfo.Has_login()) {
ShowTemplate(href, title);
} else {
ShowLoginPage();
}
} else {
ShowTemplate(href, title);
}
}
});
function ShowLoginPage() {
mui.toast('您还没有登录呢~~~');
var loginPage = mui.openWindow({
id: 'templates/Account/Login.html',
url: 'templates/Account/Login.html',
show: {
aniShow: 'slide-in-bottom',
duration: 500
},
waiting: {
autoShow: false
}
});
// loginPage.onclose = function() {
// console.log('关闭登录页了。');
// }
}
function ShowTemplateForISO(id, href, webview_style, aniShow) {
mui.openWindow({
id: id,
url: href,
styles: webview_style,
show: {
aniShow: aniShow
},
waiting: {
autoShow: false
}
});
}
function ShowTemplate(href, title) {
template = plus.webview.getWebviewById("default-main");
//获得共用子webview
subWebview = template.children()[0];
subWebview.setStyle({
top: '0px'
});
//通知模板修改标题,并显示隐藏右上角图标;
mui.fire(template, 'updateHeader', {
title: title,
showMenu: false
});
if (subWebview.getURL() != href) {
// 关闭公共子页面的子页面
var arrsub = template.children()[0].children();
for (var i = 0; i < arrsub.length; i++) {
console.log(arrsub[i].id);
arrsub[i].close('none');
}
subWebview.loadURL(href);
} else {
subWebview.show();
}
template.show('slide-in-right', 150);
}
/**
* 关闭侧滑菜单
*/
function close() {
mui.fire(mui.currentWebview.opener(), "menu:close");
}
//在android4.4.2中的swipe事件,需要preventDefault一下,否则触发不正常
window.addEventListener('dragstart', function(e) {
mui.gestures.touch.lockDirection = true; //锁定方向
mui.gestures.touch.startDirection = e.detail.direction;
});
window.addEventListener('dragleft', function(e) {
if (!mui.isScrolling) {
e.detail.gesture.preventDefault();
}
});
//监听左滑事件,若菜单已展开,左滑要关闭菜单;
window.addEventListener("swipeleft", function(e) {
if (Math.abs(e.detail.angle) > 160) {
close();
}
});
</script>
</body>
</html>