登录页面js,移到外部js

This commit is contained in:
shuzheng 2017-03-05 19:47:06 +08:00
parent 9a5f4305c3
commit 2c0cb9bc00
3 changed files with 53 additions and 53 deletions

View File

@ -8,3 +8,48 @@ $(function() {
$(this).parent().removeClass('fg-toggled');
});
});
Checkbix.init();
$(function() {
// 点击登录按钮
$('#login-bt').click(function() {
login();
});
// 回车事件
$('#username, #password').keypress(function (event) {
if (13 == event.keyCode) {
login();
}
});
});
// 登录
function login() {
$.ajax({
url: '${basePath}/sso/login',
type: 'POST',
data: {
username: $('#username').val(),
password: $('#password').val(),
rememberMe: $('#rememberMe').is(':checked'),
backurl: '${param.backurl}'
},
beforeSend: function() {
},
success: function(json){
if (json.code == 1) {
location.href = json.data;
} else {
alert(json.data);
if (10101 == json.code) {
$('#username').focus();
}
if (10102 == json.code) {
$('#password').focus();
}
}
},
error: function(error){
console.log(error);
}
});
}

View File

@ -17,19 +17,19 @@
<div class="input-group m-b-20">
<span class="input-group-addon"><i class="zmdi zmdi-account"></i></span>
<div class="fg-line">
<input type="text" class="form-control" placeholder="帐号" required autofocus>
<input id="username" type="text" class="form-control" name="username" placeholder="帐号" required autofocus value="admin">
</div>
</div>
<div class="input-group m-b-20">
<span class="input-group-addon"><i class="zmdi zmdi-male"></i></span>
<div class="fg-line">
<input type="password" class="form-control" placeholder="密码" required>
<input id="password" type="password" class="form-control" name="password" placeholder="密码" required value="123456">
</div>
</div>
<div class="clearfix">
</div>
<div class="checkbox">
<input id="rememberMe" type="checkbox" class="checkbix" data-text="自动登录">
<input id="rememberMe" type="checkbox" class="checkbix" data-text="自动登录" name="rememberMe">
</div>
<a id="login-bt" href="javascript:;" class="waves-effect waves-button waves-float"><i class="zmdi zmdi-arrow-forward"></i></a>
</div>

View File

@ -49,55 +49,10 @@
<script src="${basePath}/resources/zheng-ui/js/login.js"></script>
<script>
Checkbix.init();
$(function() {
// 点击登录按钮
$('#login-bt').click(function() {
login();
});
// 回车事件
$('#username, #password').keypress(function (event) {
if (13 == event.keyCode) {
login();
}
});
});
// 登录
function login() {
$.ajax({
url: '${basePath}/sso/login',
type: 'POST',
data: {
username: $('#username').val(),
password: $('#password').val(),
rememberMe: $('#rememberMe').is(':checked'),
backurl: '${param.backurl}'
},
beforeSend: function() {
},
success: function(json){
if (json.code == 1) {
location.href = json.data;
} else {
alert(json.data);
if (10101 == json.code) {
$('#username').focus();
}
if (10102 == json.code) {
$('#password').focus();
}
}
},
error: function(error){
console.log(error);
}
});
}
<c:if test="${param.forceLogout == 1}">
alert('您已被强制下线!');
top.location.href = '${basePath}/sso/login';
</c:if>
<c:if test="${param.forceLogout == 1}">
alert('您已被强制下线!');
top.location.href = '${basePath}/sso/login';
</c:if>
</script>
</body>
</html>
</html>