123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="csrf-token" content="{{ csrf_token() }}">
- <title>相册系统登录</title>
- <style>
- body {
- background-color: #ed9027;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100vh;
- margin: 0;
- font-family: Arial, sans-serif;
- }
- .login-wrapper {
- text-align: center;
- }
- .logo {
- margin-bottom: 20px; /* 调整 logo 与 login-container 的间距 */
- }
- .logo img {
- width: 120px;
- height: 120px;
- }
- .login-container {
- background-color: #fff;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
- text-align: center;
- }
- .login-container h2 {
- font-size: 16px;
- margin-bottom: 20px;
- font-weight: normal;
- }
- .login-container input[type="text"],
- .login-container input[type="password"] {
- width: 80%;
- padding: 10px;
- margin: 10px 0;
- border: 1px solid #ccc;
- border-radius: 4px;
- box-sizing: border-box;
- transition: border-color 0.3s ease;
- }
- .login-container button {
- margin-top: 20px;
- width: 40%;
- padding: 10px;
- background-color: #4CAF50;
- color: white;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- }
- .login-container button:hover {
- background-color: #45a049;
- }
- /* 取消默认 focus 样式并自定义 */
- .login-container input:focus {
- outline: none; /* 取消默认的蓝色轮廓 */
- border-color: #fbb141; /* 自定义聚焦时的边框颜色 */
- }
- </style>
- </head>
- <body>
- <!-- 登录表单 -->
- <form method="POST" action="/post-login" id="loginForm">
- <div class="login-wrapper">
- <div class="logo">
- <img src="/static/images/logo.png" alt="logo">
- </div>
- <div class="login-container">
- <h2>美特柏产品资料共享图库</h2>
- <input type="text" name="username" placeholder="用户名" required>
- <input type="password" name="password" placeholder="密码" required>
- <div style="color:red;" id="errorMsg"></div>
- <button type="submit">登录</button>
- </div>
- </div>
- </form>
- <script src="/static/js/jquery-3.7.0.min.js"></script>
- <script>
- $(document).ready(function() {
- // ajaj登录表单提交
- $('#loginForm').submit(function(e) {
- var username = $('input[name="username"]').val();
- var password = $('input[name="password"]').val();
- // 获取 CSRF 令牌
- var csrfToken = $('meta[name="csrf-token"]').attr('content');
- $.ajax({
- url: '/post-login',
- type: 'POST',
- headers: {
- 'X-CSRF-TOKEN': csrfToken // 添加 CSRF 令牌到请求头
- },
- data: {
- username: username,
- password: password
- },
- success: function(res) {
- if (res.status == 'success') {
- window.location.href = '/main';
- } else {
- $('#errorMsg').html(res.message);
- }
- },
- error: function(err) {
- console.log(err);
- }
- });
- return false; // 阻止表单默认提交事件
- });
- });
- </script>
- </body>
- </html>
|