register_view.html
13.4 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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!DOCTYPE html>
<html lang="zh">
{include file="public/head"/}
<style>
form .form-group{
position: relative;
}
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{
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;
}
.content .contentMain .registerBox{
width: 511px;
height: 620px;
margin: 150px 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 .registerBox img{
display: block;
width: 119px;
height: 59px;
margin: 36px auto;
}
.content .contentMain .registerBox .buttonsBox{
width: 100%;
height: 57px;
padding: 0;
background: rgba(249,249,249,1);
}
.content .contentMain .registerBox .buttonsBox div{
display: inline-block;
width: 50%;
height: 57px;
text-align: center;
padding-top: 26px;
}
.content .contentMain .registerBox .buttonsBox div .loginBtn{
display: inline-block;
width: 36px;
height: 30px;
line-height: 25px;
font-size: 18px;
font-family: PingFang SC;
font-weight: 400;
cursor: pointer;
margin: 0;
color: rgba(102,102,102,1);
}
.content .contentMain .registerBox .buttonsBox div .selectBtn{
font-family: PingFangSC-Medium;
color: rgba(0,159,142,1);
border-bottom: 3px solid rgba(0,159,142,1);
}
.content .contentMain .registerBox .formBox{
width: 100%;
height: 433px;
overflow: hidden;
}
.content .contentMain .registerBox .formBox form{
padding-top: 30px;
}
.content .contentMain .registerBox .formBox form .form-group{
margin: 0 30px 20px 30px;
}
.content .contentMain .registerBox .formBox form .form-group input{
display: inline-block;
height: 54px;
box-shadow: none;
}
.content .contentMain .registerBox .formBox form .form-group:nth-child(3) input{
width: 330px;
margin-right: 10px;
}
.content .contentMain .registerBox .formBox form .form-group:nth-child(3) .input-group-btn{
float: right;
width: 110px;
height: 54px;
}
.content .contentMain .registerBox .formBox form .form-group:nth-child(3) .input-group-btn .btn{
width: 110px;
height: 53px;
background: rgba(0,159,142,1);
color: rgba(255,255,255,1);
border: 0;
border-radius: 4px;
}
/*用户协议复选框样式*/
.content .contentMain .registerBox .formBox form .checkbox{
margin: 0 30px 5px 30px;
position: relative;
}
.content .contentMain .registerBox .formBox form .checkbox .tipsInfo{
position: absolute;
width: 100%;
height: 20px;
font-size: 10px;
color: red;
top: 16px;
left: 0;
}
.content .contentMain .registerBox .formBox form .checkbox p{
display: inline-block;
width: 295px;
height: 20px;
font-size: 14px;
font-family: PingFang SC;
font-weight: 400;
line-height: 20px;
color: #8C9198;
}
.content .contentMain .registerBox .formBox form .checkbox p a{
color: #009F8E;
}
.content .contentMain .registerBox .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;
}
</style>
<body>
{include file="public/header"/}
<!--注册框-->
<div class="content">
<div class="contentMain">
<div class="registerBox">
<img src="__CDN__/assets/store/images/loginLogo.png" alt="loginLogo">
<div class="buttonsBox">
<div>
<a class="loginBtn" href="{:url('user/login_view')}">登录</a>
</div>
<div>
<a class="loginBtn selectBtn" href="javascript:void(0)">注册</a>
</div>
</div>
<div class="formBox">
<form>
<div class="form-group">
<input type="text" class="form-control" id="userName" placeholder="请设置用户名" onblur="testUserName()">
<span id="userNameTips" class="tipsInfo"></span>
</div>
<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="testVerificationCode()">
<span id="verificationCodeTips" class="tipsInfo"></span>
<span class="input-group-btn">
<button class="btn" type="button" onclick="sendMsg()">
<span id="countDown">发送验证码</span>
</button>
</span>
</div>
<div class="form-group">
<input type="password" class="form-control" id="psw" placeholder="请设置登录密码" onblur="testPassword()">
<span id="pswTips" class="tipsInfo"></span>
</div>
<div class="checkbox">
<label>
<input id="checkbox" type="checkbox">
<p>阅读并同意<a href="javascript:void(0)" onclick="userAgreement()">《用户协议》</a>和<a href="javascript:void(0)" onclick="statement()">《和隐私保护声明》</a></p>
</label>
<span id="checkboxTips" class="tipsInfo"></span>
</div>
<button type="button" class="btn btn-submit" onclick="register()">注册</button>
</form>
</div>
</div>
</div>
<!--用户协议模态窗-->
<div class="modal fade" id="userAgreementModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">
用户协议
</h4>
</div>
<div class="modal-body">
{$site.register_agreement}
</div>
</div>
</div>
</div>
<!--隐私保护声明模态窗-->
<div class="modal fade" id="statementModal" tabindex="-1" role="dialog" aria-labelledby="statementModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="statementModalLabel">
隐私保护声明
</h4>
</div>
<div class="modal-body">
{$site.secret_agreement}
</div>
</div>
</div>
</div>
</div>
{include file="public/footer"/}
{include file="public/js"/}
<script>
var interval;
$(function () {
$("#checkbox").change(function() {
testCheckbox();
});
});
//校验用户名
function testUserName() {
if($('#userName').val().trim() == ''){
$('#userNameTips').html('请输入用户名');
return false;
}
$('#userNameTips').html('');
return true;
}
//校验手机号
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 testVerificationCode(){
if($('#verificationCode').val().trim() == ''){
$('#verificationCodeTips').html('请输入验证码');
return false;
}
$('#verificationCodeTips').html('');
return true;
}
//校验密码
function testPassword(){
var psw_test = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/;
var psw = $('#psw').val();
if(psw.trim() == ''){
$('#pswTips').html('请输入密码');
return false;
}else if(!psw_test.test(psw)){
$('#pswTips').html('至少8个字符,包括1个大写字母,1个小写字母和1个数字');
return false;
}
$('#pswTips').html('');
return true;
}
//发送验证码
function sendMsg() {
testPhoneNum();
if(!testPhoneNum()){
return false;
}
var mobile = $('#phoneNum').val();
var reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
if(mobile == ''){
toast('请输入手机号');
return false;
} else if(!reg.test(mobile)){
toast('请输入正确手机号');
return false;
}
if(!interval){
$.ajax({
url:"{:url('user/get_code1')}",
type:"POST",
data:{"mobile":mobile},
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);
}
},
error:function(res){
toast('与服务器断开连接');
}
})
}
}
//校验协议勾选
function testCheckbox() {
if(!$('#checkbox').is(':checked')){
$('#checkboxTips').html('请确认用户协议');
return false;
}
$('#checkboxTips').html('');
return true;
}
//调用注册接口
function register() {
testUserName();
testPhoneNum();
testVerificationCode();
testPassword();
testCheckbox();
if(!testPassword() || !testUserName() || !testPhoneNum() || !testVerificationCode() || !testCheckbox()){
return false;
}
var username = $('#userName').val();
var mobile = $('#phoneNum').val();
var reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
var code = $('#verificationCode').val();
var password = $('#psw').val();
if(username == ''){
toast('请输入用户名');
return false;
} else if(mobile == ''){
toast('请输入手机号');
return false;
} else if(!reg.test(mobile)){
toast('请输入正确手机号');
return false;
}else if(code == ''){
toast('请输入短信验证码');
return false;
}else if(password == ''){
toast('请设置登录密码');
return false;
}else if(!$('#checkbox').is(':checked')){
toast('请确认用户协议');
return false;
}
$.ajax({
url:"{:url('user/register_login')}",
type:"POST",
data:{'code':code,'mobile':mobile,'username':username,'password':password},
success:function(res){
console.log(res);
if(res.code == 1){
toast('注册成功');
setTimeout(function(){
window.location.href = "{:url('index/index/index')}";
},2000);
}else if(res.code == 0){
toast(res.msg);
}
},
error:function(res){
}
})
}
//用户协议
function userAgreement() {
$('#userAgreementModal').modal();
}
//隐私保护声明
function statement() {
$('#statementModal').modal();
}
</script>
</body>
</html>