-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.html
211 lines (196 loc) · 5.8 KB
/
login.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
207
208
209
210
211
<!DOCTYPE html>
<html class="ui-page-login">
<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>Education</title>
<link href="css/mui.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="css/loaders.min.css" />
<link rel="stylesheet" type="text/css" href="css/loading.css" />
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/loading.animation.js" type="text/javascript"></script>
<script src="js/config.js" type="text/javascript"></script>
<style>
.title {
margin: 15px 15px 0px;
color: #6d6d72;
font-size: 18px;
font-weight: 900;
}
.mui-icon-clear {
margin-top: 10px;
}
</style>
</head>
<!--loading页开始-->
<div class="loading">
<div class="loader">
<div class="loader-inner pacman">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
</div>
<!--loading页结束-->
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">登录</h1>
</header>
<div class="mui-content">
<div class="mui-content-padded" style="margin: 20px 15px 20px 15px;">
<form class="mui-input-group">
<div class="mui-input-row" style="height: 55px; padding: 10px;">
<input id="phone" type="text" class="mui-input-clear" placeholder="手机号">
</div>
<div class="mui-input-row" style="height: 55px; padding: 10px;">
<input id="code" type="text" style="width: 53%;" placeholder="验证码"/>
<button id="verify" type="button" class="mui-btn mui-btn-green" style="width: 45%; font-size: 15px;">
获取验证码
</button>
</div>
</form>
</div>
<div class="mui-button-row" style="height: 50px;">
<button id="login" style="width: 90%; height: 100%;" type="button" class="mui-btn mui-btn-primary" data-loading-text="登录中" data-loading-icon-position="right" style="width: 28%; font-size: 15px;">
登录
</button>
</div>
<div style="margin: 15px 20px;">
<p style="font-size: 11.5px;">
点击“登录”表示你同意<span style="color: blue;">服务使用协议</span>和<span style="color: blue;">隐私条款</span>
</p>
</div>
</div>
<script src="js/mui.min.js"></script>
<script type="text/javascript" charset="utf-8">
//mui初始化
mui.init({
swipeBack: true //启用右滑关闭功能
});
//注册点击事件
$(function() {
//先验证手机号,再发送验证码
$("#verify").click(function() {
var tel = $("#phone").val();
if(checkTel(tel)) {
//验证手机号
if(checkFlag) {
//发送手机验证码
jqxhr=$.ajax({
type: "post",
data: {
tel: tel
},
url:PREPATH + "/sendMobileCode",
dataType: "json",
async: false,
xhrFields: {
withCredentials: true
},
crossDomain: true,
beforeSend: function() {
delayURL(60);
},
success: function(data) {
if(data.state === 1) {
mui.toast("发送成功");
} else {
mui.toast("发送失败");
}
},
error: function() {
mui.toast("发送失败");
}
});
}
}
});
//验证手机号和验证码,并进行登录
$("#login").click(function() {
var tel = $("#phone").val(); //手机号
var code = $("#code").val(); //验证码
//验证手机验证码
if(checkTel(tel)) {
if(code !== null && code !== "") {
var codeReg = /^\d{6}$/;
if(codeReg.test(code)) {
mui.ajax( {
type: "post",
data: {
tel: tel,
code: code
},
url:PREPATH + "/checkMobileCode",
dataType: "json",
async: false,
xhrFields: {
withCredentials: true
},
crossDomain: true,
beforeSend: function() {
mui($("#login")).button('loading');
},
success: function(data) {
mui($("#login")).button('reset');
if(data.state === 1) {
mui.openWindow({
url: 'personal_info.html',
});
} else if(data.state === 2) {
mui.openWindow({
url: 'my_own.html',
});
} else {
mui.toast("请核对验证码");
}
},
error: function() {
mui.toast("登陆失败");
}
});
} else {
mui.toast("请核对验证码");
}
} else {
mui.toast("请输入验证码");
}
}
});
});
//手机验证码登录
//验证手机号(返回:true/false)
var telReg = /^((1[3,8][0-9])|(15[012356789])|(14[5,7,9])|(17[0,1,3,5,6,7,8]))\d{8}$/;
function checkTel(tel) {
if(tel !== null && tel !== "") {
if(telReg.test(tel)) {
return true;
} else {
mui.toast("请核对手机号");
return false;
}
} else {
mui.toast("请输入手机号");
return false;
}
}
//计时器
var checkFlag = true; //标记是否可发送手机验证码
function delayURL(delay) {
if(delay > 0) {
checkFlag = false;
$("#verify").attr("disabled", true);
$("#verify").html((delay--) + "s 后重新获取");
setTimeout("delayURL('" + delay + "')", 1000);
} else {
checkFlag = true;
$("#verify").attr("disabled", false);
$("#verify").html("获取验证码");
}
}
</script>
</body>
</html>