|
@@ -37,35 +37,27 @@
|
|
|
<p class="login-box-msg">Sign in to start your session</p>
|
|
|
|
|
|
<form action="/" method="post" id="loginForm">
|
|
|
- <div class="form-group has-feedback">
|
|
|
- <input id="phone" name="phone" type="tel" class="form-control" placeholder="请输入手机号" maxlength="11"
|
|
|
- autocomplete="off">
|
|
|
+ <div class="form-group has-feedback" id="phoneLine">
|
|
|
+ <input id="phone" name="phone" type="tel" class="form-control" placeholder="请输入手机号" maxlength="11">
|
|
|
<span class="glyphicon glyphicon-phone form-control-feedback"></span>
|
|
|
</div>
|
|
|
<div class="input-group form-group has-feedback " id="a" style="width: 100%">
|
|
|
-
|
|
|
-
|
|
|
<input type="text" class="form-control " style="float: left;z-index: 2;position: relative"
|
|
|
- placeholder="请输入图形验证码" maxlength="4"
|
|
|
+ placeholder="请输入图形验证码" maxlength="4" autocomplete="off"
|
|
|
id="verifyImgCode">
|
|
|
-
|
|
|
-
|
|
|
<img border="0" style="cursor:pointer ;z-index: 5;position: absolute;right: 1px;width: 100px;top: 1px"
|
|
|
alt="点击刷新验证码" src="/code"
|
|
|
id="verifyImg">
|
|
|
-
|
|
|
-
|
|
|
</div>
|
|
|
- <div class="input-group form-group has-feedback">
|
|
|
- <input type="text" class="form-control " aria-describedby="sizing-addon1" placeholder="请输入短信验证码"
|
|
|
- maxlength="6" id="phoneCode"
|
|
|
+ <div class="input-group form-group has-feedback" id="phoneCodeLine">
|
|
|
+ <input type="text" class="form-control " placeholder="请输入短信验证码"
|
|
|
+ maxlength="6" id="phoneCode" autocomplete="off"
|
|
|
name="phoneCode">
|
|
|
<span class="input-group-btn ">
|
|
|
- <button class="btn btn-default" type="button" id="sendVerifyCode">获取验证码</button>
|
|
|
+ <button class="btn btn-default" type="button" id="sendVerifyCode"
|
|
|
+ style="width: 100px;padding: 6px 1px">获取验证码</button>
|
|
|
</span>
|
|
|
</div>
|
|
|
-
|
|
|
-
|
|
|
<div class="row">
|
|
|
<!-- /.col -->
|
|
|
<div class="col-xs-12">
|
|
@@ -87,20 +79,24 @@
|
|
|
<!-- iCheck -->
|
|
|
<script src="/plugins/iCheck/icheck.min.js"></script>
|
|
|
<script>
|
|
|
+ <!-- 页面加载时加载cookie-->
|
|
|
+ $(document).ready(function () {
|
|
|
+ v = getCookieValue("SecondNum");//获取cookie值
|
|
|
+ if (v > 0) {
|
|
|
+ countDown();//开始倒计时
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
// 获取图片验证码
|
|
|
$("#verifyImg").click(function () {
|
|
|
- console.log("lalala")
|
|
|
$(this)[0].src = '/code?' + Math.random()
|
|
|
})
|
|
|
// 获取数字验证码
|
|
|
$("#sendVerifyCode").click(function () {
|
|
|
- console.log("lalala-发送验证码")
|
|
|
// 验证手机格式和图片验证码是否为空
|
|
|
if (checkPhone()) {
|
|
|
// 验证图片验证码位数
|
|
|
if ($("#verifyImgCode").val().trim().replace(/\s/g, "").length === 4) {
|
|
|
- console.log("发送短信验证码")
|
|
|
- // debugger
|
|
|
$.ajax({
|
|
|
url: '/sendVerifyCode',
|
|
|
data: {
|
|
@@ -112,13 +108,12 @@
|
|
|
if (r.code === 0) {
|
|
|
if (r.status !== true) {
|
|
|
$("#verifyImg")[0].src = '/code?' + Math.random()
|
|
|
+
|
|
|
alert(r.message)
|
|
|
} else {
|
|
|
addCookie("SecondNum", 60, 60);
|
|
|
- console.log("倒计时")
|
|
|
countDown()
|
|
|
alert("发送成功")
|
|
|
- debugger
|
|
|
}
|
|
|
} else {
|
|
|
alert("无响应")
|
|
@@ -128,34 +123,16 @@
|
|
|
)
|
|
|
} else {
|
|
|
$("#verifyImg")[0].src = '/code?' + Math.random()
|
|
|
- // $("#a").addClass("has-error")
|
|
|
alert("图片验证码有误,请重填");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
})
|
|
|
- // $(function () {
|
|
|
- // $('input').iCheck({
|
|
|
- // checkboxClass: 'icheckbox_square-blue',
|
|
|
- // radioClass: 'iradio_square-blue',
|
|
|
- // increaseArea: '20%' /* optional */
|
|
|
- // });
|
|
|
- //
|
|
|
- // document.onkeydown = function (event) {
|
|
|
- // var e = event || window.event;
|
|
|
- // if (e && e.keyCode == 13) { //回车键的键值为13
|
|
|
- // login();
|
|
|
- // }
|
|
|
- // };
|
|
|
- // });
|
|
|
-
|
|
|
|
|
|
+ // 登录
|
|
|
function login() {
|
|
|
+ // 验证手机号
|
|
|
if (!checkPhone()) {
|
|
|
- alert("手机号格式有误!")
|
|
|
return
|
|
|
}
|
|
|
// 短信验证码格式
|
|
@@ -174,7 +151,7 @@
|
|
|
if (r.status === false) {
|
|
|
alert(r.message)
|
|
|
} else {
|
|
|
- if (r.role === "1") {
|
|
|
+ if (r.role === 1) {
|
|
|
window.location.href = "/front/index";
|
|
|
} else {
|
|
|
window.location.href = "/client/index";
|
|
@@ -183,7 +160,7 @@
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+ // 验证手机号格式
|
|
|
function checkPhone() {
|
|
|
var phone = document.getElementById('phone').value;
|
|
|
if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(phone))) {
|
|
@@ -194,13 +171,11 @@
|
|
|
|
|
|
//倒计时
|
|
|
function countDown() {
|
|
|
- debugger
|
|
|
- console.log("倒计时")
|
|
|
var second = getCookieValue("SecondNum") ? getCookieValue("SecondNum") : 0;//获取cookie值
|
|
|
if (second == 0) {
|
|
|
$("#sendVerifyCode").attr("disabled", false);
|
|
|
document.getElementById("sendVerifyCode").style.cursor = "pointer";//启用鼠标
|
|
|
- $("#sendVerifyCode").val('获取验证码');
|
|
|
+ $("#sendVerifyCode").text('获取验证码');
|
|
|
addCookie("SecondNum", 60, 60); //添加cookie记录,有效时间60s
|
|
|
return;
|
|
|
} else {
|
|
@@ -210,7 +185,6 @@
|
|
|
second--;
|
|
|
editCookie("SecondNum", second, second + 1);
|
|
|
}
|
|
|
-
|
|
|
setTimeout(function () {
|
|
|
countDown();
|
|
|
}, 1000);
|