文件
chengduzhongchuliang/application/admin/view/index/login.html

1013 行
35 KiB
HTML

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<!DOCTYPE html>
<html lang="zh-CN" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>{$title|default='登录'} - 中央储备粮遵义直属库有限公司智慧仓储数字化管控平台</title>
<link rel="shortcut icon" href="/assets/img/favicon.ico" />
<style>
:root {
--brand-primary: #0284c7;
--brand-glow: #38bdf8;
--brand-gold: #f59e0b;
--bg-dark-900: #060d19;
--bg-dark-800: #0c182c;
--bg-card: rgba(12, 24, 44, 0.78);
--border-glass: rgba(56, 189, 248, 0.22);
--border-hover: rgba(56, 189, 248, 0.55);
--text-main: #f8fafc;
--text-sub: #94a3b8;
--text-dim: #64748b;
--danger: #ef4444;
--success: #10b981;
--warning: #f59e0b;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
-webkit-font-smoothing: antialiased;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
background-color: var(--bg-dark-900);
color: var(--text-main);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow-x: hidden;
}
/* 动态科技背景层 */
.login-bg-layer {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: {if $background}url('{$background}') center center / cover no-repeat{else}radial-gradient(circle at 18% 25%, rgba(14, 165, 233, 0.18) 0%, transparent 45%), radial-gradient(circle at 82% 75%, rgba(245, 158, 11, 0.12) 0%, transparent 50%), linear-gradient(135deg, #040914 0%, #071324 50%, #0a1b32 100%){/if};
z-index: 0;
}
/* 科技网格与扫描光斑 */
.login-bg-grid {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-image:
linear-gradient(rgba(56, 189, 248, 0.04) 1px, transparent 1px),
linear-gradient(90deg, rgba(56, 189, 248, 0.04) 1px, transparent 1px);
background-size: 40px 40px;
z-index: 1;
pointer-events: none;
}
/* 主容器 */
.login-wrapper {
position: relative;
z-index: 2;
width: 100%;
max-width: 1100px;
margin: 24px;
display: flex;
border-radius: 20px;
background: var(--bg-card);
border: 1px solid var(--border-glass);
box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), 0 0 30px -5px rgba(56, 189, 248, 0.15);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
overflow: hidden;
animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes fadeInScale {
from {
opacity: 0;
transform: scale(0.97) translateY(12px);
}
to {
opacity: 1;
transform: scale(1) translateY(0);
}
}
/* 左侧宣传展板 (大屏显示,移动端隐藏) */
.login-left-banner {
flex: 1.15;
background: linear-gradient(135deg, rgba(2, 132, 199, 0.15) 0%, rgba(15, 23, 42, 0.65) 100%);
border-right: 1px solid var(--border-glass);
padding: 48px;
display: flex;
flex-direction: column;
justify-content: space-between;
position: relative;
overflow: hidden;
}
.login-left-banner::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle at center, rgba(56, 189, 248, 0.08) 0%, transparent 60%);
pointer-events: none;
}
.banner-header {
position: relative;
z-index: 1;
}
.banner-badge {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 6px 14px;
border-radius: 9999px;
background: rgba(56, 189, 248, 0.12);
border: 1px solid rgba(56, 189, 248, 0.35);
color: var(--brand-glow);
font-size: 13px;
font-weight: 500;
letter-spacing: 0.5px;
margin-bottom: 24px;
}
.banner-badge .pulse-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #22c55e;
box-shadow: 0 0 10px #22c55e;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; transform: scale(1); }
50% { opacity: 0.4; transform: scale(0.85); }
}
.banner-title {
font-size: 30px;
font-weight: 700;
line-height: 1.35;
color: #ffffff;
margin-bottom: 16px;
letter-spacing: -0.5px;
}
.banner-title span {
background: linear-gradient(135deg, #38bdf8 0%, #f59e0b 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.banner-desc {
color: var(--text-sub);
font-size: 14.5px;
line-height: 1.7;
margin-bottom: 32px;
}
.banner-features {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 16px;
position: relative;
z-index: 1;
}
.feature-card {
background: rgba(15, 23, 42, 0.55);
border: 1px solid rgba(56, 189, 248, 0.15);
border-radius: 12px;
padding: 16px;
transition: all 0.3s ease;
}
.feature-card:hover {
border-color: rgba(56, 189, 248, 0.4);
transform: translateY(-2px);
background: rgba(15, 23, 42, 0.75);
}
.feature-title {
color: #e2e8f0;
font-size: 14px;
font-weight: 600;
margin-bottom: 4px;
display: flex;
align-items: center;
gap: 6px;
}
.feature-desc {
color: var(--text-dim);
font-size: 12px;
line-height: 1.5;
}
.banner-footer {
margin-top: 36px;
color: var(--text-dim);
font-size: 12px;
position: relative;
z-index: 1;
}
/* 右侧登录卡片 */
.login-right-form {
flex: 1;
padding: 48px;
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
}
.login-brand-logo {
display: flex;
align-items: center;
gap: 14px;
margin-bottom: 30px;
}
.logo-symbol {
width: 46px;
height: 46px;
border-radius: 12px;
background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
border: 1px solid rgba(56, 189, 248, 0.4);
box-shadow: 0 0 16px rgba(2, 132, 199, 0.4);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.logo-symbol svg {
width: 26px;
height: 26px;
fill: none;
stroke: #ffffff;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.brand-text-wrap h1 {
font-size: 19px;
font-weight: 700;
color: #ffffff;
letter-spacing: 0.3px;
}
.brand-text-wrap p {
font-size: 12.5px;
color: var(--brand-glow);
letter-spacing: 1px;
text-transform: uppercase;
margin-top: 2px;
}
.form-welcome {
margin-bottom: 28px;
}
.form-welcome h2 {
font-size: 22px;
font-weight: 600;
color: #ffffff;
margin-bottom: 6px;
}
.form-welcome p {
font-size: 13.5px;
color: var(--text-sub);
}
/* 表单输入组 */
.input-group {
margin-bottom: 20px;
position: relative;
}
.input-label {
display: block;
font-size: 13px;
font-weight: 500;
color: #cbd5e1;
margin-bottom: 8px;
}
.input-control-wrap {
position: relative;
display: flex;
align-items: center;
}
.input-icon {
position: absolute;
left: 14px;
width: 18px;
height: 18px;
color: var(--text-dim);
pointer-events: none;
transition: color 0.25s ease;
}
.form-input {
width: 100%;
height: 46px;
padding: 0 14px 0 42px;
background: rgba(15, 23, 42, 0.65);
border: 1px solid rgba(56, 189, 248, 0.2);
border-radius: 10px;
color: #ffffff;
font-size: 14.5px;
outline: none;
transition: all 0.25s ease;
}
.form-input::placeholder {
color: #64748b;
font-size: 13.5px;
}
.form-input:focus {
background: rgba(15, 23, 42, 0.9);
border-color: var(--brand-glow);
box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}
.form-input:focus + .input-icon,
.input-control-wrap:focus-within .input-icon {
color: var(--brand-glow);
}
/* 密码切换按钮 */
.password-toggle {
position: absolute;
right: 14px;
width: 20px;
height: 20px;
color: var(--text-dim);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: color 0.2s ease;
}
.password-toggle:hover {
color: #e2e8f0;
}
/* 验证码布局 */
.captcha-wrap {
display: flex;
gap: 12px;
align-items: center;
}
.captcha-wrap .form-input {
flex: 1;
}
.captcha-img-box {
height: 46px;
width: 130px;
border-radius: 10px;
border: 1px solid rgba(56, 189, 248, 0.25);
overflow: hidden;
cursor: pointer;
background: rgba(15, 23, 42, 0.85);
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
position: relative;
}
.captcha-img-box:hover {
border-color: var(--brand-glow);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15);
}
.captcha-img-box img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
/* 选项栏 */
.form-options {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
font-size: 13px;
}
.remember-checkbox {
display: flex;
align-items: center;
gap: 8px;
color: var(--text-sub);
cursor: pointer;
user-select: none;
}
.remember-checkbox input[type="checkbox"] {
appearance: none;
-webkit-appearance: none;
width: 16px;
height: 16px;
border: 1px solid rgba(56, 189, 248, 0.35);
border-radius: 4px;
background: rgba(15, 23, 42, 0.6);
outline: none;
cursor: pointer;
position: relative;
transition: all 0.2s ease;
}
.remember-checkbox input[type="checkbox"]:checked {
background: var(--brand-primary);
border-color: var(--brand-glow);
}
.remember-checkbox input[type="checkbox"]:checked::after {
content: '';
position: absolute;
top: 2px;
left: 5px;
width: 4px;
height: 8px;
border: solid white;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}
.forgot-link {
color: var(--brand-glow);
text-decoration: none;
cursor: pointer;
transition: opacity 0.2s;
}
.forgot-link:hover {
text-decoration: underline;
opacity: 0.85;
}
/* 登录提交按钮 */
.login-btn {
width: 100%;
height: 48px;
border: none;
border-radius: 10px;
background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
color: #ffffff;
font-size: 15.5px;
font-weight: 600;
letter-spacing: 1px;
cursor: pointer;
outline: none;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
transition: all 0.3s ease;
box-shadow: 0 4px 20px rgba(2, 132, 199, 0.35);
}
.login-btn:hover:not(:disabled) {
background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
box-shadow: 0 6px 24px rgba(56, 189, 248, 0.45);
transform: translateY(-1px);
}
.login-btn:active:not(:disabled) {
transform: translateY(0);
}
.login-btn:disabled {
opacity: 0.65;
cursor: not-allowed;
box-shadow: none;
}
.btn-spinner {
width: 18px;
height: 18px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: #ffffff;
animation: spin 0.8s linear infinite;
display: none;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Toast 提示通知 */
.toast-container {
position: fixed;
top: 28px;
left: 50%;
transform: translateX(-50%);
z-index: 9999;
pointer-events: none;
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
}
.toast-item {
padding: 12px 24px;
border-radius: 10px;
font-size: 14px;
font-weight: 500;
display: flex;
align-items: center;
gap: 10px;
color: #ffffff;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
backdrop-filter: blur(12px);
opacity: 0;
transform: translateY(-16px);
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
pointer-events: auto;
}
.toast-item.show {
opacity: 1;
transform: translateY(0);
}
.toast-item.toast-success {
background: rgba(16, 185, 129, 0.92);
border: 1px solid rgba(52, 211, 153, 0.3);
}
.toast-item.toast-error {
background: rgba(239, 68, 68, 0.92);
border: 1px solid rgba(248, 113, 113, 0.3);
}
.toast-item.toast-warning {
background: rgba(245, 158, 11, 0.92);
border: 1px solid rgba(251, 191, 36, 0.3);
}
.toast-item.toast-info {
background: rgba(2, 132, 199, 0.92);
border: 1px solid rgba(56, 189, 248, 0.3);
}
/* 弹窗对话框 (忘记密码) */
.modal-mask {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.65);
backdrop-filter: blur(4px);
z-index: 9998;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
pointer-events: none;
transition: opacity 0.25s ease;
}
.modal-mask.active {
opacity: 1;
pointer-events: auto;
}
.modal-box {
width: 90%;
max-width: 420px;
background: #0f1d36;
border: 1px solid var(--border-glass);
border-radius: 16px;
padding: 28px;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
transform: scale(0.95);
transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-mask.active .modal-box {
transform: scale(1);
}
.modal-title {
font-size: 18px;
font-weight: 600;
color: #ffffff;
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 8px;
}
.modal-content {
font-size: 14px;
color: var(--text-sub);
line-height: 1.6;
margin-bottom: 24px;
}
.modal-btn {
width: 100%;
height: 42px;
background: var(--brand-primary);
border: none;
border-radius: 8px;
color: #ffffff;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: background 0.2s;
}
.modal-btn:hover {
background: #0369a1;
}
/* 响应式断点 */
@media (max-width: 920px) {
.login-left-banner {
display: none;
}
.login-wrapper {
max-width: 480px;
}
.login-right-form {
padding: 36px 28px;
}
}
</style>
</head>
<body>
<!-- 背景层 -->
<div class="login-bg-layer"></div>
<div class="login-bg-grid"></div>
<!-- 提示框容器 -->
<div id="toast-container" class="toast-container"></div>
<!-- 登录主卡片 -->
<div class="login-wrapper">
<!-- 左侧展板 -->
<div class="login-left-banner">
<div class="banner-header">
<div class="banner-badge">
<span class="pulse-dot"></span>
<span>遵义直属库 · 智慧仓储数字化管控平台</span>
</div>
<h2 class="banner-title">
端牢中国饭碗<br>
<span>科技保障国家粮食安全</span>
</h2>
<p class="banner-desc">
中央储备粮遵义直属库有限公司综合数字化管理系统,集成智能温湿度监控、AI气体虫害预警、粮情三维建模及数字化仓储调度。
</p>
<div class="banner-features">
<div class="feature-card">
<div class="feature-title">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#38bdf8" stroke-width="2"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>
微气候实时监测
</div>
<div class="feature-desc">仓内外温湿度多维立体传感预警</div>
</div>
<div class="feature-card">
<div class="feature-title">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#38bdf8" stroke-width="2"><path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>
精准储量核算
</div>
<div class="feature-desc">全库平房仓与油罐储量全景可视化</div>
</div>
<div class="feature-card">
<div class="feature-title">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#38bdf8" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>
智能品质化验
</div>
<div class="feature-desc">全项质检参数超标警戒毫秒级响应</div>
</div>
<div class="feature-card">
<div class="feature-title">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#38bdf8" stroke-width="2"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
安全防御中枢
</div>
<div class="feature-desc">严格访问控制与会话安全防护</div>
</div>
</div>
</div>
<div class="banner-footer">
&copy; {:date('Y')} 中央储备粮遵义直属库有限公司 版权所有
</div>
</div>
<!-- 右侧登录表单 -->
<div class="login-right-form">
<div class="login-brand-logo">
<div class="logo-symbol">
<svg viewBox="0 0 24 24"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
</div>
<div class="brand-text-wrap">
<h1>中央储备粮遵义直属库有限公司</h1>
<p>GRAIN DEPOT MANAGEMENT SYSTEM</p>
</div>
</div>
<div class="form-welcome">
<h2>后台管理登录</h2>
<p>请输入管理员身份凭据进入管控中枢</p>
</div>
<form id="login-form" autocomplete="off" onsubmit="return false;">
{:token()}
<!-- 用户名 -->
<div class="input-group">
<label class="input-label" for="login-username">管理员账号</label>
<div class="input-control-wrap">
<svg class="input-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
<input type="text" id="login-username" name="username" class="form-input" placeholder="请输入管理员用户名" autofocus required>
</div>
</div>
<!-- 密码 -->
<div class="input-group">
<label class="input-label" for="login-password">登录密码</label>
<div class="input-control-wrap">
<svg class="input-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
<path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
</svg>
<input type="password" id="login-password" name="password" class="form-input" placeholder="请输入登录密码" required>
<div class="password-toggle" id="btn-toggle-pwd" title="显示/隐藏密码">
<svg id="eye-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
<circle cx="12" cy="12" r="3"></circle>
</svg>
</div>
</div>
</div>
<!-- 验证码 (由配置控制) -->
{if $Think.config.fastadmin.login_captcha}
<div class="input-group">
<label class="input-label" for="login-captcha">安全验证码</label>
<div class="captcha-wrap">
<div class="input-control-wrap" style="flex: 1;">
<svg class="input-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path>
</svg>
<input type="text" id="login-captcha" name="captcha" class="form-input" placeholder="请输入计算结果或验证码" maxlength="6" required>
</div>
<div class="captcha-img-box" id="captcha-box" title="点击刷新验证码">
<img id="verify-img" src="{:rtrim('__PUBLIC__', '/')}/captcha" alt="验证码" onclick="refreshCaptcha()" />
</div>
</div>
</div>
{/if}
<!-- 保持会话与忘记密码 -->
<div class="form-options">
<label class="remember-checkbox" for="login-keeplogin">
<input type="checkbox" id="login-keeplogin" name="keeplogin" value="1" checked>
<span>保持登录状态(24小时内免密访问)</span>
</label>
<a class="forgot-link" id="link-forgot-pwd" href="javascript:;">忘记密码?</a>
</div>
<!-- 登录提交按钮 -->
<button type="submit" class="login-btn" id="btn-submit">
<span class="btn-spinner" id="btn-spinner"></span>
<span id="btn-text">登 录 系 统</span>
</button>
</form>
</div>
</div>
<!-- 忘记密码说明弹窗 -->
<div class="modal-mask" id="modal-forgot">
<div class="modal-box">
<div class="modal-title">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#38bdf8" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>
密码重置与安全指引
</div>
<div class="modal-content">
为确保中央储备粮直属库系统数据与仓储安全,管理员账户不支持线上自助重置密码。<br><br>
如遇遗失或遗忘密码,请联系库区信息化管理部门或系统运维工程师进行身份核验重置。
</div>
<button class="modal-btn" id="btn-modal-close">我知道了</button>
</div>
</div>
<script>
// 验证码刷新
function refreshCaptcha() {
var img = document.getElementById('verify-img');
if (img) {
img.src = "{:rtrim('__PUBLIC__', '/')}/captcha?r=" + Math.random();
}
}
(function () {
var form = document.getElementById('login-form');
var btnSubmit = document.getElementById('btn-submit');
var btnText = document.getElementById('btn-text');
var btnSpinner = document.getElementById('btn-spinner');
var usernameInput = document.getElementById('login-username');
var passwordInput = document.getElementById('login-password');
var captchaInput = document.getElementById('login-captcha');
var keeploginInput = document.getElementById('login-keeplogin');
var btnTogglePwd = document.getElementById('btn-toggle-pwd');
var eyeIcon = document.getElementById('eye-icon');
var linkForgot = document.getElementById('link-forgot-pwd');
var modalForgot = document.getElementById('modal-forgot');
var btnModalClose = document.getElementById('btn-modal-close');
// 密码显隐切换
if (btnTogglePwd && passwordInput) {
btnTogglePwd.addEventListener('click', function () {
var isPassword = passwordInput.getAttribute('type') === 'password';
passwordInput.setAttribute('type', isPassword ? 'text' : 'password');
if (isPassword) {
eyeIcon.innerHTML = '<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"></path><line x1="1" y1="1" x2="23" y2="23"></line>';
} else {
eyeIcon.innerHTML = '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle>';
}
});
}
// 忘记密码弹窗
if (linkForgot && modalForgot && btnModalClose) {
linkForgot.addEventListener('click', function () {
modalForgot.classList.add('active');
});
btnModalClose.addEventListener('click', function () {
modalForgot.classList.remove('active');
});
modalForgot.addEventListener('click', function (e) {
if (e.target === modalForgot) {
modalForgot.classList.remove('active');
}
});
}
// 轻量 Toast 提示
function showToast(message, type) {
type = type || 'info';
var container = document.getElementById('toast-container');
if (!container) return;
var item = document.createElement('div');
item.className = 'toast-item toast-' + type;
item.textContent = message;
container.appendChild(item);
// 渐入
requestAnimationFrame(function () {
item.classList.add('show');
});
// 3秒后移除
setTimeout(function () {
item.classList.remove('show');
setTimeout(function () {
if (item.parentNode) {
item.parentNode.removeChild(item);
}
}, 300);
}, 2800);
}
// 设置 Loading 状态
function setLoading(loading) {
if (loading) {
btnSubmit.disabled = true;
btnSpinner.style.display = 'inline-block';
btnText.textContent = '登录验证中...';
} else {
btnSubmit.disabled = false;
btnSpinner.style.display = 'none';
btnText.textContent = '登 录 系 统';
}
}
// 表单提交
function handleSubmit() {
var username = usernameInput ? usernameInput.value.trim() : '';
var password = passwordInput ? passwordInput.value : '';
var captcha = captchaInput ? captchaInput.value.trim() : '';
var keeplogin = (keeploginInput && keeploginInput.checked) ? 1 : 0;
var tokenInput = document.querySelector('input[name="__token__"]');
var token = tokenInput ? tokenInput.value : '';
if (!username) {
showToast('请您输入管理员账号', 'warning');
if (usernameInput) usernameInput.focus();
return;
}
if (!password) {
showToast('请您输入登录密码', 'warning');
if (passwordInput) passwordInput.focus();
return;
}
if (captchaInput && !captcha) {
showToast('请您输入安全验证码', 'warning');
captchaInput.focus();
return;
}
setLoading(true);
// 组装 POST 数据
var postData = new URLSearchParams();
postData.append('username', username);
postData.append('password', password);
postData.append('keeplogin', keeplogin);
postData.append('__token__', token);
if (captchaInput) {
postData.append('captcha', captcha);
}
fetch('{:url("login")}', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With': 'XMLHttpRequest'
},
body: postData.toString()
})
.then(function (response) {
return response.json();
})
.then(function (res) {
setLoading(false);
// 如果后端返回了新 token,更新页面隐藏域
if (res.data && res.data.token && tokenInput) {
tokenInput.value = res.data.token;
}
if (res.code === 1) {
showToast(res.msg || '登录成功,正在进入系统...', 'success');
setTimeout(function () {
window.location.href = res.url || 'index/index';
}, 800);
} else {
// 登录失败:刷新验证码并更新 token
refreshCaptcha();
showToast(res.msg || '用户名或密码错误', 'error');
}
})
.catch(function (err) {
setLoading(false);
refreshCaptcha();
showToast('网络通信异常,请重试或检查服务状态', 'error');
});
}
// 按钮点击
btnSubmit.addEventListener('click', handleSubmit);
// 回车键快捷提交
var inputs = [usernameInput, passwordInput, captchaInput];
inputs.forEach(function (inp) {
if (inp) {
inp.addEventListener('keydown', function (e) {
if (e.key === 'Enter' || e.keyCode === 13) {
handleSubmit();
}
});
}
});
})();
</script>
</body>
</html>