<script>
const tcartStr = localStorage.getItem('tcart');
if (tcartStr) {
console.log('updated-ok');
try {
// Парсим JSON данные
const tcart = JSON.parse(tcartStr);
// Если есть поле updated, обновляем его значение
if (tcart.hasOwnProperty('updated')) {
tcart.updated = Math.floor(Date.now() / 1000);
// Сохраняем обновленные данные обратно в localStorage
localStorage.setItem('tcart', JSON.stringify(tcart));
}
} catch (e) {
console.error('Ошибка при парсинге tcart:', e);
}
}
$( document ).ready(function() {
var urlprodimg=0;
//Примваиваем классы нашим элементам
$('[href = "#prodimg"]').addClass('prodimg');
$('.prodimg').not('.prodimg:first').hide();
//Функция скрытия изображения и деактивации иконок
function activecolor(){ $('.prodimg').hide();};
//Когда изменяют цвет композиции
$(document).on('change', '.t-input-group[data-field-name="complect"] .t-img-select', function() {
// Получаем номер элемента в списке
var $label = $(this).closest('label');
// Получаем индекс этого label среди своих соседей
var place = $('.t-input-group[data-field-name="complect"] label.t-img-select__control').index($label);
activecolor();
//Показываем нужное фото
$('.prodimg:eq('+place+')').show();
//Отправляем нужное фото в ST200
urlprodimg = $('.prodimg:eq('+place+') img').attr('src');
$('.t744 .t-slds__bgimg').css('background-image', 'url('+urlprodimg+')').attr('data-original', urlprodimg);
});
});
</script> <style>
/*Скрываем ST200*/
div[data-record-type="744"]{ display:none;}
.t706__product-imgdiv {
background-repeat: no-repeat;
background-size: contain !important;
background-color: #ffffff !important;
}
</style>
<script>
$( document ).ready(function() {
var notLazyblock = '.t744 .t-slds__bgimg';
for(let i = 0; i < $(notLazyblock).length; i++){
$(notLazyblock).addClass('loaded plus');
$(notLazyblock+':eq('+i+')').css('background-image', 'url("'+$(notLazyblock+':eq('+i+')').data("original")+'")' );
};
//При клике на нашу кнопку
$('a[href="#sendtocart"]').click(function(event) {
event.preventDefault();
//***********************
//Получаем комплектацию
var complect = $('input[name="complect"]').val();
//Получаем кол-во
var colvo = $('input[name="colvo"]').val();
//Получаем срок Гарантии
var garantee = $('input[name="garantee"]').next('.t-range__value-txt').html();
//Получаем Дополнительный сервис
var dopserv = $('input[name="dopservice"]').val();
//Получаем значение Способа доставки
var delivery= $('input[name="deliveryvar"]:checked').val();
//Полчаем сумму калькулятора
var itogo = $('input[name="summazakaza"]').next('.t-calc__wrapper').children('.t-calc').html();
//***********************
//ПРисваиваем значения из калькулятора для блока ST200
$('.t744__price-value').html(itogo);//Цена товара
//Параметры
$('.t744 select:eq(0) option:selected').val(complect);//Комплектация
$('.t744 select:eq(1) option:selected').val(colvo);//Количество
$('.t744 select:eq(2) option:selected').val(garantee);//Гарантия
$('.t744 select:eq(3) option:selected').val(dopserv);//Доп сервис
$('.t744 select:eq(4) option:selected').val(delivery);//Доставка
//Отправляем заказ
let fullinput=true;
let mainBlk = $(this).closest('.t-rec');
$('.t-input-group').removeClass('js-error-control-box');
mainBlk.find('.js-tilda-rule[data-tilda-req="1"]').each(function() {
if($(this).val()==''){$(this).closest('form').find('.t-submit').click(); fullinput=false; return false;};
});
if(fullinput){
mainBlk.find('input[type="radio"][data-tilda-req="1"].js-tilda-rule').closest('.t-input-block').each(function() {
if(!$(this).find('input[type="radio"]').is(':checked')){$(this).closest('form').find('.t-submit').click();fullinput=false; return false;
};});};
if(fullinput){
mainBlk.find('input[type="checkbox"][data-tilda-req="1"].js-tilda-rule').each(function() {
if (!$(this).is(':checked')){ $(this).closest('form').find('.t-submit').click(); fullinput=false; return false;};
});};
if(fullinput){
setTimeout(function() { $(".t744__btn")[0].click(); }, 100);
};
return false;
});
$(document).on("keydown", ".t-form", function(event) {return event.key != "Enter";});
});
</script> <!--Добавляем новое поле -->
<!--ДОП СЕРВИСЫ -->
<div class="t-product__option js-product-option newselect1">
<div class="t-product__option-title t-descr t-descr_xxs js-product-option-name">Дополнительный сервис</div>
<div class="t-product__option-variants">
<select class="t-product__option-select t-descr t-descr_xxs js-product-option-variants">
<option value="Доставка" data-product-variant-price="">0</option>
</select>
</div>
</div>
<!--ДОСТАВКА -->
<div class="t-product__option js-product-option newselect2">
<div class="t-product__option-title t-descr t-descr_xxs js-product-option-name">Доставка</div>
<div class="t-product__option-variants">
<select class="t-product__option-select t-descr t-descr_xxs js-product-option-variants">
<option value="Доставка" data-product-variant-price="">0</option>
</select>
</div>
</div>
<script>
//Перемещаем новые поля в карточку товара
$(".t744 .t-product__option:eq(2)").after($(".newselect1"));
$(".t744 .t-product__option:eq(3)").after($(".newselect2"));
</script>