fix: align bd center api endpoints

This commit is contained in:
170-carry 2026-04-29 00:07:14 +08:00
parent 5b640318ec
commit 4a955504b9
2 changed files with 29 additions and 45 deletions

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
<title>BD Center</title>
<link rel="stylesheet" href="./style.css?v=20260429-0100" />
<link rel="stylesheet" href="./style.css?v=20260429-0120" />
</head>
<body>
<div class="bd-center" aria-label="BD Center" data-i18n-aria="page_label" data-loading="true">
@ -126,6 +126,6 @@
<div class="toast" id="toast" role="status" aria-live="polite" hidden></div>
</div>
<script src="./script.js?v=20260429-0100" defer></script>
<script src="./script.js?v=20260429-0120" defer></script>
</body>
</html>

View File

@ -172,12 +172,25 @@
};
const params = readURLParams();
const bdCenterEndpoints = {
profile: "/team/member/profile",
teamEntry: "/team/entry",
identity: "/app/h5/identity",
balance: "/wallet/salary-account/balance?salaryType=BD_SALARY",
giftPermission: "/sys/bd/own-permission",
agencyBill: "/team/bd/member-bill/list?type=BD",
inviteList: "/team/bd/invite-message-own",
inviteSearch: (account) => `/user/user-profile/open-search?account=${encodeURIComponent(account)}`,
inviteAgent: "/team/bd/invite-agent",
inviteCancel: (id) => `/team/bd/invite-agent-cancel/${encodeURIComponent(id)}`
};
let currentLang = normalizeLanguage(params.get("lang"));
let currentMessages = fallbackMessages[currentLang] || fallbackMessages.en;
const state = {
profile: null,
identity: null,
teamEntry: null,
giftPermission: false,
balanceTotal: {},
bill: {},
agencyBill: null,
@ -584,9 +597,9 @@
function inviteConfig(mode = state.invite.mode) {
return {
titleKey: "invite_agent_title",
list: "/team/bd/invite-message-own",
invite: "/team/bd/invite-agent",
cancel: (id) => `/team/bd/invite-agent-cancel/${encodeURIComponent(id)}`
list: bdCenterEndpoints.inviteList,
invite: bdCenterEndpoints.inviteAgent,
cancel: bdCenterEndpoints.inviteCancel
};
}
@ -765,41 +778,7 @@
}
async function searchInviteProfile(query) {
let profile = null;
let firstError = null;
try {
profile = await requestJSON(`/user/user-profile/open-search?account=${encodeURIComponent(query)}`);
} catch (error) {
firstError = error;
}
if (!profile && /^\d+$/.test(query)) {
try {
profile = await requestJSON(`/user/user-profile?userId=${encodeURIComponent(query)}`);
firstError = null;
} catch (error) {
if (!firstError) firstError = error;
}
}
const primaryProfile = Array.isArray(profile) ? profile[0] : profile;
const normalizedProfile = inviteItemProfile(primaryProfile);
if (normalizedProfile && (!pickProfileName(normalizedProfile) || pickProfileName(normalizedProfile) === "-" || !pickSpecialAccount(normalizedProfile) || !normalizedProfile.userAvatar)) {
const userId = inviteProfileId(normalizedProfile) || (/^\d+$/.test(query) ? query : "");
if (userId) {
try {
const detail = await requestJSON(`/user/user-profile?userId=${encodeURIComponent(userId)}`);
const mergedProfile = { ...normalizedProfile, ...inviteItemProfile(detail) };
profile = Array.isArray(profile)
? [{ ...primaryProfile, userProfile: mergedProfile }, ...profile.slice(1)]
: (primaryProfile?.userProfile ? { ...primaryProfile, userProfile: mergedProfile } : mergedProfile);
} catch (error) {
console.debug("Invite search detail fallback skipped:", error);
}
}
}
if (!profile && firstError) throw firstError;
const profile = await requestJSON(bdCenterEndpoints.inviteSearch(query));
return Array.isArray(profile) ? profile : (profile ? [profile] : []);
}
@ -914,25 +893,29 @@
}
async function fetchProfile() {
state.profile = await requestJSON("/team/member/profile");
state.profile = await requestJSON(bdCenterEndpoints.profile);
renderProfile();
}
async function fetchIdentity() {
state.identity = await requestJSON("/app/h5/identity");
state.identity = await requestJSON(bdCenterEndpoints.identity);
}
async function fetchTeamEntry() {
state.teamEntry = await requestJSON("/team/entry");
state.teamEntry = await requestJSON(bdCenterEndpoints.teamEntry);
}
async function fetchGiftPermission() {
state.giftPermission = Boolean(await requestJSON(bdCenterEndpoints.giftPermission));
}
async function fetchBalanceTotal() {
state.balanceTotal = await requestJSON("/wallet/salary-account/balance?salaryType=BD_SALARY") || {};
state.balanceTotal = await requestJSON(bdCenterEndpoints.balance) || {};
renderBalance();
}
async function fetchAgencyBill() {
state.agencyBill = await requestJSON("/team/bd/member-bill/list?type=BD") || {};
state.agencyBill = await requestJSON(bdCenterEndpoints.agencyBill) || {};
renderBill();
renderTeamListCard();
}
@ -1093,6 +1076,7 @@
fetchProfile(),
fetchIdentity(),
fetchTeamEntry(),
fetchGiftPermission(),
fetchBalanceTotal(),
fetchAgencyBill()
];