修改完成
This commit is contained in:
@@ -44,7 +44,6 @@ const ApiClient = {
|
||||
referralSummary: '/api/web/referral/summary',
|
||||
referralInviteList: '/api/web/referral/invite-list',
|
||||
referralRebateList: '/api/web/referral/rebate-list',
|
||||
referralBindPreview: '/api/web/referral/bind-preview',
|
||||
referralBind: '/api/web/referral/bind',
|
||||
accountInfo: '/api/web/account/info',
|
||||
accountProfile: '/api/web/account/profile',
|
||||
@@ -610,7 +609,6 @@ const ApiClient = {
|
||||
'/api/web/rebate/withdraw': { url: '/api/web/wallet/withdraw', method: 'POST', data },
|
||||
'/api/web/rebate/rebateToBalance': { url: '/api/web/wallet/transfer-to-account', method: 'POST', data },
|
||||
'/api/web/distribution/getPageList': { url: '/api/web/referral/invite-list', method: 'GET', data: pageParams },
|
||||
'/api/web/user/applyDistribution': { url: '/api/web/referral/bind', method: 'POST', data },
|
||||
'/api/web/user/applyExpert': { url: '/api/web/expert/apply', method: 'POST', data },
|
||||
'/api/web/user/expert/apply': { url: '/api/web/expert/apply', method: 'POST', data },
|
||||
'/api/web/user/updateInfo': { url: '/api/web/account/profile', method: 'PUT', data },
|
||||
|
||||
+2
-79
@@ -4,14 +4,6 @@ const AuthPageUtil = {
|
||||
slideX: 0,
|
||||
slideToken: '',
|
||||
slideCaptchaViewportCleanup: null,
|
||||
referralInviteSessionKey: 'pendingReferralInviteCode',
|
||||
|
||||
getSessionStorage() {
|
||||
if (typeof sessionStorage !== 'undefined') return sessionStorage;
|
||||
if (typeof window !== 'undefined' && window.sessionStorage) return window.sessionStorage;
|
||||
return null;
|
||||
},
|
||||
|
||||
normalizeReferralInviteCode(inviteCode) {
|
||||
return String(inviteCode || '').trim();
|
||||
},
|
||||
@@ -31,82 +23,13 @@ const AuthPageUtil = {
|
||||
try {
|
||||
const params = new Params(query || '');
|
||||
return this.normalizeReferralInviteCode(
|
||||
params.get('inviteCode') || params.get('referralCode') || '',
|
||||
params.get('inviteCode') || '',
|
||||
);
|
||||
} catch (error) {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
setPendingReferralInviteCode(inviteCode) {
|
||||
const code = this.normalizeReferralInviteCode(inviteCode);
|
||||
const storage = this.getSessionStorage();
|
||||
|
||||
if (code && storage) {
|
||||
storage.setItem(this.referralInviteSessionKey, code);
|
||||
}
|
||||
|
||||
return code;
|
||||
},
|
||||
|
||||
getPendingReferralInviteCode() {
|
||||
const storage = this.getSessionStorage();
|
||||
if (!storage) return '';
|
||||
return this.normalizeReferralInviteCode(storage.getItem(this.referralInviteSessionKey));
|
||||
},
|
||||
|
||||
clearPendingReferralInviteCode() {
|
||||
const storage = this.getSessionStorage();
|
||||
if (storage) storage.removeItem(this.referralInviteSessionKey);
|
||||
},
|
||||
|
||||
captureReferralInviteFromUrl(search) {
|
||||
const code = this.getReferralInviteCodeFromUrl(search);
|
||||
|
||||
if (code) {
|
||||
this.setPendingReferralInviteCode(code);
|
||||
}
|
||||
|
||||
return code;
|
||||
},
|
||||
|
||||
bindPendingReferralInviteCode() {
|
||||
const inviteCode = this.getPendingReferralInviteCode();
|
||||
|
||||
if (!inviteCode) {
|
||||
return Promise.resolve({ skipped: true, reason: 'empty' });
|
||||
}
|
||||
|
||||
if (
|
||||
typeof ApiClient === 'undefined' ||
|
||||
!ApiClient.API ||
|
||||
!ApiClient.API.referralBind ||
|
||||
typeof ApiClient.post !== 'function'
|
||||
) {
|
||||
return Promise.resolve({ skipped: true, reason: 'missing-api' });
|
||||
}
|
||||
|
||||
if (typeof ApiClient.token === 'function' && !ApiClient.token()) {
|
||||
return Promise.resolve({ skipped: true, reason: 'unauthenticated' });
|
||||
}
|
||||
|
||||
return ApiClient.post(ApiClient.API.referralBind, { inviteCode })
|
||||
.then((res) => {
|
||||
const isSuccess =
|
||||
typeof ApiClient.isSuccess === 'function'
|
||||
? ApiClient.isSuccess(res)
|
||||
: !!(res && (res.success === true || Number(res.code) === 0 || Number(res.code) === 200));
|
||||
|
||||
if (isSuccess) {
|
||||
this.clearPendingReferralInviteCode();
|
||||
return { skipped: false, success: true, res };
|
||||
}
|
||||
|
||||
return { skipped: false, success: false, res };
|
||||
})
|
||||
.catch((error) => ({ skipped: false, success: false, error }));
|
||||
},
|
||||
|
||||
isPhone(phone) {
|
||||
return /^1[3-9]\d{9}$/.test(String(phone || '').trim());
|
||||
},
|
||||
@@ -133,7 +56,7 @@ const AuthPageUtil = {
|
||||
}
|
||||
return 'captcha';
|
||||
})
|
||||
.catch(() => 'captcha');
|
||||
.catch(() => 'slide');
|
||||
},
|
||||
|
||||
buildSmsParams(options = {}) {
|
||||
|
||||
Reference in New Issue
Block a user