This commit is contained in:
zhx 2026-06-05 20:29:12 +08:00
parent da6d029a27
commit f2d0ae3ee9
3 changed files with 27 additions and 170 deletions

View File

@ -140,57 +140,9 @@
> >
<span class="chevron" aria-hidden="true"></span> <span class="chevron" aria-hidden="true"></span>
</button> </button>
<button
class="menu-row"
type="button"
data-action="invite-agent"
>
<span class="menu-icon" aria-hidden="true">
<svg viewBox="0 0 24 24">
<path d="M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z" />
<path
d="M2.5 21c.8-4.3 3.3-6.4 6.5-6.4 2 0 3.6.7 4.8 2"
/>
<path d="M17 11h6" />
<path d="M20 8v6" />
</svg>
</span>
<span
class="menu-label"
data-i18n="superadmin_center.invite_agent"
>Invite Agent</span
>
<span class="chevron" aria-hidden="true"></span>
</button>
</section> </section>
<section class="card team-card"> <section class="card team-card">
<div
class="team-tabs"
role="tablist"
aria-label="Team list"
>
<button
class="team-tab is-active"
type="button"
role="tab"
aria-selected="true"
data-team-tab="bd"
data-i18n="superadmin_center.bd_list"
>
BD List
</button>
<button
class="team-tab"
type="button"
role="tab"
aria-selected="false"
data-team-tab="agency"
data-i18n="superadmin_center.agency_list"
>
Agency List
</button>
</div>
<div class="team-summary" id="teamSummary"></div> <div class="team-summary" id="teamSummary"></div>
<div class="team-list" id="teamList"></div> <div class="team-list" id="teamList"></div>
</section> </section>

View File

