496 lines
15 KiB
JavaScript
496 lines
15 KiB
JavaScript
|
|
Vue.config.devtools = true;
|
||
|
|
var complexobjectspage = new Vue({
|
||
|
|
el: '#complex_objects_page',
|
||
|
|
components: {
|
||
|
|
vuejsDatepicker: window.vuejsDatepicker
|
||
|
|
},
|
||
|
|
data() {
|
||
|
|
|
||
|
|
return {
|
||
|
|
agency_id: $('#session_agency_id').val(),
|
||
|
|
user_id: $('#session_user_id').val(),
|
||
|
|
complex_id: 0,
|
||
|
|
page: 1,
|
||
|
|
all_pages: 1,
|
||
|
|
prevPage: 0,
|
||
|
|
ot: 0,
|
||
|
|
do: 0,
|
||
|
|
pagePagin: [],
|
||
|
|
ru: vdp_translation_ru.js,
|
||
|
|
show_form: false,
|
||
|
|
show_info_object: false,
|
||
|
|
errorMes: false,
|
||
|
|
errorText: '',
|
||
|
|
region_id_user: 0,
|
||
|
|
is_looad: false,
|
||
|
|
is_budget: $('#session_use_advert_budget').val(),
|
||
|
|
isPreloader: 1,
|
||
|
|
OpenIndicator: {
|
||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
||
|
|
},
|
||
|
|
country: [],
|
||
|
|
country_id: 0,
|
||
|
|
regions: [],
|
||
|
|
region_id: 0,
|
||
|
|
metro_list: [],
|
||
|
|
complex_filter: {
|
||
|
|
'metros': [],
|
||
|
|
'period': 0,
|
||
|
|
'complexes': [],
|
||
|
|
'decorations': [],
|
||
|
|
'builders': [],
|
||
|
|
'types_room': [],
|
||
|
|
'types_complex': [],
|
||
|
|
'payment_types': [],
|
||
|
|
'sq_all_do': null,
|
||
|
|
'sq_all_ot': null,
|
||
|
|
'flat_floor_ot': null,
|
||
|
|
'flat_floor_do': null,
|
||
|
|
'stoim_ot': null,
|
||
|
|
'stoim_do': null,
|
||
|
|
'region_id': 0,
|
||
|
|
'country_id': 0,
|
||
|
|
},
|
||
|
|
period_list: [],
|
||
|
|
complex: [],
|
||
|
|
decoration: [],
|
||
|
|
builder_list: [],
|
||
|
|
types_room: [],
|
||
|
|
types_complex: [],
|
||
|
|
paymentTypes: [],
|
||
|
|
items: [],
|
||
|
|
object_info: [],
|
||
|
|
tab: 'object',
|
||
|
|
view_complex: 'table',
|
||
|
|
paymentTypes2: ['', 'Субсидия', 'Ипотека', 'Военная ипотека'],
|
||
|
|
imglist: {},
|
||
|
|
fotorama: []
|
||
|
|
}
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
|
||
|
|
//Открытие
|
||
|
|
open() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
toggle_form_search() {
|
||
|
|
(this.show_form) ? this.show_form = false: this.show_form = true;
|
||
|
|
},
|
||
|
|
|
||
|
|
//Список стран
|
||
|
|
getCountry() {
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'get_country',
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
// console.log(response.data);
|
||
|
|
var res = response.data;
|
||
|
|
|
||
|
|
this.country = res.country;
|
||
|
|
this.country_id = 171;
|
||
|
|
|
||
|
|
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
//Список регионов
|
||
|
|
getRegions() {
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'get_rf_regions',
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
|
||
|
|
var res = response.data;
|
||
|
|
this.region_id = parseInt(res.region_id_user);
|
||
|
|
this.region_id_user = parseInt(res.region_id_user);
|
||
|
|
this.regions = res.regions;
|
||
|
|
this.getMetro();
|
||
|
|
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
//Метро
|
||
|
|
getMetro() {
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'get_metro',
|
||
|
|
region_id: this.region_id,
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
|
||
|
|
this.metro_list = response.data;
|
||
|
|
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
//Период
|
||
|
|
getPeriods() {
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'get_periods',
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
|
||
|
|
this.period_list = response.data;
|
||
|
|
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
//Пагинация
|
||
|
|
pagin(page) {
|
||
|
|
this.page = page;
|
||
|
|
this.getComplex();
|
||
|
|
},
|
||
|
|
|
||
|
|
//Комплексы
|
||
|
|
getComplex() {
|
||
|
|
this.isPreloader = 1;
|
||
|
|
|
||
|
|
//console.log(this.isPreloader);
|
||
|
|
if (!this.isEmpty(localStorage['complex_filter'])) {
|
||
|
|
this.complex_filter = JSON.parse(localStorage['complex_filter']);
|
||
|
|
localStorage['complex_filter'] = null;
|
||
|
|
//console.log(this.complex_filter);
|
||
|
|
}
|
||
|
|
|
||
|
|
this.pagePagin = [];
|
||
|
|
this.ot = 0;
|
||
|
|
this.do = 0;
|
||
|
|
for (var j = 0; j < this.fotorama.length; j++) {
|
||
|
|
if (this.fotorama[j]) {
|
||
|
|
//console.log(this.fotorama[j]);
|
||
|
|
this.fotorama[j].remove();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// this.fotorama = [];
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
|
||
|
|
request: 'get_complex_one',
|
||
|
|
complex_id: this.complex_id,
|
||
|
|
filter: this.complex_filter,
|
||
|
|
page: this.page,
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
console.log(response.data);
|
||
|
|
this.complex = response.data;
|
||
|
|
|
||
|
|
//alert(this.is_budget);
|
||
|
|
setTimeout(() => {
|
||
|
|
|
||
|
|
var j = 0;
|
||
|
|
for (var k in complexobjectspage.complex.objects) {
|
||
|
|
var id = complexobjectspage.complex.objects[k].id;
|
||
|
|
$('#photos' + id).append('<div v-else id="fotorama_complex_obj_' + id + '" data-fit="cover" data-nav="false" data-allowfullscreen="true" data-width="100%" data-height="343px"></div>');
|
||
|
|
|
||
|
|
var images = [];
|
||
|
|
for (var i = 0; i < complexobjectspage.complex.objects[k].photos.length; i++) {
|
||
|
|
images.push({ img: complexobjectspage.complex.objects[k].photos[i] });
|
||
|
|
//
|
||
|
|
}
|
||
|
|
complexobjectspage.imglist[id] = images;
|
||
|
|
|
||
|
|
complexobjectspage.fotorama[j] = $('#fotorama_complex_obj_' + id).fotorama({
|
||
|
|
|
||
|
|
data: complexobjectspage.imglist[id]
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
j++;
|
||
|
|
}
|
||
|
|
}, 500);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
this.all_pages = parseInt(response.data.allPages);
|
||
|
|
if (this.all_pages > 1) {
|
||
|
|
if (this.page > 1)
|
||
|
|
this.prevPage = this.page - 1;
|
||
|
|
}
|
||
|
|
if (this.all_pages > 8) {
|
||
|
|
if (this.page > 4) {
|
||
|
|
this.ot = this.page - 3;
|
||
|
|
} else {
|
||
|
|
this.ot = 2;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.page < this.all_pages - 4) {
|
||
|
|
this.do = this.page + 3;
|
||
|
|
} else {
|
||
|
|
this.do = this.all_pages;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
this.ot = 2;
|
||
|
|
this.do = this.all_pages;
|
||
|
|
}
|
||
|
|
for (var i = this.ot; i < this.do; i++) {
|
||
|
|
this.pagePagin.push(i);
|
||
|
|
}
|
||
|
|
complexobjectspage.isPreloader = 0;
|
||
|
|
|
||
|
|
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
//Отделка
|
||
|
|
getDecorations() {
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'get_decorations',
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
|
||
|
|
var res = response.data;
|
||
|
|
this.decoration = res;
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
//Выбор страны
|
||
|
|
changeCountry() {
|
||
|
|
if (this.country_id != 171) {
|
||
|
|
this.region_id = 0;
|
||
|
|
|
||
|
|
} else {
|
||
|
|
this.region_id = this.region_id_user;
|
||
|
|
this.changeRegion();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
//Выбор региона
|
||
|
|
changeRegion() {
|
||
|
|
this.getMetro();
|
||
|
|
this.getComplex();
|
||
|
|
},
|
||
|
|
|
||
|
|
//Список застройщиков
|
||
|
|
get_builders() {
|
||
|
|
if (this.isEmpty(this.builder_list)) {
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'get_builders',
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
var res = response.data;
|
||
|
|
//this.builders = res.list;
|
||
|
|
this.builder_list = res.options;
|
||
|
|
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
//Типы комнат
|
||
|
|
get_types_room() {
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'get_types_room',
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
var res = response.data;
|
||
|
|
//this.builders = res.list;
|
||
|
|
this.types_room = res;
|
||
|
|
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
//Список типов комплекосов
|
||
|
|
getTypesComplex() {
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'get_types_complex',
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
|
||
|
|
var res = response.data;
|
||
|
|
this.types_complex = res;
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
//Типы оплат
|
||
|
|
getPaymentTypes() {
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'get_payment_types',
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
|
||
|
|
var res = response.data;
|
||
|
|
this.paymentTypes = res;
|
||
|
|
//console.log(this.paymentTypes);
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
search() {
|
||
|
|
this.is_looad = true;
|
||
|
|
this.toggle_form_search();
|
||
|
|
this.is_looad = false;
|
||
|
|
},
|
||
|
|
|
||
|
|
search_global() {
|
||
|
|
console.log(this.complex_filter);
|
||
|
|
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
|
|
request: 'search',
|
||
|
|
filter: this.complex_filter,
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
|
||
|
|
var res = response.data;
|
||
|
|
console.log(res);
|
||
|
|
this.items = res.list;
|
||
|
|
this.total = res.total;
|
||
|
|
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
//Подробности объекта
|
||
|
|
showInfoObject(event, object_id) {
|
||
|
|
console.log(object_id);
|
||
|
|
if ($(event.target).closest('.jw__object compact').length == 0 && $(event.target).closest('.jw__object').length == 0 && !$(event.target).hasClass('jw__object compact')) {
|
||
|
|
this.show_info_object = true;
|
||
|
|
this.object_info = this.complex.objects['object_' + object_id];
|
||
|
|
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
//Закрыть подробности объекта
|
||
|
|
closeInfoObject() {
|
||
|
|
this.object_info = [];
|
||
|
|
this.show_info_object = false;
|
||
|
|
this.tab = 'object';
|
||
|
|
},
|
||
|
|
|
||
|
|
//Выбор таба
|
||
|
|
changeTab(tab) {
|
||
|
|
this.tab = tab;
|
||
|
|
|
||
|
|
if (tab == 'complex') {
|
||
|
|
|
||
|
|
setTimeout(function() {
|
||
|
|
$('.NB__images .fotorama').fotorama();
|
||
|
|
// koala_loader();
|
||
|
|
}, 500);
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
//Выбор вида таблицы
|
||
|
|
changeView(view) {
|
||
|
|
this.view_complex = view;
|
||
|
|
localStorage['view_complex'] = view;
|
||
|
|
if (view == 'list') {
|
||
|
|
setTimeout(() => {
|
||
|
|
complexobjectspage.isPreloader = 0;
|
||
|
|
var j = 0;
|
||
|
|
for (var k in complexobjectspage.complex.objects) {
|
||
|
|
var id = complexobjectspage.complex.objects[k].id;
|
||
|
|
$('#photos' + id).append('<div v-else id="fotorama_complex_obj_' + id + '" data-fit="cover" data-nav="false" data-allowfullscreen="true" data-width="100%" data-height="343px"></div>');
|
||
|
|
|
||
|
|
var images = [];
|
||
|
|
for (var i = 0; i < complexobjectspage.complex.objects[k].photos.length; i++) {
|
||
|
|
images.push({ img: complexobjectspage.complex.objects[k].photos[i] });
|
||
|
|
//
|
||
|
|
}
|
||
|
|
complexobjectspage.imglist[id] = images;
|
||
|
|
|
||
|
|
complexobjectspage.fotorama[j] = $('#fotorama_complex_obj_' + id).fotorama({
|
||
|
|
|
||
|
|
data: complexobjectspage.imglist[id]
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
j++;
|
||
|
|
}
|
||
|
|
}, 500);
|
||
|
|
setTimeout(function() {
|
||
|
|
// $('.object-images .fotorama').fotorama();
|
||
|
|
//koala_loader();
|
||
|
|
}, 1000);
|
||
|
|
//object - images
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
//Проверка на пустоту
|
||
|
|
isEmpty(data) {
|
||
|
|
if (typeof(data) === 'object') {
|
||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
||
|
|
return true;
|
||
|
|
} else if (!data) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
} else if (typeof(data) === 'string') {
|
||
|
|
if (!data.trim()) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
} else if (typeof(data) === 'undefined') {
|
||
|
|
return true;
|
||
|
|
} else {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
},
|
||
|
|
mounted() {
|
||
|
|
|
||
|
|
},
|
||
|
|
created: function() {
|
||
|
|
$('#complex_objects_page').removeClass('hidden');
|
||
|
|
$('#complex_objects_page .full_modal-bg').removeClass('hidden');
|
||
|
|
var queryParams = parseQueryString(window.location.search);
|
||
|
|
if (!isEmpty(queryParams.complex_id)) {
|
||
|
|
this.complex_id = queryParams.complex_id;
|
||
|
|
}
|
||
|
|
if (localStorage['view_complex']) {
|
||
|
|
this.view_complex = localStorage['view_complex'];
|
||
|
|
}
|
||
|
|
/*this.getPaymentTypes();
|
||
|
|
this.getCountry();
|
||
|
|
this.getRegions();
|
||
|
|
this.getPeriods();
|
||
|
|
this.getDecorations();
|
||
|
|
this.get_builders();
|
||
|
|
this.get_types_room();
|
||
|
|
this.getTypesComplex();
|
||
|
|
this.getPaymentTypes();*/
|
||
|
|
this.getComplex();
|
||
|
|
|
||
|
|
}
|
||
|
|
})
|