parent self registration
This commit is contained in:
parent
e48c07aa27
commit
798b9b4d48
85
index.html
85
index.html
@ -87,8 +87,9 @@ body{font:17px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
|||||||
|
|
||||||
<div style="text-align:center;margin-top:40px;display:flex;gap:16px;justify-content:center;flex-wrap:wrap">
|
<div style="text-align:center;margin-top:40px;display:flex;gap:16px;justify-content:center;flex-wrap:wrap">
|
||||||
<button class="btn" onclick="openParentCodeModal()" style="background:var(--green);color:#fff">👨👩👧 Получить код родителя</button>
|
<button class="btn" onclick="openParentCodeModal()" style="background:var(--green);color:#fff">👨👩👧 Получить код родителя</button>
|
||||||
|
<button class="btn" onclick="openParentRegisterModal()" style="background:#FF5500;color:#fff">👨👩👧 Родителям: регистрация</button>
|
||||||
|
<button class="btn" onclick="openPaymentModal()" style="background:#FF5500;color:#fff">💳 Оплатить онлайн</button>
|
||||||
<button class="btn" onclick="showPage('admin');setTimeout(() => document.getElementById('nav-admin').click(), 100)" style="background:var(--ink);color:#fff">➕ Добавить товар</button>
|
<button class="btn" onclick="showPage('admin');setTimeout(() => document.getElementById('nav-admin').click(), 100)" style="background:var(--ink);color:#fff">➕ Добавить товар</button>
|
||||||
<button class="btn" onclick="openPaymentModal()" style="background:#FF5500;color:#fff">💳 Родителям: оплатить онлайн</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@ -231,6 +232,28 @@ body{font:17px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal" id="parent-register-modal">
|
||||||
|
<div class="modal-content">
|
||||||
|
<h3>👨👩👧 Регистрация родителя</h3>
|
||||||
|
<p style="margin-bottom:20px">Контролируйте покупки ребёнка — установите лимит и получайте код</p>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Ваше имя</label>
|
||||||
|
<input type="text" id="reg-name" placeholder="Иванова Мария" style="width:100%;padding:12px;border:1px solid #ddd;border-radius:8px;margin-bottom:12px">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Телефон</label>
|
||||||
|
<input type="tel" id="reg-phone" placeholder="+7 777 123 45 67" style="width:100%;padding:12px;border:1px solid #ddd;border-radius:8px;margin-bottom:12px">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Лимит на день (₸)</label>
|
||||||
|
<input type="number" id="reg-limit" placeholder="1000" style="width:100%;padding:12px;border:1px solid #ddd;border-radius:8px;margin-bottom:12px">
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-green" onclick="registerParent()" style="width:100%">Зарегистрироваться</button>
|
||||||
|
<button class="btn" style="background:var(--gray-100);margin-top:12px;width:100%" onclick="closeParentRegisterModal()">Отмена</button>
|
||||||
|
<p style="margin-top:16px;font-size:13px;color:var(--gray-500)">После регистрации вы получите персональный код для ребёнка</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// === Данные ===
|
// === Данные ===
|
||||||
const CATEGORIES = {еда:'🍫', напитки:'🥤', школа:'✏️', разное:'🎁'};
|
const CATEGORIES = {еда:'🍫', напитки:'🥤', школа:'✏️', разное:'🎁'};
|
||||||
@ -470,6 +493,66 @@ function closeParentModal() {
|
|||||||
document.getElementById('parent-code-modal').classList.remove('on');
|
document.getElementById('parent-code-modal').classList.remove('on');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openParentRegisterModal() {
|
||||||
|
document.getElementById('parent-register-modal').classList.add('on');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeParentRegisterModal() {
|
||||||
|
document.getElementById('parent-register-modal').classList.remove('on');
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerParent() {
|
||||||
|
const name = document.getElementById('reg-name').value.trim();
|
||||||
|
const phone = document.getElementById('reg-phone').value.trim();
|
||||||
|
const limit = Number(document.getElementById('reg-limit').value);
|
||||||
|
|
||||||
|
if (!name || !phone || !limit) {
|
||||||
|
alert('Заполните все поля!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверяем, есть ли уже такой родитель
|
||||||
|
const exists = parents.find(p => p.phone === phone);
|
||||||
|
if (exists) {
|
||||||
|
alert('Такой родитель уже зарегистрирован! Ваш код: ' + exists.code);
|
||||||
|
closeParentRegisterModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const parent = {
|
||||||
|
id: Date.now(),
|
||||||
|
name: name,
|
||||||
|
phone: phone,
|
||||||
|
limit: limit,
|
||||||
|
code: generateCode()
|
||||||
|
};
|
||||||
|
|
||||||
|
parents.push(parent);
|
||||||
|
saveProducts();
|
||||||
|
render();
|
||||||
|
|
||||||
|
closeParentRegisterModal();
|
||||||
|
|
||||||
|
// Очищаем форму
|
||||||
|
document.getElementById('reg-name').value = '';
|
||||||
|
document.getElementById('reg-phone').value = '';
|
||||||
|
document.getElementById('reg-limit').value = '';
|
||||||
|
|
||||||
|
// Показываем код
|
||||||
|
document.getElementById('success-message').textContent = `✅ Вы зарегистрированы!\n\nВаш код: ${parent.code}\n\nСообщите этот код ребёнку. Он будет использовать его для покупок.`;
|
||||||
|
document.getElementById('success-code').textContent = parent.code;
|
||||||
|
document.getElementById('success-modal').classList.add('on');
|
||||||
|
|
||||||
|
// Предлагаем отправить код в WhatsApp
|
||||||
|
setTimeout(() => {
|
||||||
|
const message = `✅ Вы зарегистрированы в школьном магазине!\n\nВаш код: *${parent.code}*\nЛимит: ${limit} ₸ в день\n\nСообщите этот код ребёнку для покупок.`;
|
||||||
|
const url = `https://wa.me/${phone.replace(/\D/g, '')}?text=${encodeURIComponent(message)}`;
|
||||||
|
if (confirm('📱 Отправить себе код в WhatsApp?')) {
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
let currentProductForPayment = null;
|
let currentProductForPayment = null;
|
||||||
|
|
||||||
function openPaymentModal() {
|
function openPaymentModal() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user