fix(user-center): refresh revenue withdrawal state

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-06 12:51:01 +08:00
co-authored by Claude Fable 5
parent 8a007b9ee7
commit 487a63629c
3 changed files with 35 additions and 4 deletions
+28 -1
View File
@@ -141,7 +141,30 @@
}
});
}
var withdrawModal = document.querySelector('[data-aksrt-commission-withdraw-modal]');
function reloadRevenuePanel() {
var current = document.querySelector('[data-aksrt-revenue-page]');
if (!current) return Promise.resolve();
var panelUrl = rest + '/user-center/panel/revenue';
var query = new URL(window.location.href).searchParams;
query.delete('tab');
panelUrl += '?' + query.toString();
return fetch(panelUrl, {
credentials: 'same-origin',
headers: { 'X-WP-Nonce': data.restNonce || data.nonce || '' }
}).then(function (response) {
return response.json().then(function (payload) {
if (!response.ok || !payload.success || !payload.data || !payload.data.html) throw new Error('revenue-refresh-failed');
var wrapper = document.createElement('div');
wrapper.innerHTML = payload.data.html;
var next = wrapper.firstElementChild;
if (!next) throw new Error('revenue-html-empty');
current.replaceWith(next);
window.AKSRTRevenueCenterInit(next);
});
});
}
var withdrawModal = root.querySelector('[data-aksrt-commission-withdraw-modal]') || document.querySelector('[data-aksrt-commission-withdraw-modal]');
var withdrawForm = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-form]');
var withdrawTip = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-tip]');
var withdrawSubmit = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-submit]');
@@ -224,6 +247,10 @@
}
withdrawForm.reset();
setWithdrawBusy(false);
closeWithdrawModal();
reloadRevenuePanel().catch(function () {
if (typeof showToast === 'function') showToast('提现已提交,但收益数据刷新失败');
});
}).catch(function () { setWithdrawBusy(false); setWithdrawTip('网络错误,请稍后重试', true); });
});
}