1var jQuery = $; 2 3var slides = []; 4var current = 0; 5var links = []; 6 7var recarregado = localStorage.getItem('recarregado'); 8if (!recarregado) localStorage.setItem('recarregado', 1); 9else localStorage.setItem('recarregado', Number(localStorage.getItem('recarregado')) + 1); 10 11var intervalBox, intervalSize; 12 13function scrollBody(){ 14 if(jQuery('#colorbox').css('display') != 'none'){ 15 jQuery('body').css('overflow', 'hidden'); 16 } else { 17 jQuery('body').css('overflow', 'auto'); 18 try { clearInterval(intervalBox); } catch(e){} 19 try { clearInterval(intervalSize); } catch(e){} 20 } 21} 22 23function sizeBox(){ 24 var width = window.innerWidth - ((window.innerWidth * 0.20) / 2); 25 if(width > 450) width = 450; 26 var height = jQuery('#cboxWrapper').outerHeight(); 27 if(height >= window.innerHeight){ 28 height = window.innerHeight - ((window.innerHeight * 0.20)); 29 } 30 jQuery('#colorbox').css('width', width + 'px'); 31 jQuery('#colorbox').css('height', height + 'px'); 32 jQuery('#colorbox').css('top', (window.innerHeight - jQuery('#colorbox').outerHeight()) / 2); 33 jQuery('#cboxClose').css('margin-top', ((window.innerHeight - jQuery('#colorbox').outerHeight()) / 2)); 34 jQuery('#colorbox').css('left', (window.innerWidth - jQuery('#colorbox').outerWidth()) / 2); 35 jQuery('#cboxClose').css('margin-right', ((window.innerWidth - jQuery('#colorbox').outerWidth()) / 2) - 2); 36 if(jQuery('#cboxWrapper').outerHeight() > jQuery('#colorbox').outerHeight()){ 37 jQuery('#colorbox').addClass('arrow-bg'); 38 } else { 39 jQuery('#colorbox').removeClass('arrow-bg'); 40 } 41} 42 43if(!localStorage.getItem('data-cookie')){ 44 $('.cookies').removeClass('hidden'); 45 $('.cookies').fadeIn(); 46} 47 48/* 49 * Consentimento de cookie. 50 * 51 * Antes existia so "Permitir Todos": sem opcao de recusar, e o texto do banner 52 * afirmava que continuar navegando ja era consentimento â o que a LGPD nao 53 * aceita como manifestacao livre e inequivoca. Agora as duas escolhas ficam 54 * registradas, e o que fica gravado nao e mais so a data: e a decisao. 55 * 56 * Quem le a decisao: qualquer script que dependa de cookie opcional deve checar 57 * window.rcaConsentimento() antes de disparar. O GTM continua carregando (ele e 58 * o que mede o proprio site), mas tag de marketing dentro dele pode usar o 59 * mesmo sinal como gatilho. 60 */ 61function rcaRegistrarConsentimento(decisao) { 62 try { 63 localStorage.setItem('data-cookie', new Date().toString()); 64 localStorage.setItem('rca-consentimento', decisao); 65 } catch (e) { /* navegacao privada: segue sem registrar */ } 66 67 window.dataLayer = window.dataLayer || []; 68 window.dataLayer.push({ event: 'rca_consentimento', rca_consentimento: decisao }); 69 70 $('.cookies').fadeOut(); 71} 72 73window.rcaConsentimento = function () { 74 try { return localStorage.getItem('rca-consentimento') || 'nao-decidido'; } 75 catch (e) { return 'nao-decidido'; } 76}; 77 78$('#aceite-cookies').click(function(){ 79 rcaRegistrarConsentimento('todos'); 80}); 81 82$('#recusa-cookies').click(function(){ 83 rcaRegistrarConsentimento('somente-necessarios'); 84}); 85 86$( document ).ready(function() { 87 $('[data-open-image="true"]').on('click', function (e) { 88 e.preventDefault(); 89 90 var href = $(this).attr('href'); 91 92 $('#image-src').attr('src', href); 93 }) 94}); 95 96const targetEl = document.getElementById('loading-modal'); 97 98// options with default values 99var options = { 100 placement: 'bottom-right', 101 backdrop: 'dynamic', 102 backdropClasses: 103 'bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-40', 104 closable: true, 105 onHide: () => { 106 console.log('modal is hidden'); 107 }, 108 onShow: () => { 109 console.log('modal is shown'); 110 }, 111 onToggle: () => { 112 console.log('modal has been toggled'); 113 }, 114}; 115 116// instance options object 117var instanceOptions = { 118 id: 'loading-modal', 119 override: true 120 }; 121 122// if (!window.modalInstances) { 123// window.modalInstances = []; 124// } 125 126const modal = new Modal(targetEl, options, instanceOptions); 127 128 129var loadingModal = { 130 modal: modal, 131 targetEl, 132 responseEl: $(targetEl).find('#loading-response'), 133 responseTextEl: $(targetEl).find('#loading-response-text'), 134 responseButtonEl: $(targetEl).find('#loading-response-button'), 135 indicatorEl: $(targetEl).find('#loading-indicator'), 136 init: function () { 137 this.modal.show(); 138 this.responseEl.hide(); 139 this.indicatorEl.show(); 140 }, 141 response: function (html) { 142 this.indicatorEl.hide(); 143 this.responseEl.show(); 144 this.responseTextEl.html(html); 145 this.responseButtonEl.click((e) => { 146 this.hide(); 147 }); 148 }, 149 hide: function () { 150 this.modal.hide(); 151 this.responseEl.hide(); 152 this.indicatorEl.show(); 153 }, 154} 155 156 157setTimeout(() => { 158 loadingModal.response('Olá Mateus...'); 159}, 400); 160 161$( document ).ready(function() { 162 $('[data-request="ajax"]').on('submit', function (e) { 163 e.preventDefault(); 164 165 loadingModal.init(); 166 167 var form = $(this); 168 169 var action = form.attr('action'); 170 var method = form.attr('method'); 171 172 var data = form.serialize(); 173 174 $.ajax({ 175 url: action, 176 type: method, 177 data: data, // serializes the form's elements. 178 cache: false, // Evitar cache 179 success: function (html) { 180 setTimeout(() => { 181 loadingModal.response(html); 182 183 form.trigger("reset"); 184 }, 300); 185 }, 186 error: function(result) { 187 console.log(result); 188 setTimeout(() => { 189 loadingModal.response('Verifique sua conexão com a internet.'); 190 }, 300); 191 }, 192 }); 193 }); 194}); 195 196 197$(function() { 198 $('#button-alterar').click(function(){ 199 var codigo = $('#modalSenha #codigo').val(); 200 if(!codigo){ 201 return Swal.fire( 202 'Atenção', 203 'Informe o login', 204 'warning' 205 ); 206 } 207 var provisoria = $('#modalSenha #provisoria').val(); 208 if(!provisoria){ 209 return Swal.fire( 210 'Atenção', 211 'Informe a senha provisória / atual', 212 'warning' 213 ); 214 } 215 var senha = $('#modalSenha #nova-senha').val(); 216 if(!senha){ 217 return Swal.fire( 218 'Atenção', 219 'Informe a senha nova', 220 'warning' 221 ); 222 } 223 if(senha.length < 8 || senha.length > 12) 224 { 225 return Swal.fire( 226 'Atenção', 227 'Senha obrigatório conter de 8 a 12 caractéres', 228 'warning' 229 ); 230 } 231 if(!/[a-z]/m.test(senha)) 232 { 233 return Swal.fire( 234 'Atenção', 235 'Sua senha precisa conter pelo menos uma letra minúscula', 236 'warning' 237 ); 238 } 239 if(!/[A-Z]/m.test(senha)) 240 { 241 return Swal.fire( 242 'Atenção', 243 'Sua senha precisa conter pelo menos uma letra maiúscula', 244 'warning' 245 ); 246 } 247 if(!/[0-9]/m.test(senha)) 248 { 249 return Swal.fire( 250 'Atenção', 251 'Sua senha precisa conter pelo menos um número', 252 'warning' 253 ); 254 } 255 if(!/[\@\*\&\-\!\#\$]/gm.test(senha)) 256 { 257 return Swal.fire( 258 'Atenção', 259 'Sua senha precisa conter pelo menos um sÃmbolo (@, *, &, -, !, # ou $)', 260 'warning' 261 ); 262 } 263 var confirmacao = $('#modalSenha #confirma-senha').val(); 264 if(!confirmacao){ 265 return Swal.fire( 266 'Atenção', 267 'Confirme a senha nova', 268 'warning' 269 ); 270 } 271 if(senha != confirmacao){ 272 return Swal.fire( 273 'Atenção',
274 'A confirmação da senha está incorreta', 275 'warning' 276 ); 277 } 278 $('.loader').fadeIn(); 279 $.post('request/token-senha.php', { 280 codigo: codigo, 281 provisoria: provisoria, 282 senha: senha, 283 confirmacao: confirmacao, 284 }) 285 .done(function(response){ 286 if(!response){ 287 $('.loader').fadeOut(); 288 Swal.fire( 289 'Atenção', 290 'Erro de conexão', 291 'error' 292 ); 293 } else if(response.error){ 294 $('.loader').fadeOut(); 295 Swal.fire( 296 'Atenção', 297 response.error, 298 'error' 299 ); 300 } else if(response.warning){ 301 $('.loader').fadeOut(); 302 Swal.fire( 303 'Atenção', 304 response.warning, 305 'warning' 306 ); 307 } else if(response.success){ 308 $('.loader').fadeOut(); 309 $('#token-senha').val(''); 310 $('#recebe_email').text(response.email); 311 $('#modalSenha').hide(); 312 $('#modalToken').show(); 313 $('#token-senha').focus(); 314 } else { 315 $('.loader').fadeOut(); 316 Swal.fire( 317 'Atenção', 318 'Erro de conexão, tente novamente', 319 'error' 320 ); 321 } 322 }) 323 .fail(function(){ 324 $('.loader').fadeOut(); 325 Swal.fire( 326 'Atenção', 327 'Erro de conexão, tente novamente', 328 'error' 329 ); 330 }); 331 }); 332 $('#button-token').click(function(){ 333 var codigo = $('#codigo').val(); 334 if(!codigo){ 335 return Swal.fire( 336 'Atenção', 337 'Informe o login', 338 'warning' 339 ); 340 } 341 var provisoria = $('#provisoria').val(); 342 if(!provisoria){ 343 return Swal.fire( 344 'Atenção', 345 'Informe a senha provisória / atual', 346 'warning' 347 ); 348 } 349 var senha = $('#nova-senha').val(); 350 if(!senha){ 351 return Swal.fire( 352 'Atenção', 353 'Informe a senha nova', 354 'warning' 355 ); 356 } 357 if(senha.length < 8 || senha.length > 12) 358 { 359 return Swal.fire( 360 'Atenção', 361 'Senha obrigatório conter de 8 a 12 caractéres', 362 'warning' 363 ); 364 } 365 if(!/[a-z]/m.test(senha)) 366 { 367 return Swal.fire( 368 'Atenção', 369 'Sua senha precisa conter pelo menos uma letra minúscula', 370 'warning' 371 ); 372 } 373 if(!/[A-Z]/m.test(senha)) 374 { 375 return Swal.fire( 376 'Atenção', 377 'Sua senha precisa conter pelo menos uma letra maiúscula', 378 'warning' 379 ); 380 } 381 if(!/[0-9]/m.test(senha)) 382 { 383 return Swal.fire( 384 'Atenção', 385 'Sua senha precisa conter pelo menos um número', 386 'warning' 387 ); 388 } 389 if(!/[\@\*\&\-\!\#\$]/gm.test(senha)) 390 { 391 return Swal.fire( 392 'Atenção', 393 'Sua senha precisa conter pelo menos um sÃmbolo (@, *, &, -, !, # ou $)', 394 'warning' 395 ); 396 } 397 var confirmacao = $('#confirma-senha').val(); 398 if(!confirmacao){ 399 return Swal.fire( 400 'Atenção', 401 'Confirme a senha nova', 402 'warning' 403 ); 404 } 405 if(senha != confirmacao){ 406 return Swal.fire( 407 'Atenção', 408 'A confirmação da senha está incorreta', 409 'warning' 410 ); 411 } 412 var token = $('#token-senha').val(); 413 if(!token){ 414 return Swal.fire( 415 'Atenção', 416 'Informe o token que foi enviado via e-mail', 417 'warning' 418 ); 419 } 420 $('.loader').fadeIn();
421 $.post('request/validar-trocar-senha.php', { 422 codigo: codigo, 423 provisoria: provisoria, 424 senha: senha, 425 confirmacao: confirmacao, 426 token: token 427 }) 428 .done(function(response){ 429 if(!response){ 430 $('.loader').fadeOut(); 431 Swal.fire( 432 'Atenção', 433 'Erro de conexão', 434 'error' 435 ); 436 } else if(response.error){ 437 $('.loader').fadeOut(); 438 Swal.fire( 439 'Atenção', 440 response.error, 441 'error' 442 ); 443 } else if(response.warning){ 444 $('.loader').fadeOut(); 445 Swal.fire( 446 'Atenção', 447 response.warning, 448 'warning' 449 ); 450 } else if(response.success){ 451 Swal.fire( 452 'Senha alterada com sucesso', 453 'Pode acessar a sua conta', 454 'success' 455 ); 456 $('.loader').fadeOut(); 457 $('#modalToken').hide(); 458 $('#tlogin').val(codigo); 459 $('#tsenha').val(''); 460 $('#tsenha').focus(); 461 try { grecaptcha.reset(); } catch(e){} 462 } else { 463 $('.loader').fadeOut(); 464 Swal.fire( 465 'Atenção', 466 'Erro de conexão, tente novamente', 467 'error' 468 ); 469 } 470 }) 471 .fail(function(){ 472 $('.loader').fadeOut(); 473 Swal.fire( 474 'Atenção', 475 'Erro de conexão, tente novamente', 476 'error' 477 ); 478 }); 479 }); 480 $('#flogin').submit(function(e){ 481 e.preventDefault(); 482 try { 483 var login = $('#tlogin').val(); 484 var senha = $('#tsenha').val(); 485 if(!login){ 486 return Swal.fire( 487 'Atenção', 488 'Informe seu login', 489 'warning' 490 ); 491 } 492 if(login.length < 4){ 493 return Swal.fire( 494 'Atenção', 495 'Informe um login válido', 496 'warning' 497 ); 498 } 499 if(!senha){ 500 return Swal.fire( 501 'Atenção', 502 'Informe sua senha', 503 'warning' 504 ); 505 } 506 if(senha.length < 5){ 507 return Swal.fire( 508 'Atenção', 509 'Usuário/Senha incorreta', 510 'warning' 511 ); 512 } 513 $('.loader').fadeIn(); 514 $.post('request/validar-login.php', { 515 login: login, 516 senha: senha 517 }) 518 .done(function(res){ 519 if(!res){ 520 $('.loader').fadeOut(); 521 522 Swal.fire( 523 'Atenção', 524 'Erro de conexão', 525 'error' 526 ); 527 528 try { grecaptcha.reset(); } catch(e){} 529 } else if(res.error){ 530 $('.loader').fadeOut(); 531 532 Swal.fire( 533 'Atenção', 534 res.error, 535 'error' 536 ); 537 538 try { grecaptcha.reset(); } catch(e){} 539 } else if(res.warning){ 540 $('.loader').fadeOut(); 541 542 Swal.fire( 543 'Atenção', 544 res.warning, 545 'warning' 546 ); 547 548 try { grecaptcha.reset(); } catch(e){} 549 } else if(res.recupera){ 550 Swal.fire( 551 'Atenção', 552 "Seu acesso foi bloqueado por excesso de tentativas!<br /><br /><div>Recupere sua senha para voltar a utilizar o sistema:<br /><a href='https://www.redecredauto.com.br/portal/esqueci' style='color: blue;'>Clique aqui para recuperar</a></div>", 553 'warning' 554 ); 555 $('.loader').fadeOut(); 556 try { grecaptcha.reset(); } catch(e){} 557 } else if(res.success){ 558 if(res.captcha) 559 { 560 $('#recaptcha-login').removeClass('hidden'); 561 $('.submit-holder, .esqueci').addClass('hidden'); 562 Swal.fire( 563 'Atenção', 564 'Para continuar, prove que não é robô', 565 'warning' 566 ); 567 $('.loader').fadeOut(); 568 try { grecaptcha.reset(); } catch(e){} 569 } 570 else 571 { 572 $('#recaptcha-login').addClass('hidden'); 573 $('.submit-holder, .esqueci').removeClass('hidden'); 574 continuarLogin(); 575 } 576 } else { 577 $('.loader').fadeOut(); 578 579 Swal.fire( 580 'Atenção', 581 'Erro de conexão', 582 'error' 583 ); 584 try { grecaptcha.reset(); } catch(e){} 585 } 586 }) 587 .fail(function(){ 588 Swal.fire( 589 'Erro de conexão', 590 'Verifique sua conexão com a internet', 591 'error' 592 ); 593 $('.loader').fadeOut(); 594 try { grecaptcha.reset(); } catch(e){} 595 }); 596 } catch(e){ 597 if (window.Sentry) Sentry.captureException(e); 598 Swal.fire( 599 'Atenção', 600 'Erro de conexão', 601 'error' 602 ); 603 $('.loader').fadeOut(); 604 try { grecaptcha.reset(); } catch(e){} 605 } 606 }); 607 $('.mostrar_senha').click(function(){ 608 if($('#vSenha').attr('type') == 'text'){ 609 $('.mostrar_senha').text('Mostrar Senha'); 610 $('#vSenha, #vConfirma').prop('type', 'password'); 611 } else { 612 $('.mostrar_senha').text('Ocultar Senha'); 613 $('#vSenha, #vConfirma').prop('type', 'text'); 614 } 615 }); 616 $('.mostrar_senha1').click(function(){ 617 if($('#provisoria').attr('type') == 'text'){ 618 $('.mostrar_senha1').text('Mostrar Senha'); 619 $('#provisoria').prop('type', 'password'); 620 } else { 621 $('.mostrar_senha1').text('Ocultar Senha'); 622 $('#provisoria').prop('type', 'text'); 623 } 624 });
625 $('.mostrar_senha2').click(function(){ 626 if($('#nova-senha').attr('type') == 'text'){ 627 $('.mostrar_senha2').text('Mostrar Senha'); 628 $('#nova-senha').prop('type', 'password'); 629 } else { 630 $('.mostrar_senha2').text('Ocultar Senha'); 631 $('#nova-senha').prop('type', 'text'); 632 } 633 634 if($('#confirma-senha').attr('type') == 'text'){ 635 $('.mostrar_senha2').text('Mostrar Senha'); 636 $('#confirma-senha').prop('type', 'password'); 637 } else { 638 $('.mostrar_senha2').text('Ocultar Senha'); 639 $('#confirma-senha').prop('type', 'text'); 640 } 641 }); 642 $('#modalSenha #login').keyup(function(){ 643 var s = $(this).val().replace(/[^0-9]+/g, ''); 644 $(this).val(s); 645 }); 646 $('#token-senha').keyup(function(){ 647 var s = $(this).val().replace(/[^0-9]+/g, ''); 648 $(this).val(s); 649 }); 650 $('#senha-secret').click(function(){ 651 if($('#tsenha').attr('type') == 'text'){ 652 $('#senha-secret').text('Mostrar Senha'); 653 $('#tsenha').prop('type', 'password'); 654 } else { 655 $('#senha-secret').text('Ocultar Senha'); 656 $('#tsenha').prop('type', 'text'); 657 } 658 }); 659 $('#placa-gratis').keyup(function(){ 660 $('#placa-gratis').val($('#placa-gratis').val().trim().toUpperCase().replace(/[^A-Z0-9]/g, '').substr(0, 7)); 661 }); 662 $('.inline').click(function(){ 663 intervalBox = setInterval(scrollBody, 1); 664 intervalSize = setInterval(sizeBox, 1); 665 }); 666 $('#voltar-token').click(function(){ 667 Swal.fire({ 668 title: 'Você tem certeza?', 669 showDenyButton: true, 670 showCancelButton: true, 671 confirmButtonText: 'Sim', 672 cancelButtonText: 'Não', 673 }).then((result) => { 674 console.log(result); 675 if (result.value) { 676 $('#modalToken').hide(); 677 $('#modalSenha').show(); 678 } 679 }) 680 }); 681 $('#voltar-senha').click(function(){ 682 Swal.fire({ 683 title: 'Você tem certeza?', 684 showDenyButton: true, 685 showCancelButton: true, 686 confirmButtonText: 'Sim', 687 cancelButtonText: 'Não', 688 }).then((result) => { 689 console.log(result); 690 if (result.value) { 691 $('#modalToken').hide(); 692 $('#modalSenha').hide(); 693 } 694 }) 695 }); 696 $('#colorbox').scroll(function(){ 697 var scroll = $(this).scrollTop(); 698 var elem = $("#colorbox"); 699 var max_scroll = (elem[0].scrollHeight - elem.outerHeight()) - 35; 700 if(scroll >= max_scroll){ 701 $('#colorbox').addClass('no-image'); 702 } else { 703 $('#colorbox').removeClass('no-image'); 704 } 705 }); 706 setInterval(sizeBox, 1); 707 $('.div-produto').click(function(){ 708 var title = $(this).find('strong').html(); 709 var href = $(this).attr('href'); 710 $(href + ' .texto-lightbox h2').html(title); 711 }); 712 $('.upperize').blur(function(){ 713 $(this).val($(this).val().trim().toUpperCase()); 714 }); 715 $('.upperize').keyup(function(){ 716 $(this).val($(this).val().toUpperCase()); 717 }); 718 $('input[name=email]').keyup(function(){ 719 $(this).val($(this).val().toLowerCase().trim()); 720 }); 721 $('input[name=cnpj]').keyup(function(){ 722 if(validate.cnpj($(this).val())){ 723 $('input[name=email]').focus(); 724 setTimeout(function(){ 725 $('input[name=cnpj]').trigger('blur'); 726 }, 1); 727 } 728 }); 729 $('input[name=telefone]').keyup(function(){ 730 if(validate.telefone($(this).val())){ 731 $('input[name=cep]').focus(); 732 setTimeout(function(){ 733 $('input[name=telefone]').trigger('blur'); 734 }, 1); 735 } 736 }); 737 $('input[name=celular]').keyup(function(){ 738 if(validate.celular($(this).val())){ 739 $('input[name=telefone]').focus(); 740 setTimeout(function(){ 741 $('input[name=celular]').trigger('blur'); 742 }, 1); 743 } 744 }); 745 if(localStorage.getItem('celular-gratis')){ 746 if($('#celular-gratis').length){ 747 $('#celular-gratis').val(localStorage.getItem('celular-gratis')); 748 $('#celular-gratis').trigger('keyup'); 749 setTimeout(function(){ $('.numerize').trigger('blur'); }, 1); 750 } 751 } 752 if(localStorage.getItem('cnpj-gratis')){ 753 if($('#cnpj-gratis').length){ 754 $('#cnpj-gratis').val(localStorage.getItem('cnpj-gratis')); 755 $('#cnpj-gratis').trigger('keyup'); 756 setTimeout(function(){ $('.numerize').trigger('blur'); }, 1); 757 } 758 } 759 $('#cnpj-gratis, #celular-gratis, #placa-gratis').keyup(function(){ 760 var id = $(this).attr('id'); 761 var regex_placa = /[A-Z]{3}[0-9]{1}[A-Z0-9]{1}[0-9]{2}/gm; 762 var placa = $('#placa-gratis').val().trim().toUpperCase().replace(/[^A-Z0-9]/g, '').substr(0, 7); 763 var cnpj = $('#cnpj-gratis').val().trim().toUpperCase().replace(/[^0-9A-Z]/g, ''); 764 var celular = $('#celular-gratis').val().trim().toUpperCase().replace(/[^0-9]/g, ''); 765 if(!regex_placa.test(placa) && id == 'placa-gratis') $(this).addClass('is-invalid'); 766 if(!validate.cnpj(cnpj) && id == 'cnpj-gratis') $(this).addClass('is-invalid'); 767 if(!validate.celular(celular) && id == 'celular-gratis') $(this).addClass('is-invalid'); 768 if(regex_placa.test(placa)) $('#placa-gratis').removeClass('is-invalid'); 769 if(validate.cnpj(cnpj)) $('#cnpj-gratis').removeClass('is-invalid'); 770 if(validate.celular(celular)) $('#celular-gratis').removeClass('is-invalid'); 771 if(regex_placa.test(placa) && validate.cnpj(cnpj) && validate.celular(celular)){ 772 $('#placa-gratis, #cnpj-gratis, #celular-gratis').removeClass('is-invalid'); 773 $(this).removeClass('is-invalid').blur(); 774 localStorage.setItem('cnpj-gratis', cnpj); 775 localStorage.setItem('celular-gratis', celular); 776 try { grecaptcha.reset(); } catch(e){} 777 $('#recaptcha-consulta-gratis').css('display', 'inline-table'); 778 } else { 779 $('#recaptcha-consulta-gratis').css('display', 'none'); 780 } 781 }); 782 $('input[name=cep]').keyup(function(){ 783 var cep = $(this).val();
784 var validacep = /^[0-9]{8}$/; 785 //Valida o formato do CEP. 786 if(validacep.test(cep)) { 787 setTimeout(function(){ 788 $('input[name=cep]').trigger('blur'); 789 }, 1); 790 $('input[name=logradouro]').focus(); 791 $("input[name=logradouro]").val("..."); 792 $("input[name=bairro]").val("..."); 793 $("input[name=cidade]").val("..."); 794 $("select[name=estado]").val(""); 795 $('.loader').fadeIn(); 796 $.getJSON("https://viacep.com.br/ws/"+ cep +"/json/?callback=?", function(dados) { 797 $('.loader').fadeOut(); 798 if (!("erro" in dados)) { 799 $("input[name=logradouro]").val(dados.logradouro.toUpperCase()); 800 $("input[name=bairro]").val(dados.bairro.toUpperCase()); 801 $("input[name=cidade]").val(dados.localidade.toUpperCase()); 802 $("select[name=estado]").val(dados.uf.toUpperCase()); 803 $('input[name=numero]').focus(); 804 } else { 805 $("input[name=logradouro]").val(""); 806 $("input[name=bairro]").val(""); 807 $("input[name=cidade]").val(""); 808 $("select[name=estado]").val(""); 809 Swal.fire( 810 'Atenção', 811 'CEP não encontrado', 812 'warning' 813 ).then(function(){ 814 setTimeout(function(){ 815 $('input[name=cep]').focus(); 816 }, 500); 817 }); 818 } 819 }); 820 } 821 }); 822 $('.lowerize').blur(function(){ 823 $(this).val($(this).val().trim().toLowerCase()); 824 }); 825 $('.lowerize').keyup(function(){ 826 $(this).val($(this).val().toLowerCase()); 827 }); 828 $('.numerize').keyup(function(){ 829 var validate = $(this).attr('data-validate'); 830 var value = validate == 'cnpj' 831 ? $(this).val().trim().toUpperCase().replace(/[^0-9A-Z]/g, '') 832 : $(this).val().trim().replace(/\D/g, ''); 833 var max = 50; 834 switch(validate){ 835 case 'cnpj': max = 14; break; 836 case 'cep': max = 8; break; 837 case 'celular': max = 11; break; 838 case 'telefone': max = 10; break; 839 } 840 value = value.substr(0, max); 841 $(this).attr('maxlength', String(max)); 842 $(this).val(value); 843 }); 844 $('.numerize').focus(function(){ 845 var validate = $(this).attr('data-validate'); 846 var value = validate == 'cnpj' 847 ? $(this).val().trim().toUpperCase().replace(/[^0-9A-Z]/g, '') 848 : $(this).val().trim().replace(/\D/g, ''); 849 var max = 50; 850 switch(validate){ 851 case 'cnpj': max = 14; break; 852 case 'cep': max = 8; break; 853 case 'celular': max = 11; break; 854 case 'telefone': max = 10; break; 855 } 856 value = value.substr(0, max); 857 $(this).attr('maxlength', String(max)); 858 $(this).val(value); 859 }); 860 $('.numerize').blur(function(){ 861 var validate = $(this).attr('data-validate'); 862 var value = validate == 'cnpj' 863 ? $(this).val().trim().toUpperCase().replace(/[^0-9A-Z]/g, '') 864 : $(this).val().trim().replace(/\D/g, ''); 865 var max = 50; 866 switch(validate){ 867 case 'cnpj': 868 max = 18; 869 if(value.length >= 14) 870 value = value.substr(0, 2) + '.' + value.substr(2, 3) + '.' + value.substr(5, 3) + '/' + value.substr(8, 4) + '-' + value.substr(-2) 871 break; 872 case 'cep': 873 max = 9; 874 if(value.length >= 8) 875 value = value.substr(0, 5) + '-' + value.substr(-3); 876 break; 877 case 'celular': 878 max = 15; 879 if(value.length >= 11) 880 value = '(' + value.substr(0, 2) + ') ' + value.substr(2, 5) + '-' + value.substr(-4) 881 break; 882 case 'telefone': 883 max = 14; 884 if(value.length >= 10) 885 value = '(' + value.substr(0, 2) + ') ' + value.substr(2, 4) + '-' + value.substr(-4) 886 break; 887 } 888 $(this).attr('maxlength', String(max)); 889 $(this).val(value); 890 }); 891 $('#contratar').click(function(){ 892 var _campos = []; 893 var campos = {}; 894 $('.pageContratar label').each(function(){ 895 var title = $(this).find('span').text(); 896 $(this).find('input, select').each(function(){ 897 var element = $(this); 898 var name = $(this).attr('name'); 899 var value = $(this).val(); 900 var required = $(this).attr('required') ? true : false;
901 var validate = $(this).attr('data-validate'); 902 if($(this).attr('type') == 'checkbox' && $(this).prop('checked')) value = "ok"; 903 else if($(this).attr('type') == 'checkbox' && !$(this).prop('checked')) value = ""; 904 _campos.push({ 905 value: value, 906 title: title, 907 required: required, 908 validate: validate, 909 element: element 910 }); 911 campos[name] = value; 912 }); 913 }); 914 var erro = false; 915 for (let campo of _campos) { 916 if(campo.required && !campo.value){ 917 Swal.fire( 918 'Atenção', 919 campo.title + ' obrigatório', 920 'warning' 921 ).then(function(){ 922 setTimeout(function(){ 923 campo.element.focus(); 924 }, 500); 925 }); 926 erro = true; 927 break; 928 } 929 if(campo.validate && campo.value){ 930 var valid = false; 931 switch(campo.validate){ 932 case 'cnpj': 933 valid = validate.cnpj(campo.value); 934 break; 935 case 'cep': 936 valid = validate.cep(campo.value); 937 break; 938 case 'celular': 939 valid = validate.celular(campo.value); 940 break; 941 case 'telefone': 942 valid = validate.telefone(campo.value); 943 break; 944 case 'email': 945 valid = validate.email(campo.value); 946 break; 947 } 948 if(!valid){ 949 Swal.fire( 950 'Atenção', 951 campo.title + ' inválido', 952 'warning' 953 ).then(function(){ 954 setTimeout(function(){ 955 campo.element.focus(); 956 }, 500); 957 }); 958 erro = true; 959 break; 960 } 961 } 962 } 963 if(!$('#produto-credito:checked').length && !$('#produto-veicular:checked').length && !erro){ 964 Swal.fire( 965 'Atenção', 966 'Escolha os produtos', 967 'warning' 968 ); 969 erro = true; 970 } 971 campos['captcha'] = grecaptcha.getResponse(); 972 if(!grecaptcha.getResponse() && !erro){ 973 Swal.fire( 974 'Atenção', 975 'Resolva o captcha', 976 'warning' 977 ); 978 erro = true; 979 } 980 if(!erro){ 981 $('.loader').fadeIn(function(){ 982 $.post('request/cadastro.php', campos) 983 .done(function(res){ 984 if(!res){ 985 Swal.fire( 986 'Atenção', 987 'Erro de conexão', 988 'error' 989 ); 990 } else if(res.error){ 991 Swal.fire( 992 'Atenção', 993 res.error, 994 'error' 995 ); 996 } else if(res.warning){ 997 Swal.fire( 998 'Atenção', 999 res.warning, 1000 'warning' 1001 ); 1002 } else if(res.success){ 1003 Swal.fire( 1004 'Seus dados foram\nenviados com sucesso!', 1005 'Aguarde, pois a nossa equipe entrará<br />em contato com você em breve', 1006 'success' 1007 ).then(function(){ 1008 window.location.reload(); 1009 }); 1010 } else { 1011 Swal.fire( 1012 'Atenção', 1013 'Erro de conexão', 1014 'error' 1015 ); 1016 } 1017 $('.loader').fadeOut(); 1018 }) 1019 .fail(function(){ 1020 Swal.fire( 1021 'Atenção', 1022 'Erro de conexão', 1023 'error' 1024 ); 1025 $('.loader').fadeOut(); 1026 }) 1027 .always(function(){ 1028 try { grecaptcha.reset(); } catch(e){} 1029 }); 1030 }); 1031 } 1032 }); 1033 var i = 0; 1034 $('.pageContratar label').each(function(){ 1035 var span = $(this).find('span').text(); 1036 $(this).find('input, textarea, select').attr('placeholder', 'Preencher ' + span); 1037 $(this).attr('title', 'Preencher ' + span); 1038 i++; 1039 }); 1040 $('#entrar').click(function(){ 1041 $('#flogin').submit(); 1042 }); 1043 /*if ($('a.aviso').length) { 1044 $('a.aviso').colorbox({ open: true }); 1045 }*/ 1046 $('.icon-segvia').click(function() { 1047 $('#modalBoleto').show(); 1048 }); 1049 $('#cnpj_segvia').keyup(function(){ 1050 $(this).val($(this).val().toUpperCase().replace(/[^0-9A-Z]/g, '')); 1051 }); 1052 $('#login_segvia').keyup(function(){ 1053 $(this).val($(this).val().replace(/\D/g, '')); 1054 }); 1055 $('.fechar-segvia').click(function() { 1056 $('.modal input').prop('disabled', false); 1057 $('.segvia-buttons').show(); 1058 $('.inputs-boleto').show(); 1059 $('.loading-segvia').hide(); 1060 $('.download-segvia').hide(); 1061 $('#modalBoleto').hide(); 1062 $('#cnpj_segvia').val(''); 1063 $('#login_segvia').val(''); 1064 }); 1065 if(!localStorage.getItem('data-cookie')){ 1066 $('.cookies').fadeIn(); 1067 } 1068 $('#aceite-cookies').click(function(){ 1069 localStorage.setItem('data-cookie', new Date().toString()); 1070 $('.cookies').fadeOut(); 1071 }); 1072 $('.enviar-segvia').click(function() { 1073 var cnpj = $('#cnpj_segvia').val().toUpperCase().replace(/[^0-9A-Z]/g, ''); 1074 var login = $('#login_segvia').val(); 1075 if(!cnpj && !login){ 1076 Swal.fire( 1077 'Atenção', 1078 'Informe o CPF/CNPJ e Login', 1079 'warning' 1080 ); 1081 return false;
1082 } 1083 if(cnpj.length != 14 && cnpj.length != 11){ 1084 Swal.fire( 1085 'Atenção', 1086 'Informe um CPF ou CNPJ válido', 1087 'warning' 1088 ); 1089 return false; 1090 } 1091 if(login.length < 4){ 1092 Swal.fire( 1093 'Atenção', 1094 'Informe um Login válido', 1095 'warning' 1096 ); 1097 return false; 1098 } 1099 $('.modal input').prop('disabled', true); 1100 $('.segvia-buttons').hide(); 1101 $('.loader').fadeIn(); 1102 $.post('request/solicita-segvia.php', { 1103 cnpj: cnpj, 1104 login: login, 1105 }) 1106 .done(function(res){ 1107 if(res.includes('boleto')){ 1108 $('.segvia-buttons').hide(); 1109 $('.loader').fadeOut(); 1110 $('.inputs-boleto').hide(); 1111 $('.download-segvia').show(); 1112 $('#cnpj_segvia').val(''); 1113 $('#login_segvia').val(''); 1114 $('.baixar-segvia').attr('href', res); 1115 } else if(res == '3'){ 1116 Swal.fire( 1117 'Atenção', 1118 'Nenhum boleto em aberto foi localizado para o cliente informado', 1119 'warning' 1120 ); 1121 $('.modal input').prop('disabled', false); 1122 $('.segvia-buttons').show(); 1123 $('.loader').fadeOut(); 1124 } else if(res == '4'){ 1125 Swal.fire( 1126 'Atenção', 1127 'Cadastro não localizado', 1128 'warning' 1129 ); 1130 $('.modal input').prop('disabled', false); 1131 $('.segvia-buttons').show(); 1132 $('.loader').fadeOut(); 1133 } else { 1134 $('.modal input').prop('disabled', false); 1135 $('.segvia-buttons').show(); 1136 $('.loader').fadeOut(); 1137 $('#modalBoleto').hide(); 1138 $('#cnpj_segvia').val(''); 1139 $('#login_segvia').val(''); 1140 Swal.fire( 1141 'Atenção', 1142 'Erro desconhecido', 1143 'error' 1144 ); 1145 } 1146 }) 1147 .fail(function(){ 1148 Swal.fire( 1149 'Atenção', 1150 'Erro desconhecido', 1151 'error' 1152 ); 1153 $('.modal input').prop('disabled', false); 1154 $('.segvia-buttons').show(); 1155 $('.loader').fadeOut(); 1156 }); 1157 }); 1158 $('.solicitar-segvia').click(function() { 1159 var modal = document.getElementById('modalBoleto'); 1160 modal.style.display = 'none'; 1161 }); 1162 if ($('a.colorbox2').length) { 1163 $('a.colorbox2').colorbox(); 1164 } 1165 // if ($('#camera_wrap_1').length) { 1166 // $('#camera_wrap_1').camera({ 1167 // height: '320px', 1168 // pagination: false, 1169 // time: 3000, 1170 // loader: false, 1171 // hover: true, 1172 // fx: 'scrollLeft' 1173 // }); 1174 // } 1175 if ($('.magnific').length) { 1176 $('.magnific').magnificPopup({ 1177 type: 'image', 1178 callbacks: { 1179 elementParse: function(item) { 1180 $('.mfp-img').hide(); 1181 } 1182 } 1183 }); 1184 } 1185 if ($("#accordion").length) { 1186 $("#accordion").accordion({ 1187 autoHeight: false, 1188 active: false, 1189 navigation: true, 1190 heightStyle: "content", 1191 collapsible: true, 1192 animate: 400 1193 }); 1194 $('#accordion h3').bind('click', function() { 1195 var self = this; 1196 setTimeout(function() { 1197 theOffset = $(self).offset(); 1198 $('body,html').animate({ scrollTop: theOffset.top - 100 }); 1199 }, 310); 1200 }); 1201 } 1202 if ($("#accordion2").length) { 1203 $("#accordion2").accordion({ 1204 autoHeight: false, 1205 active: false, 1206 navigation: true, 1207 heightStyle: "content", 1208 collapsible: true, 1209 }); 1210 $('#accordion2 h3').bind('click', function() { 1211 var self = this; 1212 setTimeout(function() { 1213 theOffset = $(self).offset(); 1214 $('body,html').animate({ scrollTop: theOffset.top - 100 }); 1215 }, 310); 1216 }); 1217 } 1218 if ($('.nav').length) { 1219 $('.nav').click(function() { 1220 if ($(this).hasClass('wait')) return false;
1221 $(this).addClass('wait'); 1222 $('.menu').slideToggle('slow', function() { 1223 $('.nav').removeClass('wait'); 1224 }); 1225 }); 1226 } 1227 var verBanner = function() { 1228 $('.cameraContent').each(function() { 1229 var content = $(this); 1230 var caption = content.find('.camera_caption'); 1231 var a = caption.find('a'); 1232 if (a.hasClass('addEvent')) { 1233 var href = a.attr('href'); 1234 caption.hide(); 1235 content.css('cursor', 'pointer'); 1236 content.attr('title', href); 1237 var target = a.attr('target'); 1238 if (!a.hasClass('process')) { 1239 content.click(function() { 1240 if(target){ 1241 window.location.href = href; 1242 } else { 1243 var win = window.open(href, '_blank'); 1244 win.focus(); 1245 } 1246 }); 1247 } 1248 a.addClass('process'); 1249 } 1250 }); 1251 }; 1252 verBanner(); 1253 setInterval(verBanner, 100); 1254 setTimeout(function() { 1255 if ($('.slider-mobile').length) { 1256 $('.camera_src div').each(function() { 1257 var src = $(this).attr('data-src'); 1258 slides.push(src); 1259 }); 1260 $('.cameraContent').each(function() { 1261 var link = ''; 1262 if (!$(this).find('a').attr('href')) link = "vazio"; 1263 else link = $(this).find('a').attr('href'); 1264 links.push(link); 1265 }); 1266 $('.slider-mobile img').attr('src', slides[current]); 1267 if (links[current] != 'vazio') { 1268 $('.slider-mobile a').attr('href', links[current]); 1269 $('.slider-mobile a').css('cursor', 'pointer'); 1270 $('.slider-mobile a').attr('target', '_blank'); 1271 } else { 1272 $('.slider-mobile a').attr('href', 'javascript:void(0);'); 1273 $('.slider-mobile a').css('cursor', 'default'); 1274 $('.slider-mobile a').removeAttr('target'); 1275 } 1276 setInterval(function() { 1277 if (current > (slides.length - 1)) current = 0; 1278 $('.slider-mobile img').css('opacity', '0'); 1279 setTimeout(function() { 1280 $('.slider-mobile img').attr('src', slides[current]); 1281 if (links[current] != 'vazio') { 1282 $('.slider-mobile a').attr('href', links[current]); 1283 $('.slider-mobile a').css('cursor', 'pointer'); 1284 $('.slider-mobile a').attr('target', '_blank'); 1285 } else { 1286 $('.slider-mobile a').attr('href', 'javascript:void(0);'); 1287 $('.slider-mobile a').css('cursor', 'default'); 1288 $('.slider-mobile a').removeAttr('target'); 1289 } 1290 $('.slider-mobile img').css('opacity', '1'); 1291 }, 1000); 1292 current += 1; 1293 }, 10000); 1294 } 1295 }, 1000); 1296 $('#tipo-veiculo').change(function(){ 1297 try { grecaptcha.reset(); } catch(e){} 1298 var tipo = $(this).val(); 1299 $('#marca-veiculo, #modelo-veiculo, #ano-veiculo').html(''); 1300 $('#label-marcas, #label-modelos, #label-anos').hide(); 1301 $('#consulta-fipe').css('display', 'none'); 1302 $('#recaptcha-fipe').css('display', 'none'); 1303 if(tipo){ 1304 $('.loader').fadeIn(function(){ 1305 $.post('request/fipe.php', { 1306 action: 'marcas', 1307 tipo: tipo, 1308 }) 1309 .done(function(res){ 1310 if(!res){ 1311 Swal.fire( 1312 'Atenção', 1313 'Erro de conexão', 1314 'error' 1315 ); 1316 } else if(res.error){ 1317 Swal.fire( 1318 'Atenção', 1319 res.error, 1320 'error' 1321 ); 1322 } else if(res.warning){ 1323 Swal.fire( 1324 'Atenção', 1325 res.warning, 1326 'warning' 1327 ); 1328 } else if(res.marcas){ 1329 var html = '<option value="">SELECIONE...</option>'; 1330 for (let marca of res.marcas){ 1331 html += '<option value="' + marca.id + '">' + marca.nome.toUpperCase() + "</option>"; 1332 } 1333 $('#marca-veiculo').html(html); 1334 $('#label-marcas').css('display', 'block'); 1335 } else { 1336 Swal.fire( 1337 'Atenção', 1338 'Erro de conexão', 1339 'error' 1340 ); 1341 } 1342 }) 1343 .fail(function(){ 1344 Swal.fire( 1345 'Atenção', 1346 'Erro de conexão', 1347 'error' 1348 ); 1349 }) 1350 .always(function(){ 1351 $('.loader').fadeOut(); 1352 }); 1353 }); 1354 } 1355 }); 1356 $('#marca-veiculo').change(function(){ 1357 try { grecaptcha.reset(); } catch(e){} 1358 var marca = $(this).val(); 1359 var tipo = $('#tipo-veiculo').val(); 1360 $('#modelo-veiculo, #ano-veiculo').html(''); 1361 $('#label-modelos, #label-anos').hide(); 1362 $('#consulta-fipe').css('display', 'none'); 1363 $('#recaptcha-fipe').css('display', 'none'); 1364 if(marca){ 1365 $('.loader').fadeIn(function(){ 1366 $.post('request/fipe.php', { 1367 tipo: tipo, 1368 marca: marca, 1369 action: 'modelos' 1370 }) 1371 .done(function(res){ 1372 if(!res){ 1373 Swal.fire( 1374 'Atenção', 1375 'Erro de conexão', 1376 'error' 1377 ); 1378 } else if(res.error){ 1379 Swal.fire( 1380 'Atenção', 1381 res.error, 1382 'error' 1383 ); 1384 } else if(res.warning){ 1385 Swal.fire( 1386 'Atenção', 1387 res.warning, 1388 'warning' 1389 ); 1390 } else if(res.modelos){ 1391 var html = '<option value="">SELECIONE...</option>'; 1392 for (let modelo of res.modelos){ 1393 html += '<option value="' + modelo.id + '">' + modelo.nome.toUpperCase() + "</option>"; 1394 } 1395 $('#modelo-veiculo').html(html); 1396 $('#label-modelos').css('display', 'block'); 1397 } else { 1398 Swal.fire( 1399 'Atenção', 1400 'Erro de conexão', 1401 'error' 1402 ); 1403 } 1404 }) 1405 .fail(function(){ 1406 Swal.fire( 1407 'Atenção', 1408 'Erro de conexão', 1409 'error' 1410 ); 1411 }) 1412 .always(function(){ 1413 $('.loader').fadeOut(); 1414 }); 1415 }); 1416 } 1417 }); 1418 $('#modelo-veiculo').change(function(){ 1419 try { grecaptcha.reset(); } catch(e){} 1420 var modelo = $(this).val(); 1421 var marca = $('#marca-veiculo').val(); 1422 var tipo = $('#tipo-veiculo').val(); 1423 $('#consulta-fipe').css('display', 'none'); 1424 $('#recaptcha-fipe').css('display', 'none'); 1425 $('#ano-veiculo').html(''); 1426 $('#label-anos').hide(); 1427 if(modelo){ 1428 $('.loader').fadeIn(function(){ 1429 $.post('request/fipe.php', { 1430 tipo: tipo, 1431 marca: marca, 1432 modelo: modelo, 1433 action: 'anos' 1434 }) 1435 .done(function(res){ 1436 if(!res){ 1437 Swal.fire( 1438 'Atenção', 1439 'Erro de conexão', 1440 'error' 1441 ); 1442 } else if(res.error){ 1443 Swal.fire( 1444 'Atenção', 1445 res.error, 1446 'error' 1447 ); 1448 } else if(res.warning){ 1449 Swal.fire( 1450 'Atenção', 1451 res.warning, 1452 'warning' 1453 ); 1454 } else if(res.anos){ 1455 var html = '<option value="">SELECIONE...</option>'; 1456 for (let ano of res.anos){ 1457 html += '<option value="' + ano.id + '">' + ano.nome.toUpperCase() + "</option>"; 1458 } 1459 $('#ano-veiculo').html(html); 1460 $('#label-anos').css('display', 'block'); 1461 } else { 1462 Swal.fire( 1463 'Atenção', 1464 'Erro de conexão', 1465 'error' 1466 ); 1467 } 1468 }) 1469 .fail(function(){ 1470 Swal.fire( 1471 'Atenção', 1472 'Erro de conexão', 1473 'error' 1474 ); 1475 }) 1476 .always(function(){ 1477 $('.loader').fadeOut(); 1478 }); 1479 }); 1480 } 1481 }); 1482 $('#ano-veiculo').change(function(){ 1483 var ano = $(this).val(); 1484 if(ano){ 1485 $('#recaptcha-fipe').css('display', 'inline-table'); 1486 $('#consulta-fipe').css('display', 'inline-table'); 1487 } else { 1488 $('#consulta-fipe').css('display', 'none'); 1489 $('#recaptcha-fipe').css('display', 'none'); 1490 } 1491 }); 1492 $('#nova-fipe').click(function(){ 1493 $('.grid_resultado').addClass('hidden'); 1494 $('.grid_fipe').removeClass('hidden'); 1495 }); 1496 $('#button_senha').click(function(){ 1497 var login = $('#vEsqueciLogin').val(); 1498 var documento = $('#vEsqueciDoc').val(); 1499 if(!login){ 1500 Swal.fire( 1501 'Atenção', 1502 'Informe o login', 1503 'warning' 1504 ); 1505 } else if(!documento){ 1506 Swal.fire( 1507 'Atenção', 1508 'Informe o CPF/CNPJ', 1509 'warning' 1510 ); 1511 } else if(!validate.cnpj(documento) && !validate.cpf(documento)){ 1512 Swal.fire( 1513 'Atenção', 1514 'CPF/CNPJ inválido', 1515 'warning' 1516 ); 1517 } else { 1518 $('.loader').fadeIn(function(){ 1519 $.post('request/recuperar_senha.php', { 1520 login: login, 1521 documento: documento, 1522 action: 'dados' 1523 }) 1524 .done(function(res){ 1525 if(!res){ 1526 Swal.fire( 1527 'Atenção', 1528 'Erro de conexão', 1529 'error' 1530 ); 1531 } else if(res.error){ 1532 Swal.fire( 1533 'Atenção', 1534 res.error, 1535 'error' 1536 ); 1537 } else if(res.warning){ 1538 Swal.fire( 1539 'Atenção', 1540 res.warning, 1541 'warning' 1542 ); 1543 } else if(res.success){ 1544 $('#recebe_email').text(res.email); 1545 $('#recebe_celular').text(res.celular); 1546 if(res.email) $('#label-email').css('display', 'block'); 1547 else $('#label-email').css('display', 'none');
1548 if(res.celular) $('#label-celular').css('display', 'block'); 1549 else $('#label-celular').css('display', 'none'); 1550 if(res.email && !res.celular) $('#check-email').prop('checked', true); 1551 else if(!res.email && res.celular) $('#check-celular').prop('checked', true); 1552 else $('#check-celular').prop('checked', true); 1553 $('#esqueci_dados').hide(); 1554 $('#esqueci_metodo').show(); 1555 } else { 1556 Swal.fire( 1557 'Atenção', 1558 'Erro de conexão', 1559 'error' 1560 ); 1561 } 1562 $('.loader').fadeOut(); 1563 }) 1564 .fail(function(){ 1565 Swal.fire( 1566 'Atenção', 1567 'Erro de conexão', 1568 'error' 1569 ); 1570 $('.loader').fadeOut(); 1571 }); 1572 }); 1573 } 1574 }); 1575 $('#vToken').keyup(function(){ 1576 $(this).val($(this).val().trim().replace(/ /g, '').toUpperCase()); 1577 }); 1578 $('#button_metodo').click(function(){ 1579 var metodo = $('#check-email').prop('checked') ? 1 : 2; 1580 var login = $('#vEsqueciLogin').val(); 1581 var documento = $('#vEsqueciDoc').val(); 1582 $('.loader').fadeIn(function(){ 1583 $.post('request/recuperar_senha.php', { 1584 login: login, 1585 documento: documento, 1586 metodo: metodo, 1587 action: 'token' 1588 }) 1589 .done(function(res){ 1590 if(!res){ 1591 Swal.fire( 1592 'Atenção', 1593 'Erro de conexão', 1594 'error' 1595 ); 1596 } else if(res.error){ 1597 Swal.fire( 1598 'Atenção', 1599 res.error, 1600 'error' 1601 ); 1602 } else if(res.warning){ 1603 Swal.fire( 1604 'Atenção', 1605 res.warning, 1606 'warning' 1607 ); 1608 } else if(res.success){ 1609 Swal.fire( 1610 'Atenção', 1611 'Token enviado com sucesso', 1612 'success' 1613 ); 1614 $('#esqueci_dados').hide(); 1615 $('#esqueci_metodo').hide(); 1616 $('#esqueci_token').show(); 1617 if(metodo == 1){ 1618 $('#recebe_metodo').text('e-mail ' + $('#recebe_email').text()); 1619 } 1620 if(metodo == 2){ 1621 $('#recebe_metodo').text('SMS ' + $('#recebe_celular').text()); 1622 } 1623 $('#vToken').focus(); 1624 } else { 1625 Swal.fire( 1626 'Atenção', 1627 'Erro de conexão', 1628 'error' 1629 ); 1630 } 1631 $('.loader').fadeOut(); 1632 }) 1633 .fail(function(){ 1634 Swal.fire( 1635 'Atenção', 1636 'Erro de conexão', 1637 'error' 1638 ); 1639 $('.loader').fadeOut(); 1640 }); 1641 }); 1642 }); 1643 $('#button_recuperar').click(function(){ 1644 var login = $('#vEsqueciLogin').val(); 1645 var token = $('#vToken').val(); 1646 var documento = $('#vEsqueciDoc').val(); 1647 if(!token) 1648 { 1649 Swal.fire( 1650 'Atenção', 1651 'Informe o token', 1652 'warning' 1653 ); 1654 return false; 1655 } 1656 $('.loader').fadeIn(function(){ 1657 $.post('request/recuperar_senha.php', { 1658 login: login, 1659 documento: documento, 1660 token: token, 1661 action: 'recuperar' 1662 }) 1663 .done(function(res){ 1664 if(!res){ 1665 Swal.fire( 1666 'Atenção', 1667 'Erro de conexão', 1668 'error' 1669 ); 1670 } else if(res.error){ 1671 Swal.fire( 1672 'Atenção', 1673 res.error, 1674 'error' 1675 ); 1676 } else if(res.warning){ 1677 Swal.fire( 1678 'Atenção', 1679 res.warning, 1680 'warning' 1681 ); 1682 } else if(res.success){ 1683 Swal.fire( 1684 'Atenção', 1685 'Token validado com sucesso', 1686 'success' 1687 ); 1688 $('#recebe_login').text(login); 1689 $('#esqueci_dados').hide(); 1690 $('#esqueci_metodo').hide(); 1691 $('#esqueci_token').hide(); 1692 $('#esqueci_senha').show(); 1693 } else { 1694 Swal.fire( 1695 'Atenção', 1696 'Erro de conexão', 1697 'error' 1698 ); 1699 } 1700 $('.loader').fadeOut(); 1701 }) 1702 .fail(function(){ 1703 Swal.fire( 1704 'Atenção', 1705 'Erro de conexão', 1706 'error' 1707 ); 1708 $('.loader').fadeOut(); 1709 }); 1710 }); 1711 }); 1712 $('#button_alterar').click(function(){ 1713 var login = $('#vEsqueciLogin').val(); 1714 var token = $('#vToken').val(); 1715 var documento = $('#vEsqueciDoc').val(); 1716 var senha = $('#vSenha').val(); 1717 var confirma = $('#vConfirma').val(); 1718 if(!senha) 1719 { 1720 Swal.fire( 1721 'Atenção', 1722 'Informe a nova senha', 1723 'warning' 1724 ); 1725 return false;
1726 } 1727 if(senha.length < 8 || senha.length > 12) 1728 { 1729 Swal.fire( 1730 'Atenção', 1731 'Senha obrigatório conter de 8 a 12 caractéres', 1732 'warning' 1733 ); 1734 return false; 1735 } 1736 if(!/[a-z]/m.test(senha)) 1737 { 1738 Swal.fire( 1739 'Atenção', 1740 'Sua senha precisa conter pelo menos uma letra minúscula', 1741 'warning' 1742 ); 1743 return false; 1744 } 1745 if(!/[A-Z]/m.test(senha)) 1746 { 1747 Swal.fire( 1748 'Atenção', 1749 'Sua senha precisa conter pelo menos uma letra maiúscula', 1750 'warning' 1751 ); 1752 return false; 1753 } 1754 if(!/[0-9]/m.test(senha)) 1755 { 1756 Swal.fire( 1757 'Atenção', 1758 'Sua senha precisa conter pelo menos um número', 1759 'warning' 1760 ); 1761 return false; 1762 } 1763 if(!/[\@\*\&\-\!\#\$]/gm.test(senha)) 1764 { 1765 Swal.fire( 1766 'Atenção', 1767 'Sua senha precisa conter pelo menos um sÃmbolo (@, *, &, -, !, # ou $)', 1768 'warning' 1769 ); 1770 return false; 1771 } 1772 if(!confirma) 1773 { 1774 Swal.fire( 1775 'Atenção', 1776 'Confirme a nova senha', 1777 'warning' 1778 ); 1779 return false; 1780 } 1781 if(senha != confirma) 1782 { 1783 Swal.fire( 1784 'Atenção', 1785 'A confirmação da senha está incorreta', 1786 'warning' 1787 ); 1788 return false; 1789 } 1790 $('.loader').fadeIn(function(){ 1791 $.post('request/recuperar_senha.php', { 1792 login: login, 1793 documento: documento, 1794 senha: senha, 1795 confirma: confirma, 1796 token: token, 1797 action: 'alterar' 1798 }) 1799 .done(function(res){ 1800 if(!res){ 1801 Swal.fire( 1802 'Atenção', 1803 'Erro de conexão', 1804 'error' 1805 ); 1806 } else if(res.error){ 1807 Swal.fire( 1808 'Atenção', 1809 res.error, 1810 'error' 1811 ); 1812 } else if(res.warning){ 1813 Swal.fire( 1814 'Atenção', 1815 res.warning, 1816 'warning' 1817 ); 1818 } else if(res.success){ 1819 try { grecaptcha.reset(); } catch(e){} 1820 Swal.fire( 1821 'Atenção', 1822 'Sua senha foi alterada com sucesso', 1823 'success' 1824 ).then(function(){ 1825 window.location.href = baseURL; 1826 }); 1827 } else { 1828 Swal.fire( 1829 'Atenção', 1830 'Erro de conexão', 1831 'error' 1832 ); 1833 } 1834 $('.loader').fadeOut(); 1835 }) 1836 .fail(function(){ 1837 Swal.fire( 1838 'Atenção', 1839 'Erro de conexão', 1840 'error' 1841 ); 1842 $('.loader').fadeOut(); 1843 }); 1844 }); 1845 }); 1846}); 1847 1848 1849function continuarLogin(){ 1850 try { 1851 var login = $('#tlogin').val(); 1852 var senha = $('#tsenha').val(); 1853 var captcha = ''; 1854 try { 1855 captcha = grecaptcha.getResponse(); 1856 } catch(e){ 1857 captcha = ''; 1858 } 1859 $('.loader').fadeIn(); 1860 $.post('request/efetuar-login.php', { 1861 login: login, 1862 senha: senha, 1863 captcha: captcha 1864 }) 1865 .done(function(res){ 1866 if(!res){ 1867 $('#tlogin').val(''); 1868 $('#tsenha').val(''); 1869 1870 Swal.fire( 1871 'Atenção', 1872 'Erro de conexão', 1873 'error' 1874 ); 1875 1876 try { grecaptcha.reset(); } catch(e){} 1877 } else if(res.error){ 1878 $('#tlogin').val(''); 1879 $('#tsenha').val(''); 1880 1881 if(res.captcha) 1882 { 1883 $('#recaptcha-login').removeClass('hidden'); 1884 $('.submit-holder, .esqueci').addClass('hidden'); 1885 } 1886 else 1887 { 1888 $('#recaptcha-login').addClass('hidden'); 1889 $('.submit-holder, .esqueci').removeClass('hidden'); 1890 } 1891 1892 $('.loader').fadeOut(); 1893 1894 Swal.fire( 1895 'Atenção', 1896 res.error, 1897 'error' 1898 ); 1899 1900 try { grecaptcha.reset(); } catch(e){} 1901 } else if(res.warning){ 1902 $('#tlogin').val(''); 1903 $('#tsenha').val(''); 1904 1905 if(res.captcha) 1906 { 1907 $('#recaptcha-login').removeClass('hidden'); 1908 $('.submit-holder, .esqueci').addClass('hidden'); 1909 } 1910 else 1911 { 1912 $('#recaptcha-login').addClass('hidden'); 1913 $('.submit-holder, .esqueci').removeClass('hidden'); 1914 } 1915 1916 $('.loader').fadeOut(); 1917 1918 Swal.fire( 1919 'Atenção', 1920 res.warning, 1921 'warning' 1922 ); 1923 1924 try { grecaptcha.reset(); } catch(e){} 1925 } else if(res.log){ 1926 $('.loader').fadeOut(); 1927 $('#provisoria').val(''); 1928 $('#nova-senha').val(''); 1929 $('#confirma-senha').val(''); 1930 $('#token-senha').val(''); 1931 $('#modalSenha #codigo').val($('#tlogin').val()); 1932 $('#modalSenha').show(); 1933 $('#provisoria').focus(); 1934 } else if(res.success){ 1935 sessionStorage.removeItem('bannerTime'); 1936 $irParaSistema(res); 1937 } else if(res.bloqueio){ 1938 $('#tlogin').val(''); 1939 $('#tsenha').val(''); 1940 1941 $('.loader').fadeOut(); 1942 1943 if(res.boleto) 1944 { 1945 Swal.fire( 1946 'Atenção', 1947 `Prezado cliente (${login}),<br /<br />O seu acesso ao sistema de consultas da Rede Cred Auto encontra-se <strong>bloqueado</strong>.<br /><br /><strong>Realize o pagamento:</strong> Em caso de valores em aberto, acesse um novo boleto para pagamento<br /><br /><a href='${res.link_boleto}' target='_blank' style='color: blue'>Clique aqui para visualizar o boleto</a><br /><br /><strong>Fale com nosso time:</strong> Informações e atendimento com nossa equipe através do WhatsApp<br /><br /><a href='${res.link_atendimento}' target='_blank' style='color: blue'>Clique aqui para conversar via WhatsApp</a><br /><br />Estamos à sua inteira disposição.`, 1948 'warning' 1949 ); 1950 } 1951 else 1952 { 1953 Swal.fire( 1954 'Atenção', 1955 `Prezado cliente (${login}),<br /<br />O seu acesso ao sistema de consultas da Rede Cred Auto encontra-se <strong>bloqueado</strong>.<br /><br /><strong>Fale com nosso time:</strong> Informações e atendimento com nossa equipe através do WhatsApp<br /><br /><a href='${res.link_atendimento}' target='_blank' style='color: blue'>Clique aqui para conversar via WhatsApp</a><br /><br />Estamos à sua inteira disposição.`, 1956 'warning' 1957 ); 1958 } 1959 1960 try { grecaptcha.reset(); } catch(e){} 1961 } else if(res.recupera){ 1962 $('#tlogin').val(''); 1963 $('#tsenha').val(''); 1964 1965 Swal.fire( 1966 'Atenção', 1967 "Seu acesso foi bloqueado por excesso de tentativas!<br /><br /><div>Recupere sua senha para voltar a utilizar o sistema:<br /><a href='https://www.redecredauto.com.br/portal/esqueci' style='color: blue;'>Clique aqui para recuperar</a></div>", 1968 'warning' 1969 ); 1970 $('.loader').fadeOut(); 1971 try { grecaptcha.reset(); } catch(e){} 1972 } else { 1973 $('#tlogin').val(''); 1974 $('#tsenha').val(''); 1975 1976 $('.loader').fadeOut(); 1977 1978 Swal.fire( 1979 'Atenção', 1980 'Erro de conexão', 1981 'error' 1982 ); 1983 try { grecaptcha.reset(); } catch(e){} 1984 } 1985 }) 1986 .fail(function(){ 1987 Swal.fire( 1988 'Erro de conexão', 1989 'Verifique sua conexão com a internet', 1990 'error' 1991 ); 1992 $('.loader').fadeOut(); 1993 try { grecaptcha.reset(); } catch(e){} 1994 }); 1995 } catch(e){ 1996 if (window.Sentry) Sentry.captureException(e); 1997 Swal.fire( 1998 'Atenção', 1999 'Erro de conexão', 2000 'error' 2001 ); 2002 $('.loader').fadeOut(); 2003 try { grecaptcha.reset(); } catch(e){} 2004 } 2005} 2006 2007 2008// $('#flogin').submit(function(e){ 2009// e.preventDefault(); 2010 2011// try { 2012// var login = $('#tlogin').val(); 2013// var senha = $('#tsenha').val(); 2014// if(!login){ 2015// return Swal.fire( 2016// 'Atenção', 2017// 'Informe seu login', 2018// 'warning' 2019// ); 2020// } 2021// if(login.length < 4){ 2022// return Swal.fire( 2023// 'Atenção', 2024// 'Informe um login válido', 2025// 'warning' 2026// ); 2027// } 2028// if(!senha){ 2029// return Swal.fire( 2030// 'Atenção', 2031// 'Informe sua senha', 2032// 'warning' 2033// ); 2034// } 2035// if(senha.length < 5){ 2036// return Swal.fire( 2037// 'Atenção', 2038// 'Usuário/Senha incorreta', 2039// 'warning' 2040// ); 2041// } 2042// $('.loader').fadeIn(); 2043 2044// // var data = form.serialize(); 2045 2046// // console.log({ data }); 2047
2048// $.post('request/validar-login.php', { login: login, senha: senha }) 2049// .done(function(res){ 2050 2051// console.log({ res }); 2052// if(!res){ 2053// $('.loader').fadeOut(); 2054 2055// Swal.fire( 2056// 'Atenção', 2057// 'Erro de conexão', 2058// 'error' 2059// ); 2060 2061// try { grecaptcha.reset(); } catch(e){} 2062// } else if(res.error){ 2063// $('.loader').fadeOut(); 2064 2065// Swal.fire( 2066// 'Atenção', 2067// res.error, 2068// 'error' 2069// ); 2070 2071// try { grecaptcha.reset(); } catch(e){} 2072// } else if(res.warning){ 2073// $('.loader').fadeOut(); 2074 2075// Swal.fire( 2076// 'Atenção', 2077// res.warning, 2078// 'warning' 2079// ); 2080 2081// try { grecaptcha.reset(); } catch(e){} 2082// } else if(res.recupera){ 2083// Swal.fire( 2084// 'Atenção', 2085// "Seu acesso foi bloqueado por excesso de tentativas!<br /><br /><div>Recupere sua senha para voltar a utilizar o sistema:<br /><a href='https://www.redecredauto.com.br/portal/esqueci' style='color: blue;'>Clique aqui para recuperar</a></div>", 2086// 'warning' 2087// ); 2088// $('.loader').fadeOut(); 2089// try { grecaptcha.reset(); } catch(e){} 2090// } else if(res.success){ 2091// if(res.captcha) 2092// { 2093// $('.g-recaptcha').removeClass('hidden'); 2094// $('.submit-holder, .esqueci').addClass('hidden'); 2095// Swal.fire( 2096// 'Atenção', 2097// 'Para continuar, prove que não é robô', 2098// 'warning' 2099// ); 2100// $('.loader').fadeOut(); 2101// try { grecaptcha.reset(); } catch(e){} 2102// } 2103// else 2104// { 2105// $('.g-recaptcha').addClass('hidden'); 2106// $('.submit-holder, .esqueci').removeClass('hidden'); 2107// continuarLogin(); 2108// } 2109// } else { 2110// $('.loader').fadeOut(); 2111 2112// Swal.fire( 2113// 'Atenção', 2114// 'Erro de conexão', 2115// 'error' 2116// ); 2117// try { grecaptcha.reset(); } catch(e){} 2118// } 2119// }) 2120// .fail(function(){ 2121// Swal.fire( 2122// 'Erro de conexão', 2123// 'Verifique sua conexão com a internet', 2124// 'error' 2125// ); 2126// $('.loader').fadeOut(); 2127// try { grecaptcha.reset(); } catch(e){} 2128// }); 2129// } catch(e){ 2130// // Bugsnag.notify(e); 2131// Swal.fire( 2132// 'Atenção', 2133// 'Erro de conexão', 2134// 'error' 2135// ); 2136// $('.loader').fadeOut(); 2137// try { grecaptcha.reset(); } catch(e){} 2138// } 2139// });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.