feat: unify invite flow with referral ref

This commit is contained in:
kate522 committed 2026-08-17 13:49:59 +08:00
1 parent f1d6809109
commit b501cf4611
47 files changed
+1083 -2548

No files matched your search

+2
View File
@@ -283,6 +283,7 @@
if (result.data.verification_required) {
var verifyMessage = result.data.message || '注册成功,请完成邮箱验证';
if (result.data.notice) verifyMessage += '<br>' + escapeAttribute(result.data.notice);
if (result.data.verify_url) {
verifyMessage += ' <a href="' + escapeAttribute(result.data.verify_url) + '">前往验证</a>';
}
@@ -293,6 +294,7 @@
}
var loginMessage = result.data.message || '注册成功,请登录';
if (result.data.notice) loginMessage += ' ' + result.data.notice;
switchTab('login');
prefillLogin(result.data.user_login || result.data.user_email || '');
showMessage('login', loginMessage, 'success');
+4 -3
View File
@@ -184,7 +184,7 @@
const code = form.querySelector('[name="code"]')?.value?.trim()
const password = form.querySelector('[name="password"]')?.value
const confirm = form.querySelector('[name="password_confirm"]')?.value
const inviteCode = form.querySelector('[name="invite_code"]')?.value?.trim()
const ref = form.querySelector('[name="ref"]')?.value?.trim()
if (!phone || !code || !password) {
showToast('请填写完整信息', 'warning')
@@ -211,14 +211,15 @@
fetch(REST_BASE + '/auth/phone-register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ phone, code, password, invite_code: inviteCode, ...captchaData }),
body: JSON.stringify({ phone, code, password, ref, ...captchaData }),
})
.then(r => r.json().then(data => ({ ok: r.ok, data })))
.then(({ ok, data }) => {
if (ok && data.success) {
showToast(data.message || '注册成功', 'success')
if (data.notice) showToast(data.notice, 'warning')
setTimeout(() => {
window.location.href = data.data?.redirect || '/'
window.location.href = data.redirect || '/'
}, 500)
} else {
showToast(data.message || '注册失败', 'error')