forget_password_view.html
12.7 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<!DOCTYPE html>
<html lang="zh">
{include file="public/head"/}
<style>
.content{
width: 100%;
height: 807px;
background-image: url(__CDN__/assets/store/images/background.png);
font-size: 0;
}
.content .contentMain{
width: 1200px;
height: 807px;
margin: 0 auto;
overflow: hidden;
}
form .form-group .btn{
padding: 0;
}
form .form-group .tipsInfo{
position: absolute;
width: 100%;
height: 20px;
font-size: 10px;
color: red;
top: 55px;
left: 0;
}
/*信息验证框区域样式*/
.content .contentMain .verificationBox{
width: 511px;
height: 456px;
margin: 232px auto;
background: rgba(255,255,255,1);
box-shadow: 0 8px 16px rgba(24,36,36,0.09);
border-radius:8px;
overflow: hidden;
}
.content .contentMain .verificationBox img{
display: block;
width: 119px;
height: 59px;
margin: 40px auto;
}
form .form-group{
margin: 0 30px 20px 30px;
position: relative;
}
.content .contentMain .loginBox .formBox form .form-group .btn{
padding: 0;
}
.content .contentMain .verificationBox .formBox form .form-group input{
display: inline-block;
height: 54px;
box-shadow: none;
}
.content .contentMain .verificationBox .formBox form .form-group:nth-child(2) input{
width: 330px;
margin-right: 10px;
}
.content .contentMain .verificationBox .formBox form .form-group:nth-child(2) img{
float: right;
width: 110px;
height: 54px;
cursor: pointer;
margin: 0;
}
.content .contentMain .verificationBox .formBox form .form-group:nth-child(3){
margin-bottom: 30px;
}
.content .contentMain .verificationBox .formBox form .form-group:nth-child(3) input{
width: 330px;
margin-right: 10px;
}
.content .contentMain .verificationBox .formBox form .form-group:nth-child(3) .input-group-btn{
float: right;
width: 110px;
height: 54px;
}
.content .contentMain .verificationBox .formBox form .form-group:nth-child(3) .input-group-btn .btn{
width: 110px;
height: 54px;
background: rgba(0,159,142,1);
color: rgba(255,255,255,1);
border: 0;
border-radius: 4px;
}
.content .contentMain .verificationBox .formBox form .btn-submit{
width: 451px;
height: 54px;
margin: 0 30px 12px 30px;
border: 0;
color: rgba(255,255,255,1);
background:rgba(0,159,142,1);
border-radius: 4px;
}
/*新密码框区域样式*/
.content .contentMain .newPswBox{
display: none;
width: 511px;
height: 382px;
margin: 232px auto;
background: rgba(255,255,255,1);
box-shadow: 0 8px 16px rgba(24,36,36,0.09);
border-radius:8px;
overflow: hidden;
}
.content .contentMain .newPswBox img{
display: block;
width: 119px;
height: 59px;
margin: 40px auto;
}
.content .contentMain .newPswBox .formBox form .form-group{
margin: 0 30px 20px 30px;
}
.content .contentMain .newPswBox .formBox form .form-group input{
display: inline-block;
height: 54px;
box-shadow: none;
}
.content .contentMain .newPswBox .formBox form .btn-submit{
width: 451px;
height: 54px;
margin: 10px 30px 12px 30px;
border: 0;
color: rgba(255,255,255,1);
background:rgba(0,159,142,1);
border-radius: 4px;
}
</style>
<body>
<!--公共头部-->
{include file="public/header"/}
<!--登录框-->
<div class="content">
<div class="contentMain">
<!--信息验证框-->
<div class="verificationBox">
<img src="__CDN__/assets/store/images/logo.png" alt="loginLogo" style="width: 130px;">
<div class="formBox formBox">
<form>
<div class="form-group">
<input type="text" class="form-control" id="phoneNum" placeholder="手机号" onblur="testPhoneNum()">
<span id="phoneNumTips" class="tipsInfo"></span>
</div>
<div class="form-group">
<input type="text" class="form-control" id="verificationCode" placeholder="请输入图形验证码" onblur="testImgCode()">
<span id="imgCodeTips" class="tipsInfo"></span>
<img src="{:captcha_src()}" alt="captcha" id="codeImg" onclick="this.src='{:captcha_src()}'">
</div>
<div class="form-group">
<input type="text" class="form-control" id="msgCode" placeholder="请输入短信验证码" onblur="testCode()">
<span id="msgCodeTips" class="tipsInfo"></span>
<span class="input-group-btn">
<span class="input-group-btn">
<button class="btn" type="button" onclick="sendMsg()">
<span id="countDown" class="countDown">发送验证码</span>
</button>
</span>
</span>
</div>
<button type="button" class="btn btn-submit" onclick="next()">下一步</button>
</form>
</div>
</div>
<!--新密码框-->
<div class="newPswBox">
<img src="__CDN__/assets/store/images/loginLogo.png" alt="loginLogo">
<div class="formBox">
<form>
<div class="form-group">
<input type="password" class="form-control" id="newPsw" placeholder="请输入新密码" onblur="testNewPsw()">
<span id="newPswTips" class="tipsInfo"></span>
</div>
<div class="form-group">
<input type="password" class="form-control" id="repeatNewPsw" placeholder="重复新密码" onblur="testRepeatNewPsw()">
<span id="repeatNewPswTips" class="tipsInfo"></span>
</div>
<button type="button" class="btn btn-submit" onclick="confirm()">确认</button>
</form>
</div>
</div>
</div>
{include file="public/footer"/}
</div>
{include file="public/js"/}
<script>
var interval;
//校验手机号
function testPhoneNum() {
var reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
var phoneNum = $('#phoneNum').val();
if(!reg.test(phoneNum)){
$('#phoneNumTips').html('请输入正确的手机号码');
return false;
}
$('#phoneNumTips').html('');
return true;
}
//校验图形验证码
function testImgCode() {
if($('#verificationCode').val().trim() == ''){
$('#imgCodeTips').html('请输入图形验证码');
return false;
}
$('#imgCodeTips').html('');
return true;
}
//校验短信验证码
function testCode() {
if($('#msgCode').val().trim() == ''){
$('#msgCodeTips').html('请输入短信验证码');
return false;
}
$('#msgCodeTips').html('');
return true;
}
//发送短信验证码
function sendMsg() {
testPhoneNum();
testImgCode();
var mobile = $('#phoneNum').val();
var reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
var verificationCode = $('#verificationCode').val();
if(mobile == ''){
toast('请输入手机号');
return false;
} else if(!reg.test(mobile)){
toast('请输入正确手机号');
return false;
} else if(verificationCode == ''){
toast('请输入图形验证码');
return false;
}
if(!interval){
$.ajax({
url:"{:url('user/get_code2')}",
type:"POST",
data:{"mobile":mobile,"image_code":verificationCode},
success:function(res){
console.log(res);
if(res.code == 1){
toast('验证码已发送请注意查看~');
var time = 60;
interval = setInterval(function () {
time--;
$("#countDown").html(time + '秒后重新发送');
if (time <= 0) {
clearInterval(interval);
$("#countDown").html('重新发送');
interval = undefined;
}
}, 1000);
}else{
toast(res.msg);
}
},
error:function(res){
toast('与服务器断开连接');
}
})
}
}
//下一步
function next() {
testPhoneNum();
testCode();
var mobile = $('#phoneNum').val();
var reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
var code = $('#msgCode').val();
if(mobile == ''){
toast('请输入手机号');
return false;
} else if(!reg.test(mobile)){
toast('请输入正确手机号');
return false;
} else if(code == ''){
toast('请输入验证码');
return false;
}
$.ajax({
url:"{:url('user/next')}",
type:"POST",
data:{"mobile":mobile,"code":code},
success:function(res){
console.log(res);
if(res.code == 1){
$('.verificationBox').hide();
$('.newPswBox').show();
}else{
toast(res.msg);
}
},
error:function(res){
toast('与服务器断开连接');
}
});
}
//校验新密码
function testNewPsw() {
var psw_test = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/;
var psw = $('#newPsw').val();
if(psw.trim() == ''){
$('#newPswTips').html('请输入新密码');
return false;
}else if(!psw_test.test(psw)){
$('#newPswTips').html('至少8个字符,包括1个大写字母,1个小写字母和1个数字');
return false;
}
$('#newPswTips').html('');
return true;
}
//校验重复新密码
function testRepeatNewPsw() {
if($('#repeatNewPsw').val().trim() == ''){
$('#repeatNewPswTips').html('请重复输入新密码');
return false;
}
if($('#newPsw').val() != $('#repeatNewPsw').val()){
$('#repeatNewPswTips').html('两次密码不一致');
return false;
}
var psw_test = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/;
if(!psw_test.test($('#repeatNewPsw').val().trim())){
$('#newPswTips').html('至少8个字符,包括1个大写字母,1个小写字母和1个数字');
return false;
}
$('#repeatNewPswTips').html('');
return true;
}
//确认修改新密码
function confirm() {
testPhoneNum();
testCode();
testNewPsw();
testRepeatNewPsw();
if(!testPhoneNum() || !testCode() || !testNewPsw() || !testRepeatNewPsw()){
return false;
}
var mobile = $('#phoneNum').val();
var newPsw = $('#newPsw').val();
var repeatNewPsw = $('#repeatNewPsw').val();
if(newPsw == ''){
toast('请输入新密码~');
return false;
} else if(repeatNewPsw == ''){
toast('请输入确认密码~');
return false;
} else if(repeatNewPsw != newPsw){
toast('两次密码不一致~');
return false;
}
$.ajax({
url:"{:url('user/setting_password')}",
type:"POST",
data:{"mobile":mobile,"password":newPsw,"affirm_password":repeatNewPsw},
success:function(res){
console.log(res);
if(res.code == 1){
toast('修改成功');
setTimeout(function(){
window.location.href = res.url;
},3000);
}else{
toast(res.msg);
}
},
error:function(res){
toast('与服务器断开连接');
}
});
}
</script>
</body>
</html>