iachat/app/views/public/landing_pages/show.html.erb

197 lines
6.1 KiB
Plaintext

<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><%= @landing_host&.page_title.presence || 'Atendimento WhatsApp' %></title>
<link id="pageFavicon" rel="icon" type="image/png" href="<%= @landing_host&.logo_url || 'https://iachat.hoteis1001noites.com.br/assets/images/dashboard/captain/logo.svg' %>" />
<style>
:root {
--bg-1: #040b18;
--bg-2: #031325;
--card: #0f1729;
--card-border: #1f2c43;
--text-1: #e7ecf6;
--text-2: #96a2b5;
--btn: <%= @landing_host&.theme_color.presence || '#27c15b' %>;
--btn-text: #f4fff7;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
color: var(--text-1);
background:
radial-gradient(circle at 50% 52%, rgba(31, 150, 91, 0.18), transparent 34%),
radial-gradient(circle at 30% 30%, rgba(16, 92, 172, 0.16), transparent 46%),
linear-gradient(170deg, var(--bg-2), var(--bg-1));
}
.page {
min-height: 100vh;
display: grid;
place-items: center;
padding: 20px;
}
.card {
width: min(100%, 480px);
border: 1px solid var(--card-border);
background: rgba(15, 23, 41, 0.9);
border-radius: 20px;
padding: 34px 28px;
text-align: center;
box-shadow: 0 24px 56px rgba(0, 0, 0, 0.35);
}
.logo-wrap {
width: 82px;
height: 82px;
margin: 0 auto 18px;
border-radius: 999px;
display: grid;
place-items: center;
background: rgba(40, 215, 122, 0.16);
}
.logo-wrap img {
width: 58px;
height: 58px;
border-radius: 8px;
object-fit: cover;
}
h1 {
margin: 0;
font-size: clamp(29px, 4.2vw, 40px);
line-height: 1.15;
letter-spacing: -0.02em;
}
p.subtitle {
margin: 14px 0 26px;
font-size: 18px;
color: var(--text-2);
}
.wa-button {
width: 100%;
border: 0;
border-radius: 14px;
padding: 18px 22px;
font-size: 34px;
font-weight: 800;
color: var(--btn-text);
background: var(--btn);
cursor: pointer;
transition: transform 0.14s ease, opacity 0.14s ease;
}
.wa-button:hover {
transform: translateY(-1px);
}
.wa-button:active {
transform: translateY(0);
opacity: 0.9;
}
.foot {
margin-top: 14px;
font-size: 14px;
color: #647086;
}
</style>
</head>
<body>
<% if @landing_host.nil? %>
<div class="page">
<div class="card">
<h1>Página não encontrada</h1>
<p class="subtitle">Verifique a URL digitada e tente novamente.</p>
</div>
</div>
<% else %>
<div class="page">
<div class="card">
<div class="logo-wrap" title="logo">
<img src="<%= @landing_host.logo_url.presence || 'https://iachat.hoteis1001noites.com.br/assets/images/dashboard/captain/logo.svg' %>" alt="logo" />
</div>
<h1><%= @landing_host.page_title %></h1>
<p class="subtitle"><%= @landing_host.page_subtitle&.gsub("\n", "<br>")&.html_safe %></p>
<button id="whatsButton" class="wa-button" type="button"><%= @landing_host.button_text.presence || 'Falar no WhatsApp' %></button>
<div class="foot">Pagina segura · atendimento humano</div>
</div>
</div>
<script>
(function () {
const config = {
hostname: "<%= j @landing_host.hostname %>",
phone: "<%= j @landing_host.whatsapp_number.to_s.gsub(/[^\d]/, '') %>",
message: "<%= j @landing_host.initial_message.to_s %>",
defaultSource: "<%= j @landing_host.default_source.to_s %>",
defaultCampanha: "<%= j @landing_host.default_campanha.to_s %>",
};
const params = new URLSearchParams(window.location.search);
const clickKey = "lp_click_id_" + window.location.hostname;
function getClickId() {
const fromUrl = params.get("click_id") || params.get("clickid") || params.get("utm_id") || params.get("gclid");
if (fromUrl) {
localStorage.setItem(clickKey, fromUrl);
return fromUrl;
}
const existing = localStorage.getItem(clickKey);
if (existing) return existing;
const generated = `lp-${Date.now()}-${Math.floor(Math.random() * 100000)}`;
localStorage.setItem(clickKey, generated);
return generated;
}
function currentSource() {
return params.get("utm_source") || params.get("source") || config.defaultSource || "direto";
}
function currentCampanha() {
return params.get("utm_campaign") || params.get("campanha") || config.defaultCampanha || "site";
}
async function sendTrack() {
const payload = {
hostname: config.hostname || window.location.hostname,
lp: window.location.href,
click_id: getClickId(),
source: currentSource(),
campanha: currentCampanha(),
};
try {
await fetch("/track/click", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
keepalive: true,
});
} catch (_) {}
}
async function openWhatsapp() {
await sendTrack();
const text = encodeURIComponent(config.message);
window.location.href = `https://wa.me/${config.phone}?text=${text}`;
}
document.getElementById("whatsButton").addEventListener("click", openWhatsapp);
})();
</script>
<% end %>
</body>
</html>