ZHIWEI666 commited on
Commit
2633637
·
verified ·
1 Parent(s): e12a676

Upload 2 files

Browse files
前端页面/market/资金与钱包_充值组件.js CHANGED
@@ -48,13 +48,6 @@ export async function openRechargeModal(currentUser, onBalanceChange) {
48
  container.querySelector('#qr-image')?.removeAttribute('src');
49
  });
50
  container._cleanup = () => scope.dispose();
51
- let balanceText = t('wallet.recharge.balance_unavailable');
52
- try {
53
- const wallet = normalizeWalletData(await api.getWallet(account, readOptions));
54
- if (!scope.isCurrent()) return;
55
- if (Number.isSafeInteger(wallet.balance)) balanceText = String(wallet.balance);
56
- } catch (_) { if (!scope.isCurrent()) return; }
57
-
58
  container.className = "wallet-modal wallet-modal--recharge";
59
 
60
  const rechargeOptions = [
@@ -85,7 +78,7 @@ export async function openRechargeModal(currentUser, onBalanceChange) {
85
  container.innerHTML = `
86
  <div class="wallet-recharge__balance">
87
  <div class="wallet-modal__muted">${t('wallet.recharge.current_balance')}</div>
88
- <div class="wallet-recharge__balance-value">${balanceText} <span class="wallet-recharge__balance-unit">${t('wallet.recharge.points_suffix')}</span></div>
89
  </div>
90
 
91
  <div class="wallet-modal__field">
@@ -249,4 +242,15 @@ export async function openRechargeModal(currentUser, onBalanceChange) {
249
  modalElement = globalModal.activeModals.find(modal => modal.contains(container));
250
  constructing = false;
251
  observer.observe(document.body, { childList: true, subtree: true });
 
 
 
 
 
 
 
 
 
 
 
252
  }
 
48
  container.querySelector('#qr-image')?.removeAttribute('src');
49
  });
50
  container._cleanup = () => scope.dispose();
 
 
 
 
 
 
 
51
  container.className = "wallet-modal wallet-modal--recharge";
52
 
53
  const rechargeOptions = [
 
78
  container.innerHTML = `
79
  <div class="wallet-recharge__balance">
80
  <div class="wallet-modal__muted">${t('wallet.recharge.current_balance')}</div>
81
+ <div class="wallet-recharge__balance-value" data-recharge-balance role="status" aria-live="polite" aria-busy="true"><span data-recharge-balance-value>${t('common.loading')}</span> <span data-recharge-balance-unit class="wallet-recharge__balance-unit" hidden>${t('wallet.recharge.points_suffix')}</span></div>
82
  </div>
83
 
84
  <div class="wallet-modal__field">
 
242
  modalElement = globalModal.activeModals.find(modal => modal.contains(container));
243
  constructing = false;
244
  observer.observe(document.body, { childList: true, subtree: true });
245
+
246
+ let balance;
247
+ try {
248
+ const wallet = normalizeWalletData(await api.getWallet(account, readOptions));
249
+ if (!scope.isCurrent()) return;
250
+ if (Number.isSafeInteger(wallet.balance)) balance = wallet.balance;
251
+ } catch (_) { if (!scope.isCurrent()) return; }
252
+ container.querySelector('[data-recharge-balance-value]').textContent = balance === undefined
253
+ ? t('wallet.recharge.balance_unavailable') : String(balance);
254
+ container.querySelector('[data-recharge-balance-unit]').hidden = balance === undefined;
255
+ container.querySelector('[data-recharge-balance]').setAttribute('aria-busy', 'false');
256
  }
前端页面/market/资金与钱包_提现组件.js CHANGED
@@ -68,6 +68,20 @@ export async function openWithdrawModal(currentUser, onSuccess) {
68
  container.querySelectorAll('input').forEach(input => { input.value = ''; });
69
  });
70
  container._cleanup = () => scope.dispose();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  let walletData;
