<!--Суточный-->
<script>
$( document ).ready(function() {
let persent = 5; //Процент
let currency = ' руб.'; //Валюта
//Функция разрядности
function divideNumberByPieces(x, delimiter) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, delimiter || " ");
};
function prodCompleteDay(){
//При загрузке товаров
let tistore = setInterval(function() {
setTimeout(function(){
if ( $('.js-store-grid-cont div').length>0 || $('.t-store__prod-snippet__container').length>0 ){
clearInterval(tistore)
setTimeout(function(){
countDataDay();
}, 200);
};
}, 600);
}, 100);
};
prodCompleteDay();
//Проверяем товар в корзине
function countDataDay(){
//Проставляем месяц в нашем выпадающем списке
$('.js-product').each(function(){
let month = 0;
let prod = $(this);
let optionName = prod.find('.js-product-option-name').text();
if (optionName.indexOf("Ежесуточный платеж") >= 0) {
let numOption = $(this).find('.js-product-option-variants:first option').length;
if(numOption){
$(this).find('.js-product-option-variants:first option').each(function(index){
if(index==0){
$(this).attr('data-month', 36);
}else{
month = month+6;
$(this).attr('data-month', month);
};
});
//Получаем текущую карточку
let elem = $(this);
DayPay(elem);
};
};
});
};
//Функция вычисления месячного платежа
function DayPay(em){
let col = em;
let cost = +col.find('.js-product-price').attr('data-product-price-def');//Получаем цену
let prevPay = cost*0.05;
col.find('.js-product-option-variants:eq(1) option:first').val( divideNumberByPieces(prevPay)+ ' руб.');
col.find('.js-product-option-variants:eq(1) option:first').text( divideNumberByPieces(prevPay)+ ' руб.');
let contrib = prevPay; //Первоначальный взнос
let term = +col.find('.js-product-option-variants:first option:selected').attr('data-month'); // Получаем срок
//Разрядность в первоначальном взносе
col.find('.js-product-option-variants:eq(1) option:selected').val( divideNumberByPieces(contrib)+currency ).text( divideNumberByPieces(contrib)+currency );
let mPayment = (cost-prevPay)*( (persent/1200)*(1+ (persent/1200) )**term)/((1+ (persent/1200) )**term-1);
mPayment = mPayment*12/365;
mPayment = mPayment.toFixed();
let mPaymentSp = divideNumberByPieces(mPayment);
//Выводим платёж в карточку
col.find('.js-product-option-variants:last option:selected').text(mPaymentSp+currency).val(mPaymentSp+currency);
};
$('.t-store').on('change','.js-product select' , function(){
let prod = $(this).closest('.js-product');
let optionName = prod.find('.js-product-option-name').text();
if (optionName.indexOf("Ежесуточный платеж") >= 0) {
let elem = $(this).closest('.js-product');
DayPay(elem);
};
});
//При открытии карточки товара
$(document).on('click','a[href*="/tproduct/"]',function(e){ prodCompleteDay() });
$(document).on('click','.js-store-filter , .js-store-filter-chosen-item , .js-store-load-more-btn , .js-store-parts-switcher, .js-pagination-item',function(e){ prodCompleteDay(); });
$(document).on('keydown','.js-store-filter',function(event){if(event.keyCode == 13) { prodCompleteDay()}});
$(document).on('change','.t-store__sort-select',function(e){ prodCompleteDay() });
});
</script>
<style>
/*Настройка карточек*/
@media screen and (min-width:680px){
.t-product__option {
display: flex;
align-items: baseline;
}
.t-product__option-variants {
margin-left: 10px;
}
}
.t-store__card__sku {
position: absolute;
top: -25px;
right: 0;
font-size: 14px;
}
@media screen and (max-width:960px){
right: 20px;
}
.js-product.t-store__card {
position: relative;
}
.js-product-option-name.t-product__option-title {
font-size: 13px;
}
.js-product .t-product__option-select {
background: #fff;
font-size: 15px;
}
.js-product .js-product-option.t-product__option:nth-child(2) .t-product__option-select,
.js-product .js-product-option.t-product__option:nth-child(3) .t-product__option-select {
border: 0;
padding-left: 0;
pointer-events: none;
}
.js-product .js-product-option.t-product__option:nth-child(2) .t-product__option-variants:after,
.js-product .js-product-option.t-product__option:nth-child(3) .t-product__option-variants:after{
display: none;
}
.t-store__card__sku {
box-shadow: 0 0 0 1px #e2e2e2;
padding: 2px 4px 0 4px;
border-radius: 4px 4px 0 0;
}
.js-product.t-store__card {
box-shadow: 0 5px 10px 0 #e2e2e2;
}
.js-product-controls-wrapper {
padding: 0 8px;
padding-bottom: 15px;
}
.t-store__card__textwrapper {
padding-left: 8px;
padding-right: 8px;
}
.js-product .js-product-option.t-product__option:nth-child(3) .t-product__option-select {
color: #ef6c00;
}
.js-product-option.t-product__option {
margin: 5px 0;
}
.js-store-prod-name:hover {
color: #ff9c4b !important;
text-decoration: underline;
}
/*Насройка фильтров*/
@media screen and (min-width:960px){
.t-store__filter__controls-wrapper {
background-color: #f5f5f5;
padding: 10px 10px;
}
.t-store__filter__options {
display: flex;
align-items: center;
}
.t-store__filter__item.t-store__filter__item_price {
order: 1;
margin-left: 20px;
display: flex;
align-items: center;
}
.t-store__filter__item {
font-size: 16px;
}
.t-store__filter__item-controls-wrap.t-store__filter__item-price-box {
position: static;
padding: 0;
background: none;
box-shadow: none;
display: block !important;
margin-top: 0;
}
.t-store__filter__item.t-store__filter__item_price .t-store__filter__item-title:after {
display: none;
}
.t-store__filter__options input {
background: #fff;
}
button.t-store__filter__btn.js-store-filter-price-btn {
float: none;
font-size: 0;
background-color: #ef6c00;
color: #fff;
width: 80px;
}
button.t-store__filter__btn.js-store-filter-price-btn:after {
content: "Найти";
font-size: 16px;
}
.t-store__filter__controls-wrapper {
display: flex;
align-items: center;
}
.t-store__filter__search-and-sort {
order: -1;
margin-right: 20px;
margin-top: -4px;
}
input.t-store__filter__input.js-store-filter-search {
font-size: 16px;
width: 150px;
background-color: #fff;
}
.t-store__search-wrapper:before {
content: "№";
font-size: 18px;
}
.t-store__filter__item.t-store__filter__item_select {
border: 1px #ddd solid;
background-color: #fff;
height: 30px;
display: flex;
align-items: center;
width: 100px;
justify-content: center;
}
.t-store__filter__item-controls-wrap.js-store-filter-item-controls-wr {
top: 23px;
left: 0;
}
}
/*Настройка окна */
.t-store__tabs__button-title {
display: none;
}
.t-store__tabs__button.js-store-tab-button {
padding: 0 !important;
}
.t-store__product-popup .js-store-prod-price,
.t-store__product-snippet .js-store-prod-price,{
font-size: 24px;
color: #ef6c00;
}
.t-store__product-popup .js-product-option.t-product__option,
.t-store__product-snippet .js-product-option.t-product__option
{
display: block;
}
.t-store__product-popup .js-product-controls-wrapper,
.t-store__product-snippet .js-product-controls-wrapper
{
padding-left: 0;
}
.t-store__product-popup .t-product__option-variants,
.t-store__product-snippet .t-product__option-variants
{
margin-left: 0;
}
.t-store__product-popup .js-product-controls-wrapper,
.t-store__product-snippet .js-product-controls-wrapper
{
border: 1px solid #e2e2e2;
padding: 10px 20px;
width: max-content;
margin: 20px 0;
background-color: #f9f9f9;
}
.t-store__product-popup .js-product-option.t-product__option:nth-child(2) .t-product__option-select,
.t-store__product-popup .js-product-option.t-product__option:nth-child(3) .t-product__option-select,
.t-store__product-snippet .js-product-option.t-product__option:nth-child(2) .t-product__option-select,
.t-store__product-snippet .js-product-option.t-product__option:nth-child(3) .t-product__option-select
{
background: none;
}
</style> <!--Месячный-->
<script>
$( document ).ready(function() {
let persent2 = 66; //Процент
let currency = ' руб.'; //Валюта
//Функция разрядности
function divideNumberByPieces(x, delimiter) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, delimiter || " ");
};
function prodCompleteMonth(){
//При загрузке товаров
let tistore = setInterval(function() {
setTimeout(function(){
if ( $('.js-store-grid-cont div').length>0 || $('.t-store__prod-snippet__container').length>0 ){
clearInterval(tistore)
setTimeout(function(){
countDataMonth();
}, 200);
};
}, 600);
}, 100);
};
prodCompleteMonth();
//Проверяем товар в корзине
function countDataMonth(){
//Проставляем месяц в нашем выпадающем списке
$('.js-product').each(function(){
let prod = $(this);
let optionName = prod.find('.js-product-option-name').text();
if (optionName.indexOf("Ежемесячный платёж") >= 0) {
let month = 0;
let numOption = $(this).find('.js-product-option-variants:first option').length;
if(numOption){
$(this).find('.js-product-option-variants:first option').each(function(index){
if(index==0){
$(this).attr('data-month', 36);
}else{
month = month+6;
$(this).attr('data-month', month);
};
});
//Получаем текущую карточку
let elem = $(this);
monthPay(elem);
};
};
});
};
//Функция вычисления месячного платежа
function monthPay(em){
let col = em;
let cost = +col.find('.js-product-price').attr('data-product-price-def');//Получаем цену
let prevPay = cost*0.25;
col.find('.js-product-option-variants:eq(1) option:first').val( divideNumberByPieces(prevPay)+ ' руб.');
col.find('.js-product-option-variants:eq(1) option:first').text( divideNumberByPieces(prevPay)+ ' руб.');
let contrib = prevPay; //Первоначальный взнос
let term = +col.find('.js-product-option-variants:first option:selected').attr('data-month'); // Получаем срок
//Разрядность в первоначальном взносе
col.find('.js-product-option-variants:eq(1) option:selected').val( divideNumberByPieces(contrib)+currency ).text( divideNumberByPieces(contrib)+currency );
let mPayment = (cost-prevPay)*( (persent2/1200)*(1+ (persent2/1200) )**term)/((1+ (persent2/1200) )**term-1);
mPayment = mPayment.toFixed();
let mPaymentSp = divideNumberByPieces(mPayment);
//Выводим платёж в карточку
col.find('.js-product-option-variants:last option:selected').text(mPaymentSp+currency).val(mPaymentSp+currency);
};
$('.t-store').on('change','.js-product select' , function(){
let prod = $(this).closest('.js-product');
let optionName = prod.find('.js-product-option-name').text();
if (optionName.indexOf("Ежемесячный платёж") >= 0) {
let elem = $(this).closest('.js-product');
monthPay(elem);
};
});
//При открытии карточки товара
$(document).on('click','a[href*="/tproduct/"]',function(e){ prodCompleteMonth() });
$(document).on('click','.js-store-filter , .js-store-filter-chosen-item , .js-store-load-more-btn , .js-store-parts-switcher, .js-pagination-item ',function(e){ prodCompleteMonth(); });
$(document).on('keydown','.js-store-filter',function(event){if(event.keyCode == 13) { prodCompleteMonth()}});
$(document).on('change','.t-store__sort-select',function(e){ prodCompleteMonth() });
});
</script>
<style>
/*Настройка карточек*/
@media screen and (min-width:680px){
.t-product__option {
display: flex;
align-items: baseline;
}
.t-product__option-variants {
margin-left: 10px;
}
}
.t-store__card__sku {
position: absolute;
top: -25px;
right: 0;
font-size: 14px;
}
@media screen and (max-width:960px){
right: 20px;
}
.js-product.t-store__card {
position: relative;
}
.js-product-option-name.t-product__option-title {
font-size: 13px;
}
.js-product .t-product__option-select {
background: #fff;
font-size: 15px;
}
.js-product .js-product-option.t-product__option:nth-child(2) .t-product__option-select,
.js-product .js-product-option.t-product__option:nth-child(3) .t-product__option-select {
border: 0;
padding-left: 0;
pointer-events: none;
}
.js-product .js-product-option.t-product__option:nth-child(2) .t-product__option-variants:after,
.js-product .js-product-option.t-product__option:nth-child(3) .t-product__option-variants:after{
display: none;
}
.t-store__card__sku {
box-shadow: 0 0 0 1px #e2e2e2;
padding: 2px 4px 0 4px;
border-radius: 4px 4px 0 0;
}
.js-product.t-store__card {
box-shadow: 0 5px 10px 0 #e2e2e2;
}
.js-product-controls-wrapper {
padding: 0 8px;
padding-bottom: 15px;
}
.t-store__card__textwrapper {
padding-left: 8px;
padding-right: 8px;
}
.js-product .js-product-option.t-product__option:nth-child(3) .t-product__option-select {
color: #ef6c00;
}
.js-product-option.t-product__option {
margin: 5px 0;
}
.js-store-prod-name:hover {
color: #ff9c4b !important;
text-decoration: underline;
}
/*Насройка фильтров*/
@media screen and (min-width:960px){
.t-store__filter__controls-wrapper {
background-color: #f5f5f5;
padding: 10px 10px;
}
.t-store__filter__options {
display: flex;
align-items: center;
}
.t-store__filter__item.t-store__filter__item_price {
order: 1;
margin-left: 20px;
display: flex;
align-items: center;
}
.t-store__filter__item {
font-size: 16px;
}
.t-store__filter__item-controls-wrap.t-store__filter__item-price-box {
position: static;
padding: 0;
background: none;
box-shadow: none;
display: block !important;
margin-top: 0;
}
.t-store__filter__item.t-store__filter__item_price .t-store__filter__item-title:after {
display: none;
}
.t-store__filter__options input {
background: #fff;
}
button.t-store__filter__btn.js-store-filter-price-btn {
float: none;
font-size: 0;
background-color: #ef6c00;
color: #fff;
width: 80px;
}
button.t-store__filter__btn.js-store-filter-price-btn:after {
content: "Найти";
font-size: 16px;
}
.t-store__filter__controls-wrapper {
display: flex;
align-items: center;
}
.t-store__filter__search-and-sort {
order: -1;
margin-right: 20px;
margin-top: -4px;
}
input.t-store__filter__input.js-store-filter-search {
font-size: 16px;
width: 150px;
background-color: #fff;
}
.t-store__search-wrapper:before {
content: "№";
font-size: 18px;
}
.t-store__filter__item.t-store__filter__item_select {
border: 1px #ddd solid;
background-color: #fff;
height: 30px;
display: flex;
align-items: center;
width: 100px;
justify-content: center;
}
.t-store__filter__item-controls-wrap.js-store-filter-item-controls-wr {
top: 23px;
left: 0;
}
}
/*Настройка окна */
.t-store__tabs__button-title {
display: none;
}
.t-store__tabs__button.js-store-tab-button {
padding: 0 !important;
}
.t-store__product-popup .js-store-prod-price,
.t-store__product-snippet .js-store-prod-price,{
font-size: 24px;
color: #ef6c00;
}
.t-store__product-popup .js-product-option.t-product__option,
.t-store__product-snippet .js-product-option.t-product__option
{
display: block;
}
.t-store__product-popup .js-product-controls-wrapper,
.t-store__product-snippet .js-product-controls-wrapper
{
padding-left: 0;
}
.t-store__product-popup .t-product__option-variants,
.t-store__product-snippet .t-product__option-variants
{
margin-left: 0;
}
.t-store__product-popup .js-product-controls-wrapper,
.t-store__product-snippet .js-product-controls-wrapper
{
border: 1px solid #e2e2e2;
padding: 10px 20px;
width: max-content;
margin: 20px 0;
background-color: #f9f9f9;
}
.t-store__product-popup .js-product-option.t-product__option:nth-child(2) .t-product__option-select,
.t-store__product-popup .js-product-option.t-product__option:nth-child(3) .t-product__option-select,
.t-store__product-snippet .js-product-option.t-product__option:nth-child(2) .t-product__option-select,
.t-store__product-snippet .js-product-option.t-product__option:nth-child(3) .t-product__option-select
{
background: none;
}
</style>