<script>
$(document).ready(function() {
//Процент
let persent = 75;
function divideNumberByPieces(x, delimiter) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, delimiter || " ");
};
$('.t754__col').each(function(){
var datalid = $(this).attr('data-product-lid');
$(this).find('.js-product-sku').after($('.t754__product-full[data-product-lid='+datalid+'] .t-product__option'));
$(this).find('.t754__price-wrapper').after($('.t754__product-full[data-product-lid='+datalid+'] .t754__descr'));
});
$('.t754__content').unwrap()
//Проставляем месяц в нашем выпадающем списке
$('.uc-car-list .t-col select').each(function(){
let month = 0;
$(this).find('option').each(function(){
month = month+6;
$(this).attr('data-month', month);
});
let elem = $(this).closest('.t-col');
monthPay(elem);
});
//Функция вычисления месячного платежа
function monthPay(em){
let col = em;
let cost = +( col.find('.js-product-sku').text()).replace(/[^+\d]/g, '');
let contrib = +( col.find('.t754__price_old .t754__price-value').text()).replace(/[^+\d]/g, '');
let term = +col.find('option:selected').attr('data-month');
let mPercent = persent/(12*100);
let st = Math.pow( (1+mPercent) , term);
let kAnn = mPercent + mPercent/(st - 1);
let mPayment = (kAnn*(cost-contrib)).toFixed();
let mPaymentSp = divideNumberByPieces(mPayment);
col.find('.t754__price .t754__price-value').text(mPaymentSp).attr({
'data-product-price-def':mPayment,
'data-product-price-def-str':mPayment
});
};
$('.uc-car-list .t-col').on('change','select' , function(){
let elem = $(this).closest('.t-col');
monthPay(elem);
});
});
</script>
<style>
.js-product-sku {
display: block !important;
}
</style>
<style>
.t-product__option {
display: flex;
align-items: center;
}
.t754 .t-product__option-title {
padding: 0;
margin-right: 5px;
}
.js-product-sku {
font-size: 16px;
font-weight: 400;
font-family: 'Montserrat',Arial,sans-serif;
margin-top: 8px;
}
.t754__price-wrapper {
display: flex;
flex-wrap: wrap;
}
.t754__price.t754__price-item {
order: 1;
margin-top: 3px;
color: #ef6c00;
}
.t754__price-item {
width: 100%;
display: flex;
flex-wrap: wrap;
align-items: center;
font-size: 16px;
color: #000;
}
.t754__price_old:before {
content: 'Первоначальный взнос: ';
margin-right: 5px;
font-size: 14px;
}
.t754__price_old:after {
display: none;
}
.t754__price-value, .t754__price-currency {
float: none;
}
.t754__price:before {
content: "Ежемесячный платеж: ";
margin-right: 5px;
font-size: 14px;
color: #000;
}
img.t754__img {max-height: none;}
img.t754__img {max-height: none;}
.t754__price-currency:before {
display: none;
}
.t754__price-currency {
margin-left: 3px;
}
.t754__descr {
font-size: 13px;
}
.t754__content {
box-shadow: 1px 1px 5px rgb(0 0 0 / 15%);
}
.t754__textwrapper {
padding: 0 10px 10px 10px;
}
#allrecords .t754 ul {
padding-left: 30px;
}
.t754__descr {
font-weight: 500;
}
.t754__descr a {
color: #007bff !important;
}
.t754__descr a:hover {
text-decoration: underline !important;
}
.t754 .t-product__option-variants {
min-width: 120px;
}
.js-product .t-product__option-select {
background: #fff;
}
.js-product .t-product__option-select {
background: #fff;
}
.t754__descr p:last-of-type a {
background-image: url(https://static.tildacdn.com/tild3530-3066-4432-a662-376236333739/avito.png);
background-repeat: no-repeat;
background-position: right center;
height: 30px;
background-size: contain;
padding-right: 85px;
display: flex;
align-items: center;
justify-content: flex-end;
margin-top: 20px;
margin-bottom: 15px;
}
@media screen and (max-width: 640px){
.t754 .t-product__option-select {
font-size: 12px;
}
.t754__price_old:before {
font-size: 12px;
}
.t754__price:before {
font-size: 12px;
}
}
@media screen and (max-width:1200px){
.t754__price_old:before {
font-size: 12px;
}
.t754__price:before {
font-size: 12px;
}
}
@media screen and (max-width:640px){
.t754__price_old:before {
width:100%;
}
.t754__price:before {
width:100%;
}
}
</style>