Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

Uma resposta para “Hello world!”

  1. Avatar de A WordPress Commenter

    Hi, this is a comment.
    To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
    Commenter avatars come from Gravatar.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

`); w.document.close(); } document.addEventListener('click', async function(e){ if(e.target && e.target.id==='sim_pdf'){ openPDFSimulacao(); } if(e.target && e.target.id==='sim_proposta'){ e.preventDefault(); const nome=document.getElementById('sim_nome').value.trim(); const tel=document.getElementById('sim_tel').value.trim(); const email=document.getElementById('sim_email').value.trim(); const uf=document.getElementById('sim_estado').value; const dist=document.getElementById('sim_distribuidora').value; const contaRaw=parseFloat(document.getElementById('sim_conta').dataset.raw||'0'); const desc=(window.SimSolarData.discounts||{})[dist]||0.10; if(!nome||!tel||!email){ alert('Preencha Nome, Telefone e E-mail para continuar.'); return; } try{ await fetch(window.SimSolarData.restLead,{ method:'POST', headers:{'Content-Type':'application/json','X-WP-Nonce':window.SimSolarData.nonce}, body: JSON.stringify({nome,tel,email,uf,distribuidora:dist,conta:contaRaw,desconto:desc})}); }catch(_){ } const base = window.SimSolarData.proposal || window.location.href; const url = new URL(base, window.location.origin); ['nome','tel','email','uf','distribuidora','conta','desconto'].forEach(k=>url.searchParams.set(k, eval(k))); window.open(url.toString(), '_blank'); } }); // ===== PÁGINA PROPOSTA function fillIfExists(id,v){ var el=document.getElementById(id); if(el && v){ el.value=v; }} document.addEventListener('DOMContentLoaded', function(){ // Pré-preenche campos vindos da simulação fillIfExists('prop_nome', params.nome); fillIfExists('prop_email', params.email); fillIfExists('prop_tel', params.tel); fillIfExists('prop_uf', params.uf); fillIfExists('prop_dist', params.distribuidora); fillIfExists('prop_conta', params.conta); fillIfExists('prop_desc', params.desconto); }); async function salvarProposta(payload){ const r= await fetch(window.SimSolarData.restProp,{ method:'POST', headers:{'Content-Type':'application/json','X-WP-Nonce':window.SimSolarData.nonce}, body: JSON.stringify(payload)}); return await r.json(); } function openPDFProposta(){ const get=(id)=>document.getElementById(id)?.value||''; const w=window.open('', '_blank'); w.document.write(`Proposta – Pague Menos na Luz

Proposta Comercial

Pague Menos na Luz

Razão Social${get('prop_razao')}
CNPJ${get('prop_cnpj')}
Responsável${get('prop_nome')}
E-mail${get('prop_email')}
Telefone${get('prop_tel')}
UF${get('prop_uf')}
Distribuidora${get('prop_dist')}
Conta médiaR$ ${(parseFloat(get('prop_conta'))||0).toFixed(2)}
Desconto${Math.round((parseFloat(get('prop_desc'))||0)*100)}%

Valores estimados...