Compare commits

...

2 Commits

Author SHA1 Message Date
geyun
5741135f2a 登陆界面 样式美化 修复一些bug 2026-10-15 10:58:43 +08:00
geyun
8acce63d8f 跳出到 登录功能 重构 2026-10-15 10:07:42 +08:00
4 changed files with 642 additions and 631 deletions

View File

@@ -1886,6 +1886,18 @@
let token = params.get("token");//app的token let token = params.get("token");//app的token
let localtoken = params.get("localtoken");//公众号的localtoken let localtoken = params.get("localtoken");//公众号的localtoken
function clearOldRootDomainCookies() {
const names = ['Admin-Token', 'token', 'userId', 'username', 'nickname', 'headimgurl', 'headingimg'];
const parts = location.hostname.split('.');
const rootDomain = parts.length >= 2 ? '.' + parts.slice(-2).join('.') : '';
if (!rootDomain || rootDomain === '.') return;
names.forEach(name => {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=' + rootDomain + ';';
});
console.log('[cookie] 已清除旧 root-domain cookie:', rootDomain);
}
clearOldRootDomainCookies();
// app会得到token; // app会得到token;
// 手机端会验证token // 手机端会验证token
@@ -2135,6 +2147,7 @@
} }
questions.forEach(q => { questions.forEach(q => {
q.addEventListener("click", () => { q.addEventListener("click", () => {
@@ -2214,6 +2227,8 @@
function logout() { function logout() {
deleteCookie('userId'); deleteCookie('userId');
deleteCookie('token'); deleteCookie('token');
deleteCookie('nickname');
deleteCookie('headimgurl');
deleteCookie("sharetoken", "ai.satabot.com") deleteCookie("sharetoken", "ai.satabot.com")
// 清空历史记录(黑科技) // 清空历史记录(黑科技)
history.pushState(null, null, location.href); history.pushState(null, null, location.href);

View File

@@ -1,6 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh-CN"> <html lang="zh-CN">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
@@ -18,54 +17,83 @@
padding: 0; padding: 0;
box-sizing: border-box; box-sizing: border-box;
} }
html, html,
body { body {
height: 100%; height: 100%;
width: 100%; width: 100%;
} }
body { body {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft Yahei", "Segoe UI", Arial, sans-serif; font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft Yahei", "Segoe UI", Arial, sans-serif;
font-size: 12px; font-size: 12px;
background: repeating-linear-gradient(to bottom right, #cee3fc 20%, #a8c7ed87 50%, #ffffffe7 50%, #ffffffc2 80%); /* 美化背景:柔和蓝渐变 + 微弱径向光晕 */
background: linear-gradient(135deg, #e8f2ff 0%, #d6e8fc 100%);
color: #a0a5a8; color: #a0a5a8;
overflow: hidden; overflow: hidden;
/* 页面载入淡入 */
animation: pageFadeIn .8s ease;
}
@keyframes pageFadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
/* 可选:微弱浮动光点背景,不想用直接删掉这一段 */
body::before{
content:"";
position:fixed;
width:600px;
height:600px;
border-radius:50%;
background: radial-gradient(circle, rgba(22,119,255,0.08) 0%, transparent 70%);
top:-100px;
right:-100px;
z-index:-1;
}
body::after{
content:"";
position:fixed;
width:450px;
height:450px;
border-radius:50%;
background: radial-gradient(circle, rgba(22,119,255,0.06) 0%, transparent 70%);
bottom:-80px;
left:-80px;
z-index:-1;
} }
.main { .main {
position: relative; position: relative;
width: 1100px; width: 1100px;
height: 600px; height: 620px;
padding: 25px; padding: 0;
background-color: #fff; background-color: #fff;
box-shadow: 10px 0 10px #d0d5dd; box-shadow: 0 12px 40px rgba(22, 119, 255, 0.12), 0 4px 12px rgba(0,0,0,0.06);
border-radius: 12px; border-radius: 20px;
overflow: hidden; overflow: hidden;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.main:hover{
box-shadow: 0 16px 50px rgba(22, 119, 255, 0.15), 0 6px 16px rgba(0,0,0,0.08);
} }
.container { .container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-start; justify-content: center;
align-items: center; align-items: center;
position: absolute; position: absolute;
top: 0; top: 0;
width: 600px; width: 600px;
height: 100%; height: 100%;
padding: 25px; padding: 40px 30px;
background-color: #fff; background-color: #fff;
transition: 1.25s; transition: 1.25s cubic-bezier(0.25, 0.8, 0.25, 1);
} }
.a-container { .a-container {
z-index: 100; z-index: 100;
left: calc(100% - 600px); left: calc(100% - 600px);
} }
.form { .form {
display: flex; display: flex;
justify-content: center; justify-content: center;
@@ -74,175 +102,175 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.tab { .tab {
display: flex; display: flex;
border-bottom: 1px solid #eee; border-bottom: 1px solid #f0f0f0;
margin-bottom: 20px; margin-bottom: 32px;
width: 65%; width: 70%;
} }
.tab-item { .tab-item {
flex: 1; flex: 1;
text-align: center; text-align: center;
padding: 12px 0; padding: 14px 0;
cursor: pointer; cursor: pointer;
font-size: 16px; font-size: 16px;
color: #666; color: #666;
transition: all .24s;
}
.tab-item:hover{
color:#1677ff88;
} }
.tab-item.active { .tab-item.active {
color: #1677ff; color: #1677ff;
border-bottom: 2px solid #1677ff; border-bottom: 2px solid #1677ff;
font-weight:500;
} }
.form-panel { .form-panel {
display: none; display: none;
width: 350px; width: 360px;
} }
.form-panel.active { .form-panel.active {
display: block; display: block;
animation: panelFade 0.4s ease;
}
@keyframes panelFade {
from {opacity:0;transform: translateY(8px);}
to {opacity:1;transform: translateY(0);}
} }
.input-group { .input-group {
margin-bottom: 20px; margin-bottom: 24px;
width: 100%; width: 100%;
} }
.label { .label {
font-size: 14px; font-size: 14px;
color: #555; color: #333;
margin-bottom: 8px; margin-bottom: 8px;
font-weight:500;
} }
.username, .username,
.password { .password {
position: relative; position: relative;
} }
.username .icon, .username .icon,
.password .icon.left { .password .icon.left {
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 0.5rem; left: 0.75rem;
transform: translateY(-50%); transform: translateY(-50%);
color: #888; color: #b0b8c4;
width: 18px; width: 20px;
height: 18px; height: 20px;
transition: color .2s;
} }
.password .icon.right { .password .icon.right {
position: absolute; position: absolute;
top: 50%; top: 50%;
right: 0.5rem; right: 0.75rem;
transform: translateY(-50%); transform: translateY(-50%);
color: #888; color: #b0b8c4;
cursor: pointer; cursor: pointer;
width: 20px; width: 22px;
height: 20px; height: 22px;
transition: color .2s;
}
.username:focus-within .icon,
.password:focus-within .icon{
color:#1677ff;
} }
.form__input { .form__input {
width: 100%; width: 100%;
height: 40px; height: 44px;
margin: 4px 0; margin: 4px 0;
padding-left: 2rem; padding-left: 2.5rem;
padding-right: 2.5rem; padding-right: 2.8rem;
font-size: 13px; font-size: 14px;
letter-spacing: 0.15px; letter-spacing: 0.15px;
border: none; border: 1px solid #f0f2f5;
outline: none; outline: none;
background-color: #fff; background-color: #fcfcfd;
transition: 0.25s ease; transition: 0.25s ease;
border-radius: 8px; border-radius: 10px;
box-shadow: inset 2px 2px 4px #d1d9e6, inset -2px -2px 4px #f9f9f9;
} }
.form__input:focus { .form__input:focus {
box-shadow: inset 4px 4px 4px #d1d9e6, inset -4px -4px 4px #f9f9f9; border-color:#1677ff;
box-shadow: 0 0 0 3px rgba(22,119,255,0.12);
background:#fff;
} }
.remember { .remember {
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: 6px;
margin: 16px 0 0; margin: 8px 0 0;
font-size: 13px; font-size: 13px;
color: #000; color: #333;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
} }
.remember input { .remember input {
accent-color: #0f73ee; accent-color: #1677ff;
cursor: pointer; cursor: pointer;
} }
.button { .button {
width: 100%; width: 100%;
height: 46px; height: 48px;
border-radius: 8px; border-radius: 10px;
margin-top: 20px; margin-top: 24px;
font-weight: 700; font-weight: 600;
font-size: 14px; font-size: 15px;
letter-spacing: 1.15px; letter-spacing: 0.5px;
background-color: #0f73ee; background-color: #1677ff;
color: #f9f9f9; color: #ffffff;
border: none; border: none;
outline: none; outline: none;
cursor: pointer; cursor: pointer;
box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #f9f9f9; transition: all 0.24s ease;
transition: all 0.2s ease;
} }
.button:hover { .button:hover {
box-shadow: 6px 6px 10px #d1d9e6, -6px -6px 10px #f9f9f9; background-color:#0f66dd;
transform: scale(0.985); transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(22,119,255,0.28);
} }
.button:active { .button:active {
box-shadow: 2px 2px 6px #d1d9e6, -2px -2px 6px #f9f9f9; transform: translateY(0px);
transform: scale(0.97); box-shadow: 0 2px 8px rgba(22,119,255,0.2);
} }
.button:disabled { .button:disabled {
opacity: 0.6; opacity: 0.6;
cursor: not-allowed; cursor: not-allowed;
transform:none;
box-shadow:none;
} }
.agree { .agree {
font-size: 12px; font-size: 12px;
color: #666; color: #666;
margin-top: 14px; margin-top: 16px;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
} }
.agree input { .agree input {
accent-color: #0f73ee; accent-color: #1677ff;
} }
.link { .link {
color: #1677ff; color: #1677ff;
cursor: pointer; cursor: pointer;
transition: .2s;
}
.link:hover{
text-decoration:underline;
} }
#weixin_container { #weixin_container {
width: 300px; width: 300px;
height: 300px; height: 300px;
margin: 0 auto; margin: 0 auto;
} }
.wechat-tip { .wechat-tip {
text-align: center; text-align: center;
margin-top: 16px; margin-top: 16px;
font-size: 13px; font-size: 13px;
color: #666; color: #666;
} }
.switch { .switch {
display: flex; display: flex;
justify-content: center; justify-content: center;
@@ -254,23 +282,20 @@
width: 500px; width: 500px;
padding: 50px; padding: 50px;
z-index: 200; z-index: 200;
transition: 1.25s; transition: 1.25s cubic-bezier(0.25, 0.8, 0.25, 1);
background-color: #fff; background: linear-gradient(145deg,#1677ff,#4096ff);
overflow: hidden; overflow: hidden;
} }
.switch__circle { .switch__circle {
position: absolute; position: absolute;
width: 450px; width: 550px;
height: 450px; height: 550px;
border-radius: 50%; border-radius: 50%;
background-color: #fff; background-color: rgba(255,255,255,0.12);
box-shadow: inset 8px 8px 12px #dde6f4, inset -8px -8px 12px #f9f9f9; bottom: -70%;
bottom: -60%; left: -65%;
left: -60%; transition: 1.25s cubic-bezier(0.25, 0.8, 0.25, 1);
transition: 1.25s;
} }
.switch__container { .switch__container {
display: flex; display: flex;
justify-content: center; justify-content: center;
@@ -278,131 +303,121 @@
flex-direction: column; flex-direction: column;
position: absolute; position: absolute;
width: 480px; width: 480px;
transition: 1.25s; transition: 1.25s cubic-bezier(0.25, 0.8, 0.25, 1);
} }
.switch__title { .switch__title {
font-size: 34px; font-size: 36px;
font-weight: 700; font-weight: 700;
line-height: 1.5; line-height: 1.4;
color: #181818; color: #ffffff;
margin-left: 10px; margin-left: 10px;
} }
.switch__subtitle { .switch__subtitle {
font-size: 20px; font-size: 20px;
font-weight: 500; font-weight: 400;
color: #666; color: rgba(255,255,255,0.85);
margin-left: 10px; margin-left: 10px;
margin-top:6px;
} }
.logo-row { .logo-row {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.logo-row img { .logo-row img {
width: 60px; width: 64px;
} }
.toast { .toast {
position: fixed; position: fixed;
top: 22%; top: 22%;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
background: rgba(0, 0, 0, 0.78); background: rgba(0, 0, 0, 0.72);
color: #fff; color: #fff;
padding: 10px 18px; padding: 12px 20px;
border-radius: 8px; border-radius: 10px;
font-size: 14px; font-size: 14px;
opacity: 0; opacity: 0;
transition: opacity 0.3s ease; transition: opacity 0.3s ease, transform 0.3s ease;
z-index: 9999; z-index: 9999;
pointer-events: none; pointer-events: none;
white-space: nowrap; white-space: nowrap;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
transform: translate(-50%, -8px);
} }
.toast.show { .toast.show {
opacity: 1; opacity: 1;
transform: translate(-50%, 0);
} }
@media (max-width: 1200px) { @media (max-width: 1200px) {
.main { .main {
transform: scale(0.9); transform: scale(0.92);
} }
.switch { .switch {
width: 40%; width: 42%;
} }
.container { .container {
width: 60%; width: 58%;
} }
} }
@media (max-width: 1000px) { @media (max-width: 1000px) {
.main { .main {
transform: scale(0.8); transform: scale(0.85);
} }
} }
@media (max-width: 800px) { @media (max-width: 800px) {
body { body {
padding: 0; padding: 0;
} }
.main { .main {
transform: scale(0.9); transform: scale(1);
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 100vh; height: 100vh;
width: 600px; width: 100%;
border-radius:0;
box-shadow: none; box-shadow: none;
} }
.a-container { .a-container {
position: absolute; position: absolute;
z-index: 100; z-index: 100;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
width:100%;
} }
.switch { .switch {
display: none; display: none;
} }
.tab { .tab {
width: 100%; width: 100%;
} }
} }
@media (max-width: 600px) { @media (max-width: 600px) {
.main { .main {
transform: scale(0.9); transform: scale(1);
display: flex; width:100%;
justify-content: center; height:100vh;
align-items: center; border-radius:0;
height: 75vh;
width: 100vh;
box-shadow: 10px 0 10px #5c7aaa;
} }
.a-container { .a-container {
position: absolute;
width: 100%; width: 100%;
z-index: 100;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
} }
.form-panel{
width:90%;
}
#weixin_container{
width:260px;
height:260px;
}
.switch { .switch {
display: none; display: none;
} }
} }
</style> </style>
</head> </head>
<body> <body>
<div class="login"> <div class="login">
<div class="main"> <div class="main">
@@ -411,7 +426,6 @@
<div class="tab-item active" data-tab="password">密码登录</div> <div class="tab-item active" data-tab="password">密码登录</div>
<div class="tab-item" data-tab="weixin">微信登录</div> <div class="tab-item" data-tab="weixin">微信登录</div>
</div> </div>
<div class="form-panel active" id="password-panel"> <div class="form-panel active" id="password-panel">
<div class="input-group"> <div class="input-group">
<div class="label">账号</div> <div class="label">账号</div>
@@ -424,9 +438,8 @@
autocomplete="off" /> autocomplete="off" />
</div> </div>
</div> </div>
<div class="input-group"> <div class="input-group">
<div class="label" style="margin-top:20px;">密码</div> <div class="label">密码</div>
<div class="password"> <div class="password">
<svg class="icon left" viewBox="0 0 24 24" fill="none" stroke="currentColor" <svg class="icon left" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2"> stroke-width="2">
@@ -442,14 +455,11 @@
</svg> </svg>
</div> </div>
</div> </div>
<label class="remember"> <label class="remember">
<input type="checkbox" id="rememberMe" /> <input type="checkbox" id="rememberMe" />
记住密码 记住密码
</label> </label>
<button class="button" id="loginBtn" onclick="handleLogin()">登录</button> <button class="button" id="loginBtn" onclick="handleLogin()">登录</button>
<div class="agree"> <div class="agree">
<input type="checkbox" id="agree" checked /> <input type="checkbox" id="agree" checked />
我已阅读并同意 我已阅读并同意
@@ -457,13 +467,10 @@
<span class="link">《隐私政策》</span> <span class="link">《隐私政策》</span>
</div> </div>
</div> </div>
<div class="form-panel" id="weixin-panel"> <div class="form-panel" id="weixin-panel">
<div id="weixin_container"></div> <div id="weixin_container"></div>
<p class="wechat-tip">请使用微信扫描二维码登录</p>
</div> </div>
</div> </div>
<div class="switch" id="switch-cnt"> <div class="switch" id="switch-cnt">
<div class="switch__circle"></div> <div class="switch__circle"></div>
<div class="switch__container"> <div class="switch__container">
@@ -478,29 +485,27 @@
</div> </div>
</div> </div>
</div> </div>
<div class="toast" id="toast"></div> <div class="toast" id="toast"></div>
<script src="./wxLogin.js"></script>
<script> <script>
const WECHAT_APPID = 'wx0eeb7556d60121db'; const WECHAT_APPID = 'wx0eeb7556d60121db';
const WECHAT_REDIRECT_URI = encodeURIComponent('https://serviceai.satabot.com/webCallback/'); const WECHAT_REDIRECT_URI = encodeURIComponent('https://serviceai.satabot.com/webCallback/');
removeCookie('username');
removeCookie('nickname');
removeCookie('headimgurl');
function setCookie(name, value, days) { function setCookie(name, value, days) {
days = days || 30; days = days || 30;
const d = new Date(); const d = new Date();
d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000); d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000);
document.cookie = name + '=' + encodeURIComponent(value) + ';expires=' + d.toUTCString() + ';path=/'; document.cookie = name + '=' + encodeURIComponent(value) + ';expires=' + d.toUTCString() + ';path=/';
} }
function getCookie(name) { function getCookie(name) {
const m = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); const m = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
return m ? decodeURIComponent(m[2]) : undefined; return m ? decodeURIComponent(m[2]) : undefined;
} }
function removeCookie(name) { function removeCookie(name) {
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/;'; document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00 UTC;path=/;';
} }
function showToast(msg) { function showToast(msg) {
const t = document.getElementById('toast'); const t = document.getElementById('toast');
t.innerText = msg; t.innerText = msg;
@@ -508,7 +513,6 @@
clearTimeout(t._timer); clearTimeout(t._timer);
t._timer = setTimeout(() => t.classList.remove('show'), 2200); t._timer = setTimeout(() => t.classList.remove('show'), 2200);
} }
const tabs = document.querySelectorAll('.tab-item'); const tabs = document.querySelectorAll('.tab-item');
const panels = document.querySelectorAll('.form-panel'); const panels = document.querySelectorAll('.form-panel');
tabs.forEach(tab => { tabs.forEach(tab => {
@@ -523,7 +527,6 @@
} }
}); });
}); });
const eyeBtn = document.getElementById('eyeBtn'); const eyeBtn = document.getElementById('eyeBtn');
const pwdInput = document.getElementById('password'); const pwdInput = document.getElementById('password');
eyeBtn.addEventListener('click', () => { eyeBtn.addEventListener('click', () => {
@@ -533,7 +536,6 @@
? '<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"/><line x1="1" y1="1" x2="23" y2="23"/>' ? '<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"/><line x1="1" y1="1" x2="23" y2="23"/>'
: '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>'; : '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>';
}); });
function getCookieCredentials() { function getCookieCredentials() {
const username = getCookie('username'); const username = getCookie('username');
const password = getCookie('password'); const password = getCookie('password');
@@ -542,23 +544,21 @@
if (password !== undefined) document.getElementById('password').value = password; if (password !== undefined) document.getElementById('password').value = password;
if (rememberMe !== undefined) document.getElementById('rememberMe').checked = Boolean(rememberMe === 'true' || rememberMe === true); if (rememberMe !== undefined) document.getElementById('rememberMe').checked = Boolean(rememberMe === 'true' || rememberMe === true);
} }
getCookieCredentials();
getCookieCredentials();
function handleLogin() { function handleLogin() {
const agree = document.getElementById('agree').checked; const agree = document.getElementById('agree').checked;
if (!agree) { if (!agree) {
showToast('请阅读并同意用户协议!'); showToast('请阅读并同意用户协议!');
return; return;
} }
const username = document.getElementById('username').value.trim(); const username = document.getElementById('username').value.trim();
const password = document.getElementById('password').value; const password = document.getElementById('password').value;
const rememberMe = document.getElementById('rememberMe').checked; const rememberMe = document.getElementById('rememberMe').checked;
const btn = document.getElementById('loginBtn'); const btn = document.getElementById('loginBtn');
if (!username) { showToast('请输入账号'); return; } if (!username) { showToast('请输入账号'); return; }
if (!password) { showToast('请输入密码'); return; } if (!password) { showToast('请输入密码'); return; }
if (rememberMe) { if (rememberMe) {
setCookie('username', username, 30); setCookie('username', username, 30);
setCookie('password', password, 30); setCookie('password', password, 30);
@@ -568,26 +568,25 @@
removeCookie('password'); removeCookie('password');
removeCookie('rememberMe'); removeCookie('rememberMe');
} }
btn.disabled = true; btn.disabled = true;
btn.innerText = '登陆中...'; btn.innerText = '登录中...';
fetch('https://serviceri.satabot.com/login', {
fetch('http://1.95.137.212:8081/login', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password, sourceType: 1 }) body: JSON.stringify({ username, password, sourceType: 1 })
}) })
.then(r => r.json()) .then(r => r.json())
.then(data => { .then(data => {
if (data && data.code === 200 && data.userId) { if (data && data.code === 200 && data.userId) {
const rawUserId = String(data.userId); const rawUserId = String(data.userId);
const encodedUserId = btoa(unescape(encodeURIComponent(rawUserId))); const encodedUserId = btoa(unescape(encodeURIComponent(rawUserId)));
setCookie('token', data.token || ('t_' + Date.now()), 7); setCookie('token', data.token || ('t_' + Date.now()), 7);
setCookie('userId', rawUserId, 7); setCookie('userId', rawUserId, 7);
if (data.userName) setCookie('nickname', data.userName, 7); //if (data.username) setCookie('nickname', data.username, 7);
setTimeout(() => { setTimeout(() => {
window.location.href = './index.html?userId=' + encodedUserId; window.location.href = './index.html?userId=' + encodedUserId;
}, 500); }, 100);
} else { } else {
showToast((data && data.msg) || '账号或密码错误'); showToast((data && data.msg) || '账号或密码错误');
btn.disabled = false; btn.disabled = false;
@@ -600,7 +599,6 @@
btn.innerText = '登录'; btn.innerText = '登录';
}); });
} }
let wxInited = false; let wxInited = false;
function initWxLogin() { function initWxLogin() {
if (wxInited) return; if (wxInited) return;
@@ -621,12 +619,10 @@
console.error('WxLogin init error:', e); console.error('WxLogin init error:', e);
} }
} }
history.pushState(null, null, location.href); history.pushState(null, null, location.href);
window.addEventListener('popstate', () => { window.addEventListener('popstate', () => {
history.pushState(null, null, location.href); history.pushState(null, null, location.href);
}); });
if (getCookie('token') && getCookie('userId')) { if (getCookie('token') && getCookie('userId')) {
const rawUserId = getCookie('userId'); const rawUserId = getCookie('userId');
const encodedUserId = btoa(unescape(encodeURIComponent(rawUserId))); const encodedUserId = btoa(unescape(encodeURIComponent(rawUserId)));
@@ -634,5 +630,4 @@
} }
</script> </script>
</body> </body>
</html> </html>

