; (function () { window.calculate = function (data) { this.show_volume = false; this.dimensions = false; this.sum_1 = 0; this.sum_2 = 0; this.sum_3 = 0; this.sum_4 = 0; this.sum_5 = 0; this.time = 0; this.price_kg = (data.price_kg) ? parseFloat(data.price_kg) : 0; this.price_package = (data.price_package) ? parseFloat(data.price_package) : 0; this.price_count = (data.price_count) ? parseFloat(data.price_count) : 0; this.price_take = (data.price_take) ? parseFloat(data.price_take) : 0; this.price_shipment = (data.price_shipment) ? parseFloat(data.price_shipment) : 0; this.price_deliver = (data.price_deliver) ? parseFloat(data.price_deliver) : 0; console.log(this.price_deliver); this.price_discharge = (data.price_discharge) ? parseFloat(data.price_discharge) : 0; this.price_send = (data.price_send) ? parseFloat(data.price_send) : 0; this.price_return = (data.price_return) ? parseFloat(data.price_return) : 0; this.city = (data.city) ? data.city : [] this.result = { goods: [ { height: 1, width: 1, depth: 1, weight: 1, volume: 0, count: 0, } ] }; this.init(); // дефолтные значения на странице Направления if (data.parameters) { if (data.parameters.CITY_FROM) { this.result.shipping_address = data.parameters.CITY_FROM; $('#shipping_address').val(data.parameters.CITY_FROM); } if (data.parameters.CITY_TO) { this.result.receiving_address = data.parameters.CITY_TO; $('#receiving_address').val(data.parameters.CITY_TO); } if (data.parameters.CITY_FROM || data.parameters.CITY_TO) { this.result.weight = '1'; $('#weight').val('1'); this.result.volume = '0.01'; $('#volume').val('0.01'); } $('#weight').trigger('change'); } } window.calculate.prototype.init = function () { _this = this; ymaps.ready(init); function init() { arr = _this.city; // Создаем выпадающую панель с поисковыми подсказками и прикрепляем ее к HTML-элементу по его id. find = function (arr, find) { return arr.filter(function (value) { return (value + "").toLowerCase().indexOf(find.toLowerCase()) != -1; }); }; var city_provider = { suggest: function (request, options) { var res = find(arr, request), arrayResult = [], results = Math.min(options.results, res.length); for (var i = 0; i < results; i++) { arrayResult.push({ displayName: res[i], value: res[i] }) } return ymaps.vow.resolve(arrayResult); } } var shipping_addressView = new ymaps.SuggestView('shipping_address', { container: document.getElementById('shipping_address_result'), provider: city_provider }); var receiving_addressView = new ymaps.SuggestView('receiving_address', { container: document.getElementById('receiving_address_result'), provider: city_provider }); shipping_addressView.events.add(['select'], function (event) { $('#shipping_address').change(); }) receiving_addressView.events.add(['select'], function (event) { $('#receiving_address').change(); }) // shipping_address.events.add('select', function (e) { // console.log(e); // }); } $('[name="depth"], [name="width"], [name="height"], [name="volume"]').inputmask({ mask: "9{1,*}(.|,)999", placeholder: "0000" }); $('.js-select2').select2({ minimumResultsForSearch: Infinity }); this.tabs(); // изменение полей $('#calculate').on('change', '.calculate-delivery-input', function (e) { value = $(this).val(); value = value.replace(',', '.') name = $(this).attr('name'); index = $(this).data('index'); if (index !== undefined) { _this.result['goods'][parseInt(index)][name] = parseFloat(value); } else { _this.result[name] = value; } $.proxy(_this.updateInput(name, index), _this); let cityEx=['Бодайбо','Якутск','Киренск','Мама','Артемовский','Балахнинский (Бдб)','Высочайший ГОК','ГОК Вернинский','ГОК Светловский','Кропоткин','Маракан','Перевоз','Сухой Лог','Угахан'] if(cityEx.includes((shipping_address))) { // document.querySelector('.aeroglisser').classList.add('showwarning') } else if(['Бодайбо','Якутск','Киренск','Мама'].includes((receiving_address))) { // document.querySelector('.aeroglisser').classList.add('showwarning') } else { // document.querySelector('.aeroglisser').classList.remove('showwarning') } }); $('.calculate-delivery-input__checkbox').change(function (e) { value = $(this).is(':checked') ? 1 : 0; name = $(this).attr('name'); _this.result[name] = value; $.proxy(_this.updateInput(name), _this); }); $('.calculate-delivery-input__radio').change(function (e) { value = $(this).val(); name = $(this).attr('name'); _this.result[name] = value; $.proxy(_this.updateInput(name), _this); }); // добавление габаритов $('#good_add').on('click', function (e) { e.preventDefault(); html = $('#good_new').html().replaceAll('#i#', _this.result.goods.length); _this.result.goods.push({ height: 0, width: 0, depth: 0, weight: 0, volume: 0, count: 0, }); $(this).parent('.calculate-delivery-row').before(html); $('[name="depth"], [name="width"], [name="height"], [name="volume"]').inputmask({ mask: "9{1,*}(.|,)999", placeholder: "0000" }); }) $('#show_all_goods').on('click', '.calculate-delivery-row-coll__delete', function (e) { index = $(this).data('index'); $('#show_all_goods .calculate-delivery-row[data-index="' + index + '"]').remove(); _this.result.goods[index] = { // height: 0, // width: 0, // depth: 0, // weight: 0, // volume: 0, // count: 0, } _this.calculete(); _this.disableButton(); }) // изменение адресов -> получаем цену // $('#shipping_address, #receiving_address, #weight, #volume, #height, #width, #depth').on('change', function (e) { // setTimeout(function () { // shipping_address = $('#shipping_address').val(); // receiving_address = $('#receiving_address').val(); // weight = $('#weight').val(); // // weight = $('#weight').val(); // volume = ($('#volume').val()) ? parseFloat($('#volume').val().replace(',', '.')) : 0; // // weight = Math.max(weight, 280 * volume); // // if (shipping_address && receiving_address) { // // $.post( // '/local/components/mmit/calculate.delivery/ajax.php', // { // action: 'price', // shipping_address: shipping_address, // receiving_address: receiving_address, // weight: weight, // }, // function (result) { // if (result.shipping_address === false) { // $('#shipping_address').parent('.calculate-delivery-row').addClass('error'); // } else { // if ($(e.target).attr('id') == 'shipping_address' && !['Иркутск', 'Красноярск', 'Бодайбо'].includes(result.shipping_address)) { // $('#take').prop('checked', true); // $('#take_city').prop('checked', true); // $('#take').change(); // $('#take_city').change(); // } // } // if (result.receiving_address === false) { // $('#receiving_address').parent('.calculate-delivery-row').addClass('error'); // } else { // if ($(e.target).attr('id') == 'receiving_address' && !['Иркутск', 'Красноярск', 'Бодайбо'].includes(result.shipping_address)) { // $('#deliver').prop('checked', true); // $('#deliver_city').prop('checked', true); // $('#deliver').change(); // $('#deliver_city').change(); // } // } // _this.price_kg = parseFloat(result.price); // _this.min_price = parseFloat(result.min_price); // _this.time = parseFloat(result.time); // _this.calculete(); // }, // 'json' // ); // } // }, 1000); // }); $('#shipping_address, #receiving_address, #weight').on('focus', function (e) { $(this).parent('.calculate-delivery-row').removeClass('error'); }); $('#send, #return').on('change', function () { if ($(this).prop('id') == 'send' && $(this).is(':checked')) { $('#return').prop('checked', false); } if ($(this).prop('id') == 'return' && $(this).is(':checked')) { $('#send').prop('checked', false); } }); $('.calculate-delivery-input:not(.calculate-delivery-input__checkbox, .calculate-delivery-input__radio)').on('keypress', function (e) { if (e.keyCode === 13) { $('.calculate-delivery-input:not(.calculate-delivery-input__checkbox, .calculate-delivery-input__radio)').each(function (key, item) { if ($(item)[0] === $(e.target)[0]) { list = $('.calculate-delivery-input:not(.calculate-delivery-input__checkbox, .calculate-delivery-input__radio)'); if (list[key + 1]) { if (!(list[key + 1].offsetWidth > 0 && list[key + 1].offsetHeight > 0)) { if (list[key + 2]) { list[key + 2].focus(); } } else { if (list[key + 1]) { list[key + 1].focus(); } } } } }); } }); $('#calculate').on('keyup', '.js_input__number', function (e) { e.target.value = e.target.value.replace(' ', ''); e.target.value = e.target.value.replace(',', '.'); }) // изменение полей // $('.calculate-delivery-input, .calculate-delivery-input__checkbox, .calculate-delivery-input__radio').change(function () { // if (['height', 'width', 'depth'].includes($(this).attr('id'))) { // height = ($('#height').val()) ? parseFloat($('#height').val().replace(',', '.')) : 0; // width = ($('#width').val()) ? parseFloat($('#width').val().replace(',', '.')) : 0; // depth = ($('#depth').val()) ? parseFloat($('#depth').val().replace(',', '.')) : 0; // // volume = parseInt(height * width * depth * 1000) / 1000; // $('#volume').val(volume); // } else { // volume = $('#volume').val(); // } // // if ($('#take').is(':checked')) { // $('#show_take').show(); // } else { // $('#show_take').hide(); // } // if ($('#deliver').is(':checked')) { // $('#show_deliver').show(); // $('#deliver').parent('.calculate-delivery-row').removeClass('margin-bottom-big'); // $('#deliver').parent('.calculate-delivery-row').addClass('margin-bottom-small'); // } else { // $('#show_deliver').hide(); // $('#deliver').parent('.calculate-delivery-row').addClass('margin-bottom-big'); // $('#deliver').parent('.calculate-delivery-row').removeClass('margin-bottom-small'); // } // // if (['weight', 'volume', 'height', 'width', 'depth', 'take', 'take_city', 'take_no_city', 'shipping_address'].includes($(this).attr('id'))) { // if ($('#take').is(':checked') && $('#shipping_address').val() && $('#weight').val()) { // // weight = $('#weight').val(); // volume = ($('#volume').val()) ? parseFloat($('#volume').val().replace(',', '.')) : 0; // // weight = Math.max(weight, 280 * volume); // // $.post( // '/local/components/mmit/calculate.delivery/ajax.php', // { // action: 'delivery', // city: $('#shipping_address').val(), // isCity: ($('#take_city').is(':checked') ? 1 : 0), // weight: weight, // }, // function (result) { // _this.price_take = parseFloat(result.price); // // _this.calculete(); // _this.disableButton(); // }, // 'json' // ); // } // } // if (['weight', 'volume', 'height', 'width', 'depth', 'deliver', 'deliver_city', 'deliver_no_city', 'receiving_address'].includes($(this).attr('id'))) { // if ($('#deliver').is(':checked') && $('#receiving_address').val() && $('#weight').val()) { // // weight = $('#weight').val(); // volume = ($('#volume').val()) ? parseFloat($('#volume').val().replace(',', '.')) : 0; // // weight = Math.max(weight, 280 * volume); // // $.post( // '/local/components/mmit/calculate.delivery/ajax.php', // { // action: 'delivery', // city: $('#receiving_address').val(), // isCity: ($('#deliver_city').is(':checked') ? 1 : 0), // weight: weight, // }, // function (result) { // _this.price_deliver = parseFloat(result.price); // // _this.calculete(); // _this.disableButton(); // }, // 'json' // ); // } // } // // // if (['volume', 'height', 'width', 'depth'].includes($(this).attr('id'))) { // // $('#count').val(Math.ceil(volume)); // // } // // _this.calculete(); // _this.disableButton(); // }); // попапы $('.js__open_form_popup').on('click', function () { if ($(this).hasClass('disabled')) { return; } $('#form_popup_name').show(); $('#form_popup_name').css('top', window.pageYOffset + 'px'); $('#form_popup_overlay').show(); }); $('.js__open_form_popup_mail').on('click', function (e) { e.preventDefault(); if ($(this).hasClass('disabled')) { return; } $('#form_popup_mail').show(); $('#form_popup_mail').css('top', window.pageYOffset + 'px'); $('#form_popup_overlay').show(); }); $(document).keyup(function (e) { if (e.key === "Escape") { $('#form_popup_name').hide(); $('#form_popup_name_result').hide(); $('#form_popup_mail').hide(); $('#form_popup_mail_result').hide(); $('#form_popup_overlay').hide(); } }); $('.js__close_form_popup, #form_popup_overlay').on('click', function () { $('#form_popup_name').hide(); $('#form_popup_name_result').hide(); $('#form_popup_mail').hide(); $('#form_popup_mail_result').hide(); $('#form_popup_overlay').hide(); }) this.forms(); }; window.calculate.prototype.forms = function () { _this = this; // отправка формы $('#form_popup_name form').on('submit', function (e) { e.preventDefault(); $.post( '/local/components/mmit/calculate.delivery/ajax.php', { action: 'form', name: $('#form_popup_name form input[name="name"]').val(), phone: $('#form_popup_name form input[name="phone"]').val(), data: _this.result // data: { // type: $('#type').val(), // weight: ($('#weight').val()) ? parseInt($('#weight').val()) : 0, // depth: ($('#depth').val()) ? parseInt($('#depth').val()) : 0, // width: ($('#width').val()) ? parseInt($('#width').val()) : 0, // height: ($('#height').val()) ? parseInt($('#height').val()) : 0, // volume: ($('#volume').val()) ? parseInt($('#volume').val()) : 0, // count: ($('#count').val()) ? parseInt($('#count').val()) : 0, // dangerous: ($('#dangerous').is(':checked')) ? 1 : 0, // price: ($('#price').val()) ? $('#price').val() : 0, // take: ($('#take').is(':checked')) ? 1 : 0, // shipment: ($('#shipment').is(':checked')) ? 1 : 0, // deliver: ($('#deliver').is(':checked')) ? 1 : 0, // discharge: ($('#discharge').is(':checked')) ? 1 : 0, // send: ($('#send').is(':checked')) ? 1 : 0, // return: ($('#return').is(':checked')) ? 1 : 0, // sum_1: _this.result.sum_1, // sum_2: _this.result.sum_2, // sum_3: _this.result.sum_3, // sum_4: _this.result.sum_4, // sum_5: _this.result.sum_5, // sum_6: _this.result.sum_6, // sum_7: _this.result.sum_7, // sum_all: _this.result.sum_all, // } }, function (result) { $('.js__form_popup_name_result').text($('#form_popup_name form input[name="name"]').val()) $('#form_popup_name_result').show(); $('#form_popup_name').hide(); $('#form_popup_overlay').show(); }, 'json' ); }); $('#form_popup_mail form').on('submit', function (e) { e.preventDefault(); $.post( '/local/components/mmit/calculate.delivery/ajax.php', { action: 'form_email', email: $('#form_popup_mail form input[name="email"]').val(), data: _this.result // data: { // type: $('#type').val(), // weight: ($('#weight').val()) ? parseInt($('#weight').val()) : 0, // depth: ($('#depth').val()) ? parseInt($('#depth').val()) : 0, // width: ($('#width').val()) ? parseInt($('#width').val()) : 0, // height: ($('#height').val()) ? parseInt($('#height').val()) : 0, // volume: ($('#volume').val()) ? parseInt($('#volume').val()) : 0, // count: ($('#count').val()) ? parseInt($('#count').val()) : 0, // dangerous: ($('#dangerous').is(':checked')) ? 1 : 0, // price: ($('#price').val()) ? $('#price').val() : 0, // take: ($('#take').is(':checked')) ? 1 : 0, // shipment: ($('#shipment').is(':checked')) ? 1 : 0, // deliver: ($('#deliver').is(':checked')) ? 1 : 0, // discharge: ($('#discharge').is(':checked')) ? 1 : 0, // send: ($('#send').is(':checked')) ? 1 : 0, // return: ($('#return').is(':checked')) ? 1 : 0, // sum_1: _this.result.sum_1, // sum_2: _this.result.sum_2, // sum_3: _this.result.sum_3, // sum_4: _this.result.sum_4, // sum_5: _this.result.sum_5, // sum_6: _this.result.sum_6, // sum_7: _this.result.sum_7, // sum_all: _this.result.sum_all, // } }, function (result) { $('#form_popup_mail_result').show(); $('#form_popup_mail').hide(); $('#form_popup_overlay').show(); }, 'json' ); }); } window.calculate.prototype.tabs = function () { _this = this; $('#all_weight').on('click', function (e) { _this.result.dimensions = 0; e.preventDefault(); $(this).addClass('active'); $('#all_goods').removeClass('active'); $('#show_all_weight').show(); $('#show_all_goods').hide(); _this.calculete(); _this.disableButton(); }) $('#all_goods').on('click', function (e) { _this.result.dimensions = 1; e.preventDefault(); $(this).addClass('active'); $('#all_weight').removeClass('active'); $('#show_all_goods').show(); $('#show_all_weight').hide(); _this.calculete(); _this.disableButton(); }) } window.calculate.prototype.renderList = function () { _this = this; $('#show_all_goods .calculate-delivery-list').html(''); _this.result.goods } window.calculate.prototype.updateInput = function (name, index = undefined) { _this = this; timer = 0; if (name == 'shipping_address' || name == 'receiving_address') { timer = 1000; } setTimeout(function () { if (_this.result.shipping_address && !['Иркутск', 'Бодайбо'].includes(_this.result.shipping_address)) { if (!$('#take').is(':checked')) { $('#take').prop('checked', true); $('#take_city').prop('checked', true); $('#take').change(); $('#take_city').change(); } } if (_this.result.receiving_address && !['Иркутск', 'Бодайбо'].includes(_this.result.receiving_address)) { if (!$('#deliver').is(':checked')) { $('#deliver').prop('checked', true); $('#deliver_city').prop('checked', true); $('#deliver').change(); $('#deliver_city').change(); } } }, timer) if (index !== undefined) { _this.result.goods[index].volume = parseFloat(_this.result.goods[index].height) * parseFloat(_this.result.goods[index].width) * parseFloat(_this.result.goods[index].depth); $('#show_all_goods .calculate-delivery-row-coll__result span[data-index="' + index + '"]').text(_this.result.goods[index].volume); } if ($('#take').is(':checked')) { $('#show_take').show(); } else { $('#show_take').hide(); } if ($('#deliver').is(':checked')) { $('#show_deliver').show(); $('#deliver').parent('.calculate-delivery-row').removeClass('margin-bottom-big'); $('#deliver').parent('.calculate-delivery-row').addClass('margin-bottom-small'); } else { $('#show_deliver').hide(); $('#deliver').parent('.calculate-delivery-row').addClass('margin-bottom-big'); $('#deliver').parent('.calculate-delivery-row').removeClass('margin-bottom-small'); } if (['shipping_address', 'receiving_address', 'weight', 'volume', 'height', 'width', 'depth'].includes(name)) { _this.loadPice(name); } if (['weight', 'volume', 'height', 'width', 'depth', 'take', 'take_city', 'take_no_city', 'take_is_city', 'shipping_address'].includes(name)) { if (_this.result.take && _this.result.shipping_address && _this.result.weight) { _this.loadDelivery(_this.result.shipping_address, ($('#take_city').is(':checked') ? 1 : 0), function (result) { _this.price_take = parseFloat(result.price); _this.calculete(); _this.disableButton(); }); } } if (['weight', 'volume', 'height', 'width', 'depth', 'deliver', 'deliver_city', 'deliver_no_city', 'deliver_is_city', 'receiving_address'].includes(name)) { if (_this.result.deliver && _this.result.receiving_address && _this.result.weight) { _this.loadDelivery(_this.result.receiving_address, ($('#deliver_city').is(':checked') ? 1 : 0), function (result) { _this.price_deliver = parseFloat(result.price); _this.calculete(); _this.disableButton(); }); } } _this.calculete(); _this.disableButton(); } window.calculate.prototype.loadPice = function (name) { _this = this; setTimeout(function () { weight = Math.max(_this.result.weight, 280 * _this.result.volume); if (_this.result.shipping_address && _this.result.receiving_address) { console.log('load_price'); $.post( '/local/components/mmit/calculate.delivery/ajax.php', { action: 'price', shipping_address: _this.result.shipping_address, receiving_address: _this.result.receiving_address, weight: weight, }, function (result) { if (result.shipping_address === 0) { $('#shipping_address').parent('.calculate-delivery-row').addClass('error'); } else { if (name == 'shipping_address' && !['Иркутск', 'Красноярск', 'Бодайбо'].includes(result.shipping_address)) { console.log('ex2-',result.shipping_address); $('#take').prop('checked', true); $('#take_city').prop('checked', true); $('#take').change(); $('#take_city').change(); } } if (result.receiving_address === 0) { $('#receiving_address').parent('.calculate-delivery-row').addClass('error'); } else { if (name == 'receiving_address' && !['Иркутск', 'Красноярск', 'Бодайбо'].includes(result.receiving_address)) { $('#deliver').prop('checked', true); $('#deliver_city').prop('checked', true); // $('#deliver').change(); // $('#deliver_city').change(); } } _this.price_kg = parseFloat(result.price); _this.ar_price_kg = result.arPrice; _this.min_price = parseFloat(result.min_price); _this.time = parseFloat(result.time); _this.calculete(); }, 'json' ); } }, 1000); } window.calculate.prototype.loadDelivery = function (city, isCity, event) { _this = this; weight = _this.result.weight; volume = (_this.result.volume) ? parseFloat(_this.result.volume.replace(',', '.')) : 0; weight = Math.max(weight, 280 * volume); console.log('load_delivery'); $.post( '/local/components/mmit/calculate.delivery/ajax.php', { action: 'delivery', city: city, isCity: isCity, weight: weight, }, event, 'json' ); } window.calculate.prototype.disableButton = function () { _this = this; weight = ($('#weight').val()) ? parseInt($('#weight').val()) : 0; volume = ($('#volume').val()) ? parseFloat($('#volume').val().replace(',', '.')) : 0; shipping_address = $('#shipping_address').val(); receiving_address = $('#receiving_address').val(); if (((weight && volume) || _this.result.dimensions) && shipping_address && receiving_address) { $('.js__open_form_popup').prop('disabled', false).removeClass('disabled'); $('.js__open_form_popup_mail').prop('disabled', false).removeClass('disabled'); } else { $('.js__open_form_popup').prop('disabled', true).addClass('disabled'); $('.js__open_form_popup_mail').prop('disabled', true).addClass('disabled'); } } window.calculate.prototype.calculete = function () { _this = this; console.log(_this); _this.result.sum_1 = 0; _this.result.sum_2 = 0; _this.result.sum_3 = 0; _this.result.sum_4 = 0; _this.result.sum_5 = 0; _this.result.sum_6 = 0; _this.result.sum_7 = 0; _this.result.sum_8 = 0; _this.result.sum_9 = 0; type = (_this.result.type) ? _this.result.type : ''; shipping_address = (_this.result.shipping_address) ? (_this.result.shipping_address) : ''; receiving_address = (_this.result.receiving_address) ? (_this.result.receiving_address) : ''; weight = (_this.result.weight) ? parseFloat(_this.result.weight) : 0; count = (_this.result.count) ? parseInt(_this.result.count) : 0; if (count < 1) { count = 1; } dangerous = (_this.result.dangerous) ? _this.result.dangerous : false; price = (_this.result.price) ? parseInt(_this.result.price) : 0; isPackage = (_this.result.package) ? _this.result.package : false; // height = ($('#height').val()) ? parseFloat($('#height').val().replace(',', '.')) : 0; // width = ($('#width').val()) ? parseFloat($('#width').val().replace(',', '.')) : 0; // depth = ($('#depth').val()) ? parseFloat($('#depth').val().replace(',', '.')) : 0; volume = (_this.result.volume) ? parseFloat(_this.result.volume.replace(',', '.')) : 0; if (!shipping_address || !receiving_address || ((!volume || !weight) && !_this.result.dimensions)) { return; } price_kg = _this.price_kg; //транспортные услуги if (_this.result.dimensions) { _this.result.goods.map(function (item) { if (item && item.weight !== undefined && item.weight !== 0 && item.volume !== 0) { sum_1 = 0; price_kg = 0; if (item.weight <= 100) { price_kg = parseFloat(_this.ar_price_kg[0]); } else if (item.weight <= 1000) { price_kg = parseFloat(_this.ar_price_kg[1]); } else if (item.weight <= 3000) { price_kg = parseFloat(_this.ar_price_kg[2]); } else { price_kg = parseFloat(_this.ar_price_kg[3]); } if (dangerous) { price_kg = price_kg * 1.9; } if ((type.toLowerCase() === 'окна' || type.toLowerCase() === 'окно') && (receiving_address === 'Таксимо' || receiving_address === 'Бодайбо')) { price_kg = price_kg * 1.9; } var nacenka = 1; // if (item.weight / item.count >= 10001) { // nacenka = Math.max(nacenka, 1.3); // // price_kg = price_kg * 1.3; // } else if (item.weight / item.count >= 5001) { // nacenka = Math.max(nacenka, 1.2); // // price_kg = price_kg * 1.2; // } else if (item.weight / item.count >= 3001) { // nacenka = Math.max(nacenka, 1.1); // // price_kg = price_kg * 1.1; // } if (item.depth) { if (item.depth >= 6) { nacenka = Math.max(nacenka, 1.5); // price_kg = price_kg * 1.5; } else if (item.depth >= 3) { nacenka = Math.max(nacenka, 1.2); // price_kg = price_kg * 1.2; } } price_kg = price_kg * nacenka; if (item.weight / item.volume > 280) { sum_1 = item.weight * price_kg * 1.2 } else { sum_1 = 280 * item.volume * price_kg * 1.2 } if (_this.min_price && _this.min_price > sum_1) { sum_1 = _this.min_price; } _this.result.sum_1 += sum_1; } }) } else { if (dangerous) { price_kg = price_kg * 1.9; } if ((type.toLowerCase() === 'окна' || type.toLowerCase() === 'окно') && (receiving_address === 'Таксимо' || receiving_address === 'Бодайбо')) { price_kg = price_kg * 1.9; } var nacenka = 1; // if (weight / count >= 10001) { // nacenka = Math.max(nacenka, 1.3); // // price_kg = price_kg * 1.3; // } else if (weight / count >= 5001) { // nacenka = Math.max(nacenka, 1.2); // // price_kg = price_kg * 1.2; // } else if (weight / count >= 3001) { // nacenka = Math.max(nacenka, 1.1); // // price_kg = price_kg * 1.1; // } // if (depth) { // if (depth >= 6) { // nacenka = Math.max(nacenka, 1.5); // // price_kg = price_kg * 1.5; // } else if (depth >= 3) { // nacenka = Math.max(nacenka, 1.2); // // price_kg = price_kg * 1.2; // } // } price_kg = price_kg * nacenka; if (weight / volume > 280) { _this.result.sum_1 = weight * price_kg * 1.2 } else { _this.result.sum_1 = 280 * volume * price_kg * 1.2 } if (_this.min_price && _this.min_price > _this.result.sum_1) { _this.result.sum_1 = _this.min_price; } } // if (weight / count < 280) { // weight = 280 * count; // } // if (dangerous) { // price_kg = price_kg * 1.9; // } // if (weight / volume < 90) { // price_kg = price_kg * 0.8; // } // if (weight / volume > 1000) { // price_kg = price_kg * 0.8; // } // if (type === 'Окна' && shipping_address === 'Иркутск' && (receiving_address === 'Таксимо' || receiving_address === 'Бодайбо')) { // price_kg = price_kg * 1.9; // } // if (weight / volume < 280) { // _this.result.sum_1 = 280 * volume * price_kg; // } else { // _this.result.sum_1 = weight * price_kg; // } _this.result.sum_1 = parseInt(_this.result.sum_1 * 100) / 100; //дополнительная упаковка if (isPackage) { if (_this.result.dimensions) { _this.result.goods.map(function (item) { if (item && item.weight !== undefined && item.weight !== 0 && item.volume !== 0) { price_kg = 0; if (item.weight <= 100) { price_kg = parseFloat(_this.ar_price_kg[0]); } else if (item.weight <= 1000) { price_kg = parseFloat(_this.ar_price_kg[1]); } else if (item.weight <= 3000) { price_kg = parseFloat(_this.ar_price_kg[2]); } else { price_kg = parseFloat(_this.ar_price_kg[3]); } if (dangerous) { price_kg = price_kg * 1.9; } if ((type.toLowerCase() === 'окна' || type.toLowerCase() === 'окно') && (receiving_address === 'Таксимо' || receiving_address === 'Бодайбо')) { price_kg = price_kg * 1.9; } var nacenka = 1; if (item.weight / item.count >= 10001) { nacenka = Math.max(nacenka, 1.3); // price_kg = price_kg * 1.3; } else if (item.weight / item.count >= 5001) { nacenka = Math.max(nacenka, 1.2); // price_kg = price_kg * 1.2; } else if (item.weight / item.count >= 3001) { nacenka = Math.max(nacenka, 1.1); // price_kg = price_kg * 1.1; } if (item.depth) { if (item.depth >= 6) { nacenka = Math.max(nacenka, 1.5); // price_kg = price_kg * 1.5; } else if (item.depth >= 3) { nacenka = Math.max(nacenka, 1.2); // price_kg = price_kg * 1.2; } } price_kg = price_kg * nacenka; sum_2 = Math.max(item.volume * _this.price_package, 420); sum_2 = parseInt(sum_2 * 100) / 100; sum_3 = 280 * item.volume * 0.3 * price_kg * 1.2 sum_3 = parseInt(sum_3 * 100) / 100; _this.result.sum_2 += sum_2; _this.result.sum_3 += sum_3; } }); } else { _this.result.sum_2 = volume * _this.price_package; if (_this.result.sum_2 < 420) { _this.result.sum_2 = 420; } _this.result.sum_2 = parseInt(_this.result.sum_2 * 100) / 100; _this.result.sum_3 = 280 * volume * 0.3 * price_kg * 1.2 _this.result.sum_3 = parseInt(_this.result.sum_3 * 100) / 100; } } //Маркировка груза if (_this.result.dimensions) { _this.result.goods.map(function (item) { if (item && item.weight !== undefined && item.weight !== 0 && item.volume !== 0) { sum_4 = item.count * _this.price_count; sum_4 = parseInt(sum_4 * 100) / 100; _this.result.sum_4 += sum_4; } }); } else { _this.result.sum_4 = count * _this.price_count; _this.result.sum_4 = parseInt(_this.result.sum_4 * 100) / 100; } //Страхование груза if (_this.result.dimensions) { _this.result.goods.map(function (item) { if (item && item.weight !== undefined && item.weight !== 0 && item.volume !== 0) { if (price) { sum_5 = price * 0.0022; } else { // sum_5 = item.weight * 100 * 0.0022; sum_5 = 90; } sum_5 = Math.max(sum_5, 90); _this.result.sum_5 += sum_5; } }); } else { if (price) { _this.result.sum_5 = price * 0.0022; } else { // _this.result.sum_5 = weight * 100 * 0.0022; _this.result.sum_5 = 90; } if (_this.result.sum_5 < 90) { _this.result.sum_5 = 90; } } _this.result.sum_5 = parseInt(_this.result.sum_5 * 100) / 100; //Дополнительные услуги // _this.result.sum_5 = 0; if (_this.result.take) { _this.result.sum_6 += _this.price_take * 1.2; $('#show_sum_6').show(); } else { $('#show_sum_6').hide(); } // if ($('#shipment').is(':checked')) { // _this.result.sum_5 += _this.price_shipment; // } if (_this.result.deliver) { _this.result.sum_7 += _this.price_deliver * 1.2; $('#show_sum_7').show(); } else { $('#show_sum_7').hide(); } // if ($('#discharge').is(':checked')) { // _this.result.sum_5 += _this.price_discharge; // } if (_this.result.send) { _this.result.sum_8 = _this.price_send; $('#show_sum_8').show(); } else { $('#show_sum_8').hide(); } if (_this.result.return) { _this.result.sum_9 = _this.price_return; $('#show_sum_9').show(); } else { $('#show_sum_9').hide(); } // _this.result.sum_5 = parseInt(_this.result.sum_5 * 100) / 100; // console.log(_this.result.sum_1, _this.result.sum_2, _this.result.sum_3, _this.result.sum_4, _this.result.sum_5); //Стоимость перевозки _this.result.sum_1*=1.2; _this.result.sum_all = _this.result.sum_1 + _this.result.sum_2 + _this.result.sum_3 + _this.result.sum_4 + _this.result.sum_5 + _this.result.sum_6 + _this.result.sum_7 + _this.result.sum_8 + _this.result.sum_9; $('#sum_1').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_1))); $('#sum_2').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_2))); $('#sum_3').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_3))); $('#sum_4').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_4))); $('#sum_5').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_5))); $('#sum_6').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_6))); $('#sum_7').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_7))); $('#sum_8').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_8))); $('#sum_9').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_9))); $('#sum_all').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_all))); $('#sum_time').text(_this.time); if (document.querySelector("#all_weight.active")) { if (weight >= 10000 || volume >= 35) { document.querySelector(".calculate-delivery-sum_bold .calculate-delivery-sum__result").classList.add("big_order"); _this.result.sum_all = "У Вас крупная перевозка, свяжитесь с менеджером для получения специальной цены"; $('#sum_all').text(_this.result.sum_all); $('#sum_1').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(0))); } else { if(shipping_address && receiving_address && _this.result.sum_1===0) { $('#sum_1').text('0'); $('#sum_2').text('0'); $('#sum_3').text('0'); $('#sum_4').text('0'); $('#sum_5').text('0'); $('#sum_6').text('0'); $('#sum_7').text('0'); $('#sum_8').text('0'); $('#sum_9').text('0'); document.querySelector(".calculate-delivery-sum_bold .calculate-delivery-sum__result").classList.add("big_order"); $('#sum_all').text('Не удалось рассчитать стоимость перевозки'); } else { document.querySelector(".calculate-delivery-sum_bold .calculate-delivery-sum__result").classList.remove("big_order"); } } } if(shipping_address && receiving_address && _this.price_deliver===0) { $('#sum_1').text('0'); $('#sum_2').text('0'); $('#sum_3').text('0'); $('#sum_4').text('0'); $('#sum_5').text('0'); $('#sum_6').text('0'); $('#sum_7').text('0'); $('#sum_8').text('0'); $('#sum_9').text('0'); document.querySelector(".calculate-delivery-sum_bold .calculate-delivery-sum__result").classList.add("big_order"); $('#sum_all').text('Не удалось рассчитать стоимость перевозки'); } if (document.querySelector("#all_goods.active")) { if (document.querySelector("#show_all_goods .calculate-delivery-row-coll__result span").innerHTML >= 35 || document.querySelector("#show_all_goods input.calculate-delivery-input.calculate-delivery-input__weight.js_input__number").value >= 10000) { document.querySelector(".calculate-delivery-sum_bold .calculate-delivery-sum__result").classList.add("big_order"); _this.result.sum_all = "У Вас крупная перевозка, свяжитесь с менеджером для получения специальной цены"; $('#sum_all').text(_this.result.sum_all); $('#sum_1').text(new Intl.NumberFormat('ru-RU').format(Math.ceil(0))); } else { if(shipping_address && receiving_address && _this.result.sum_1===0) { $('#sum_1').text('0'); $('#sum_2').text('0'); $('#sum_3').text('0'); $('#sum_4').text('0'); $('#sum_5').text('0'); $('#sum_6').text('0'); $('#sum_7').text('0'); $('#sum_8').text('0'); $('#sum_9').text('0'); document.querySelector(".calculate-delivery-sum_bold .calculate-delivery-sum__result").classList.add("big_order"); $('#sum_all').text('Не удалось рассчитать стоимость перевозки'); } else { document.querySelector(".calculate-delivery-sum_bold .calculate-delivery-sum__result").classList.remove("big_order"); } } } //цена от на странице тренировки if (parseInt(_this.result.weight) === 1 && parseFloat(_this.result.volume) === 0.01) { $('.catalog-element-banner-purchase-price').html(' от ' + new Intl.NumberFormat('ru-RU').format(Math.ceil(_this.result.sum_all)) + ' руб.'); } //аэроглиссер для бодайбо на время закрытия // if((shipping_address)==='Бодайбо' || (receiving_address)==='Бодайбо') { // $('#sum_1').text('0'); // $('#sum_2').text('0'); // $('#sum_3').text('0'); // $('#sum_4').text('0'); // $('#sum_5').text('0'); // $('#sum_6').text('0'); // $('#sum_7').text('0'); // $('#sum_8').text('0'); // $('#sum_9').text('0'); // document.querySelector(".calculate-delivery-sum_bold .calculate-delivery-sum__result").classList.add("big_order"); // $('#sum_all').text('Не удалось рассчитать стоимость перевозки'); // } } })();