mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-26 17:20:52 +00:00
117 lines
4.0 KiB
Java
117 lines
4.0 KiB
Java
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||
<title>登录</title>
|
||
|
||
<div th:include="mobile/common/css :: css"></div>
|
||
|
||
|
||
</head>
|
||
<body id="read">
|
||
|
||
<div style="height: 50px;line-height: 50px;text-align: center" class="layui-header header header-doc layui-bg-cyan">
|
||
|
||
<div style="width:10%;float: left;margin-left: 10px">
|
||
<a href="javascript:history.go(-1)">
|
||
<i style="font-size: 20px;color: #fff;" class="layui-icon"></i></a>
|
||
</div>
|
||
<b class="layui-icon">登录</b>
|
||
<div style="width:10%;float: right;margin-right: 10px"><a href="/">
|
||
<i style="font-size: 20px;color: #fff;" class="layui-icon"></i>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
<form lay-filter="loginForm" id="form1" style="height: 500px;padding-top:30px;padding-right: 20px" class="layui-form"
|
||
action="">
|
||
<input type="hidden" id="bookIdHidden" name="bookId" th:value="${bookId}"/>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">手机号码</label>
|
||
<div class="layui-input-inline">
|
||
<input name="txtUName" type="text" id="txtUName" placeholder="请输入手机号"
|
||
autocomplete="off" class="layui-input">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">密码</label>
|
||
<div class="layui-input-inline">
|
||
<input name="txtPassword" type="password" id="txtPassword" placeholder="请输入密码"
|
||
autocomplete="off" class="layui-input">
|
||
</div>
|
||
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<div class="layui-input-block">
|
||
<input id="autoLogin" type="checkbox" lay-skin="primary" title="下次自动登录">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<div class="layui-input-block">
|
||
<input type="button" value="登录" id="btnLogin" class="layui-btn"/>
|
||
<a class="layui-btn layui-btn-primary" href="/user/register.html">注册</a>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
|
||
|
||
<div th:replace="mobile/common/footer :: footer">
|
||
</div>
|
||
</body>
|
||
<div th:replace="mobile/common/js :: js">
|
||
</div>
|
||
<script type="text/javascript">
|
||
if (localStorage.getItem("autoLogin") == 1) {
|
||
$("#autoLogin").prop("checked", 'true');
|
||
layui.form.render('checkbox', 'loginForm');
|
||
} else {
|
||
$("#autoLogin").removeAttr("checked");
|
||
}
|
||
$("#btnLogin").click(function () {
|
||
var username = $("#txtUName").val();
|
||
if (username.isBlank()) {
|
||
layer.alert("手机号不能为空!");
|
||
return;
|
||
}
|
||
if (!username.isPhone()) {
|
||
layer.alert("手机号格式不正确!");
|
||
return;
|
||
}
|
||
var password = $("#txtPassword").val();
|
||
if (password.isBlank()) {
|
||
layer.alert("密码不能为空!");
|
||
return;
|
||
}
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "/user/login",
|
||
data: {"username": username, "password": password},
|
||
dataType: "json",
|
||
success: function (data) {
|
||
if (data.code == 200) {
|
||
if ($("#autoLogin").is(':checked')) {
|
||
$.cookie('Authorization', data.data.token, {expires: 7, path: '/'});
|
||
localStorage.setItem("autoLogin", "1");
|
||
} else {
|
||
$.cookie('Authorization', data.data.token, {path: '/'});
|
||
localStorage.setItem("autoLogin", "0");
|
||
}
|
||
var orginUrl = getSearchString("originUrl");
|
||
window.location.href = orginUrl == undefined || orginUrl.isBlank() ? "/" : orginUrl;
|
||
} else {
|
||
layer.alert(data.msg);
|
||
}
|
||
|
||
},
|
||
error: function () {
|
||
layer.alert('网络异常');
|
||
}
|
||
})
|
||
|
||
})
|
||
</script>
|
||
|
||
|
||
</html> |