China Express Airlines | Destinatii
Va rugam sa schimbati originea sau destinatia
Ne pare rau, cautarea din/spre acelasi oras nu este posibila...
' } let hasDirect = false; let flightColor = '#808080'; const deals = this.flightDeals[dep.code + arr.code]; if (typeof deals !== 'undefined') { if (deals?.some(obj => obj.isDirect === true)) { flightColor = '#0dcaf0'; hasDirect = true; } } let html = '
'; html += `
${dep.name} – ${arr.name.slice(0, 10)}
`; html += loadingText; if (deals?.length > 1) { html += '
'; if (hasDirect) { html += '
● ' + 'direct' + '
'; } html += '
● ' + 'escale' + '
'; html += '
○ ' + 'ieftin' + '
'; html += '
'; } else if(deals?.length < 1 && !this.isDealsLoading) { html += 'Alege datele calatoriei' } html += '
'; return html; }, populateCalendar(dep, arr) { if (dep.code === arr.code) { return; } if (!dep || !arr || !Cookies.get('csrftoken')) { return; } const key = dep.code + arr.code; if (this.flightDeals.hasOwnProperty(key) && this.flightDeals[key].length > 0) { return; } this.getFlightDealsYear(dep, arr) .then(deals => { this.flightDeals[key] = deals this.$forceUpdate(); }) .catch(error => { console.error(error); }); }, getFlightDealsYear: function (dep, arr) { this.isDealsLoading = true; const url = '/sky_ajax/indicative/year'; const data = { is_direct: false, departure_iata: dep.code, arrival_iata: arr.code, departure_country: dep.country_code, arrival_country: arr.country_code, }; return fetch(url, { method: 'POST', headers: { 'X-CSRFToken': Cookies.get('csrftoken'), 'X-Requested-With': 'XMLHttpRequest', }, body: JSON.stringify(data) }) .then(response => response.json()) .then(result => { if (!Array.isArray(result) && result.length === 0) { return [] } const deals = result .sort((a, b) => { const directComparison = (b.is_direct || 0) - (a.is_direct || 0); if (directComparison !== 0) { return directComparison; } const aMinPrice = parseFloat(a.min_price || 0); const bMinPrice = parseFloat(b.min_price || 0); return aMinPrice - bMinPrice; }) .reduce((uniqueDeals, item, index, array) => { const existingDeal = uniqueDeals.find(deal => deal.dates === item.outbound_leg.date_time); if (!existingDeal) { const isCheapest = index < array.length / 3; let highlight = null; if (isCheapest) { highlight = { fillMode: 'outline', color: 'red', style: { borderWidth: '1px' }, contentStyle: { fontWeight: '500', color: 'inherit', }, } } const dotStyle = { backgroundColor: item.is_direct ? '#0dcaf0' : '#808080', } const newDeal = { key: item.quote_id, dates: item.outbound_leg.date_time, isDirect: item.is_direct, dot: {style: dotStyle}, minPrice: item.min_price, highlight: highlight }; uniqueDeals.push(newDeal); } return uniqueDeals; }, []); this.isDealsLoading = false; return deals; }) .catch(error => { console.error('Error:', error); }); }, searchFlights: function () { if (this.selectedDeparture.code === this.selectedArrival.code) { $("#toast_same_origin_destination").toast("show"); } else { showLoader(); var dep = this.selectedDeparture.code; var arr = this.selectedArrival.code; var outbound_date_ymd = ''; var inbound_date_ymd = ''; outbound_date_ymd = new Date(this.oneWayDepartDate).getFullYear() + ("0" + (new Date(this.oneWayDepartDate).getMonth() + 1)).slice(-2) + ("0" + new Date(this.oneWayDepartDate).getDate()).slice(-2); if (!this.isOneWay) { inbound_date_ymd = new Date(this.returnDate).getFullYear() + ("0" + (new Date(this.returnDate).getMonth() + 1)).slice(-2) + ("0" + new Date(this.returnDate).getDate()).slice(-2); } var adt = this.adultsCount; var chd = this.childrenCount !== 0 ? this.childrenCount : ''; var inf = this.infantsCount !== 0 ? this.infantsCount : ''; var searchUrl = '/sky/?departure_iata=' + dep + '&arrival_iata=' + arr + '&departure_date=' + outbound_date_ymd + '&return_date=' + inbound_date_ymd + '&adt=' + adt + '&chd=' +chd + '&inf=' + inf + '¤cy=' + this.selectedCurrency.code; location.href = searchUrl; } }, exchangeCities: function () { this.rotatePlane = !this.rotatePlane; const temp = this.selectedDeparture; this.selectedDeparture = this.selectedArrival; this.selectedArrival = temp; this.arrivalOptions = []; this.departureOptions = []; }, closeDropdown: function () { $('#paxDropDownBtn').dropdown('toggle'); }, decreaseAdultsCount: function () { if (this.passengersCount > 1 && this.adultsCount > this.infantsCount && this.adultsCount > 1) { this.adultsCount--; } }, increaseAdultsCount: function () { if (this.adultsCount < 8 && this.passengersCount < 8) { this.adultsCount++; } }, decreaseChildrenCount: function () { if (this.childrenCount > 0 && this.passengersCount > 1) { this.childrenCount--; } }, increaseChildrenCount: function () { if (this.childrenCount < 8 && this.passengersCount < 8) { this.childrenCount++; } }, decreaseInfantsCount: function () { if (this.infantsCount > 0 && this.passengersCount > 1 && this.infantsCount <= this.adultsCount) { this.infantsCount--; } }, increaseInfantsCount: function () { if (this.infantsCount < 4 && this.infantsCount < this.adultsCount && this.passengersCount < 8) { this.infantsCount++; } }, setIsOneWay: function () { this.isOneWay = true; }, setIsRoundTrip: function () { const storedReturnDate = JSON.parse(localStorage.getItem('zd_retDate')); if (!storedReturnDate) { const departDate = new Date(this.oneWayDepartDate); const sevenDaysLater = new Date(departDate); sevenDaysLater.setDate(sevenDaysLater.getDate() + 7); this.returnDate = sevenDaysLater; } else { this.returnDate = storedReturnDate; } this.isOneWay = false; }, departureAutoComplete: function (search) { var component = this; term = search ? search : component.selectedDeparture.country_name ? component.selectedDeparture.country_name : ''; component.isSearchingDeparture = true; if (this.timeout) clearTimeout(this.timeout); this.timeout = setTimeout(() => { $.ajax({ url: '/sky_ajax/autosuggest', method: 'GET', data: { 'term': term.replace(' ', ''), 'locale_iso': localeISO, 'types': 'city,airport', }, success: function (response) { component.departureOptions = response; component.isSearchingDeparture = false; }, complete: function () { component.isSearchingDeparture = false; }, error: function () { console.log('api error'); }, }); }, component.debounceDelay); }, arrivalAutoComplete: function (search) { var component = this; term = search ? search : component.selectedArrival.country_name ? component.selectedArrival.country_name : ''; component.isSearchingArrival = true; if (this.timeout) clearTimeout(this.timeout); this.timeout = setTimeout(() => { $.ajax({ url: '/sky_ajax/autosuggest', method: 'GET', data: { 'term': term.replace(' ', ''), 'locale_iso': localeISO, 'types': 'city,airport', }, success: function (response) { component.arrivalOptions = response; component.isSearchingArrival = false; }, complete: function () { component.isSearchingArrival = false; }, error: function () { console.log('api error'); }, }); }, component.debounceDelay); }, }, computed: { roundTripMask() { return { input: 'WWW, D MMM', } }, oneWayMask() { return { input: this.isOneWay ? 'WWWW, DD MMMM' : 'WWW, D MMM' } }, isSearchButtonDisabled() { return ( this.startedSearch || this.selectedDeparture === '' || this.selectedDeparture.length === 0 || this.selectedArrival === '' || this.selectedArrival.length === 0 ) }, selectedCurrency() { if (!localStorage.selectedCurrency) { const currency = {code: 'EUR', symbol: '€'} localStorage.setItem('selectedCurrency', JSON.stringify(currency)) return currency; } else { return JSON.parse(localStorage.getItem('selectedCurrency')); } }, passengersCount: function () { return this.adultsCount + this.childrenCount + this.infantsCount; } }, });