(fix):update user profile toast
This commit is contained in:
1 parent
b556384025
commit
e429b59077
7 files changed
+41
-48
No files matched your search
@@ -419,13 +419,6 @@
|
||||
background: none;
|
||||
border: none;
|
||||
}
|
||||
.profile-form__submit-msg {
|
||||
font-size: 14px;
|
||||
color: var(--color-ink-3);
|
||||
}
|
||||
.profile-form__submit-msg.is-error {
|
||||
color: var(--color-error);
|
||||
}
|
||||
.profile-add-contact {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
@@ -449,10 +449,6 @@
|
||||
color: var(--color-error);
|
||||
}
|
||||
|
||||
/* ---- 保存反馈 ---- */
|
||||
#profile-save-msg.success { color: var(--color-success); }
|
||||
#profile-save-msg.error { color: var(--color-error); }
|
||||
|
||||
/* ==================== 账号设置区 ==================== */
|
||||
.settings-section {
|
||||
margin-bottom: 20px;
|
||||
|
||||
@@ -261,43 +261,49 @@
|
||||
/* ==================== 个人信息保存 ==================== */
|
||||
|
||||
|
||||
function initProfileForm() {
|
||||
var form = document.getElementById('profile-form');
|
||||
function initProfileForm(root) {
|
||||
root = root || document;
|
||||
var form = root.id === 'profile-form' ? root : root.querySelector('#profile-form');
|
||||
if (!form) return;
|
||||
if (form.dataset.aksrtProfileInitialized === 'true') return;
|
||||
form.dataset.aksrtProfileInitialized = 'true';
|
||||
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
var btn = document.getElementById('profile-save-btn');
|
||||
var msg = document.getElementById('profile-save-msg');
|
||||
var btn = form.querySelector('#profile-save-btn');
|
||||
if (!btn || btn.disabled) return;
|
||||
btn.disabled = true;
|
||||
btn.textContent = i18n.saving || '保存中…';
|
||||
msg.className = 'profile-form__submit-msg';
|
||||
msg.textContent = '';
|
||||
notyf(i18n.saving || '正在保存资料…', 'load', '', 'aksrt-profile-save-toast');
|
||||
|
||||
var data = new FormData(form);
|
||||
data.append('user_id', String(userId));
|
||||
data.set('user_id', String(userId));
|
||||
|
||||
fetch(ajaxUrl, { method: 'POST', body: data })
|
||||
fetch(ajaxUrl, { method: 'POST', credentials: 'same-origin', body: data })
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(res) {
|
||||
btn.disabled = false;
|
||||
btn.textContent = i18n.saveBtn || '保存修改';
|
||||
if (res.success) {
|
||||
notyf(i18n.saved || '已保存');
|
||||
notyf((res.data && res.data.message) || i18n.saved || '保存成功!', 'success', 5, 'aksrt-profile-save-toast');
|
||||
} else {
|
||||
msg.className = 'profile-form__submit-msg is-error';
|
||||
msg.textContent = res.data.message || (i18n.saveFailed || '保存失败');
|
||||
notyf((res.data && res.data.message) || i18n.saveFailed || '保存失败', 'danger', 5, 'aksrt-profile-save-toast');
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
btn.disabled = false;
|
||||
btn.textContent = i18n.saveBtn || '保存修改';
|
||||
msg.className = 'profile-form__submit-msg is-error';
|
||||
msg.textContent = i18n.networkError || '网络错误,请重试';
|
||||
notyf(i18n.networkError || '网络错误,请重试', 'danger', 5, 'aksrt-profile-save-toast');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (window.AksrtFrontend && typeof window.AksrtFrontend.register === 'function') {
|
||||
window.AksrtFrontend.register('aksrt-profile-form', function(root) {
|
||||
initProfileForm(root);
|
||||
});
|
||||
}
|
||||
|
||||
function initAuthForm() {
|
||||
var root = document.querySelector('[data-identity-root]');
|
||||
if (root && window.AKSRTUserCenterAuth && typeof window.AKSRTUserCenterAuth.init === 'function') {
|
||||
|
||||
Reference in new issue
Block a user