View File

@@ -750,7 +750,7 @@ app.post("/user", async (req, res) => {
if (!userId && userId != "NaN") { if (!userId && userId != "NaN") {
res.json({ res.json({
code: 300, code: 300,
error: "http://ri.satabot.com/#/login?goRemote=1", error: "https://ai.satabot.com/login.html",
msg: "未找到该用户" msg: "未找到该用户"
}); });
return; return;
@@ -765,7 +765,7 @@ app.post("/user", async (req, res) => {
if (rows.length === 0) { if (rows.length === 0) {
res.json({ res.json({
code: 300, code: 300,
error: "http://ri.satabot.com/#/login?goRemote=1", error: "https://ai.satabot.com/login.html",
msg: "未找到该用户" msg: "未找到该用户"
}); });
return; return;
@@ -836,7 +836,7 @@ app.get("/sessions", async (req, res) => {
code: 300, code: 300,
// error:'https://gsgg.com' // error:'https://gsgg.com'
// error: "http://ri.satabot.com/#/dhhdghgbshwadhg" // error: "http://ri.satabot.com/#/dhhdghgbshwadhg"
error: "http://ri.satabot.com/#/login?goRemote=1" error: "https://ai.satabot.com/login.html"
}); });
return; return;
// return res.status(500).json({ code: 505, error: "http://1.95.137.212/#/login?redirect=%2Findex&goRemote=1" }); // return res.status(500).json({ code: 505, error: "http://1.95.137.212/#/login?redirect=%2Findex&goRemote=1" });

1
wxLogin.js Normal file
View File

@@ -0,0 +1 @@
!function (e, t) { e.WxLogin = function (o) { var n = "default"; !0 === o.self_redirect ? n = "true" : !1 === o.self_redirect && (n = "false"); var r = t.createElement("iframe"), s = (new Date).getTime(), a = "https://open.weixin.qq.com/connect/qrconnect?appid=" + o.appid + "&scope=" + o.scope + "&redirect_uri=" + o.redirect_uri + "&state=" + o.state + "&login_type=jssdk&self_redirect=" + n + "&styletype=" + (o.styletype || "") + "&sizetype=" + (o.sizetype || "") + "&bgcolor=" + (o.bgcolor || "") + "&rst=" + (o.rst || "") + "&ts=" + s; a += o.style ? "&style=" + o.style : "", a += o.href ? "&href=" + o.href : "", a += "en" === o.lang ? "&lang=en" : "", a += 1 === o.stylelite ? "&stylelite=1" : "", a += 0 === o.fast_login ? "&fast_login=0" : "", "auto" === o.color_scheme ? a += "&color_scheme=auto" : "dark" === o.color_scheme ? a += "&color_scheme=dark" : "light" === o.color_scheme && (a += "&color_scheme=light"), r.src = a, r.frameBorder = "0", r.allowTransparency = "true", r.scrolling = "no", r.width = "300px", r.height = "400px", r.allow = "local-network-access"; var c = t.getElementById(o.id); if (c.innerHTML = "", c.appendChild(r), e.addEventListener && e.JSON) { var i = function (t) { if ("https://open.weixin.qq.com" === t.origin) try { var n = JSON.parse(t.data); if (n && "status" === n.type) { var r = "wxReady" === n.status; r && o.onReady && "function" == typeof o.onReady && o.onReady(r), "wxQRcodeReady" === n.status && o.onQRcodeReady && "function" == typeof o.onQRcodeReady && o.onQRcodeReady() } } catch (t) { e.console && "function" == typeof e.console.log && e.console.log("wxLogin postMessage error", t) } }; e.addEventListener("message", i, !1); var l = !1; o.onCleanup = function () { !l && e.removeEventListener && (e.removeEventListener("message", i, !1), l = !0) } } } }(window, document);