PetMap: кнопка WhatsApp сразу открывает чат с сообщением

This commit is contained in:
Medet 2026-08-07 06:37:19 +00:00
parent 7375fc9dcd
commit 1bc1041267

View File

@ -576,7 +576,7 @@
<p class="preview-desc" id="preview-desc">Описание</p>
<div class="preview-contact" id="preview-contact"></div>
<div class="preview-actions">
<button class="preview-btn call" id="preview-call">📞 Позвонить</button>
<button class="preview-btn call" id="preview-whatsapp">💬 Написать в WhatsApp</button>
<button class="preview-btn primary" id="preview-share">📤 Поделиться</button>
<button class="preview-btn secondary" id="preview-close">Закрыть</button>
</div>
@ -970,7 +970,15 @@
<strong>📞 Контакт:</strong><br>
<a href="tel:${item.contact}" style="color: var(--primary); text-decoration: none; font-size: 16px;">${item.contact}</a>
`;
document.getElementById('preview-call').onclick = () => window.open(`tel:${item.contact}`);
// WhatsApp кнопка — сразу переход
document.getElementById('preview-whatsapp').onclick = () => {
const phone = item.contact.replace(/[^0-9]/g, ''); // Удаляем всё кроме цифр
const msg = encodeURIComponent(`Здравствуйте! Пишу по объявлению: ${item.title}\n${item.description}`);
const waUrl = `https://wa.me/${phone}?text=${msg}`;
window.open(waUrl, '_blank');
};
document.getElementById('preview-share').onclick = () => {
const shareData = {
title: item.title,