72
  try {
73
  walletData = normalizeWalletData(await api.getWallet(account, { noCache: true, componentId,
@@ -76,16 +90,15 @@ export async function openWithdrawModal(currentUser, onSuccess) {
76
  if (!Number.isSafeInteger(walletData.balance) || !Number.isSafeInteger(walletData.total_withdrawn)) throw new Error('wallet unavailable');
77
  } catch (_) {
78
  if (scope.isCurrent()) showToast(t('wallet.withdraw.balance_unavailable'), 'warning');
79
- scope.dispose(); return;
80
  }
81
  const maxWithdraw = walletData.balance;
82
  const totalWithdrawn = walletData.total_withdrawn;
83
  if (maxWithdraw <= 0) {
84
- showToast(t('wallet.withdraw.no_balance'), "warning"); scope.dispose(); return;
 
85
  }
86
 
87
- container.className = "wallet-modal wallet-modal--withdraw";
88
-
89
  container.innerHTML = `
90
  <div class="wallet-withdraw__summary">
91
  <div>
@@ -244,10 +257,5 @@ export async function openWithdrawModal(currentUser, onSuccess) {
244
  const input = label.parentElement.querySelector('input');
245
  if (input) input.setAttribute('aria-label', label.textContent.trim());
246
  });
247
- const observer = new MutationObserver(() => { if (!container.isConnected) scope.dispose(); });
248
- scope.addCleanup(() => observer.disconnect());
249
- globalModal.openModal(t('wallet.withdraw.title'), container, { width: "420px" });
250
- modalElement = globalModal.activeModals.find(modal => modal.contains(container));
251
- constructing = false;
252
- observer.observe(document.body, { childList: true, subtree: true });
253
- }
 
68
  container.querySelectorAll('input').forEach(input => { input.value = ''; });
69
  });
70
  container._cleanup = () => scope.dispose();
71
+ if (!scope.isCurrent()) return;
72
+ container.className = "wallet-modal wallet-modal--withdraw";
73
+ container.setAttribute('aria-busy', 'true');
74
+ const status = document.createElement('div');
75
+ status.setAttribute('role', 'status');
76
+ status.setAttribute('aria-live', 'polite');
77
+ status.textContent = t('common.loading');
78
+ container.append(status);
79
+ const observer = new MutationObserver(() => { if (!container.isConnected) scope.dispose(); });
80
+ scope.addCleanup(() => observer.disconnect());
81
+ globalModal.openModal(t('wallet.withdraw.title'), container, { width: "420px" });
82
+ modalElement = globalModal.activeModals.find(modal => modal.contains(container));
83
+ constructing = false;
84
+ observer.observe(document.body, { childList: true, subtree: true });
85
  let walletData;
86
  try {
87
  walletData = normalizeWalletData(await api.getWallet(account, { noCache: true, componentId,
 
90
  if (!Number.isSafeInteger(walletData.balance) || !Number.isSafeInteger(walletData.total_withdrawn)) throw new Error('wallet unavailable');
91
  } catch (_) {
92
  if (scope.isCurrent()) showToast(t('wallet.withdraw.balance_unavailable'), 'warning');
93
+ scope.dispose(); globalModal.closeModal(modalElement); return;
94
  }
95
  const maxWithdraw = walletData.balance;
96
  const totalWithdrawn = walletData.total_withdrawn;
97
  if (maxWithdraw <= 0) {
98
+ showToast(t('wallet.withdraw.no_balance'), "warning");
99
+ scope.dispose(); globalModal.closeModal(modalElement); return;
100
  }
101
 
 
 
102
  container.innerHTML = `
103
  <div class="wallet-withdraw__summary">
104
  <div>
 
257
  const input = label.parentElement.querySelector('input');
258
  if (input) input.setAttribute('aria-label', label.textContent.trim());
259
  });
260
+ container.setAttribute('aria-busy', 'false');
261
+ }