let countdown = 0; let timer = null; function checkInputs() { const phone = document.getElementById('phoneInput').value; const code = document.getElementById('codeInput').value; const btn = document.getElementById('bindBtn'); if (phone.length === 11 && code.length >= 4) { btn.style.opacity = '1'; } else { btn.style.opacity = '0.6'; } } function getCode() { const phone = document.getElementById('phoneInput').value; if (phone.length !== 11) { alert('请输入正确的手机号'); return; } if (countdown > 0) return; const loadingOverlay = document.getElementById('loadingOverlay'); loadingOverlay.style.display = 'flex'; setTimeout(() => { loadingOverlay.style.display = 'none'; startCountdown(); }, 1500); } function startCountdown() { countdown = 60; const btn = document.getElementById('getCodeBtn'); timer = setInterval(() => { countdown--; if (countdown <= 0) { clearInterval(timer); btn.textContent = '获取验证码'; btn.style.color = '#333'; } else { btn.textContent = `${countdown}s`; btn.style.color = '#999'; } }, 1000); } function doBind() { const phone = document.getElementById('phoneInput').value; const code = document.getElementById('codeInput').value; if (phone.length !== 11) { alert('请输入正确的手机号'); return; } if (code.length < 4) { alert('请输入验证码'); return; } const toastOverlay = document.getElementById('toastOverlay'); toastOverlay.style.display = 'flex'; setTimeout(() => { toastOverlay.style.display = 'none'; localStorage.setItem('isBound', 'true'); window.location.href = 'profile.html'; }, 1500); } document.addEventListener('DOMContentLoaded', function() { document.getElementById('bindBtn').style.opacity = '0.6'; });