-
Notifications
You must be signed in to change notification settings - Fork 0
/
unlock.html
125 lines (117 loc) · 2.99 KB
/
unlock.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
<!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>
<link href="css/mui.min.css" rel="stylesheet" />
<style>
html,
body {
background-color: #efeff4;
overflow: hidden;
}
.mui-locker {
margin: 35px auto;
}
#forget {
display: block;
margin-top: 10px;
text-align: center;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<h1 class="mui-title">解锁</h1>
</header>
<div class="mui-content">
<div class="mui-content-padded" style="margin: 10px 0px;">
<div class="mui-locker" data-locker-options='{"ringColor":"rgba(221,221,221,1)","fillColor":"#ffffff","pointColor":"rgba(0,136,204,1)","lineColor":"rgba(0,136,204,1)"}' data-locker-width='320' data-locker-height='320'>
</div>
</div>
<a id='forget'>忘记手势密码?</a>
</div>
<script src="js/mui.min.js"></script>
<script src="js/mui.locker.js"></script>
<script src="js/app.js"></script>
<script>
(function($, doc) {
$.init();
$.plusReady(function() {
var mainPage = $.preload({
"id": 'index2',
"url": 'index2.html'
});
var toMain = function() {
$.fire(mainPage, 'show', null);
setTimeout(function() {
$.openWindow({
id: 'index2',
show: {
aniShow: 'pop-in'
},
waiting: {
autoShow: false
}
});
}, 0);
};
var settings = app.getSettings();
var forgetButton = doc.getElementById("forget");
var locker = doc.querySelector('.mui-locker');
var clearStateAndToLogin = function() {
settings.gestures = '';
settings.autoLogin = false;
app.setSettings(settings);
var state = app.getState();
state.token = '';
app.setState(state);
$.openWindow({
url: 'login.html',
id: 'login',
show: {
aniShow: 'pop-in'
},
waiting: {
autoShow: false
}
});
};
forgetButton.addEventListener('tap', function(event) {
clearStateAndToLogin();
});
var tryNumber = 5;
locker.addEventListener('done', function(event) {
var rs = event.detail;
if(settings.gestures == rs.points.join('')) {
toMain()
rs.sender.clear();
} else {
tryNumber--;
rs.sender.clear();
if(tryNumber > 0) {
plus.nativeUI.toast('解锁手势错误,还能尝试 ' + tryNumber + ' 次。');
} else {
clearStateAndToLogin();
}
}
}, false);
var backButtonPress = 0;
$.back = function(event) {
backButtonPress++;
if(backButtonPress > 1) {
plus.runtime.quit();
} else {
plus.nativeUI.toast('再按一次退出应用');
}
setTimeout(function() {
backButtonPress = 0;
}, 1000);
return false;
};
});
}(mui, document));
</script>
</body>
</html>