116 lines
4.3 KiB
HTML
116 lines
4.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title></title>
|
|
<link rel="stylesheet" href="/v1/static/css/login.css">
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
|
|
|
</head>
|
|
<body>
|
|
<div class="container right-panel-active">
|
|
<!-- Sign Up -->
|
|
<div class="container__form container--signup">
|
|
<form action="#" class="form" id="form1" method="post">
|
|
<h2 class="form__title">Sign Up</h2>
|
|
<input type="text" placeholder="User" class="input" name="name"/>
|
|
<input type="email" placeholder="email" class="input" name="account"/>
|
|
<input type="password" placeholder="password" class="input" name="password" autocomplete="off"/>
|
|
<button class="btn" onclick="register(this)">Sign Up</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Sign In -->
|
|
<div class="container__form container--signin">
|
|
<form action="#" class="form" id="form2" method="post">
|
|
<h2 class="form__title">Sign In</h2>
|
|
<input type="email" placeholder="email" class="input" name="account"/>
|
|
<input type="password" placeholder="password" class="input" name="password" autocomplete="off"/>
|
|
<a href="#" class="link">Forgot your password?</a>
|
|
<button class="btn" onclick="login(this)">Sign In</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Overlay -->
|
|
<div class="container__overlay">
|
|
<div class="overlay">
|
|
<div class="overlay__panel overlay--left">
|
|
<button class="btn" id="signIn">Sign In</button>
|
|
</div>
|
|
<div class="overlay__panel overlay--right">
|
|
<button class="btn" id="signUp">Sign Up</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<p><a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">沪ICP备18034819号</a></p>
|
|
<p><a href="" target="_blank" rel="nofollow"><i class="police-ico"></i>沪公网安备31011302007198号</a></p>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
const signInBtn = document.getElementById("signIn");
|
|
const signUpBtn = document.getElementById("signUp");
|
|
const fistForm = document.getElementById("form1");
|
|
const secondForm = document.getElementById("form2");
|
|
const container = document.querySelector(".container");
|
|
|
|
signInBtn.addEventListener("click", () => {
|
|
container.classList.remove("right-panel-active");
|
|
});
|
|
|
|
signUpBtn.addEventListener("click", () => {
|
|
container.classList.add("right-panel-active");
|
|
});
|
|
|
|
fistForm.addEventListener("submit", (e) => e.preventDefault());
|
|
secondForm.addEventListener("submit", (e) => e.preventDefault());
|
|
|
|
function register(obj){
|
|
var fields = $(obj).parent().serializeArray();
|
|
var obj = {}; //声明一个对象
|
|
$.each(fields, function(index, field) {
|
|
obj[field.name] = field.value; //通过变量,将属性值,属性一起放到对象中
|
|
})
|
|
$.ajax({
|
|
url:"https://gateway.mylomen.com/v1/user/register",
|
|
type: "POST",
|
|
contentType: "application/json; charset=utf-8",
|
|
data: JSON.stringify(obj),//将对象转为json字符串
|
|
dataType: "json",
|
|
success: function(result) {
|
|
if (result.code==0){
|
|
localStorage.setItem("token",result.data.token);
|
|
location.href ="/chat"
|
|
}else{
|
|
alert(result.msg);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function login(obj){
|
|
var fields = $(obj).parent().serializeArray();
|
|
var obj = {}; //声明一个对象
|
|
$.each(fields, function(index, field) {
|
|
obj[field.name] = field.value; //通过变量,将属性值,属性一起放到对象中
|
|
})
|
|
$.ajax({
|
|
url:"https://gateway.mylomen.com/v1/user/login",
|
|
type: "POST",
|
|
contentType: "application/json; charset=utf-8",
|
|
data: JSON.stringify(obj),//将对象转为json字符串
|
|
dataType: "json",
|
|
success: function(result){
|
|
if (result.code==0){
|
|
localStorage.setItem("token",result.data.token);
|
|
location.href ="/chat"
|
|
}else{
|
|
alert(result.msg);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
</script>
|
|
</html> |