@ -1,8 +1,6 @@
(function () { (function () {
var query = new URLSearchParams(window.location.search); var query = new URLSearchParams(window.location.search);
var state = { var state = {
activeTab: 'bd',
inviteMode: 'bd',
inviteQuery: '', inviteQuery: '',
inviteStatus: '', inviteStatus: '',
inviteStatusType: '', inviteStatusType: '',
@ -350,7 +348,6 @@
data.balance = mock.balance; data.balance = mock.balance;
data.overview = mock.overview; data.overview = mock.overview;
data.bdList = mock.bdList; data.bdList = mock.bdList;
data.agencyList = mock.agencyList;
data.history = mock.history; data.history = mock.history;
data.inviteRecords = mock.inviteRecords; data.inviteRecords = mock.inviteRecords;
} }
@ -366,9 +363,8 @@
teamRecharge: 0, teamRecharge: 0,
}; };
data.bdList = []; data.bdList = [];
data.agencyList = [];
data.history = []; data.history = [];
data.inviteRecords = { bd: [], agent: [] }; data.inviteRecords = { bd: [] };
} }
function normalizeOverview(payload) { function normalizeOverview(payload) {
@ -468,20 +464,15 @@
return Promise.all([ return Promise.all([
centerAPI.overview(), centerAPI.overview(),
centerAPI.bds(50), centerAPI.bds(50),
centerAPI.agencies(50),
]) ])
.then(function (results) { .then(function (results) {
var overviewPayload = results[0] || {}; var overviewPayload = results[0] || {};
var bdPayload = results[1] || {}; var bdPayload = results[1] || {};
var agencyPayload = results[2] || {};
var profile = overviewPayload.profile || {}; var profile = overviewPayload.profile || {};
var overview = normalizeOverview(overviewPayload); var overview = normalizeOverview(overviewPayload);
var agencies = (agencyPayload.items || []).map(
normalizeAgencyItem
);
var bds = (bdPayload.items || []).map(normalizeBDItem); var bds = (bdPayload.items || []).map(normalizeBDItem);
if (!overview.totalHosts) { if (!overview.totalHosts) {
overview.totalHosts = agencies.reduce(function (sum, item) { overview.totalHosts = bds.reduce(function (sum, item) {
return sum + Number(item.hosts || 0); return sum + Number(item.hosts || 0);
}, 0); }, 0);
} }
@ -496,7 +487,6 @@
}; };
data.overview = overview; data.overview = overview;
data.bdList = bds; data.bdList = bds;
data.agencyList = agencies;
data.history = [ data.history = [
{ {
month: new Date().toISOString().slice(0, 7), month: new Date().toISOString().slice(0, 7),
@ -507,7 +497,7 @@
totalRecharge: overview.teamRecharge, totalRecharge: overview.teamRecharge,
}, },
]; ];
data.inviteRecords = { bd: [], agent: [] }; data.inviteRecords = { bd: [] };
render(); render();
}) })
.catch(function (error) { .catch(function (error) {
@ -546,40 +536,21 @@
} }
function activeItems() { function activeItems() {
return state.activeTab === 'agency' ? data.agencyList : data.bdList; return data.bdList;
} }
function renderTeamSummary() { function renderTeamSummary() {
$('teamSummary').classList.toggle( $('teamSummary').classList.add('is-two');
'is-two', var cells = [
state.activeTab !== 'agency' summaryCell(
); t('superadmin_center.bd_number', 'BD number'),
var cells = count(data.overview.totalBD)
state.activeTab === 'agency' ),
? [ summaryCell(
summaryCell( t('superadmin_center.agencies', 'Agencies'),
t('superadmin_center.agency_number', 'Agency number'), count(data.overview.totalAgency)
count(data.overview.totalAgency) ),
), ];
summaryCell(
t('superadmin_center.hosts', 'Hosts'),
count(data.overview.totalHosts)
),
summaryCell(
t('superadmin_center.team_salary', 'Team salary'),
'$' + compactMoney(data.overview.teamSalary)
),
]
: [
summaryCell(
t('superadmin_center.bd_number', 'BD number'),
count(data.overview.totalBD)
),
summaryCell(
t('superadmin_center.agencies', 'Agencies'),
count(data.overview.totalAgency)
),
];
replaceChildren($('teamSummary'), cells); replaceChildren($('teamSummary'), cells);
} }
@ -599,13 +570,9 @@
var subText = var subText =
item.sideSub !== undefined item.sideSub !== undefined
? item.sideSub ? item.sideSub
: state.activeTab === 'agency' : count(item.agencies) +
? count(item.hosts) + ' ' +
' ' + t('superadmin_center.agencies', 'Agencies');
t('superadmin_center.hosts', 'Hosts')
: count(item.agencies) +
' ' +
t('superadmin_center.agencies', 'Agencies');
row.className = 'member-row'; row.className = 'member-row';
main.className = 'member-main'; main.className = 'member-main';
@ -614,10 +581,7 @@
side.className = 'member-side'; side.className = 'member-side';
name.textContent = item.name; name.textContent = item.name;
meta.textContent = meta.textContent = 'ID: ' + item.id;
state.activeTab === 'agency'
? 'ID: ' + item.id + ' · BD: ' + item.bdId
: 'ID: ' + item.id;
salary.textContent = sideValue || subText; salary.textContent = sideValue || subText;
sub.textContent = sideValue ? subText : ''; sub.textContent = sideValue ? subText : '';
@ -637,12 +601,6 @@
} }
function renderTeamList() { function renderTeamList() {
document.querySelectorAll('[data-team-tab]').forEach(function (button) {
var active =
button.getAttribute('data-team-tab') === state.activeTab;
button.classList.toggle('is-active', active);
button.setAttribute('aria-selected', String(active));
});
renderTeamSummary(); renderTeamSummary();
replaceChildren( replaceChildren(
$('teamList'), $('teamList'),
@ -717,21 +675,11 @@
) )
); );
} }
if (item.recharge !== null && item.recharge !== undefined) {
summaryRows.push(
summaryCell(
t('superadmin_center.team_recharge', 'Team recharge'),
'$' + money(item.recharge)
)
);
}
replaceChildren($('detailsSummary'), summaryRows); replaceChildren($('detailsSummary'), summaryRows);
replaceChildren($('detailsList'), [ replaceChildren($('detailsList'), [
createReadonlyLine( createReadonlyLine(
state.activeTab === 'agency' t('superadmin_center.agencies', 'Agencies'),
? t('superadmin_center.hosts', 'Hosts') count(item.agencies)
: t('superadmin_center.agencies', 'Agencies'),
count(state.activeTab === 'agency' ? item.hosts : item.agencies)
), ),
]); ]);
} }
@ -749,16 +697,14 @@
} }
function inviteTitle() { function inviteTitle() {
return state.inviteMode === 'agent' return t('superadmin_center.invite_bd', 'Invite BD');
? t('superadmin_center.invite_agent', 'Invite Agent')
: t('superadmin_center.invite_bd', 'Invite BD');
} }
function inviteRecords() { function inviteRecords() {
if (!state.inviteQuery) return data.inviteRecords[state.inviteMode] || []; if (!state.inviteQuery) return data.inviteRecords.bd || [];
if (!state.isMock) return state.inviteSearchResults; if (!state.isMock) return state.inviteSearchResults;
var keyword = state.inviteQuery.toLowerCase(); var keyword = state.inviteQuery.toLowerCase();
return mock.searchPool[state.inviteMode].filter(function (item) { return mock.searchPool.bd.filter(function (item) {
return ( return (
item.name.toLowerCase().indexOf(keyword) >= 0 || item.name.toLowerCase().indexOf(keyword) >= 0 ||
item.account.indexOf(keyword) >= 0 || item.account.indexOf(keyword) >= 0 ||
@ -872,17 +818,10 @@
state.inviteSubmitting[targetUserID] = true; state.inviteSubmitting[targetUserID] = true;
renderInvite(); renderInvite();
var payload = { var payload = {
command_id: commandID(state.inviteMode, targetUserID), command_id: commandID('bd', targetUserID),
target_user_id: targetUserID, target_user_id: targetUserID,
}; };
var request = var request = centerAPI.inviteBD(payload);
state.inviteMode === 'agent'
? centerAPI.inviteAgency(
Object.assign({}, payload, {
agency_name: profile.name,
})
)
: centerAPI.inviteBD(payload);
request request
.then(function () { .then(function () {
record.status = 'Success'; record.status = 'Success';
@ -952,9 +891,7 @@
openModal('historyModal'); openModal('historyModal');
return; return;
} }
if (action === 'invite-bd' || action === 'invite-agent') { if (action === 'invite-bd') {
state.inviteMode =
action === 'invite-agent' ? 'agent' : 'bd';
state.inviteQuery = ''; state.inviteQuery = '';
state.inviteStatus = ''; state.inviteStatus = '';
state.inviteStatusType = ''; state.inviteStatusType = '';
@ -965,12 +902,6 @@
} }
}); });
}); });
document.querySelectorAll('[data-team-tab]').forEach(function (button) {
button.addEventListener('click', function () {
state.activeTab = button.getAttribute('data-team-tab') || 'bd';
renderTeamList();
});
});
document document
.querySelectorAll('[data-close-modal]') .querySelectorAll('[data-close-modal]')
.forEach(function (node) { .forEach(function (node) {

View File

@ -126,32 +126,6 @@
gap: 12px; gap: 12px;
} }
.team-tabs {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 6px;
padding: 6px;
border-radius: 8px;
background: var(--hy-theme-primary-soft, #f4ebff);
}
.team-tab {
display: flex;
align-items: center;
justify-content: center;
min-height: 42px;
border-radius: 7px;
color: var(--muted);
font-size: 15px;
font-weight: 900;
}
.team-tab.is-active {
background: #fff;
color: var(--text);
box-shadow: 0 8px 18px rgba(98, 72, 155, 0.08);
}
.team-summary, .team-summary,
.history-summary { .history-summary {
display: grid; display: grid;