✏️ 正在编辑: simulacao-aberta.js
路径:
/srv/systems_dir/yuppiecred/public/scripts/simulacao-aberta.js
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
// function preventBack() { window.history.forward(); } // window.onunload = function () { null }; // window.history.forward(); // window.history.pushState(null, null, window.location.href); // window.onpopstate = function () { // window.history.go(1); // }; $(document).ready(function(){ // setTimeout("preventBack()", 0); $(function() { $('.jcarousel').jcarousel(); $('.jcarousel-control-prev') .on('jcarouselcontrol:active', function() { $(this).removeClass('inactive'); }) .on('jcarouselcontrol:inactive', function() { $(this).addClass('inactive'); }) .jcarouselControl({ target: '-=1' }); $('.jcarousel-control-next') .on('jcarouselcontrol:active', function() { $(this).removeClass('inactive'); }) .on('jcarouselcontrol:inactive', function() { $(this).addClass('inactive'); }) .jcarouselControl({ target: '+=1' }); $('.jcarousel-pagination') .on('jcarouselpagination:active', 'a', function() { $(this).addClass('active'); }) .on('jcarouselpagination:inactive', 'a', function() { $(this).removeClass('active'); }) .jcarouselPagination(); }); $('#orgao_siape').combobox(); // $('#numero_banco').combobox(); // $('#orgao_emissor').combobox(); // $('#especie').combobox(); $("#numero_banco").not(".inss").combobox(); $("#orgao_emissor").not(".inss").combobox(); $("#especie").not(".inss").combobox(); markRequiredFiedls('inclusao_fgts'); markRequiredFiedls('inclusao_inss'); $('#tooltipfixed').tooltip('show'); if ($('#tipo').val() === 'gov_ba') { $('#tipo_beneficio').parent().hide(); $('#possui_representante_legal').parent().hide(); $('#beneficio_invalidez').parent().hide(); $('#especie').parent().hide(); $('#n_beneficio').html('Nº da sua Matrícula:'); } // bloquearColar(); }); function bloquearColar() { var elements = $(document).find("input[type=text]"); $.each(elements, function (index, item) { item.addEventListener("paste", function(e) { e.preventDefault(); }); }); } function registrarSolicitacao(simulacaoId, simulacaoBancoId) { $('.full-loading').show(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/simulacao-aberta/registrar-solicitacao', data: { simulacaoId: simulacaoId, simulacaoBancoId: simulacaoBancoId }, success: function (result) { if (result.error) { Swal.fire({ title: 'Atenção!', text: 'Simulação não encontrada.', icon: "warning" }); return false; } if (result.success) { Swal.fire({ title: 'Sucesso!', text: 'Solicitação realizada com sucesso.', icon: 'success' }); return false; } }, error: function () { Swal.fire({ title: 'DESCULPE!', text: 'Ocorreu uma falha!', icon: 'warning' }); }, complete: function () { $('.full-loading').hide(); } }); } function validaCampos(botao) { var elements = $(botao).parent().parent().find("input[type=text], select"); var validacao = true; if (!$('#aceite').is(':checked')) { Swal.fire({ title: 'Atenção!', text: 'Você precisa marcar a caixinha de aceite!', icon: "warning" }); return false; } if (elements.length > 0) { $.each(elements, function (index, item) { if (item.required && item.value.length <= 0) { Swal.fire({ title: 'Atenção!', text: 'Os campos marcados com asterisco (*) são obrigatórios.', icon: "warning" }); validacao = false; return false; } if (item.name == 'numero_conta' && (parseInt(item.value) <= 0 || parseInt(item.value) == NaN)) { Swal.fire({ title: 'Atenção!', text: 'Você deve fornecer uma conta válida. É nela que o valor do seu saque será depositado!', icon: "error" }); validacao = false; return false; } if (item.name == 'fone' && item.value.replace(/\D/g, "").length < 11) { Swal.fire({ title: 'Atenção!', text: 'Informe um celular válido, inclusive com o 9º dígito. Nele você receberá o link do banco para formalizar seu contrato.', icon: "error" }); validacao = false; return false; } if (item.name == 'cep' && item.value.replace(/\D/g, "").length < 8) { Swal.fire({ title: 'Atenção!', text: 'Informe um CEP válido. Apenas números!', icon: "error" }); validacao = false; return false; } if (item.name == 'nome' && item.value.length < 3) { Swal.fire({ title: 'Atenção!', text: 'Informe o seu nome completo!', icon: "error" }); validacao = false; return false; } if ((item.name == 'data_nascimento' || item.name == 'data_emissao_documento') && !isValidDate(item.value)) { Swal.fire({ title: 'Atenção!', text: 'Informe uma data válida!', icon: "error" }); validacao = false; return false; } if (item.name == 'cpf' && !validarCPF(item.value)) { Swal.fire({ title: 'Atenção!', text: 'O CPF informado é inválido!', icon: "error" }); validacao = false; return false; } }); } return validacao; } function proximoSection(botao, ocultarBotao = true) { var proximo = $(botao).attr('data-value'); var validacao = validaCampos(botao); $('.erro-message-box').hide(); $('.field-quantidade').hide(); $('.btn-resimular').hide(); $('.btn-reset').hide(); if (validacao) { $('#' + proximo).show(); if (ocultarBotao) { $(botao).parent().hide(); } $('#' + proximo)[0].scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"}); // scrollWindow('#' + proximo); if (proximo == "passo04") { $('#orgao_emissor').combobox(); $("#toggle").click(function () { $('#orgao_emissor').toggle(); }); } if (proximo == "passo06") { $('#numero_banco').combobox(); $("#toggle").click(function () { $('#numero_banco').toggle(); }); } return true; } return false; } function consultaFgts() { $('#passo02').hide(); var banco = $('#consulta_banco option:selected'); var cpfValido = validarCPF($('#cpf').val()); $('#inclusao_fgts #nome').val($('#nome').val()); $('#inclusao_fgts #cpf').val($('#cpf').val()); $('#inclusao_fgts #fone').val($('#fone').val()); $('#inclusao_fgts #corretor_id').val($('#corretor_id').val()); $('#inclusao_fgts #tipo').val($('#tipo').val()); $('#' + banco.val()).prop('checked',true); if (cpfValido === false) { Swal.fire({ title: 'ATENÇÃO!', text: 'O CPF informado é inválido.', icon: "warning" }); return false; } var validacao = validaCampos($(".consultar-fgts")); if (validacao) { $('.full-loading').show(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/simulacao-aberta/autocontratacao-capture', data: $('#inclusao_fgts').serialize(), success: function (result) { console.log(result); if (result.track) { trackConsulta(); } if (result.error) { $('#inclusao_fgts .erro-message-box').html(result.error); $('#inclusao_fgts .erro-message-box').show(); $('#inclusao_fgts .message-box').hide(); $('#inclusao_fgts .success-message-box').hide(); if (result.back == 1 || result.back == 2) { ativarModal(); $('#passo02').show(); Swal.fire({ title: 'ATENÇÃO!', text: result.error, icon: "warning" }); } if (result.back == 0) { Swal.fire({ title: 'ATENÇÃO!', text: result.error, icon: "warning" }); } if (result.track && result.back == 1) { trackLeadAderirSaque(); } if (result.track && result.back == 2) { trackLeadAutorizarBanco(); } if (result.back == 3) { Swal.fire({ title: 'ATENÇÃO!', text: result.error, icon: "warning" }); if (result.track) { trackLeadSemSaldo(); } } if (result.back == 4) { Swal.fire({ title: 'ATENÇÃO!', text: result.error, icon: "warning" }); if (result.track) { trackLeadAniversarioProximo(); } } if (result.back == 5) { Swal.fire({ title: 'ATENÇÃO!', text: result.error, icon: "warning" }); $('#passo04').show(); $('#passo04 .dados_consulta_banco').hide(); $('#passo04 .success-message-box').show(); } return false; } if (result.success && result.parcelas.length > 0) { ativarModal(); $('#passo04').show(); $('.dados_consulta_banco').show(); $('#passo04 .valor_liberado').html(result.valor_liberado); $('#passo04 .valor_financiado').html(result.valor_financiado); $('#passo04 .taxa_juros').html(result.taxa_juros); $('#passo04 .origem_consulta').html(result.origem_consulta); $('#passo04 .message-box').hide(); $('#passo04 .erro-message-box').hide(); $('#passo04 .success-message-box').show(); $('#passo04 .dados_consulta_banco').show(); $('#passo04 .nome_cliente').html($("#nome").val()); if (result.parcelas) { $("#parcelas_simuladas tbody").html(''); } var count = 1; $.each(result.parcelas, function (index, item) { if (item.valor_parcela > 0) { let dataVencimento = new Date(item.data_vencimento); let dados = "<tr>" + "<td>" + count++ + "</td>" + "<td>" + dataVencimento.toLocaleDateString() + "</td>" + "<td>R$ " + number_format(item.valor_parcela, 2, ",", ".") + "</td>" + "</tr>"; $("#parcelas_simuladas > table > tbody").append(dados); } }); $('#passo04 .qtd_parcelas').html(count - 1); if (result.track) { trackLeadQualificado(); } fieldsKeyPix(banco.val()); return false; } else { Swal.fire({ title: 'DESCULPE!', text: 'Parcelas não foram retornadas pelo banco selecionado.', icon: 'warning' }); } }, error: function () { Swal.fire({ title: 'DESCULPE!', text: 'Ocorreu uma falha!', icon: 'warning' }); }, complete: function () { $('.full-loading').hide(); } }); } } function refazerConsulta(botao) { parcelas = $('#parcelas').val(); if (parcelas > 0) { var atual = $(botao).attr('data-value'); $('.erro-message-box').hide(); $('#' + atual).hide(); $('html, body').animate({scrollTop:0}, 'slow'); return consultaFgts(); } Swal.fire({ title: 'ATNÇÃO!', text: 'Informe a quantidade de parcelas desejada!', icon: 'warning' }); } function selectBanco(value) { $('.form-fgts #consulta_banco').val(value); fieldsKeyPix(value); } function scrollWindow(objId) { $('#modalFgts').animate({ 'scrollTop' : $(objId).offset().top }, 500); } function buscarCepSimulacao(objeto) { initBuscaEndereco(objeto); $(window).scrollTop(0); } function buscarNovoCepSimulacao(objeto) { initBuscaEndereco(objeto); $('#passo08').show(); $('#passo09').hide(); $(window).scrollTop(0); } function inclusaoFgts(botao) { if (!validaCampos(botao)) { return false; } $(botao).prop('disabled', true); proximoSection(botao, false); var campos = $('form#inclusao_fgts').serialize(); $('.full-loading').show(); $('#finalizar').prev().hide(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/simulacao-aberta/inclusao-fgts', data: campos, success: function (result) { if (result.error) { $('.message-finalizar').hide(); $('.message-result').hide(); Swal.fire({ title: result.error, text: result.description, icon: 'warning' }); return false; } if (result.success) { trackContratou(); Swal.fire({ title: result.success, html: result.url_formalizacao ? "Clique em OK e você será direcionado para o link de formalização do contrato!" : result.description, icon: 'success', showDenyButton: true, footer: result.url_formalizacao ? '<a href="' + result.url_formalizacao + '" target="_blank">[ENVIAR DOCUMENTAÇÃO]</a>' : "" }).then(function (res) { if (res.isConfirmed) { if (result.url_formalizacao) { window.open(result.url_formalizacao); return true; } window.location.reload(); } }); return false; } }, error: function () { Swal.fire({ title: 'Erro!', text: 'Ocorreu uma falha no processamento da proposta. Verifique os dados e tente novamente!', icon: 'warning' }); }, complete: function () { $('.full-loading').hide(); $(botao).removeAttr('disabled'); } }); } function trackLead() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Lead'); } } function trackConsulta() { console.log('trackConsulta'); if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Consulta Saldo'); } if (typeof gtag !== 'undefined' && typeof googleConversionConsulta !== 'undefined') { gtag('event', 'conversion', { 'send_to': googleConversionConsulta, }); } } function trackConsultaAvulsa() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Consulta Saldo Avulso'); } } function trackConsultaInss() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Simulação INSS'); } if (typeof gtag !== 'undefined' && typeof googleConversionConsulta !== 'undefined') { gtag('event', 'conversion', { 'send_to': googleConversionConsulta, }); } } function trackLeadQualificado() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Lead Qualificado'); } if (typeof gtag !== 'undefined' && typeof googleConversionLeadQualificado !== 'undefined') { gtag('event', 'conversion', { 'send_to': googleConversionLeadQualificado, }); } } function trackContratou() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Lead Contratou'); } if (typeof gtag !== 'undefined' && typeof googleConversionContratou !== 'undefined') { gtag('event', 'conversion', { 'send_to': googleConversionContratou, }); } } function trackContratouInss() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Lead Contratou INSS'); } if (typeof gtag !== 'undefined' && typeof googleConversionContratou !== 'undefined') { gtag('event', 'conversion', { 'send_to': googleConversionContratou, }); } } function trackLeadAderirSaque() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Lead Aderir Saque'); } } function trackLeadAutorizarBanco() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Lead Autorizar Banco'); } } function trackLeadSemSaldo() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Lead Sem Saldo'); } } function trackLeadAniversarioProximo() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Aniversario Proximo'); } } function trackContratouCredcesta() { if (typeof fbq !== 'undefined') { fbq('trackCustom', 'Lead Contratou Credcesta'); } if (typeof gtag !== 'undefined' && typeof googleConversionContratou !== 'undefined') { gtag('event', 'conversion', { 'send_to': googleConversionContratou, }); } } $(".simular-fgts").click(function() { var saldo = $('#saldo-fgts'); $('.full-loading').show(); trackConsultaAvulsa(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/simulacao-aberta/consulta-por-saldo', data: { "saldo-fgts" : saldo.val() }, success: function (result) { if (result.valor_liberado) { Swal.fire({ title: 'Simulação realizada', html: 'Valor liberado aproximado de<strong> R$' + result.valor_liberado + ' </strong>. <br><br> Taxa de <strong>' + number_format(result.taxa, 2, ',', '.') + '%</strong>', icon: 'success' }); $('.valor_liberado_avulso').html('Valor liberado: R$ ' + number_format(result.valor_liberado, 2, ',', '.')); } if (result.error) { Swal.fire({ title: 'DESCULPE!', text: 'O saque não pode ser calculado!', icon: 'warning' }); } }, error: function () { Swal.fire({ title: 'DESCULPE!', text: 'Ocorreu uma falha!', icon: 'warning' }); }, complete: function () { $('.full-loading').hide(); } }); }); function ativarModal() { $('#modalFgts').modal({ keyboard: false, show: true, backdrop: 'static' }); } $('.btn_cancelar').on('click', function() { $('#finalizar_cancelado').show(); botao = this; proximoSection(botao, false); }); $('#modalFgts').on('hidden.bs.modal', function () { window.location.reload(); }); $(".consultar-inss").click(function() { var nome = $('#nome'); var cpf = $('#cpf'); var fone = $('#fone'); var dtNasc = $('#data_nascimento'); var matricula = $('#numero_beneficio'); var especie = $('#especie'); var valorSolicitado = $('#valor_solicitado'); var valorRenda = $('#renda_valor'); var corretor = $('#corretor_id'); var tipo = $('#tipo'); var cpfValido = validarCPF(cpf.val()); var codigoOrgao = $('#codigo_orgao'); if (cpfValido === false) { Swal.fire({ title: 'ATENÇÃO!', text: 'O CPF informado é inválido.', icon: "warning" }); return false; } var botao = this; var validacao = validaCampos(botao); if (validacao) { $('.full-loading').show(); // $('.message-box').show(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/simulacao-aberta/autocontratacao-consignado', data: $('form#inclusao_inss').serialize(), success: function (result) { if (result.track) { trackConsultaInss(); } $('#nome').val(nome.val()); $('#cpf').val(cpf.val()); $('#fone').val(fone.val()); $('#data_nascimento').val(dtNasc.val()); $('#numero_beneficio').val(matricula.val()); $('#especie').val(especie.val()); $('#valor_solicitado').val(valorSolicitado.val()); $('#renda_valor').val(valorRenda.val()); $('#corretor_id').val(corretor.val()); $('#tipo').val(tipo.val()); $('#codigo_orgao').val(codigoOrgao.val()); if (result.error) { // $('.erro-message-box').html(result.error); $('.erro-message-box').show(); $('.message-box').hide(); $('.success-message-box').hide(); $(botao).parent().show(); Swal.fire({ title: 'ATENÇÃO!', text: result.error, icon: "warning" }); return false; } if (result.success) { if ($('#simular_direto').val() == 0) { $('.dados_consulta_banco').show(); } else { $('.dados_consulta_banco2').show(); } $('.nome_cliente').html($("#nome").val()); $('.valor_liberado').html(result.valor_liberado); $('.valor_financiado').html(result.valor_financiado); $('.valor_parcela').html(result.valor_parcela); $('.taxa_juros').html(result.taxa_juros); $('.qtd_parcelas').html(result.prazo); $('.origem_consulta').html(result.origem_consulta); $('.message-box').hide(); $('.erro-message-box').hide(); $('.success-message-box').show(); $('.dados_consulta_bancos').hide(); return false; } if (result.dados) { $.each(result.dados, function (index, campo) { $('#' + index).val(campo); }); if (result.simulacoes) { console.log(result.simulacoes); vlrLiberado = 0; $.each(result.simulacoes, function (index, banco) { if (banco.valor_parcela > 0) { $('.' + index.toLowerCase() + '_valor_liberado').html(number_format(banco.valor_liberado, 2, ",", ".")); $('.' + index.toLowerCase() + '_qtd_parcelas').html(banco.prazo); $('.' + index.toLowerCase() + '_valor_parcela').html(number_format(banco.valor_parcela, 2, ",", ".")); $('.' + index.toLowerCase() + '_selecionar').show(); if (banco.valor_liberado > vlrLiberado) { vlrLiberado = banco.valor_liberado; if ($('#simular_direto').val() == 0) { $('.success-message-box #' + index.toLowerCase()).prop('checked',true); } else { $('.success-message-box2 #' + index.toLowerCase()).prop('checked',true); } } } }); if ($('#simular_direto').val() == 0) { $('.success-message-box').show(); $('.btn-continuar').show(); } else { $('.success-message-box2').show(); } $('.message-box').hide(); return false; } $('#simular_direto').val(1); $('.message-box').hide(); $('.erro-message-box').hide(); $('#passo03').show(); $('.btn-simular').show(); $('#passo03').animate({scrollTop:0}, 'slow'); Swal.fire({ title: 'DESCULPE!', text: 'Nenhuma simulação retornada!', icon: 'warning' }); return false; } else { $('#simular_direto').val(1); $('.message-box').hide(); $('.erro-message-box').hide(); $('#passo03').show(); $('.btn-simular').show(); $('#passo03').animate({scrollTop:0}, 'slow'); return false; } }, error: function () { Swal.fire({ title: 'DESCULPE!', text: 'Ocorreu uma falha!', icon: 'warning' }); }, complete: function () { $('.full-loading').hide(); } }); } }); function resetConsulta(botao) { var banco = $('#consulta_banco option:selected'); $('#parcelas').val(''); if (banco.val() === '_consultarIcred') { window.location.reload(); return false; } var atual = $(botao).attr('data-value'); $('.erro-message-box').hide(); $('#' + atual).hide(); $('.btn-simular').show(); $('#passo01').show(); $('html, body').animate({scrollTop:0}, 'slow'); } function inclusaoInss(botao) { if (!validaCampos(botao)) { return false; } proximoSection(botao, false); var campos = $('form#inclusao_inss').serialize(); $('.full-loading').show(); $('#finalizar').prev().hide(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/simulacao-aberta/inclusao-inss', data: campos, success: function (result) { if (result.error) { $('.message-finalizar').hide(); $('.message-result').hide(); Swal.fire({ title: result.error, text: result.description, icon: 'warning' }); return false; } if (result.success) { trackContratouInss(); Swal.fire({ title: result.success, html: result.url_formalizacao ? "Clique em OK e você será direcionado para o link de formalização do contrato!" : result.description, icon: 'success', showDenyButton: true, footer: result.url_formalizacao ? '<a href="' + result.url_formalizacao + '" target="_blank">[ENVIAR DOCUMENTAÇÃO]</a>' : "" }).then(function (res) { if (res.isConfirmed) { if (result.url_formalizacao) { window.open(result.url_formalizacao); return true; } window.location.reload(); } }); return false; } }, error: function () { Swal.fire({ title: 'Erro!', text: 'Ocorreu uma falha no processamento da proposta. Verifique os dados e tente novamente!', icon: 'warning' }); }, complete: function () { $('.full-loading').hide(); } }); } function markRequiredFiedls(id) { var form = document.getElementById(id); if (!form || form == undefined) { return; } var inputs = form.elements; for (i = 0; i < inputs.length; i++) { if (inputs[i].type != 'button') { var required = inputs[i].getAttribute("required") == "required"; if (required) { var label = $("label[for='" + inputs[i].id + "']"); label.append("*"); } } } } function populateComboCredcestaOrgaos(objOrigem, objDestino) { var id = $('#' + objOrigem).val(); $('#orgao_especifico').val(""); $.ajax({ type: 'GET', data: 'convenio=' + id, dataType: 'json', url: baseUrl + "/ajax/get-credcesta-orgaos", beforeSend: function () { $('.full-loading').show(); }, success: function (result) { if (result.error) { alert(result.error); } if (result.orgaos.length == 0) { $('select#orgao_id').parent().css('display', 'none'); return; } $('select#orgao_id').parent().css('display', 'block'); $('#' + objDestino).empty(); $('#' + objDestino).append(new Option('', '')); $.each(result.orgaos, function (i) { $("#" + objDestino).append(new Option(this.descricao, this.codigo)); }); }, error: function (result) { console.log(result); }, complete: function () { $('.full-loading').hide(); } }) } function populateConvenioCredcesta(obj) { var convenio = $(obj).find(':selected').attr('label'); $('#codigo_orgao').val(convenio); } function populateOrgaoCredcesta(obj) { var orgao = $(obj).find(':selected').text(); $('#orgao_especifico').val(orgao); } $(".consultar-credcesta").click(function() { $('.success-message-box').hide(); var cpfValido = validarCPF($('#cpf').val()); if (cpfValido === false) { Swal.fire({ title: 'ATENÇÃO!', text: 'O CPF informado é inválido.', icon: "warning" }); return false; } var botao = this; var validacao = validaCampos(botao); if (validacao) { $('.full-loading').show(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/simulacao-aberta/autocontratacao-credcesta', data: $('form#inclusao_credcesta').serialize(), success: function (result) { if (result.error) { $('.erro-message-box').html(result.error); $('.erro-message-box').show(); $('.message-box').hide(); $('.success-message-box').hide(); Swal.fire({ title: 'ATENÇÃO!', text: result.error, icon: "warning" }); $('.consultar-credcesta').parent().show(); return false; } if (result.success) { $('.origem_consulta').html(result.origem_consulta); $('.message-box').hide(); $('.erro-message-box').hide(); $('.success-message-box').show(); if (result.cliente.opcoes.length > 0) { console.log(result.cliente.opcoes); var blocos = null; $.each(result.cliente.opcoes, function (index, opcao) { classCssH5 = opcao.melhor_opcao == true ? 'white' : ''; classCssBtn = opcao.melhor_opcao == true ? 'btn_melhor_opcao btn-primary' : 'btn_opcao'; classCss = opcao.melhor_opcao == true ? 'melhor-oferta' : ''; h4 = opcao.melhor_opcao == true ? '<h4>Melhor Oferta</h4>' : ''; blocos = '<div class="col-lg-4"> ' + '<div class="container-simulacao ' + classCss + '">' + '<div class="' + classCssH5 + '">' + h4 + '<h5>Opção ' + opcao.numero_opcao + '</h5>' + '</div>' + '<div class="proposta_banco">' + '<p>Prazo: ' + opcao.prazo + 'x</p>' + '<p>Valor de liberação: R$ ' + number_format(opcao.valor_total, 2, ',', '.') + '</p>' + '<p>Parcela: R$ ' + number_format(opcao.valor_parcela, 2, ',', '.') + ' / mês</p>' + '<div class="btn_melhor_opcao btn-primary"><a href="javascript://" onclick="confirmarSolicitacao(' + opcao.prazo + ', ' + opcao.valor_total + ', ' + opcao.valor_parcela + ')"><span>Solicitar Agora</span></a></div>' + '</div>' + '</div>' + '</div>'; $('#row').append($(blocos)); }); mensagem = '<div class="clear col-lg-12"><p>Valores e prazos poderão sofrer alterações sem aviso prévio e sujeito a análise bancária por taxa diária. Dúvidas, contate um dos nossos consultores.</p></div>'; $('#row').append($(mensagem)); $('#nome').val(result.cliente.nome); $('#numero_banco').val(result.cliente.cdBanco); $('#numero_agencia').val(result.cliente.cdAgencia); $('#numero_conta').val(result.cliente.cdConta); $('.message-box').hide(); return false; } else { $('.message-box').hide(); Swal.fire({ title: 'DESCULPE!', text: 'Não há opções disponíveis no momento. Mas não se preocupe, entraremos em contato com você!', icon: 'warning' }); window.location.reload(); return false; } } }, error: function () { Swal.fire({ title: 'DESCULPE!', text: 'Ocorreu uma falha!', icon: 'warning' }); }, complete: function () { $('.full-loading').hide(); } }); } }); function confirmarSolicitacao(prazo, total, parcela) { $('#prazo').val(prazo); $('#valor_solicitado').val(total); $('.prazo-selecionado').html(prazo); $('.total-selecionado').html(number_format(total, 2, ',', '.')); $('.parcela-selecionado').html(number_format(parcela, 2, ',', '.')); $('#passo02').hide(); $('#passo03').show(); $('#passo03')[0].scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"}); } function inclusaoCredcesta(botao) { if (!validaCampos(botao)) { return false; } proximoSection(botao, false); var campos = $('form#inclusao_credcesta').serialize(); $('.full-loading').show(); $('#finalizar').prev().hide(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/simulacao-aberta/inclusao-credcesta', data: campos, success: function (result) { if (result.error) { $('.message-finalizar').hide(); $('.message-result').hide(); Swal.fire({ title: result.error, text: result.description, icon: 'warning' }); return false; } if (result.success) { trackContratouCredcesta(); Swal.fire({ title: result.success, html: result.url_formalizacao ? "Clique em OK e você será direcionado para o link de formalização do contrato!" : result.description, icon: 'success', showDenyButton: true, footer: result.url_formalizacao ? '<a href="' + result.url_formalizacao + '" target="_blank">[ENVIAR DOCUMENTAÇÃO]</a>' : "" }).then(function (res) { if (res.isConfirmed) { if (result.url_formalizacao) { window.open(result.url_formalizacao); return true; } window.location.reload(); } }); return false; } }, error: function () { Swal.fire({ title: 'Erro!', text: 'Ocorreu uma falha no processamento da proposta. Verifique os dados e tente novamente!', icon: 'warning' }); }, complete: function () { $('.full-loading').hide(); } }); } function carregarComboOrgaoSiape(banco) { var url = baseUrl + '/ajax/combo-orgao-siape'; definirRequired(banco); $.ajax({ url: url, type: 'get', data: {banco: banco}, dataType: 'json', success: function (response) { if (response.dados.length == 0) { $('select#orgao_siape').parent().css('display', 'none'); return; } $('select#orgao_siape').parent().css('display', 'block'); $('#orgao_siape').empty(); $('#orgao_siape').append(new Option('', '')); $.each(response.dados, function (key, orgao) { $("#orgao_siape").append(new Option(orgao.descricao, orgao.codigo)); }); }, error: function (response) { console.log(response); } }); } function camposRepresentanteLegal() { var possuiRepresentanteLegal = $('#possui_representante_legal option:selected').val(); console.log(possuiRepresentanteLegal); if (possuiRepresentanteLegal != 1) { $("#nome_representante_legal").parent().remove(); $("#cpf_representante_legal").parent().remove(); $("#sexo_representante_legal").parent().remove(); $("#data_nascimento_representante_legal").parent().remove(); $("#rg_representante_legal").parent().remove(); $("#data_emissao_documento_representante_legal").parent().remove(); $("#nome_mae_representnte_legal").parent().remove(); $("#nome_pai_representnte_legal").parent().remove(); $("#msg-representante").remove(); return; } fields = '<div class="form-group"><label for="nome_representante_legal">Nome Representante Legal:</label><input type="text" class="form-control" name="nome_representante_legal" id="nome_representante_legal" size="35" maxlength="35" placeholder="Nome completo do representante legal" required="required" value=""/></div>' + '<div class="form-group"><label for="cpf_representante_legal">CPF do Representante Legal:</label><input type="text" class="form-control" name="cpf_representante_legal" id="cpf_representante_legal" inputmode="numeric" onkeypress="mascara(this, fcpf)" maxlength="14" placeholder="000.000.000-00" required="required" value="" /></div>' ; fieldsRep = '<h1 class="message-box" id="msg-representante">Informe os dados do Representante Legal.</h1>' + '<div class="form-group"><label for="sexo_representante_legal">Sexo (Representante Legal):</label><select name="sexo_representante_legal" id="sexo_representante_legal" class="form-control" required="required"><option value=""></option><option value="F">Feminino</option><option value="M">Masculino</option></select></div>' + '<div class="form-group"><label for="data_nascimento_representante_legal">Data de Nascimento (Representante Legal):</label><input type="text" class="form-control" name="data_nascimento_representante_legal" id="data_nascimento_representante_legal" inputmode="numeric" onkeypress="mascara(this, data)" maxlength="10" size="11" placeholder="dd/mm/aaaa" required="required"></div>' + '<div class="form-group"><label for="rg_representante_legal">Nº Documento (RG Representante Legal):</label><input type="text" class="form-control" id="rg_representante_legal" name="rg_representante_legal" placeholder="Insira o documento de identificação do representante" required="required"></div>' + '<div class="form-group"><label for="data_emissao_documento_representante_legal">Data de Emissão (Representante Legal):</label><input type="text" class="form-control" name="data_emissao_documento_representante_legal" id="data_emissao_documento_representante_legal" inputmode="numeric" size="10" maxlength="10" onkeypress="mascara(this, data)" placeholder="dd/mm/aaaa"></div>' + '<div class="form-group"><label for="nome_mae_representnte_legal">Nome da Mãe (Representante Legal):</label><input type="text" class="form-control" name="nome_mae_representnte_legal" id="nome_mae_representnte_legal" size="30" maxlength="35" placeholder="Nome completo da mãe do representante" required="required"></div>' + '<div class="form-group"><label for="nome_pai_representnte_legal">Nome do Pai (Representante Legal):</label><input type="text" class="form-control" name="nome_pai_representnte_legal" id="nome_pai_representnte_legal" size="30" maxlength="35" placeholder="Nome completo do pai do representante" required="required"></div>' ; $(fields).insertAfter($("#possui_representante_legal").parent()); $(fieldsRep).insertAfter($("#nome_mae").parent()); } function fieldsKeyPix(banco) { if (banco === '_consultarIcred' || banco === '_consultarV8') { fields = '<h1 class="message-box" id="msg-pix">Informe os dados para depósito.</h1>' + '<div class="form-group"><label for="tipo_pix">Tipo de Chave PIX:</label><select name="tipo_pix" id="tipo_pix" class="form-control" required="required" onchange="changeKeyPix()"><option value=""></option><option value="cpf">CPF</option><option value="telefone">Telefone</option><option value="aleatoria">Chave Aleatória</option></select></div>' + '<div class="form-group"><label for="chave_pix">Chave PIX:</label><input type="text" class="form-control not_upper" name="chave_pix" id="chave_pix" size="35" placeholder="Chave PIX" onkeypress="" required="required" value=""/></div>' + '<div class="col-md-12"><button type="button" class="btn_continuar btn btn-lg btn-primary btn-block" data-value="passo10" onclick="inclusaoFgts(this)">Finalizar</button></div>' + '<div class="clear"></div>' ; $("#passo09").html(fields); } } function changeKeyPix() { var tipo = $('#tipo_pix').val(); switch (tipo) { case 'cpf': $('#chave_pix').val(''); $('#chave_pix').attr('onkeypress','mascara(this, fcpf)'); $('#chave_pix').prop('placeholder','000.000.000-00'); $('#chave_pix').prop('inputmode','numeric'); $('#chave_pix').prop('maxlength',14); break; case 'telefone': $('#chave_pix').val(''); $('#chave_pix').attr('onkeypress','mascara(this, telefone)'); $('#chave_pix').prop('placeholder','(00) 00000-0000'); $('#chave_pix').prop('inputmode','numeric'); $('#chave_pix').prop('maxlength',15); break; case 'aleatoria': $('#chave_pix').val(''); $('#chave_pix').removeAttr('onkeypress'); $('#chave_pix').prop('placeholder', 'Digite a chave ' + tipo); $('#chave_pix').removeAttr('inputmode'); $('#chave_pix').removeAttr('maxlength'); } } function definirRequired(banco) { if (banco === 'Daycoval') { $('#email').attr('required', 'required'); $('#label-email').html('E-mail:*'); } else { $('#email').removeAttr('required'); $('#label-email').html('E-mail:'); } }
💾 保存文件
← 返回文件管理器