fix: align bd center api endpoints
This commit is contained in:
parent
5b640318ec
commit
4a955504b9
@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<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" />
|
<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>
|
<title>BD Center</title>
|
||||||
<link rel="stylesheet" href="./style.css?v=20260429-0100" />
|
<link rel="stylesheet" href="./style.css?v=20260429-0120" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="bd-center" aria-label="BD Center" data-i18n-aria="page_label" data-loading="true">
|
<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 class="toast" id="toast" role="status" aria-live="polite" hidden></div>
|
||||||
</div>
|
</div>
|
||||||
<script src="./script.js?v=20260429-0100" defer></script>
|
<script src="./script.js?v=20260429-0120" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -172,12 +172,25 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const params = readURLParams();
|
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 currentLang = normalizeLanguage(params.get("lang"));
|
||||||
let currentMessages = fallbackMessages[currentLang] || fallbackMessages.en;
|
let currentMessages = fallbackMessages[currentLang] || fallbackMessages.en;
|
||||||
const state = {
|
const state = {
|
||||||
profile: null,
|
profile: null,
|
||||||
identity: null,
|
identity: null,
|
||||||
teamEntry: null,
|
teamEntry: null,
|
||||||
|
giftPermission: false,
|
||||||
balanceTotal: {},
|
balanceTotal: {},
|
||||||
bill: {},
|
bill: {},
|
||||||
agencyBill: null,
|
agencyBill: null,
|
||||||
@ -584,9 +597,9 @@
|
|||||||
function inviteConfig(mode = state.invite.mode) {
|
function inviteConfig(mode = state.invite.mode) {
|
||||||
return {
|
return {
|
||||||
titleKey: "invite_agent_title",
|
titleKey: "invite_agent_title",
|
||||||
list: "/team/bd/invite-message-own",
|
list: bdCenterEndpoints.inviteList,
|
||||||
invite: "/team/bd/invite-agent",
|
invite: bdCenterEndpoints.inviteAgent,
|
||||||
cancel: (id) => `/team/bd/invite-agent-cancel/${encodeURIComponent(id)}`
|
cancel: bdCenterEndpoints.inviteCancel
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,41 +778,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function searchInviteProfile(query) {
|
async function searchInviteProfile(query) {
|
||||||
let profile = null;
|
const profile = await requestJSON(bdCenterEndpoints.inviteSearch(query));
|
||||||
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;
|
|
||||||
return Array.isArray(profile) ? profile : (profile ? [profile] : []);
|
return Array.isArray(profile) ? profile : (profile ? [profile] : []);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,25 +893,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchProfile() {
|
async function fetchProfile() {
|
||||||
state.profile = await requestJSON("/team/member/profile");
|
state.profile = await requestJSON(bdCenterEndpoints.profile);
|
||||||
renderProfile();
|
renderProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchIdentity() {
|
async function fetchIdentity() {
|
||||||
state.identity = await requestJSON("/app/h5/identity");
|
state.identity = await requestJSON(bdCenterEndpoints.identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchTeamEntry() {
|
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() {
|
async function fetchBalanceTotal() {
|
||||||
state.balanceTotal = await requestJSON("/wallet/salary-account/balance?salaryType=BD_SALARY") || {};
|
state.balanceTotal = await requestJSON(bdCenterEndpoints.balance) || {};
|
||||||
renderBalance();
|
renderBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchAgencyBill() {
|
async function fetchAgencyBill() {
|
||||||
state.agencyBill = await requestJSON("/team/bd/member-bill/list?type=BD") || {};
|
state.agencyBill = await requestJSON(bdCenterEndpoints.agencyBill) || {};
|
||||||
renderBill();
|
renderBill();
|
||||||
renderTeamListCard();
|
renderTeamListCard();
|
||||||
}
|
}
|
||||||
@ -1093,6 +1076,7 @@
|
|||||||
fetchProfile(),
|
fetchProfile(),
|
||||||
fetchIdentity(),
|
fetchIdentity(),
|
||||||
fetchTeamEntry(),
|
fetchTeamEntry(),
|
||||||
|
fetchGiftPermission(),
|
||||||
fetchBalanceTotal(),
|
fetchBalanceTotal(),
|
||||||
fetchAgencyBill()
|
fetchAgencyBill()
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user