From 4a955504b9fc0c1b83f34d94faf77ccdeabba5cf Mon Sep 17 00:00:00 2001 From: 170-carry Date: Wed, 29 Apr 2026 00:07:14 +0800 Subject: [PATCH] fix: align bd center api endpoints --- h5/hyapp/bd-center/index.html | 4 +- h5/hyapp/bd-center/script.js | 70 ++++++++++++++--------------------- 2 files changed, 29 insertions(+), 45 deletions(-) diff --git a/h5/hyapp/bd-center/index.html b/h5/hyapp/bd-center/index.html index e81ae30..f64f8c4 100644 --- a/h5/hyapp/bd-center/index.html +++ b/h5/hyapp/bd-center/index.html @@ -4,7 +4,7 @@ BD Center - +
@@ -126,6 +126,6 @@
- + diff --git a/h5/hyapp/bd-center/script.js b/h5/hyapp/bd-center/script.js index 196a76e..0f9be77 100644 --- a/h5/hyapp/bd-center/script.js +++ b/h5/hyapp/bd-center/script.js @@ -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() ];