Skip to content
// 🔥 COUNTDOWN
let slot = 7;
setInterval(() => {
if (slot > 1) {
slot--;
$("#countdown-slot").text(slot);
} else {
slot = Math.floor(Math.random() * 3) + 3;
}
}, 5000);
// 🔥 VALIDATE
function isValidPhone(phone) {
return /^(0|+84)[0-9]{8,9}$/.test(phone);
}
// 🔥 GỬI LEAD CHUNG
function sendLead(phone, msgBox) {
if (!isValidPhone(phone)) {
$(msgBox).html("❌ Số chưa đúng");
return;
}
$.ajax({
type: "post",
url: devvn_laivay_array.ajaxurl,
data: {
action: "save_lead",
phone: phone,
url: window.location.href
},
beforeSend: function () {
$(msgBox).html("⏳ Đang giữ căn...");
},
success: function () {
$(msgBox).html("🔥 Thành công!");
// 👉 TRACK FB
if (typeof fbq !== 'undefined') {
fbq('track', 'Lead');
}
setTimeout(() => {
window.location.href = "https://zalo.me/0900000000";
}, 1500);
}
});
}
// 👉 FORM 1
$(document).on("click", "#btn_send_lead", function () {
sendLead($("#phone_lead").val(), ".lead-msg");
});
// 👉 FORM 2
function sendLead2() {
sendLead($("#phone_lead_2").val(), "#msg2");
}
// 👉 POPUP
function sendLeadPopup() {
sendLead($("#phone_lead_popup").val(), "#msg_popup");
}
// 🔥 POPUP DELAY
setTimeout(() => {
$("#popup-lead").fadeIn();
}, 5000);
// 🔥 SOCIAL PROOF
setInterval(() => {
let names = ["Anh Minh", "Chị Lan", "Anh Tuấn", "Chị Hương"];
let random = names[Math.floor(Math.random() * names.length)];
$(".fake-noti").fadeIn().text(`${random} vừa giữ 1 căn`);
setTimeout(() => {
$(".fake-noti").fadeOut();
}, 3000);
}, 7000);