feat(ux): after-sale multi-step, ban appeal, message types, coupon wallet
Orders center gains after-sale tickets (return ship/cancel/timeline), coupon wallet list, ban-appeal page, and expanded message center tabs.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Ban appeal form submit.
|
||||
* @package AKSRT
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
function ajaxUrl() {
|
||||
if (window.aksrtData && window.aksrtData.ajaxUrl) return window.aksrtData.ajaxUrl;
|
||||
if (window._win && window._win.ajax_url) return window._win.ajax_url;
|
||||
return '/wp-admin/admin-ajax.php';
|
||||
}
|
||||
function toast(msg) {
|
||||
if (window.aksrt && typeof window.aksrt.toast === 'function') {
|
||||
window.aksrt.toast(msg);
|
||||
return;
|
||||
}
|
||||
window.alert(msg);
|
||||
}
|
||||
function init() {
|
||||
var form = document.querySelector('.aksrt-ban-appeal-form');
|
||||
if (!form) return;
|
||||
form.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var btn = form.querySelector('button[type="submit"]');
|
||||
if (btn) btn.disabled = true;
|
||||
var fd = new FormData(form);
|
||||
if (!fd.get('action')) fd.set('action', 'aksrt_ban_appeal_submit');
|
||||
fetch(ajaxUrl(), { method: 'POST', body: fd, credentials: 'same-origin' })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (data) {
|
||||
if (!data || data.error) {
|
||||
toast((data && data.msg) || '提交失败');
|
||||
return;
|
||||
}
|
||||
toast(data.msg || '提交成功');
|
||||
if (data.reload) window.setTimeout(function () { location.reload(); }, 400);
|
||||
})
|
||||
.catch(function () { toast('网络错误'); })
|
||||
.finally(function () { if (btn) btn.disabled = false; });
|
||||
});
|
||||
}
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init);
|
||||
else init();
|
||||
})();
|
||||
Reference in New Issue
Block a user