01 KT하이오더
02 서빙로봇
03 통신상품
04 제공 서비스
제출되었습니다!
// Local storage
const KEY = 'km_consult_submissions_v1';
const loadAll = () => { try { return JSON.parse(localStorage.getItem(KEY) || '[]'); } catch { return []; } };
const saveAll = (arr) => localStorage.setItem(KEY, JSON.stringify(arr));
// 신청 폼
const contact = document.getElementById('contact');
const openContact = document.getElementById('openContact');
const cancelBtn = document.getElementById('cancelBtn');
const form = document.getElementById('contactForm');
const toast = document.getElementById('toast');
openContact.addEventListener('click', () => contact.showModal());
cancelBtn.addEventListener('click', () => contact.close());
form.addEventListener('submit', (e) => {
e.preventDefault();
const name = document.getElementById('name').value.trim();
const phone = document.getElementById('phone').value.trim();
if (!name || !phone) { alert('이름과 연락처를 입력해주세요.'); return; }
const list = loadAll();
list.push({ ts: new Date().toISOString(), name, phone });
saveAll(list);
if (toast) { toast.style.display = 'block'; setTimeout(() => toast.style.display = 'none', 1800); }
form.reset();
contact.close();
updateBadge();
});
const name = document.getElementById('name').value.trim();
const phone = document.getElementById('phone').value.trim();
if (!name || !phone) { alert('이름과 연락처를 입력해주세요.'); return; }
const list = loadAll();
list.push({ ts: new Date().toISOString(), name, phone });
saveAll(list);
if (toast) { toast.style.display = 'block'; setTimeout(() => toast.style.display = 'none', 1800); }
form.reset();
contact.close();
updateBadge();
});
const name = document.getElementById('name').value.trim();
const phone = document.getElementById('phone').value.trim();
if (!name || !phone) { alert('이름과 연락처를 입력해주세요.'); return; }
try {
const res = await fetch(SUBMIT_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, phone })
});
if (!res.ok) throw new Error('전송 실패: ' + res.status);
toast.style.display = 'block'; setTimeout(() => toast.style.display = 'none', 1800);
form.reset(); contact.close();
} catch (err) {
alert('제출에 실패했습니다. 잠시 후 다시 시도해주세요.
' + err.message);
}
});
const name = document.getElementById('name').value.trim();
const phone = document.getElementById('phone').value.trim();
if (!name || !phone) { alert('이름과 연락처를 입력해주세요.'); return; }
const list = loadAll();
list.push({ ts: new Date().toISOString(), name, phone });
saveAll(list);
toast.style.display = 'block'; setTimeout(() => toast.style.display = 'none', 1800);
form.reset(); contact.close();
});