commit
This commit is contained in:
79
figma_html_page/js/phone-login.js
Normal file
79
figma_html_page/js/phone-login.js
Normal file
@@ -0,0 +1,79 @@
|
||||
let countdown = 0;
|
||||
let timer = null;
|
||||
|
||||
function checkInputs() {
|
||||
const phone = document.getElementById('phoneInput').value;
|
||||
const code = document.getElementById('codeInput').value;
|
||||
const btn = document.getElementById('loginBtn');
|
||||
|
||||
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 doLogin() {
|
||||
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('isLoggedIn', 'true');
|
||||
localStorage.setItem('userName', '星阿星');
|
||||
localStorage.setItem('userCompany', '北京乐航时代科技有限公司');
|
||||
window.location.href = 'select-product.html';
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.getElementById('loginBtn').style.opacity = '0.6';
|
||||
});
|
||||
Reference in New Issue
Block a user