更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

-61
View File
@@ -30,7 +30,6 @@
.login-page { display: flex; min-height: 100vh; width: 100%; }
/* ---------- 左侧品牌区 ---------- */
.brand-panel {
position: relative;
flex: 1 1 58%;
@@ -59,7 +58,6 @@
border-radius: 50%;
background: rgba(255, 255, 255, 0.08);
}
/* 配置了背景图:浅色底 + 深色文字,叠一层白色蒙版保证可读性 */
.brand-panel.has-bg { background: #eaf1fb; color: var(--text); }
.brand-panel.has-bg::before,
.brand-panel.has-bg::after { display: none; }
@@ -132,7 +130,6 @@
.brand-panel.has-bg .brand-foot { color: var(--muted); }
.brand-foot svg { width: 13px; height: 13px; flex: 0 0 auto; }
/* ---------- 右侧表单区 ---------- */
.form-panel {
position: relative;
flex: 0 0 42%;
@@ -150,7 +147,6 @@
.panel-title { font-size: 30px; font-weight: 700; letter-spacing: .5px; }
.panel-sub { margin-top: 10px; font-size: 13.5px; color: var(--text-sub); line-height: 1.7; }
/* ---------- 登录方式 tab ---------- */
.login-tabs {
display: flex;
gap: 4px;
@@ -181,7 +177,6 @@
}
.login-panel { display: none; }
/* ---------- 登录方式全部关闭 ---------- */
.login-disabled {
display: flex;
flex-direction: column;
@@ -212,7 +207,6 @@
to { opacity: 1; transform: none; }
}
/* 表单上方品牌 Logo 区:显示在「登录」字样上方 */
.form-brand { display: flex; align-items: center; margin-bottom: 24px; }
.form-brand-img { height: 42px; max-width: 240px; object-fit: contain; display: block; }
.form-brand-fallback { display: inline-flex; align-items: center; gap: 12px; }
@@ -238,7 +232,6 @@
font-size: 12px;
color: #a3acbf;
}
/* 底部「清除缓存」文字按钮 */
.cache-clear-btn {
border: 0;
background: none;
@@ -266,7 +259,6 @@
animation: shake .32s ease;
}
.error.show { display: flex; }
/* 中性的提示语气(功能未上线 / 操作引导) */
.error.is-info { background: #f2f7ff; border-color: #d2e2ff; color: #2b5fc7; }
.error svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px; }
@keyframes shake {
@@ -377,7 +369,6 @@
.btn.is-loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
/* 第三方登录 */
.third-area { margin-top: 4px; }
.divider {
position: relative; text-align: center;
@@ -407,7 +398,6 @@
background: #f5f9ff;
transform: translateY(-1px);
}
/* 第三方图标色块:微信绿 / QQ 蓝 / 其余统一主色 */
.third-icon {
width: 22px; height: 22px;
flex: 0 0 22px;
@@ -420,7 +410,6 @@
.third-icon.is-qq { background: rgba(18, 183, 245, .14); color: #12b7f5; }
.third-icon.is-generic { background: rgba(57, 115, 255, .10); color: var(--primary); }
/* 短信验证码 */
.code-row { display: flex; align-items: center; gap: 10px; }
.code-row .input-wrap { flex: 1 1 auto; }
.code-btn {
@@ -441,7 +430,6 @@
.code-btn:disabled { background: #f5f7fb; border-color: var(--border); color: var(--muted); cursor: not-allowed; }
.form-hint { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.8; text-align: center; }
/* 企业选择 */
.tenant-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.tenant-item {
display: flex; align-items: center; gap: 14px;
@@ -479,7 +467,6 @@
.back { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-sub); line-height: 1.7; }
/* ---------- 扫码登录 ---------- */
.qr-panel { padding: 4px 0 2px; text-align: center; }
.qr-box {
position: relative;
@@ -543,7 +530,6 @@
</head>
<body>
<div class="login-page">
<!-- 左侧品牌区:背景图 / 主副标题由 platform「平台设置 → 登录页设置」提供 -->
<aside class="brand-panel{{if .LoginBg}} has-bg{{end}}">
{{if .LoginBg}}
<img class="brand-bg" src="{{.LoginBg}}" alt="" />
@@ -574,10 +560,8 @@
</div>
</aside>
<!-- 右侧表单区 -->
<main class="form-panel">
<div class="form-inner">
<!-- 品牌 Logo 区:显示在「登录」字样上方 -->
<div class="form-brand">
{{if .LoginLogo}}
<img class="form-brand-img" src="{{.LoginLogo}}" alt="温新云科技 - 统一认证中心" />
@@ -631,7 +615,6 @@
{{else}}
<div class="panel-head">
<h1 class="panel-title">欢迎登陆您的工作空间</h1>
<!-- <p class="panel-sub"></p> -->
</div>
<div class="error" id="error">
@@ -642,7 +625,6 @@
</div>
{{if .LoginDisabled}}
<!-- 平台设置已关闭全部登录方式 -->
<div class="login-disabled">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<rect x="4" y="11" width="16" height="10" rx="2"/><path d="M8 11V8a4 4 0 018 0v3"/>
@@ -651,7 +633,6 @@
<p class="login-disabled-desc">管理员已在平台设置中关闭全部登录方式,请联系管理员开启后再试。</p>
</div>
{{else}}
<!-- 登录方式切换:按平台设置的开关渲染,默认选中第一个可用方式 -->
{{if .LoginShowTabs}}
<div class="login-tabs" role="tablist">
{{if .LoginPwdOn}}<button class="login-tab{{if eq .LoginDefaultTab "account"}} active{{end}}" type="button" role="tab" data-tab="account" onclick="switchLoginTab('account')">账号密码</button>{{end}}
@@ -660,7 +641,6 @@
</div>
{{end}}
<!-- 账号密码登录 -->
{{if .LoginPwdOn}}
<div class="login-panel{{if eq .LoginDefaultTab "account"}} active{{end}}" id="panel-account">
{{if .Notice}}
@@ -718,7 +698,6 @@
</div>
{{end}}
<!-- 手机号验证码登录 -->
{{if .LoginSmsOn}}
<div class="login-panel{{if eq .LoginDefaultTab "sms"}} active{{end}}" id="panel-sms">
<form onsubmit="return submitSmsLogin(event)" autocomplete="on">
@@ -754,7 +733,6 @@
</div>
{{end}}
<!-- 扫码登录:微信扫码 → 小程序内确认 -->
{{if .LoginQrOn}}
<div class="login-panel{{if eq .LoginDefaultTab "qr"}} active{{end}}" id="panel-qr">
<div class="qr-panel">
@@ -772,7 +750,6 @@
</div>
{{end}}
<!-- 第三方登录(未配置时点击提示即将上线) -->
<div class="third-area" id="thirdArea">
<div class="divider"><span>其他登录方式</span></div>
<div class="third-list" id="thirdList">
@@ -806,9 +783,7 @@
var CLIENT_ID = "{{.ClientID}}";
var REDIRECT = "{{.Redirect}}";
// 人机验证配置:页面加载时拉取,决定是否弹出极验
var verifyCfg = { openVerify: 0, verifyType: '', needGeetest: false, geetestVersion: '4', captchaId: '' };
// 极验 4.0 SDK:优先官方 CDN,失败回退到本地副本(static/js/gt4.js)
var GEETEST_SDK_CDN = 'https://static.geetest.com/v4/gt4.js';
var GEETEST_SDK_LOCAL = '/static/js/gt4.js';
var geetestSDKPromise = null;
@@ -829,7 +804,6 @@
if (box) box.classList.remove('show');
}
// ==================== 登录方式切换(账号密码 / 短信 / 扫码) ====================
var LOGIN_PANELS = { account: 'panel-account', sms: 'panel-sms', qr: 'panel-qr' };
function switchLoginTab(name) {
@@ -843,7 +817,6 @@
if (panel) panel.classList.toggle('active', key === name);
});
hideError();
// 扫码 tab 才拉二维码,离开则停止轮询
if (name === 'qr') restartWechatScan(); else stopWechatScan();
}
@@ -872,7 +845,6 @@
btn.title = show ? '隐藏密码' : '显示密码';
}
// 记住账号:只存账号,绝不明文保存密码
(function initRemember() {
var box = document.getElementById('remember');
if (!box) return;
@@ -901,7 +873,6 @@
});
}
// 加载极验 4.0 SDK(多次调用只加载一次)
function loadGeetestSDK() {
if (window.initGeetest4) return Promise.resolve();
if (geetestSDKPromise) return geetestSDKPromise;
@@ -917,7 +888,6 @@
return geetestSDKPromise;
}
// 拉取登录验证配置(含极验 captcha_id)
function loadVerifyConfig() {
return fetch('/auth/verify-config')
.then(function (r) { return r.json(); })
@@ -928,7 +898,6 @@
verifyCfg.needGeetest = !!d.needGeetest;
verifyCfg.geetestVersion = d.geetestVersion || '4';
verifyCfg.captchaId = d.captchaId || '';
// 预加载 SDK,点击登录时能立刻弹出
if (verifyCfg.needGeetest && verifyCfg.captchaId) {
loadGeetestSDK().catch(function () { /* 点击时再提示 */ });
}
@@ -938,7 +907,6 @@
loadVerifyConfig();
// 已开通的第三方登录方式:记录状态,供静态 QQ / 微信入口判断是否可用
var thirdEnabled = {};
var THIRD_STATIC = { wechat: 1, qq: 1 };
@@ -950,7 +918,6 @@
.then(function (res) {
var list = (res && res.data) || [];
thirdEnabled = {};
// 清掉上一轮动态追加的按钮(静态 QQ / 微信入口保留)
Array.prototype.slice.call(box.querySelectorAll('[data-dynamic="1"]')).forEach(function (n) {
if (n.parentNode) n.parentNode.removeChild(n);
});
@@ -970,7 +937,6 @@
btn.onclick = function () { startThird(item.provider); };
box.appendChild(btn);
});
// 未开通的入口:保留样式,悬停提示即将上线,点击给中性提示
Array.prototype.forEach.call(box.querySelectorAll('[data-third-provider]'), function (btn) {
var provider = btn.getAttribute('data-third-provider');
btn.title = thirdEnabled[provider] ? '' : '即将上线';
@@ -991,7 +957,6 @@
loadThirdProviders();
// 弹出极验 4.0,验证通过才 resolve 出校验参数
function showGeetest(captchaId) {
return loadGeetestSDK().then(function () {
return new Promise(function (resolve, reject) {
@@ -1050,7 +1015,6 @@
});
}
// ==================== 手机号验证码登录(仅样式,接口待接入) ====================
function sendSmsCode() {
var input = document.getElementById('smsMobile');
var mobile = input ? input.value.trim() : '';
@@ -1079,13 +1043,11 @@
if (!account) { showError('请输入账号'); return false; }
if (!password) { showError('请输入密码'); return false; }
// 记住账号
try {
if (document.getElementById('remember').checked) localStorage.setItem('authCenterAccount', account);
else localStorage.removeItem('authCenterAccount');
} catch (err) { /* ignore */ }
// 开启极验时:先弹验证,通过后才继续登录
if (verifyCfg.needGeetest) {
if (!verifyCfg.captchaId) {
showError('人机验证未配置,请联系管理员');
@@ -1136,7 +1098,6 @@
return;
}
if (res.redirect) { window.location.href = res.redirect; return; }
// 会话已建立但确实没有回跳地址:明确提示,绝不再跳回登录页造成死循环
showError('登录成功,但未获取到回跳地址,请从业务系统重新进入');
setBtnLoading(false);
})
@@ -1168,20 +1129,10 @@
});
}
/**
* 清除本站在当前浏览器里的全部缓存数据。
*
* localStorage / sessionStorage / document.cookie / Cache Storage /
* IndexedDB / Service Worker 都受同源策略约束,只会作用于认证中心自己的
* origin,不会影响 back.yunzer.cn 等其它站点。
* HttpOnly 的 yz_sid 前端读不到,交给 /auth/clear-site-data 的
* Clear-Site-Data 响应头与 Set-Cookie 一起清除。
*/
function clearSiteCache() {
var btn = document.getElementById('cacheClearBtn');
if (btn) { btn.disabled = true; btn.textContent = '清除中...'; }
// 1. Web Storage(记住账号、各类前端状态)
try {
localStorage.clear();
sessionStorage.clear();
@@ -1204,21 +1155,18 @@
var tasks = [];
// 3. Cache Storage(离线资源 / 静态资源缓存)
if (window.caches && caches.keys) {
tasks.push(caches.keys().then(function (keys) {
return Promise.all((keys || []).map(function (key) { return caches.delete(key); }));
}).catch(function () {}));
}
// 4. Service Worker 注册
if (navigator.serviceWorker && navigator.serviceWorker.getRegistrations) {
tasks.push(navigator.serviceWorker.getRegistrations().then(function (regs) {
return Promise.all((regs || []).map(function (reg) { return reg.unregister(); }));
}).catch(function () {}));
}
// 5. IndexedDB(databases() 在部分浏览器不可用,跳过即可)
if (window.indexedDB && indexedDB.databases) {
tasks.push(indexedDB.databases().then(function (dbs) {
return Promise.all((dbs || []).map(function (db) {
@@ -1228,16 +1176,12 @@
var finish = function () { if (!done) { done = true; resolve(); } };
var req = indexedDB.deleteDatabase(db.name);
req.onsuccess = req.onerror = req.onblocked = finish;
// 其它标签页占用数据库时 onblocked 可能不触发,兜底避免卡住
setTimeout(finish, 1500);
});
}));
}).catch(function () {}));
}
// 6. 后端清 HttpOnly 会话 Cookie,并让浏览器按 origin 清 HTTP 缓存与存储;
// 服务尚未部署新端点(404)或接口异常时退回已有登出接口,
// 至少保证会话 Cookie 被清除;整体超时也不阻断前面的前端清理结果
var legacyClear = function () {
return fetch('/auth/logout', { method: 'POST', credentials: 'same-origin', cache: 'no-store' })
.catch(function () {});
@@ -1256,19 +1200,15 @@
]));
Promise.all(tasks).then(function () {
// 保留 client_id / redirect,清完直接从登录页重新开始
window.location.replace('/auth/login?client_id=' + encodeURIComponent(CLIENT_ID) +
(REDIRECT ? '&redirect=' + encodeURIComponent(REDIRECT) : ''));
});
}
// ==================== 微信扫码登录(扫码 → 小程序内确认;已接 scan/start、scan/status) ====================
var scanScene = '';
var scanExpireAt = 0;
var scanPollTimer = null;
// 显隐由 switchLoginTab 控制,切换 tab 时自动启停轮询
function stopWechatScan() {
if (scanPollTimer) { clearInterval(scanPollTimer); scanPollTimer = null; }
}
@@ -1303,7 +1243,6 @@
} else {
setScanQrMask('暂无二维码', true);
}
// 回退原因只写控制台,不在页面展示
if (d.notice && window.console) console.warn('[wechat-scan]', d.notice);
scanPollTimer = setInterval(pollWechatScan, 3000);
})