Skip to content

登录注册

输入验证码!', 'error'); return; } if (!password) { showMessage('请输入新密码!', 'error'); return; } if (password !== confirmPassword) { showMessage('两次输入的密码不一致!', 'error'); return; } // 显示加载状态 const submitBtn = resetForm.querySelector('button[type="submit"]'); const originalText = submitBtn.textContent; submitBtn.textContent = '重置中...'; submitBtn.disabled = true; // 发送AJAX请求 fetch(`${baseUrl}/fty/resetpwd`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ type: 1, // 固定为邮箱类型 username: email, code: verificationCode, password: password, confirm_password: confirmPassword }) }) .then(response => response.json()) .then(data => { console.log("重置密码返回",data); if (data.code==2000) { showMessage('密码重置成功!请使用新密码登录', 'success'); resetResetCountdown(); // 延迟切换到登录标签 setTimeout(() => { switchTab('login'); // 清空重置表单 resetForm.reset(); }, 1500); } else { showMessage(data.msg || '密码重置失败,请检查输入信息!', 'error'); } }) .catch(error => { console.error('Error:', error); showMessage('密码重置请求失败,请稍后重试!', 'error'); }) .finally(() => { // 恢复按钮状态 submitBtn.textContent = originalText; submitBtn.disabled = false; }); } // 页面加载时检查登录状态 document.addEventListener('DOMContentLoaded', async function() { const isLoggedIn = await validateToken(); if (isLoggedIn) { showMessage('您已经登录,正在跳转到首页...', 'info'); setTimeout(() => { window.location.href = '/'; }, 2000); } }); })(); // 立即执行函数结束