Update index.html

This commit is contained in:
Egor
2026-01-12 18:13:02 +03:00
committed by GitHub
parent 26e242cac7
commit df17f2be4a

View File

@@ -21114,6 +21114,34 @@
return;
}
// Для суточных тарифов показываем специальную информацию
const isDaily = selectedTariffData.is_daily ?? selectedTariffData.isDaily ?? false;
if (isDaily) {
const dailyPriceLabel = selectedTariffData.daily_price_label ?? selectedTariffData.dailyPriceLabel ?? '';
section.classList.remove('hidden');
list.innerHTML = `
<div style="padding: 16px; background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(99, 102, 241, 0.05)); border-radius: 12px; border: 1px solid rgba(139, 92, 246, 0.2);">
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px;">
<span style="font-size: 24px;">🔄</span>
<div>
<div style="font-weight: 600; color: var(--text-primary);">Суточная подписка</div>
<div style="font-size: 12px; color: var(--text-secondary);">Ежедневное списание с баланса</div>
</div>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 1px solid rgba(139, 92, 246, 0.1);">
<span style="font-size: 13px; color: var(--text-secondary);">Стоимость в день:</span>
<span style="font-weight: 700; color: var(--primary); font-size: 16px;">${dailyPriceLabel}</span>
</div>
<div style="font-size: 11px; color: var(--text-secondary); margin-top: 8px; line-height: 1.4;">
💡 Списание происходит автоматически каждые 24 часа. Можно приостановить в любой момент.
</div>
</div>
`;
summary?.classList.add('hidden');
updateTariffButton();
return;
}
const periods = selectedTariffData.periods || [];
if (periods.length === 0) {
section.classList.add('hidden');
@@ -21233,12 +21261,24 @@
const btn = document.getElementById('tariffsSelectBtn');
if (!btn) return;
if (selectedTariffData && selectedTariffPeriod) {
// Для суточных тарифов не требуем выбора периода
const isDaily = selectedTariffData?.is_daily ?? selectedTariffData?.isDaily ?? false;
if (selectedTariffData && (selectedTariffPeriod || isDaily)) {
btn.disabled = false;
const priceKopeks = selectedTariffPeriod.price_kopeks || selectedTariffPeriod.priceKopeks ||
selectedTariffPeriod.final_price || selectedTariffPeriod.finalPrice || 0;
const priceLabel = formatPriceFromKopeks(priceKopeks, tariffsData?.currency || 'RUB');
btn.textContent = `Купить за ${priceLabel}`;
let priceKopeks, priceLabel;
if (isDaily) {
// Суточный тариф - используем daily_price
priceKopeks = selectedTariffData.daily_price_kopeks ?? selectedTariffData.dailyPriceKopeks ?? 0;
priceLabel = selectedTariffData.daily_price_label ?? selectedTariffData.dailyPriceLabel ?? formatPriceFromKopeks(priceKopeks, tariffsData?.currency || 'RUB');
btn.textContent = `Активировать за ${priceLabel}`;
} else {
priceKopeks = selectedTariffPeriod.price_kopeks || selectedTariffPeriod.priceKopeks ||
selectedTariffPeriod.final_price || selectedTariffPeriod.finalPrice || 0;
priceLabel = formatPriceFromKopeks(priceKopeks, tariffsData?.currency || 'RUB');
btn.textContent = `Купить за ${priceLabel}`;
}
} else {
btn.disabled = true;
btn.textContent = t('tariffs.select');
@@ -21246,7 +21286,10 @@
}
async function purchaseTariff() {
if (!selectedTariffId || !selectedTariffPeriod) {
const isDaily = selectedTariffData?.is_daily ?? selectedTariffData?.isDaily ?? false;
// Для суточных тарифов не требуем выбора периода
if (!selectedTariffId || (!selectedTariffPeriod && !isDaily)) {
showPopup('Выберите тариф', 'Ошибка');
return;
}
@@ -21259,7 +21302,10 @@
try {
const initData = tg.initData || '';
const periodDays = selectedTariffPeriod.days || selectedTariffPeriod.period_days || selectedTariffPeriod.periodDays;
// Для суточных тарифов используем period_days=1
const periodDays = isDaily
? 1
: (selectedTariffPeriod.days || selectedTariffPeriod.period_days || selectedTariffPeriod.periodDays);
const response = await fetch('/miniapp/subscription/tariff/purchase', {
method: 'POST',
@@ -21277,7 +21323,10 @@
throw new Error(result?.detail?.message || result?.message || 'Ошибка покупки тарифа');
}
showPopup(result.message || 'Тариф успешно активирован!', 'Успех');
const successMsg = isDaily
? (result.message || 'Суточный тариф активирован!')
: (result.message || 'Тариф успешно активирован!');
showPopup(successMsg, 'Успех');
await refreshSubscriptionData();
} catch (err) {
console.error('Tariff purchase failed:', err);