63 lines
2.6 KiB
HTML
63 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<head>
|
|
<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>로그인 — EV AS 관리</title>
|
|
<link rel="stylesheet" href="/css/style.css">
|
|
<style>
|
|
body{display:flex;align-items:center;justify-content:center;min-height:100vh;background:var(--navy);}
|
|
.login-box{background:white;border-radius:14px;padding:40px 36px;width:100%;max-width:380px;box-shadow:0 8px 32px rgba(0,0,0,.3);}
|
|
.login-logo{text-align:center;margin-bottom:28px;}
|
|
.login-logo h1{font-size:22px;font-weight:900;color:var(--navy);}
|
|
.login-logo p{font-size:12px;color:var(--gray4);margin-top:4px;}
|
|
.login-box .form-group{margin-bottom:14px;}
|
|
#err{color:var(--red);font-size:13px;text-align:center;min-height:18px;margin-bottom:8px;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-box">
|
|
<div class="login-logo">
|
|
<h1>⚡ EV AS 관리</h1>
|
|
<p>cs.byunc.com</p>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>아이디</label>
|
|
<input type="text" id="username" placeholder="아이디 입력" autofocus>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>비밀번호</label>
|
|
<input type="password" id="password" placeholder="비밀번호 입력">
|
|
</div>
|
|
<div id="err"></div>
|
|
<button class="btn btn-primary btn-lg" id="loginBtn">로그인</button>
|
|
</div>
|
|
<script src="/js/api.js"></script>
|
|
<script src="/js/auth.js"></script>
|
|
<script>
|
|
async function doLogin() {
|
|
const u = document.getElementById('username').value.trim();
|
|
const p = document.getElementById('password').value;
|
|
if (!u || !p) { document.getElementById('err').textContent = '아이디와 비밀번호를 입력하세요.'; return; }
|
|
document.getElementById('loginBtn').disabled = true;
|
|
document.getElementById('err').textContent = '';
|
|
try {
|
|
const fd = new FormData();
|
|
fd.append('username', u); fd.append('password', p);
|
|
const res = await fetch('/api/auth/login', { method:'POST', body: fd });
|
|
if (!res.ok) { const e = await res.json(); throw new Error(e.detail); }
|
|
const data = await res.json();
|
|
Auth.save(data.access_token, data.role, data.name, data.user_id);
|
|
if (data.role === 'admin') location.href = '/pages/admin/dashboard.html';
|
|
else if (data.role === 'mechanic') location.href = '/pages/mechanic/dashboard.html';
|
|
else location.href = '/pages/manufacturer/dashboard.html';
|
|
} catch(e) {
|
|
document.getElementById('err').textContent = e.message;
|
|
document.getElementById('loginBtn').disabled = false;
|
|
}
|
|
}
|
|
document.getElementById('loginBtn').addEventListener('click', doLogin);
|
|
document.getElementById('password').addEventListener('keydown', e => { if(e.key==='Enter') doLogin(); });
|
|
</script>
|
|
</body>
|
|
</html>
|