Добавлена автоподстановка суммы для оплаты с кошелька и подсказка при нулевом балансе
This commit is contained in:
@@ -695,6 +695,10 @@
|
||||
</div>
|
||||
<!-- Один скрытый инпут: имя будет меняться в зависимости от режима -->
|
||||
<input type="hidden" id="unified-method-id" required>
|
||||
<!-- Подсказка при пустом кошельке -->
|
||||
<div class="alert alert-warning py-2 mt-2 mb-0" id="wallet-empty-hint" style="display:none;">
|
||||
<i class="bi bi-exclamation-triangle-fill"></i> На личном счете клиента нет остатка, используйте другой способ оплаты
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Сумма (одно поле для обоих режимов) -->
|
||||
@@ -884,6 +888,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
const amountInput = document.getElementById('unified-amount');
|
||||
const amountHint = document.getElementById('amount-hint');
|
||||
const amountMaxSpan = document.getElementById('amount-max');
|
||||
const walletEmptyHint = document.getElementById('wallet-empty-hint');
|
||||
|
||||
const refundReasonWrap = document.getElementById('refund-reason-wrap');
|
||||
const refundReasonInput = document.getElementById('refund-reason');
|
||||
@@ -974,12 +979,28 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// Выбор способа (не активируем по умолчанию)
|
||||
methodButtons.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
const methodCode = btn.dataset.code;
|
||||
|
||||
// Скрываем подсказку перед проверкой
|
||||
if (walletEmptyHint) walletEmptyHint.style.display = 'none';
|
||||
|
||||
// Проверяем баланс кошелька для платежа
|
||||
if (currentMode === 'payment' && methodCode === 'account_balance' && walletBalance === 0) {
|
||||
if (walletEmptyHint) walletEmptyHint.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
methodButtons.forEach(b => b.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
methodHidden.value = btn.dataset.id;
|
||||
currentMethodCode = btn.dataset.code;
|
||||
currentMethodCode = methodCode;
|
||||
|
||||
if (currentMode === 'payment') {
|
||||
// Для кошелька: подставляем максимум из (остаток к оплате, баланс)
|
||||
if (methodCode === 'account_balance') {
|
||||
const max = Math.min(amountDue, walletBalance);
|
||||
amountInput.value = max.toFixed(2);
|
||||
}
|
||||
updateLimitsForPayment();
|
||||
} else {
|
||||
updateLimitsForRefund();
|
||||
|
||||
Reference in New Issue
Block a user