Compare commits

..

2 Commits
main ... pages

View File

@ -36,7 +36,7 @@
<section class="kt-ai-hero" data-align="center">
<div class="kt-ai-wrap">
<h1 class="reveal">Рассчитайте стоимость подключения</h1>
<h1 class="reveal" style="color: var(--kt-ai-ok)">Рассчитайте стоимость подключения</h1>
<p class="kt-ai-hero-sub reveal">Выберите тариф, скорость и оборудование — сумма обновится автоматически</p>
</div>
</section>
@ -67,6 +67,10 @@
<div class="total-block reveal">
<span style="font-size: var(--kt-ai-text-lg); color: var(--kt-ai-fg-muted)">Итого в месяц</span>
<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">
<svg class="kt-icon" style="margin-right: 8px"><use href="#copy"></use></svg>
Скопировать расчёт
@ -114,7 +118,8 @@ const EQUIPMENT = [
let state = {
tariff: null,
speed: null,
equipment: null
equipment: null,
discount: false
};
// Инициализация
@ -124,6 +129,7 @@ function init() {
updateTotal();
renderJournal();
setupReveal();
setupDiscount();
}
// Рендер опций
@ -183,7 +189,10 @@ function updateTotal() {
const e = EQUIPMENT.find(x => x.id === state.equipment);
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
@ -200,6 +209,18 @@ function loadState() {
} 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() {
const entry = {
@ -225,7 +246,8 @@ function calculateTotal() {
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.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() {
@ -268,11 +290,12 @@ document.getElementById('copyBtn').addEventListener('click', () => {
const e = EQUIPMENT.find(x => x.id === state.equipment);
const total = calculateTotal();
const discountText = state.discount ? '\n🎁 Скидка 10% (сотрудник КТ): применена' : '';
const text = `📊 Расчёт стоимости подключения:
🔹 Тариф: ${t.name} — ${t.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()} ₸ в месяц`;