145 lines
9.2 KiB
Plaintext
Executable File
145 lines
9.2 KiB
Plaintext
Executable File
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Gaussian 登录</title>
|
|
<style>
|
|
*{margin:0;padding:0;box-sizing:border-box}
|
|
body{font-family:'Microsoft YaHei','PingFang SC',sans-serif;background:linear-gradient(135deg,#1a73e8,#1557b0);min-height:100vh;display:flex;justify-content:center;align-items:center;padding:20px}
|
|
.login-box{background:#fff;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,.2);width:100%;max-width:420px;padding:40px 36px}
|
|
.login-box .logo{text-align:center;font-size:22px;font-weight:700;color:#1a73e8;margin-bottom:6px}
|
|
.login-box .sub{text-align:center;font-size:13px;color:#999;margin-bottom:28px}
|
|
.form-group{margin-bottom:18px}
|
|
.form-group label{display:block;font-size:13px;font-weight:600;color:#333;margin-bottom:6px}
|
|
.form-group input{width:100%;height:44px;padding:0 14px;border:2px solid #e0e0e0;border-radius:8px;font-size:14px;outline:0;transition:border-color .25s,box-shadow .25s}
|
|
.form-group input:focus{border-color:#1a73e8;box-shadow:0 0 0 3px rgba(26,115,232,.12)}
|
|
.btn{width:100%;height:46px;border:0;border-radius:8px;font-size:16px;font-weight:600;cursor:pointer;transition:.2s;margin-top:6px}
|
|
.btn-primary{background:linear-gradient(135deg,#1a73e8,#1557b0);color:#fff}
|
|
.btn-primary:hover{opacity:.92}
|
|
.btn-primary:disabled{opacity:.6;cursor:default}
|
|
.btn-link{background:0 0;color:#1a73e8;font-size:13px;height:auto;padding:8px 0;text-decoration:underline}
|
|
.btn-link:hover{color:#1557b0}
|
|
.error{color:#e74c3c;font-size:13px;margin-top:10px;display:none;text-align:center}
|
|
.error.show{display:block}
|
|
.loading{display:inline-block;width:18px;height:18px;border:2px solid rgba(255,255,255,.3);border-top-color:#fff;border-radius:50%;animation:spin .7s linear infinite;vertical-align:middle;margin-right:8px}
|
|
@keyframes spin{to{transform:rotate(360deg)}}
|
|
.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:999;justify-content:center;align-items:center}
|
|
.modal-overlay.show{display:flex}
|
|
.modal{background:#fff;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,.2);width:100%;max-width:400px;padding:32px 30px}
|
|
.modal h3{font-size:18px;color:#333;margin-bottom:20px;text-align:center}
|
|
.modal .form-group{margin-bottom:14px}
|
|
.modal .btn-row{display:flex;gap:10px;margin-top:8px}
|
|
.modal .btn-row .btn{flex:1}
|
|
.btn-secondary{background:#f0f0f0;color:#666}
|
|
.btn-secondary:hover{background:#e0e0e0}
|
|
.toast{position:fixed;top:14px;left:50%;transform:translateX(-50%);padding:10px 22px;border-radius:8px;font-size:13px;z-index:1001;box-shadow:0 4px 20px rgba(0,0,0,.15);display:none;min-width:240px;text-align:center}
|
|
.toast.error{background:#fdeaea;color:#b71c1c;display:block}
|
|
.toast.success{background:#e6f9ed;color:#1a7a3a;display:block}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="toast" id="toast"></div>
|
|
<div class="login-box">
|
|
<div class="logo">Gaussian</div>
|
|
<div class="sub">Gaussian IT管理系统</div>
|
|
<div id="loginForm">
|
|
<div class="form-group"><label>用户名</label><input type="text" id="txtUserId" placeholder="请输入用户账号" autocomplete="off" /></div>
|
|
<div class="form-group"><label>密码</label><input type="password" id="txtPassword" placeholder="请输入密码" /></div>
|
|
<div class="error" id="loginError"></div>
|
|
<button class="btn btn-primary" id="btnLogin" onclick="doLogin()">登 录</button>
|
|
<button class="btn btn-link" onclick="showChangePwd()">修改密码</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal-overlay" id="pwdModal">
|
|
<div class="modal">
|
|
<h3>修改密码</h3>
|
|
<div class="form-group"><label>用户名</label><input type="text" id="cpUserId" placeholder="请输入用户账号" /></div>
|
|
<div class="form-group"><label>原密码</label><input type="password" id="cpOldPwd" placeholder="请输入原密码" /></div>
|
|
<div class="form-group"><label>新密码</label><input type="password" id="cpNewPwd" placeholder="请输入新密码" /></div>
|
|
<div class="error" id="cpError"></div>
|
|
<div class="btn-row">
|
|
<button class="btn btn-secondary" onclick="hideChangePwd()">取消</button>
|
|
<button class="btn btn-primary" id="btnChangePwd" onclick="doChangePwd()">确认修改</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function toast(msg,tp){var el=document.getElementById('toast');el.textContent=msg;el.className='toast '+tp;clearTimeout(el._timer);el._timer=setTimeout(function(){el.className='toast'},3500)}
|
|
function logout(){sessionStorage.removeItem('gx_user');window.location.href='login.html'}
|
|
function showChangePwd(){document.getElementById('pwdModal').classList.add('show');document.getElementById('cpError').classList.remove('show')}
|
|
function hideChangePwd(){document.getElementById('pwdModal').classList.remove('show');document.getElementById('cpError').classList.remove('show')}
|
|
|
|
function doLogin(){
|
|
var userId=document.getElementById('txtUserId').value.trim();
|
|
var pwd=document.getElementById('txtPassword').value.trim();
|
|
if(!userId){document.getElementById('loginError').textContent='请输入用户名';document.getElementById('loginError').classList.add('show');return}
|
|
document.getElementById('loginError').classList.remove('show');
|
|
var btn=document.getElementById('btnLogin');btn.disabled=true;btn.innerHTML='<span class="loading"></span>登录中...';
|
|
var xhr=new XMLHttpRequest();
|
|
xhr.open('POST','api/Auth/Login',true);
|
|
xhr.setRequestHeader('Content-Type','application/json');
|
|
xhr.onload=function(){
|
|
btn.disabled=false;btn.innerHTML='登 录';
|
|
try{
|
|
var r=JSON.parse(xhr.responseText);
|
|
if(r.success){
|
|
sessionStorage.setItem('gx_user',JSON.stringify(r.data));
|
|
var roles=r.data.roleNumbers||[];
|
|
if(roles.indexOf('Produce02')>=0)window.location.href='View/MES/mes_dashboard.html';
|
|
else if(roles.indexOf('Purchase01')>=0)window.location.href='procurement.html';
|
|
else if(roles.indexOf('YF01')>=0)window.location.href='dashboard.html';
|
|
else if(roles.indexOf('CRM01')>=0)window.location.href='index.html';
|
|
else window.location.href='procurement.html';
|
|
}else{
|
|
document.getElementById('loginError').textContent=r.message||'登录失败';
|
|
document.getElementById('loginError').classList.add('show');
|
|
}
|
|
}catch(e){document.getElementById('loginError').textContent='登录异常';document.getElementById('loginError').classList.add('show')}
|
|
};
|
|
xhr.onerror=function(){btn.disabled=false;btn.innerHTML='登 录';document.getElementById('loginError').textContent='网络连接失败';document.getElementById('loginError').classList.add('show')};
|
|
xhr.send(JSON.stringify({userId:userId,password:pwd}));
|
|
}
|
|
|
|
function doChangePwd(){
|
|
var userId=document.getElementById('cpUserId').value.trim();
|
|
var oldPwd=document.getElementById('cpOldPwd').value.trim();
|
|
var newPwd=document.getElementById('cpNewPwd').value.trim();
|
|
if(!userId){document.getElementById('cpError').textContent='请输入用户名';document.getElementById('cpError').classList.add('show');return}
|
|
document.getElementById('cpError').classList.remove('show');
|
|
var btn=document.getElementById('btnChangePwd');btn.disabled=true;btn.innerHTML='提交中...';
|
|
var xhr=new XMLHttpRequest();
|
|
xhr.open('POST','api/Auth/ChangePassword',true);
|
|
xhr.setRequestHeader('Content-Type','application/json');
|
|
xhr.onload=function(){
|
|
btn.disabled=false;btn.innerHTML='确认修改';
|
|
try{var r=JSON.parse(xhr.responseText);
|
|
if(r.success){toast('密码修改成功','success');hideChangePwd();document.getElementById('cpUserId').value='';document.getElementById('cpOldPwd').value='';document.getElementById('cpNewPwd').value=''}
|
|
else{document.getElementById('cpError').textContent=r.message||'修改失败';document.getElementById('cpError').classList.add('show')}
|
|
}catch(e){document.getElementById('cpError').textContent='请求异常';document.getElementById('cpError').classList.add('show')}
|
|
};
|
|
xhr.onerror=function(){btn.disabled=false;btn.innerHTML='确认修改';toast('网络连接失败','error')};
|
|
xhr.send(JSON.stringify({userId:userId,oldPassword:oldPwd,newPassword:newPwd}));
|
|
}
|
|
|
|
document.getElementById('txtPassword').addEventListener('keydown',function(e){if(e.key==='Enter')doLogin()});
|
|
document.getElementById('txtUserId').addEventListener('keydown',function(e){if(e.key==='Enter')document.getElementById('txtPassword').focus()});
|
|
|
|
(function(){
|
|
var user=sessionStorage.getItem('gx_user');
|
|
if(user){
|
|
try{var data=JSON.parse(user);var roles=data.roleNumbers||[];
|
|
if(roles.indexOf('Produce02')>=0)window.location.href='View/MES/mes_dashboard.html';
|
|
else if(roles.indexOf('Purchase01')>=0)window.location.href='procurement.html';
|
|
else if(roles.indexOf('YF01')>=0)window.location.href='dashboard.html';
|
|
else if(roles.indexOf('CRM01')>=0)window.location.href='index.html';
|
|
else window.location.href='procurement.html';
|
|
}catch(e){}
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|