h5相关
This commit is contained in:
parent
da6d029a27
commit
f2d0ae3ee9
@ -140,57 +140,9 @@
|
||||
>
|
||||
<span class="chevron" aria-hidden="true">›</span>
|
||||
</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 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-list" id="teamList"></div>
|
||||
</section>
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
(function () {
|
||||
var query = new URLSearchParams(window.location.search);
|
||||
var state = {
|
||||
activeTab: 'bd',
|
||||
inviteMode: 'bd',
|
||||
inviteQuery: '',
|
||||
inviteStatus: '',
|
||||
inviteStatusType: '',
|
||||
@ -350,7 +348,6 @@
|
||||
data.balance = mock.balance;
|
||||
data.overview = mock.overview;
|
||||
data.bdList = mock.bdList;
|
||||
data.agencyList = mock.agencyList;
|
||||
data.history = mock.history;
|
||||
data.inviteRecords = mock.inviteRecords;
|
||||
}
|
||||
@ -366,9 +363,8 @@
|
||||
teamRecharge: 0,
|
||||
};
|
||||
data.bdList = [];
|
||||
data.agencyList = [];
|
||||
data.history = [];
|
||||
data.inviteRecords = { bd: [], agent: [] };
|
||||
data.inviteRecords = { bd: [] };
|
||||
}
|
||||
|
||||
function normalizeOverview(payload) {
|
||||
@ -468,20 +464,15 @@
|
||||
return Promise.all([
|
||||
centerAPI.overview(),
|
||||
centerAPI.bds(50),
|
||||
centerAPI.agencies(50),
|
||||
])
|
||||
.then(function (results) {
|
||||
var overviewPayload = results[0] || {};
|
||||
var bdPayload = results[1] || {};
|
||||
var agencyPayload = results[2] || {};
|
||||
var profile = overviewPayload.profile || {};
|
||||
var overview = normalizeOverview(overviewPayload);
|
||||
var agencies = (agencyPayload.items || []).map(
|
||||
normalizeAgencyItem
|
||||
);
|
||||
var bds = (bdPayload.items || []).map(normalizeBDItem);
|
||||
if (!overview.totalHosts) {
|
||||
overview.totalHosts = agencies.reduce(function (sum, item) {
|
||||
overview.totalHosts = bds.reduce(function (sum, item) {
|
||||
return sum + Number(item.hosts || 0);
|
||||
}, 0);
|
||||
}
|
||||
@ -496,7 +487,6 @@
|
||||
};
|
||||
data.overview = overview;
|
||||
data.bdList = bds;
|
||||
data.agencyList = agencies;
|
||||
data.history = [
|
||||
{
|
||||
month: new Date().toISOString().slice(0, 7),
|
||||
@ -507,7 +497,7 @@
|
||||
totalRecharge: overview.teamRecharge,
|
||||
},
|
||||
];
|
||||
data.inviteRecords = { bd: [], agent: [] };
|
||||
data.inviteRecords = { bd: [] };
|
||||
render();
|
||||
})
|
||||
.catch(function (error) {
|
||||
@ -546,40 +536,21 @@
|
||||
}
|
||||
|
||||
function activeItems() {
|
||||
return state.activeTab === 'agency' ? data.agencyList : data.bdList;
|
||||
return data.bdList;
|
||||
}
|
||||
|
||||
function renderTeamSummary() {
|
||||
$('teamSummary').classList.toggle(
|
||||
'is-two',
|
||||
state.activeTab !== 'agency'
|
||||
);
|
||||
var cells =
|
||||
state.activeTab === 'agency'
|
||||
? [
|
||||
summaryCell(
|
||||
t('superadmin_center.agency_number', 'Agency number'),
|
||||
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)
|
||||
),
|
||||
];
|
||||
$('teamSummary').classList.add('is-two');
|
||||
var cells = [
|
||||
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);
|
||||
}
|
||||
|
||||
@ -599,13 +570,9 @@
|
||||
var subText =
|
||||
item.sideSub !== undefined
|
||||
? item.sideSub
|
||||
: state.activeTab === 'agency'
|
||||
? count(item.hosts) +
|
||||
' ' +
|
||||
t('superadmin_center.hosts', 'Hosts')
|
||||
: count(item.agencies) +
|
||||
' ' +
|
||||
t('superadmin_center.agencies', 'Agencies');
|
||||
: count(item.agencies) +
|
||||
' ' +
|
||||
t('superadmin_center.agencies', 'Agencies');
|
||||
|
||||
row.className = 'member-row';
|
||||
main.className = 'member-main';
|
||||
@ -614,10 +581,7 @@
|
||||
side.className = 'member-side';
|
||||
|
||||
name.textContent = item.name;
|
||||
meta.textContent =
|
||||
state.activeTab === 'agency'
|
||||
? 'ID: ' + item.id + ' · BD: ' + item.bdId
|
||||
: 'ID: ' + item.id;
|
||||
meta.textContent = 'ID: ' + item.id;
|
||||
salary.textContent = sideValue || subText;
|
||||
sub.textContent = sideValue ? subText : '';
|
||||
|
||||
@ -637,12 +601,6 @@
|
||||
}
|
||||
|
||||
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();
|
||||
replaceChildren(
|
||||
$('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($('detailsList'), [
|
||||
createReadonlyLine(
|
||||
state.activeTab === 'agency'
|
||||
? t('superadmin_center.hosts', 'Hosts')
|
||||
: t('superadmin_center.agencies', 'Agencies'),
|
||||
count(state.activeTab === 'agency' ? item.hosts : item.agencies)
|
||||
t('superadmin_center.agencies', 'Agencies'),
|
||||
count(item.agencies)
|
||||
),
|
||||
]);
|
||||
}
|
||||
@ -749,16 +697,14 @@
|
||||
}
|
||||
|
||||
function inviteTitle() {
|
||||
return state.inviteMode === 'agent'
|
||||
? t('superadmin_center.invite_agent', 'Invite Agent')
|
||||
: t('superadmin_center.invite_bd', 'Invite BD');
|
||||
return t('superadmin_center.invite_bd', 'Invite BD');
|
||||
}
|
||||
|
||||
function inviteRecords() {
|
||||
if (!state.inviteQuery) return data.inviteRecords[state.inviteMode] || [];
|
||||
if (!state.inviteQuery) return data.inviteRecords.bd || [];
|
||||
if (!state.isMock) return state.inviteSearchResults;
|
||||
var keyword = state.inviteQuery.toLowerCase();
|
||||
return mock.searchPool[state.inviteMode].filter(function (item) {
|
||||
return mock.searchPool.bd.filter(function (item) {
|
||||
return (
|
||||
item.name.toLowerCase().indexOf(keyword) >= 0 ||
|
||||
item.account.indexOf(keyword) >= 0 ||
|
||||
@ -872,17 +818,10 @@
|
||||
state.inviteSubmitting[targetUserID] = true;
|
||||
renderInvite();
|
||||
var payload = {
|
||||
command_id: commandID(state.inviteMode, targetUserID),
|
||||
command_id: commandID('bd', targetUserID),
|
||||
target_user_id: targetUserID,
|
||||
};
|
||||
var request =
|
||||
state.inviteMode === 'agent'
|
||||
? centerAPI.inviteAgency(
|
||||
Object.assign({}, payload, {
|
||||
agency_name: profile.name,
|
||||
})
|
||||
)
|
||||
: centerAPI.inviteBD(payload);
|
||||
var request = centerAPI.inviteBD(payload);
|
||||
request
|
||||
.then(function () {
|
||||
record.status = 'Success';
|
||||
@ -952,9 +891,7 @@
|
||||
openModal('historyModal');
|
||||
return;
|
||||
}
|
||||
if (action === 'invite-bd' || action === 'invite-agent') {
|
||||
state.inviteMode =
|
||||
action === 'invite-agent' ? 'agent' : 'bd';
|
||||
if (action === 'invite-bd') {
|
||||
state.inviteQuery = '';
|
||||
state.inviteStatus = '';
|
||||
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
|
||||
.querySelectorAll('[data-close-modal]')
|
||||
.forEach(function (node) {
|
||||
|
||||
@ -126,32 +126,6 @@
|
||||
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,
|
||||
.history-summary {
|
||||
display: grid;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user