3201},32023203getCityCoordinates: function (mapType, city, onDone) {3204var xhr = new XMLHttpRequest();3205xhr.onload = function () {3206if (xhr.readyState === xhr.DONE && xhr.status === 200) {3207onDone(JSON.parse(xhr.responseText));3208}3209};3210xhr.open(3211'GET',3212'https://geocode-maps.yandex.ru/1.x/?apikey=' +
this.deliveryState.ymapApiKey + '&format=json&geocode=' + city ); xhr.timeout = 30000; xhr.send(); }, getAddresses: function (dataToSend, type, onDone, onFail) { var that = this; var data = dataToSend; if (that.deliveryState.currentRequest) { that.deliveryState.currentRequest.abort(); } if (!that.endpointDelivery) { that.endpointDelivery = '.tildacdn.com'; } var apiURL = { street: 'https://geoserv' + that.endpointDelivery + '/api/address/', city: 'https://geoserv' + that.endpointDelivery + '/api/city/', pickup: 'https://delivery' + that.endpointDelivery + '/cart-api/', house: 'https://geoserv' + that.endpointDelivery + '/api/house/', }; var pattern = ''; try { var json = JSON.parse(data); // Устанавливаем язык доставки в запрос json.lang = window.t_delivery__lang.lang; // Добавляем доступные страны в запрос const { state } = t_cart__useDeliveryAvailableCountries(); if (type === 'city' && typeof state.availableCountries === 'string') { json.countries = state.availableCountries; } if (window.testCountries) { json.test = true; if (type === 'street' || type === 'house') { if (that.deliveryState?.city?.countryIso) { json.country = that.deliveryState.city.countryIso; } if (type === 'street') { if (that.deliveryState?.city?.guid) { json.parent = that.deliveryState.city.guid; } } if (type === 'house') { if (that.deliveryState?.streetGuid) { json.parent = that.deliveryState.streetGuid; } } } } // Сохраняет тип и язык в LS pattern = 't' + type + '_' + json.lang + '_' + json.pattern.toLowerCase(); if (json.fias !== undefined) { pattern += '_' + json.fias; } if (window.dev === undefined) { var tDataFromGeo = sessionStorage.getItem(pattern); if (tDataFromGeo !== null) { try { onDone(JSON.parse(tDataFromGeo)); return; } catch (e) { /**/ } } } /* Adding in data new field `lang` */ var allRecords = document.getElementById('allrecords'); var tildaRootZone = allRecords.getAttribute('data-tilda-root-zone'); if (tildaRootZone) { json.rz = tildaRootZone; data = JSON.stringify(json); } } catch (e) { /**/ } var xhr = new XMLHttpRequest(); xhr.onload = function () {