Добавлена скидка 10% для сотрудников КТ
This commit is contained in:
parent
65429102a4
commit
508d2d0214
31
index.html
31
index.html
@ -67,6 +67,10 @@
|
|||||||
<div class="total-block reveal">
|
<div class="total-block reveal">
|
||||||
<span style="font-size: var(--kt-ai-text-lg); color: var(--kt-ai-fg-muted)">Итого в месяц</span>
|
<span style="font-size: var(--kt-ai-text-lg); color: var(--kt-ai-fg-muted)">Итого в месяц</span>
|
||||||
<div class="total-amount" id="totalAmount">0 ₸</div>
|
<div class="total-amount" id="totalAmount">0 ₸</div>
|
||||||
|
<label class="kt-ai-card" style="display: inline-flex; align-items: center; gap: var(--kt-ai-space-3); padding: var(--kt-ai-space-4) var(--kt-ai-space-5); margin: var(--kt-ai-space-5) 0; cursor: pointer">
|
||||||
|
<input type="checkbox" id="discountCheck" style="width: 18px; height: 18px">
|
||||||
|
<span style="font-weight: var(--kt-ai-weight-medium)">Скидка 10% для сотрудников КТ</span>
|
||||||
|
</label>
|
||||||
<button class="kt-ai-btn" data-variant="primary" data-size="lg" id="copyBtn">
|
<button class="kt-ai-btn" data-variant="primary" data-size="lg" id="copyBtn">
|
||||||
<svg class="kt-icon" style="margin-right: 8px"><use href="#copy"></use></svg>
|
<svg class="kt-icon" style="margin-right: 8px"><use href="#copy"></use></svg>
|
||||||
Скопировать расчёт
|
Скопировать расчёт
|
||||||
@ -114,7 +118,8 @@ const EQUIPMENT = [
|
|||||||
let state = {
|
let state = {
|
||||||
tariff: null,
|
tariff: null,
|
||||||
speed: null,
|
speed: null,
|
||||||
equipment: null
|
equipment: null,
|
||||||
|
discount: false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
@ -124,6 +129,7 @@ function init() {
|
|||||||
updateTotal();
|
updateTotal();
|
||||||
renderJournal();
|
renderJournal();
|
||||||
setupReveal();
|
setupReveal();
|
||||||
|
setupDiscount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Рендер опций
|
// Рендер опций
|
||||||
@ -183,7 +189,10 @@ function updateTotal() {
|
|||||||
const e = EQUIPMENT.find(x => x.id === state.equipment);
|
const e = EQUIPMENT.find(x => x.id === state.equipment);
|
||||||
total += e.price;
|
total += e.price;
|
||||||
}
|
}
|
||||||
document.getElementById('totalAmount').textContent = total.toLocaleString() + ' ₸';
|
if (state.discount) {
|
||||||
|
total = total * 0.9;
|
||||||
|
}
|
||||||
|
document.getElementById('totalAmount').textContent = Math.round(total).toLocaleString() + ' ₸';
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalStorage
|
// LocalStorage
|
||||||
@ -200,6 +209,18 @@ function loadState() {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Скидка
|
||||||
|
function setupDiscount() {
|
||||||
|
const check = document.getElementById('discountCheck');
|
||||||
|
check.checked = state.discount;
|
||||||
|
check.addEventListener('change', () => {
|
||||||
|
state.discount = check.checked;
|
||||||
|
saveState();
|
||||||
|
updateTotal();
|
||||||
|
logAction();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Журнал
|
// Журнал
|
||||||
function logAction() {
|
function logAction() {
|
||||||
const entry = {
|
const entry = {
|
||||||
@ -225,7 +246,8 @@ function calculateTotal() {
|
|||||||
if (state.tariff) total += TARIFFS.find(x => x.id === state.tariff).price;
|
if (state.tariff) total += TARIFFS.find(x => x.id === state.tariff).price;
|
||||||
if (state.speed) total += SPEEDS.find(x => x.id === state.speed).price;
|
if (state.speed) total += SPEEDS.find(x => x.id === state.speed).price;
|
||||||
if (state.equipment) total += EQUIPMENT.find(x => x.id === state.equipment).price;
|
if (state.equipment) total += EQUIPMENT.find(x => x.id === state.equipment).price;
|
||||||
return total;
|
if (state.discount) total = total * 0.9;
|
||||||
|
return Math.round(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderJournal() {
|
function renderJournal() {
|
||||||
@ -268,11 +290,12 @@ document.getElementById('copyBtn').addEventListener('click', () => {
|
|||||||
const e = EQUIPMENT.find(x => x.id === state.equipment);
|
const e = EQUIPMENT.find(x => x.id === state.equipment);
|
||||||
const total = calculateTotal();
|
const total = calculateTotal();
|
||||||
|
|
||||||
|
const discountText = state.discount ? '\n🎁 Скидка 10% (сотрудник КТ): применена' : '';
|
||||||
const text = `📊 Расчёт стоимости подключения:
|
const text = `📊 Расчёт стоимости подключения:
|
||||||
|
|
||||||
🔹 Тариф: ${t.name} — ${t.price.toLocaleString()} ₸
|
🔹 Тариф: ${t.name} — ${t.price.toLocaleString()} ₸
|
||||||
🔹 Скорость: ${s.name} — ${s.price === 0 ? 'Бесплатно' : '+' + s.price.toLocaleString() + ' ₸'}
|
🔹 Скорость: ${s.name} — ${s.price === 0 ? 'Бесплатно' : '+' + s.price.toLocaleString() + ' ₸'}
|
||||||
🔹 Оборудование: ${e.name} — ${e.price === 0 ? 'Бесплатно' : '+' + e.price.toLocaleString() + ' ₸/мес'}
|
🔹 Оборудование: ${e.name} — ${e.price === 0 ? 'Бесплатно' : '+' + e.price.toLocaleString() + ' ₸/мес'}${discountText}
|
||||||
|
|
||||||
💰 Итого: ${total.toLocaleString()} ₸ в месяц`;
|
💰 Итого: ${total.toLocaleString()} ₸ в месяц`;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user