<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="jquery-3.6.0.min.js"></script>
<script src="js/index.js"></script>
<script src="jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/reset.css">
<title>Document</title>
</head>
<body>
<div class="container">
<div class="wrapper">
<div class="logo-wrapper">
<img src="./img/news (1).png" alt="">
</div>
<div class="item">
<div class="label">用户名:</div>
<input type="my-input" name="" id="username" placeholder="请输入用户名">
</div>
<div class="item">
<div class="label">密码:</div>
<input type="my-input" name="" id="password" placeholder="请输入密码">
</div>
<div class="item">
<button id="btn" class="login-btn">登录</button>
</div>
</div>
</div>
</body>
</html>
$(document).ready(function () {
$('btn').click(function (e) {
e.preventDefault();
let username = $('#username').val();
let password = $('#password').val();
if (username === '' || password === ''){
alert('请输入完整信息')
return
}
$.ajax({
type: 'get',
url: `http://localhost:8081/user?username=${username}&password=${password}`,
data: "data",
dataType: "json",
success: function (response) {
if(response.isSuccess){
alter('登录成功,欢迎你: '+response.info.name)
}
else
{
alert('登录失败')
}
}
});
});
});