grereegrerg
This commit is contained in:
parent
5ca5bc07a2
commit
8f00705265
@ -2,25 +2,100 @@
|
|||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Connexion WhatsApp</title>
|
<title>Connexion WhatsApp & Envoi Interactif</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: Arial, sans-serif; max-width: 600px; margin: auto; padding: 20px; }
|
||||||
|
h1, h2 { text-align: center; }
|
||||||
|
#qrcode { text-align: center; margin-bottom: 20px; }
|
||||||
|
form { display: flex; flex-direction: column; gap: 10px; }
|
||||||
|
label { display: flex; flex-direction: column; font-weight: bold; }
|
||||||
|
input { padding: 8px; font-size: 1rem; }
|
||||||
|
button { padding: 10px; font-size: 1rem; cursor: pointer; }
|
||||||
|
#result { margin-top: 15px; font-weight: bold; }
|
||||||
|
hr { margin: 30px 0; }
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Scanne le QR Code WhatsApp</h1>
|
<h1>Scanne le QR Code WhatsApp</h1>
|
||||||
<div id="qrcode">Chargement...</div>
|
<div id="qrcode">Chargement...</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2>Envoyer du message interactif avec image</h2>
|
||||||
|
<form id="interactiveForm">
|
||||||
|
<label>
|
||||||
|
Téléphone (sans +, ex: 33612345678):
|
||||||
|
<input type="text" name="phone" required placeholder="33612345678">
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Caption:
|
||||||
|
<input type="text" name="caption" placeholder="Description par défaut">
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Title:
|
||||||
|
<input type="text" name="title" placeholder="Titre par défaut">
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Subtitle:
|
||||||
|
<input type="text" name="subtitle" placeholder="Sous-titre">
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Footer:
|
||||||
|
<input type="text" name="footer" placeholder="Pied de page">
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
URL Proposition:
|
||||||
|
<input type="url" name="propositionUrl" placeholder="https://exemple.com/prop.pdf" required>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
URL Spec Machine:
|
||||||
|
<input type="url" name="specUrl" placeholder="https://exemple.com/spec.pdf" required>
|
||||||
|
</label>
|
||||||
|
<button type="submit">Envoyer le message</button>
|
||||||
|
</form>
|
||||||
|
<div id="result"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// Vérification du QR code et statut de connexion
|
||||||
async function checkQR() {
|
async function checkQR() {
|
||||||
const res = await fetch('/api/qrcode');
|
try {
|
||||||
const data = await res.json();
|
const res = await fetch('/api/qrcode');
|
||||||
if (data.connected) {
|
const data = await res.json();
|
||||||
document.getElementById('qrcode').innerHTML = '✅ Connecté à WhatsApp !';
|
const qrContainer = document.getElementById('qrcode');
|
||||||
} else if (data.qr) {
|
if (data.connected) {
|
||||||
document.getElementById('qrcode').innerHTML = `<img src="${data.qr}" />`;
|
qrContainer.innerHTML = '✅ Connecté à WhatsApp !';
|
||||||
|
} else if (data.qr) {
|
||||||
|
qrContainer.innerHTML = `<img src="${data.qr}" alt="QR Code WhatsApp" width="200" height="200"/>`;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Erreur checkQR:', err);
|
||||||
}
|
}
|
||||||
setTimeout(checkQR, 3000);
|
setTimeout(checkQR, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkQR();
|
checkQR();
|
||||||
|
|
||||||
|
// Envoi du formulaire interactif
|
||||||
|
document.getElementById('interactiveForm').addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const formData = new FormData(e.target);
|
||||||
|
const body = {};
|
||||||
|
formData.forEach((value, key) => body[key] = value);
|
||||||
|
|
||||||
|
const res = await fetch('/sendInteractiveImage', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(body)
|
||||||
|
});
|
||||||
|
const data = await res.json();
|
||||||
|
const resultDiv = document.getElementById('result');
|
||||||
|
if (data.success) {
|
||||||
|
resultDiv.textContent = '✅ Message envoyé avec succès';
|
||||||
|
resultDiv.style.color = 'green';
|
||||||
|
} else {
|
||||||
|
resultDiv.textContent = '❌ Erreur : ' + (data.error || 'Inconnue');
|
||||||
|
resultDiv.style.color = 'red';
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user