243 lines
10 KiB
JavaScript
243 lines
10 KiB
JavaScript
if ($('#antiznak_modals').length > 0) {
|
|
Vue.config.devtools = true;
|
|
var antiznak_modals = new Vue({
|
|
el: '#antiznak_modals',
|
|
data() {
|
|
|
|
return {
|
|
user_id: $('#session_user_id').val(),
|
|
agency_id: $('#session_agency_id').val(),
|
|
is_modal_request_antiznak: false,
|
|
is_modal_photo_antiznak: false,
|
|
tariffs: [],
|
|
tariff_id: null,
|
|
is_show_tariffs: true,
|
|
is_show_edit_tariff: false,
|
|
edit_id: 0,
|
|
error_edit: false,
|
|
edit_count: null,
|
|
edit_price: null,
|
|
request_message: '',
|
|
request_done: false,
|
|
photo_total: 0,
|
|
photo_work_total: 0,
|
|
load_photos_modal: false,
|
|
result_photos: [],
|
|
send_photos: false,
|
|
progress: 0,
|
|
max_send_api: 100,
|
|
total_send_api: 0,
|
|
error_api: '',
|
|
result_api: '',
|
|
object_id: 0,
|
|
obj_ads_id: 0,
|
|
}
|
|
},
|
|
methods: {
|
|
//Типы оплат
|
|
getTariffs() {
|
|
|
|
axios.post('/ajax/vue_ajax/antiznak_axios.php', {
|
|
request: 'get_tariffs',
|
|
|
|
}, )
|
|
.then((response) => {
|
|
console.log(response.data);
|
|
var res = response.data;
|
|
this.tariffs = res;
|
|
})
|
|
.catch(function(error) {
|
|
console.log(error);
|
|
});
|
|
},
|
|
|
|
open_modal_request() {
|
|
$("body").addClass("lock");
|
|
$('.jw__add-popup').removeClass('is__show');
|
|
this.request_done = false;
|
|
this.request_message = "";
|
|
this.is_modal_request_antiznak = true;
|
|
this.getTariffs();
|
|
},
|
|
|
|
close_modal_request() {
|
|
$("body").removeClass("lock");
|
|
$('.jw__add-popup').removeClass('is__show');
|
|
this.is_modal_request_antiznak = false;
|
|
},
|
|
|
|
request_aniznak(id) {
|
|
let selectTariff = this.tariffs.find(x => x.id === id);
|
|
if (this.isEmpty(selectTariff)) {
|
|
this.request_done = true;
|
|
this.request_message = '<p><i style="color:#EE6161;font-size: 23px;margin-right: 7px;" class="ti-face-sad"></i><span>Тариф не найден</span></p>';
|
|
} else {
|
|
axios.post('/ajax/vue_ajax/antiznak_axios.php', {
|
|
request: 'request_tariff',
|
|
tariff: selectTariff,
|
|
user_id: this.user_id,
|
|
|
|
}, )
|
|
.then((response) => {
|
|
console.log(response.data);
|
|
this.request_done = true;
|
|
this.request_message = response.data;
|
|
|
|
})
|
|
.catch(function(error) {
|
|
console.log(error);
|
|
});
|
|
}
|
|
|
|
},
|
|
|
|
open_modal_photos(object_id) {
|
|
|
|
this.progress = 0;
|
|
this.error_api = '';
|
|
this.result_api = '';
|
|
this.load_photos_modal = true;
|
|
this.result_photos = [];
|
|
this.obj_ads_id = 0;
|
|
this.object_id = 0;
|
|
this.photo_total = 0;
|
|
this.send_photos = false;
|
|
$("body").addClass("lock");
|
|
$('.jw__add-popup').removeClass('is__show');
|
|
console.log(object_id);
|
|
this.object_id = object_id;
|
|
this.is_modal_photo_antiznak = true;
|
|
axios.post('/ajax/vue_ajax/antiznak_axios.php', {
|
|
request: 'get_place_object',
|
|
object_id: object_id,
|
|
user_id: this.user_id,
|
|
agency_id: this.agency_id,
|
|
}, )
|
|
.then((response) => {
|
|
console.log(response.data);
|
|
let res = response.data;
|
|
|
|
this.result_photos = res;
|
|
this.object_ads_id = res.object_ads_id;
|
|
this.photo_total = res.photos;
|
|
|
|
this.load_photos_modal = false;
|
|
if (res.status == 'pre_save') {
|
|
this.result_api = "Вы уже обрабатывали этот объект. Фотографии очищены";
|
|
}
|
|
|
|
})
|
|
.catch(function(error) {
|
|
console.log(error);
|
|
});
|
|
|
|
|
|
},
|
|
|
|
send_antiznak() {
|
|
this.send_photos = true;
|
|
this.photo_total = this.result_photos.photos;
|
|
this.photo_work_total = 0;
|
|
this.progress = 0;
|
|
this.total_send_api = 0;
|
|
this.send_api();
|
|
|
|
},
|
|
|
|
send_api() {
|
|
axios.post('/ajax/vue_ajax/antiznak_axios.php', {
|
|
request: 'send_api',
|
|
url: this.result_photos.place,
|
|
user_id: this.user_id,
|
|
agency_id: this.agency_id,
|
|
object_id: this.object_id,
|
|
object_ads_id: this.object_ads_id,
|
|
num_query: (this.total_send_api + 1),
|
|
|
|
photos_count: this.photo_total
|
|
|
|
}, )
|
|
.then((response) => {
|
|
console.log(response.data);
|
|
let res = response.data;
|
|
|
|
|
|
if (res.status.indexOf('processed') != -1 || res.status == 'searching') {
|
|
this.total_send_api++;
|
|
if (res.status.indexOf('processed') != -1)
|
|
this.progress = parseInt(res.status.replace('processed ', ''));
|
|
setTimeout(function() {
|
|
|
|
antiznak_modals.send_api();
|
|
|
|
}, 3000)
|
|
|
|
} else {
|
|
if (res.status == 'error') {
|
|
this.error_api = "Возникла ошибка, объявление не обработано";
|
|
} else if (res.status == 'save') {
|
|
this.result_api = "Фотографии успешно обработаны и сохранены.";
|
|
this.new_fotorama(this.object_id, res.photos);
|
|
} else if (res.status == 'pre_save') {
|
|
this.result_api = "Вы уже обрабатывали этот объект. Фотографии очищены";
|
|
|
|
}
|
|
}
|
|
})
|
|
.catch(function(error) {
|
|
console.log(error);
|
|
});
|
|
|
|
},
|
|
|
|
new_fotorama(object_id, photos) {
|
|
// var photos = { 1: 'https://data.joywork.ru/antyznak/f/1/f/f1bf7c1f51ed7083a4679acb757ee63f.jpeg', 2: 'https://data.joywork.ru/antyznak/7/6/8/76e87fb3b30f258e4bb9fc868fb672fe.jpeg', 3: 'https://data.joywork.ru/antyznak/9/8/6/989698f7fa424effa349baaa29d98ef2.jpeg', 4: 'https://data.joywork.ru/antyznak/a/8/8/a8883ea3dccfee316f2585a25bc7893b.jpeg', 5: 'https://data.joywork.ru/antyznak/2/e/e/2e0e00f1f93a6f83b27425db96953169.jpeg', 6: 'https://data.joywork.ru/antyznak/3/2/1/32a114820a345afc1b8cecd720dd9bd8.jpeg', 7: 'https://data.joywork.ru/antyznak/c/1/7/c107ed88f30a955b9fee320e90e8a418.jpeg', 8: 'https://data.joywork.ru/antyznak/9/7/6/97e68ead6b511658d731da80876c9aca.jpeg', 9: 'https://data.joywork.ru/antyznak/0/c/e/0cae7956ee93c704122a7dccb2cd5f31.jpeg', 10: 'https://data.joywork.ru/antyznak/6/b/5/6b2517718cf311ada250096b5c100081.jpeg', 11: 'https://data.joywork.ru/antyznak/d/a/7/da370875d93ec5a794be65b45101c8af.jpeg', 12: 'https://data.joywork.ru/antyznak/5/a/6/5a66a1d3f485bfd00c732dd941e5e102.jpeg' };
|
|
//console.log(photos);
|
|
$('#photos' + object_id + ' .fotorama--hidden').remove();
|
|
$('#photos' + object_id + ' .fotorama').remove();
|
|
let div_fotorama = '<div class="fotorama" data-fit="cover" data-nav="false" data-allowfullscreen="true" data-width="100%" data-height="343px">';
|
|
for (var i in photos) {
|
|
div_fotorama += '<img src="' + photos[i] + '">';
|
|
}
|
|
div_fotorama += '</div>';
|
|
$('#photos' + object_id + ' .arrow_box').after(
|
|
div_fotorama
|
|
);
|
|
$('#photos' + object_id + ' .fotorama').fotorama();
|
|
},
|
|
|
|
close_modal_photo() {
|
|
$("body").removeClass("lock");
|
|
$('.jw__add-popup').removeClass('is__show');
|
|
this.is_modal_photo_antiznak = false;
|
|
},
|
|
|
|
//Проверка на пустоту
|
|
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;
|
|
}
|
|
},
|
|
},
|
|
created: function() {
|
|
$('#antiznak_modals').removeClass('hidden');
|
|
|
|
// this.getTariffs();
|
|
console.log('ddd');
|
|
}
|
|
})
|
|
} |