import { state } from './state.js'; export const Login = { render(onLoginSuccess) { const container = document.getElementById('view-container'); container.innerHTML = `

欢迎回来

开启你的数字生命档案

登录即代表同意《用户协议》与《隐私政策》,我们将妥善保管您的生命数据。

`; const phoneInput = document.getElementById('login-phone'); const codeInput = document.getElementById('login-code'); const codeBtn = document.getElementById('get-code-btn'); const loginBtn = document.getElementById('login-submit'); codeBtn.onclick = () => { if (phoneInput.value.length !== 11) return alert('请输入正确的手机号'); codeBtn.disabled = true; let count = 60; const timer = setInterval(() => { codeBtn.innerText = `${count}S`; count--; if (count < 0) { clearInterval(timer); codeBtn.disabled = false; codeBtn.innerText = '获取'; } }, 1000); alert('验证码已发送 (模拟验证码: 888888)'); }; loginBtn.onclick = () => { if (phoneInput.value.length === 11 && codeInput.value === '888888') { state.isLoggedIn = true; state.phone = phoneInput.value; state.save(); onLoginSuccess(); } else { alert('验证失败,请检查手机号或验证码'); } }; } };