login.html
4.2 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="yes" name="apple-touch-fullscreen">
<meta name="viewport"
content="width=device-width, initial-scale=1,maximum-scale=1,maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>登录</title>
<link rel="stylesheet" href="/static/css/common.css">
<link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<div class="box">
<h1 class="login_title">欢迎登录</h1>
<div class="login_list">
<b>手机号</b>
<input type="tel" class="login_phone">
</div>
<div class="login_list">
<b>验证码</b>
<input type="number" class="login_code">
<u class="get_code">获取验证码</u>
</div>
<div class="login_tab">
<b></b>
<i>抱歉,此手机号没有权限登录</i>
</div>
<div class="btn_login">
<img src="/static/image/btn_login.png"/>
</div>
</div>
<script type="text/javascript" src="/static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/static/js/layer/layer.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script>
$(function () {
//获取短信验证码
var times = 1;
var validCode = true;
$(".get_code").click(function () {
if (validCode) {
var user_phone = $(".login_phone").val();
console.log(user_phone);
if (!user_phone) {
layer.msg("手机号码格式不正确")
} else {
if (times == 1) {
times++;
$.ajax({
type: "post",
url: "{:url('portal/tool/get_sms_code')}",
data: {
mobile: user_phone
},
success: function () {
var time = 60;
var code = $(".get_code");
if (validCode) {
code.html("60秒");
validCode = false;
code.addClass("msgs1");
var t = setInterval(function () {
if (time >= 0) {
time--;
code.html(time + "秒");
validCode = false;
} else {
validCode = true;
code.html("重新获取");
clearInterval(t);
}
}, 1000)
}
}
})
}
}
}
});
$('.btn_login').click(function () {
var user_phone = $(".login_phone").val();
var user_code = $('.login_code').val();
if (!user_code) {
layer.msg("验证码不能为空")
} else {
$.ajax({
type: "post",
url: "{:url('user/login/do_login')}",
data: {
mobile: user_phone,
sms_code: user_code
},
success: function (res) {
if (res.code == 0) {
layer.msg(res.msg);
} else {
window.location.href = "{:url('user/profile/percenter')}"
}
},
error: function () {
}
})
}
});
})
</script>
</body>
</html>