whatsapp code sending
This commit is contained in:
parent
d5ca8012e6
commit
e48c07aa27
26
index.html
26
index.html
@ -366,7 +366,10 @@ function render(filter = 'all') {
|
|||||||
<span style="color:var(--gray-500)">Родитель: ${o.parentName} (${o.parentPhone})</span><br>
|
<span style="color:var(--gray-500)">Родитель: ${o.parentName} (${o.parentPhone})</span><br>
|
||||||
<span style="color:var(--gray-500)">Код выдачи: <strong style="color:var(--cyan);font-size:20px">${o.code}</strong></span><br>
|
<span style="color:var(--gray-500)">Код выдачи: <strong style="color:var(--cyan);font-size:20px">${o.code}</strong></span><br>
|
||||||
<span style="color:var(--gray-500)">Оплачено: ${o.price} ₸ | ${new Date(o.date).toLocaleString('ru-RU')}</span><br>
|
<span style="color:var(--gray-500)">Оплачено: ${o.price} ₸ | ${new Date(o.date).toLocaleString('ru-RU')}</span><br>
|
||||||
<button class="btn btn-green" style="margin-top:12px;padding:8px 16px" onclick="markAsPickedUp(${o.id})">✅ Товар выдан</button>
|
<div style="display:flex;gap:8px;margin-top:12px">
|
||||||
|
<button class="btn btn-green" style="flex:1;padding:8px 16px" onclick="markAsPickedUp(${o.id})">✅ Товар выдан</button>
|
||||||
|
<button class="btn" style="flex:1;padding:8px 16px;background:#25D366;color:#fff" onclick="resendWhatsApp('${o.parentPhone}','${o.product}',${o.price},'${o.code}')">📱 WhatsApp</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`).join('');
|
`).join('');
|
||||||
}
|
}
|
||||||
@ -499,7 +502,7 @@ function processPayment() {
|
|||||||
product: currentProductForPayment.name,
|
product: currentProductForPayment.name,
|
||||||
price: currentProductForPayment.price,
|
price: currentProductForPayment.price,
|
||||||
parentPhone: phone,
|
parentPhone: phone,
|
||||||
parentName: phone, // Потом родитель представится при получении
|
parentName: phone,
|
||||||
code: orderCode,
|
code: orderCode,
|
||||||
date: new Date().toISOString(),
|
date: new Date().toISOString(),
|
||||||
pickedUp: false,
|
pickedUp: false,
|
||||||
@ -511,10 +514,21 @@ function processPayment() {
|
|||||||
|
|
||||||
closePaymentModal();
|
closePaymentModal();
|
||||||
|
|
||||||
document.getElementById('success-message').textContent = `✅ Оплата прошла успешно!\n\nВаш код выдачи: ${orderCode}\n\nПокажите этот код в магазине и получите товар.`;
|
// Отправка в WhatsApp
|
||||||
|
const whatsappMessage = `✅ *Оплата в школьном магазине*\n\nТовар: ${order.product}\nЦена: ${order.price} ₸\n\n🔑 *Ваш код выдачи: ${orderCode}*\n\nПокажите этот код продавцу и получите товар.\nСпасибо за покупку! 🏪`;
|
||||||
|
const whatsappUrl = `https://wa.me/${phone.replace(/\D/g, '')}?text=${encodeURIComponent(whatsappMessage)}`;
|
||||||
|
|
||||||
|
document.getElementById('success-message').textContent = `✅ Оплата прошла успешно!\n\nКод отправлен в WhatsApp на номер ${phone}`;
|
||||||
document.getElementById('success-code').textContent = orderCode;
|
document.getElementById('success-code').textContent = orderCode;
|
||||||
document.getElementById('success-modal').classList.add('on');
|
document.getElementById('success-modal').classList.add('on');
|
||||||
|
|
||||||
|
// Открываем WhatsApp через 1 секунду
|
||||||
|
setTimeout(() => {
|
||||||
|
if (confirm('📱 Открыть WhatsApp для отправки кода родителю?')) {
|
||||||
|
window.open(whatsappUrl, '_blank');
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
currentProductForPayment = null;
|
currentProductForPayment = null;
|
||||||
document.getElementById('pay-phone').value = '';
|
document.getElementById('pay-phone').value = '';
|
||||||
}
|
}
|
||||||
@ -568,6 +582,12 @@ function markAsPickedUp(orderId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resendWhatsApp(phone, product, price, code) {
|
||||||
|
const message = `✅ *Оплата в школьном магазине*\n\nТовар: ${product}\nЦена: ${price} ₸\n\n🔑 *Ваш код выдачи: ${code}*\n\nПокажите этот код продавцу и получите товар.\nСпасибо за покупку! 🏪`;
|
||||||
|
const url = `https://wa.me/${phone.replace(/\D/g, '')}?text=${encodeURIComponent(message)}`;
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
|
|
||||||
// === Родители ===
|
// === Родители ===
|
||||||
document.getElementById('parent-form').addEventListener('submit', (e) => {
|
document.getElementById('parent-form').addEventListener('submit', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user