Files
kefu-server/views/agent-login.ejs
T
Kefu Admin 5471eda6c1 Initial commit: kefu-server-saas v2.0
客服服务器完整源码,包含:
- Express HTTP服务 (port 9501)
- WebSocket服务 (port 9502)
- SaaS多租户认证
- 坐席管理、消息管理、连接管理
- SQLite数据库(5张核心表)
- 管理后台 (/admin)
- 坐席工作台 (/agent, /agent-mobile)
- 商城REST API (/plugin.yunqian-api)
- 消息推送API (/message/push)

技术栈:Node.js 18 + Express 4 + ws 8 + better-sqlite3 + EJS + PM2
2026-08-23 21:22:34 +08:00

84 lines
3.5 KiB
Plaintext

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>客服登录 - 坐席工作台</title>
<style>
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Microsoft YaHei",sans-serif;background:linear-gradient(135deg,#1a73e8 0%,#0d47a1 100%);min-height:100vh;display:flex;align-items:center;justify-content:center}
.login-card{background:#fff;border-radius:16px;box-shadow:0 20px 60px rgba(0,0,0,0.3);padding:40px;width:480px;max-width:90vw}
.login-card h1{text-align:center;color:#333;font-size:20px;margin-bottom:6px}
.login-card .subtitle{text-align:center;color:#999;font-size:13px;margin-bottom:30px}
.form-group{margin-bottom:16px}
.form-group label{display:block;font-size:13px;color:#555;margin-bottom:6px;font-weight:500}
.form-group input,.form-group select{width:100%;padding:10px 14px;border:1px solid #ddd;border-radius:8px;font-size:14px;outline:none}
.form-group input:focus,.form-group select:focus{border-color:#1a73e8;box-shadow:0 0 0 3px rgba(26,115,232,0.15)}
.btn-login{width:100%;padding:12px;background:linear-gradient(135deg,#1a73e8 0%,#0d47a1 100%);color:#fff;border:none;border-radius:8px;font-size:16px;font-weight:600;cursor:pointer;margin-top:10px}
.btn-login:hover{opacity:.9}
.error-msg{background:#fff0f0;border:1px solid #ffcccc;color:#cc3333;padding:10px 14px;border-radius:8px;font-size:13px;margin-bottom:16px;display:none}
.error-msg.show{display:block}
.hint{color:#999;font-size:12px;margin-top:16px;text-align:center}
.hint a{color:#1a73e8;text-decoration:none}
</style>
</head>
<body>
<div class="login-card">
<h1>客服坐席登录</h1>
<div class="subtitle">连接到客服服务器工作台</div>
<div class="error-msg" id="errorMsg"></div>
<div class="form-group">
<label>AppID(商城标识)</label>
<input type="text" id="appId" placeholder="如: abc12345" value="<%= tenants.length > 0 ? tenants[0].app_id : '' %>">
</div>
<div class="form-group">
<label>AppSecret(密钥)</label>
<input type="password" id="appSecret" placeholder="商城密钥">
</div>
<div class="form-group">
<label>坐席ID(可选)</label>
<input type="text" id="agentId" placeholder="如不填写则自动分配">
</div>
<button class="btn-login" id="btnLogin">登录工作台</button>
<div class="hint">已有商城?<a href="/admin">去管理后台</a></div>
</div>
<script>
document.getElementById('btnLogin').addEventListener('click', async () => {
const app_id = document.getElementById('appId').value.trim();
const app_secret = document.getElementById('appSecret').value.trim();
const agent_id = document.getElementById('agentId').value.trim();
if (!app_id || !app_secret) {
showError('请输入 AppID 和 AppSecret');
return;
}
const res = await fetch('/agent/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ app_id, app_secret, agent_id })
});
const data = await res.json();
if (data.success) {
location.href = '/agent/dashboard';
} else {
showError(data.message || '登录失败');
}
});
function showError(msg) {
const el = document.getElementById('errorMsg');
el.textContent = msg;
el.classList.add('show');
}
document.querySelectorAll('input').forEach(input => {
input.addEventListener('keypress', (e) => {
if (e.key === 'Enter') document.getElementById('btnLogin').click();
});
});
</script>
</body>
</html>