$(document).ready(function () { var produto = document.location.pathname.split('/')[2]; var tela = window.innerWidth; if (tela > 768) { selecionaFotosProdutos(produto); } else { selecionaFotosProdutosMobile(produto); } $('.tumb').hide(); $('.controls').hide(); setTimeout(() => { $('.foto1').click(); },2000) $('.cores').on('change', function () { var produto = $(this).val(); if (produto !== '') { $('.foto1').html('
'); $('.tumb1').html('
'); $('.tumb2').html('
'); $('.tumb3').html('
'); $('.tumb4').html('
'); selecionaFotosProdutos(produto); pegaDiferencial(); $('#codigoInterno').html(produto); $('.produto_comprar').val(produto); $('.complemento-produto').html($(this).children("option").filter(":selected").text()); } }); }); function tumb_ativa(id, g) { var localFotos = 'https://autotudo.com.br'; $('.foto1').html('
').fadeIn(); } function selecionaFotosProdutos(produto) { $('.foto1').html('
'); $.post('/util/Util.php', { acao: 'getFotos', produto: produto }, function (data) { console.log(data); var dados = $.parseJSON(data); console.log(dados); var localFotos = 'https://autotudo.com.br'; if (dados.tumb2.length > 0) { $('.foto1').html('').fadeIn(); } var total = dados.tumb.length; for (i = 0; i < total; i++) { $('.tumb' + (i + 1)).html('').show(); } // $('.foto-sem-estoque').html('').fadeIn(); $('.fotos-produto-tumb a:first').trigger('click'); }); } function pegaDiferencial() { var loja = localStorage.getItem("loja"); $.post('/util/Util.php', { acao: 'getDiff', nome: $('.nome-produto-h1').html(), complemento: $('.complemento-produto').html(), idloja: loja }, function (data) { var dados = $.parseJSON(data); $('.aj_valor_de').html(dados.valor); $('.aj_valor_por').html(dados.valor2); }); } function selecionaFotosProdutosMobile(produto) { console.log('produto mobile'); $.post('/util/Util.php', { acao: 'getFotos', produto: produto }, function (data) { var dados = $.parseJSON(data); var localFotos = 'https://ecommerce.vipsystem.com.br'; var ativo = null; if (dados.length > 1) { $('.controls').show(); } for (i = 0; i < dados.length; i++) { if (i === 0) { ativo = 'active'; } else { ativo = null; } $('.carousel-inner').append('
'); } }); }