| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>登录页面</title>
- <script src="js/jquery-2.1.4.min.js"></script>
- <style>
- /* 全局样式重置 */
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- font-family: "Microsoft YaHei", sans-serif;
- }
- /* 页面背景 */
- body {
- background-color: #f5f5f5;
- display: flex;
- justify-content: center;
- align-items: center;
- min-height: 100vh;
- }
- /* 登录表单容器 */
- .login-container {
- background-color: #ffffff;
- padding: 30px 40px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- width: 100%;
- max-width: 400px;
- }
- /* 表单标题 */
- .login-title {
- text-align: center;
- font-size: 24px;
- color: #333;
- margin-bottom: 25px;
- font-weight: 600;
- }
- /* 输入项样式 */
- .form-item {
- margin-bottom: 20px;
- }
- /* 标签样式 */
- .form-item label {
- display: block;
- margin-bottom: 8px;
- color: #666;
- font-size: 14px;
- }
- /* 输入框样式 */
- .form-item input {
- width: 100%;
- height: 40px;
- padding: 0 10px;
- border: 1px solid #ddd;
- border-radius: 4px;
- font-size: 14px;
- transition: border-color 0.3s;
- }
- /* 输入框聚焦样式 */
- .form-item input:focus {
- outline: none;
- border-color: #409eff;
- box-shadow: 0 0 5px rgba(64, 158, 255, 0.2);
- }
- /* 登录按钮样式 */
- .login-btn {
- width: 100%;
- height: 40px;
- background-color: #409eff;
- color: #ffffff;
- border: none;
- border-radius: 4px;
- font-size: 16px;
- cursor: pointer;
- transition: background-color 0.3s;
- }
- /* 按钮hover样式 */
- .login-btn:hover {
- background-color: #3399ff;
- }
- /* 密码输入框特殊样式(可选) */
- #password {
- letter-spacing: 2px;
- }
- </style>
- </head>
- <body>
- <!--<h1>这是登录界面</h1>-->
- <div class="login-container">
- <h2 class="login-title">用户登录</h2>
- <form action="#" method="post">
- <div class="form-item">
- <label for="username">账号</label>
- <input type="text" id="username" name="username">
- </div>
- <div class="form-item">
- <label for="password">密码</label>
- <input type="password" id="password" name="password">
- </div>
- <input type="button" class="login-btn" value="登录" onclick="login()">
- </form>
- </div>
- </body>
- <script>
- // 点击登录按钮的时候去发送异步请求
- function login() {
- // 获取输入框当中账号和密码
- var username = document.getElementById("username").value
- var password = document.getElementById("password").value
- console.log(username,password)
- // $: jquery 对象 $.post jquery post 函数
- // post 函数第一参数请求路径, 第二个参数: 请求参数 , 第三个参数: 回调函数
- $.post("/login",{"username": username,"password": password},function (result){
- // 回调函数当中result 就是后端给前端返回数据
- if(result.success){
- alert("登录成功")
- }else{
- alert(result.msg)
- }
- })
- }
- </script>
- </html>
|