EngineGP/template/js/sections/services/mc.js

64 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2023-03-04 23:45:46 +00:00
$('#mc').ajaxForm({
dataType: 'json',
success: function (data) {
$.each(data, function (i, val) {
if (i == 'e')
bootbox.dialog('<h3 class="red">Ошибка</h3>' + val,
[{
"label": "Продолжить",
}]
);
2023-03-04 23:45:46 +00:00
if (i == 's')
location.href = home + 'servers/id/' + data['id'];
});
2023-03-04 23:45:46 +00:00
loading(0);
}
2023-03-04 23:45:46 +00:00
});
function change_data(data) {
$.getJSON('services/section/mc/id/' + $('#unit').val() + '/tarif/' + $('#tarifs').val() + '/get/' + data, function (arr) {
$.each(arr, function (id, val) {
$('#' + id).html(val);
});
2023-03-04 23:45:46 +00:00
upd_price();
promo();
});
2023-03-04 23:45:46 +00:00
}
function upd_price() {
$.getJSON('services/section/mc/id/' + $('#unit').val() + '/tarif/' + $('#tarifs').val() + '/slots/' + $('#slots').val() + '/time/' + $('#time').val() + '/ram/' + $('#ram').val() + '/get/price', function (arr) {
$.each(arr, function (id, val) {
$('#' + id).html(val);
});
2023-03-04 23:45:46 +00:00
promo();
});
2023-03-04 23:45:46 +00:00
}
function promo() {
if ($('#promo').val() == '') {
$('#promo_tr').css('display', 'none');
$('#sum_info').css('text-decoration', 'none');
return false;
}
2023-03-04 23:45:46 +00:00
$.getJSON('services/section/mc/id/' + $('#unit').val() + '/tarif/' + $('#tarifs').val() + '/slots/' + $('#slots').val() + '/time/' + $('#time').val() + '/ram/' + $('#ram').val() + '/cod/' + $('#promo').val() + '/get/promo', function (arr) {
$('#promo_tr').css('display', 'table-row');
2023-03-04 23:45:46 +00:00
if (arr['e'] != undefined) {
$('#promo_info').html(arr['e']);
$('#sum_info').css('text-decoration', 'none');
} else {
if (arr['discount'] == 1) {
$('#sum_info').css('text-decoration', 'line-through');
$('#promo_info').html('Цена с учетом промо-кода: ' + arr['sum'] + ' ' + arr['cur']);
} else {
$('#sum_info').css('text-decoration', 'none');
$('#promo_info').html('Подарочные дни: ' + arr['days']);
}
}
});
2023-03-04 23:45:46 +00:00
}