diff --git a/h5/hyapp/host-center/index.html b/h5/hyapp/host-center/index.html index 4e1e0c5..0b4a8d3 100644 --- a/h5/hyapp/host-center/index.html +++ b/h5/hyapp/host-center/index.html @@ -4,7 +4,7 @@ Stream Center - +
@@ -59,9 +59,9 @@
-
Target
-
@@ -102,8 +102,23 @@ + + - + diff --git a/h5/hyapp/host-center/locales/ar.json b/h5/hyapp/host-center/locales/ar.json index bbdc8e4..9a5e86d 100644 --- a/h5/hyapp/host-center/locales/ar.json +++ b/h5/hyapp/host-center/locales/ar.json @@ -7,7 +7,13 @@ "uid": "معرّف المستخدم: 1234567890", "agency": "الوكالة: Bilibili(101013)", "streaming_duration": "مدة البث
(بالدقائق)", - "target": "الهدف", + "current": "الحالي", + "daily_details": "البيانات اليومية", + "gift_points": "نقاط الهدايا", + "online_minutes": "دقائق الاتصال", + "no_daily_data": "لا توجد بيانات يومية", + "close": "إغلاق", + "open_daily_data": "فتح البيانات اليومية", "my_income": "دخلي", "withdraw_exchange": "سحب/استبدال", "open_withdraw_exchange": "فتح صفحة السحب والاستبدال", diff --git a/h5/hyapp/host-center/locales/en.json b/h5/hyapp/host-center/locales/en.json index dcf8e4d..391f58d 100644 --- a/h5/hyapp/host-center/locales/en.json +++ b/h5/hyapp/host-center/locales/en.json @@ -7,7 +7,13 @@ "uid": "UID: 1234567890", "agency": "Agency: Bilibili(101013)", "streaming_duration": "Streaming Duration
(Minutes)", - "target": "Target", + "current": "Current", + "daily_details": "Daily data", + "gift_points": "Gift points", + "online_minutes": "Online minutes", + "no_daily_data": "No daily data", + "close": "Close", + "open_daily_data": "Open daily data", "my_income": "My Income", "withdraw_exchange": "Withdraw/Exchange", "open_withdraw_exchange": "Open withdraw and exchange page", diff --git a/h5/hyapp/host-center/locales/id.json b/h5/hyapp/host-center/locales/id.json index 15e2fa3..ede4e41 100644 --- a/h5/hyapp/host-center/locales/id.json +++ b/h5/hyapp/host-center/locales/id.json @@ -7,7 +7,13 @@ "uid": "UID: 1234567890", "agency": "Agensi: Bilibili(101013)", "streaming_duration": "Durasi Streaming
(Menit)", - "target": "Target", + "current": "Saat ini", + "daily_details": "Data harian", + "gift_points": "Poin hadiah", + "online_minutes": "Menit online", + "no_daily_data": "Tidak ada data harian", + "close": "Tutup", + "open_daily_data": "Buka data harian", "my_income": "Penghasilan Saya", "withdraw_exchange": "Tarik/Tukar", "open_withdraw_exchange": "Buka halaman tarik dan tukar", diff --git a/h5/hyapp/host-center/locales/tr.json b/h5/hyapp/host-center/locales/tr.json index 1413d68..df78452 100644 --- a/h5/hyapp/host-center/locales/tr.json +++ b/h5/hyapp/host-center/locales/tr.json @@ -7,7 +7,13 @@ "uid": "UID: 1234567890", "agency": "Ajans: Bilibili(101013)", "streaming_duration": "Yayın Süresi
(Dakika)", - "target": "Hedef", + "current": "Mevcut", + "daily_details": "Günlük veri", + "gift_points": "Hediye puanı", + "online_minutes": "Online dakika", + "no_daily_data": "Günlük veri yok", + "close": "Kapat", + "open_daily_data": "Günlük veriyi aç", "my_income": "Gelirim", "withdraw_exchange": "Çek/Değiştir", "open_withdraw_exchange": "Çekme ve değişim sayfasını aç", diff --git a/h5/hyapp/host-center/original-vue-logic.md b/h5/hyapp/host-center/original-vue-logic.md index 984864f..b300110 100644 --- a/h5/hyapp/host-center/original-vue-logic.md +++ b/h5/hyapp/host-center/original-vue-logic.md @@ -92,6 +92,8 @@ - `historySalary` 写入本地变量 - 读取 `targets[0]` - 当前 `hyapp/host-center` 的 Streaming Duration 使用 `targets[0].target.onlineTime` 作为总直播时长 + - 当前 `hyapp/host-center` 的 Current 使用 `targets[0].target.acceptGiftValue` 作为当前礼物积分 + - Current 点击明细使用 `targets[0].target.dailyTargets[]`,展示每日 `dateNumber`、`acceptGiftValue`、`onlineTime` - 结算状态映射: - `SETTLED` -> `Completed` - `UNPAID` -> `In Progress` @@ -255,6 +257,8 @@ - `historySalary` - `targets` - `targets[0].target.onlineTime`,当前 `hyapp/host-center` 用作 Streaming Duration 总时长 + - `targets[0].target.acceptGiftValue`,当前 `hyapp/host-center` 用作 Current 礼物积分 + - `targets[0].target.dailyTargets[]`,当前 `hyapp/host-center` 用作每日明细 - `targets[].status` - `targets[].target.settlementResult.level` - `targets[].target.level` diff --git a/h5/hyapp/host-center/script.js b/h5/hyapp/host-center/script.js index 5336660..bdbe9c8 100644 --- a/h5/hyapp/host-center/script.js +++ b/h5/hyapp/host-center/script.js @@ -18,7 +18,13 @@ uid: "UID: 1234567890", agency: "Agency: Bilibili(101013)", streaming_duration: "Streaming Duration
(Minutes)", - target: "Target", + current: "Current", + daily_details: "Daily data", + gift_points: "Gift points", + online_minutes: "Online minutes", + no_daily_data: "No daily data", + close: "Close", + open_daily_data: "Open daily data", my_income: "My Income", withdraw_exchange: "Withdraw/Exchange", open_withdraw_exchange: "Open withdraw and exchange page", @@ -45,7 +51,13 @@ uid: "معرّف المستخدم: 1234567890", agency: "الوكالة: Bilibili(101013)", streaming_duration: "مدة البث
(بالدقائق)", - target: "الهدف", + current: "الحالي", + daily_details: "البيانات اليومية", + gift_points: "نقاط الهدايا", + online_minutes: "دقائق الاتصال", + no_daily_data: "لا توجد بيانات يومية", + close: "إغلاق", + open_daily_data: "فتح البيانات اليومية", my_income: "دخلي", withdraw_exchange: "سحب/استبدال", open_withdraw_exchange: "فتح صفحة السحب والاستبدال", @@ -72,7 +84,13 @@ uid: "UID: 1234567890", agency: "Ajans: Bilibili(101013)", streaming_duration: "Yayın Süresi
(Dakika)", - target: "Hedef", + current: "Mevcut", + daily_details: "Günlük veri", + gift_points: "Hediye puanı", + online_minutes: "Online dakika", + no_daily_data: "Günlük veri yok", + close: "Kapat", + open_daily_data: "Günlük veriyi aç", my_income: "Gelirim", withdraw_exchange: "Çek/Değiştir", open_withdraw_exchange: "Çekme ve değişim sayfasını aç", @@ -99,7 +117,13 @@ uid: "UID: 1234567890", agency: "Agensi: Bilibili(101013)", streaming_duration: "Durasi Streaming
(Menit)", - target: "Target", + current: "Saat ini", + daily_details: "Data harian", + gift_points: "Poin hadiah", + online_minutes: "Menit online", + no_daily_data: "Tidak ada data harian", + close: "Tutup", + open_daily_data: "Buka data harian", my_income: "Penghasilan Saya", withdraw_exchange: "Tarik/Tukar", open_withdraw_exchange: "Buka halaman tarik dan tukar", @@ -128,7 +152,8 @@ let currentIdentity = null; let currentSalary = "0.00"; let currentStreamingDuration = "0"; - let nextTargetValue = "-"; + let currentGiftValue = "0"; + let currentDailyTargets = []; function readURLParams() { const result = new URLSearchParams(window.location.search); @@ -177,7 +202,7 @@ if (window.location.protocol === "file:") return fallbackMessages[normalizedLang]; try { - const response = await fetch(`./locales/${normalizedLang}.json`, { cache: "no-store" }); + const response = await fetch(`./locales/${normalizedLang}.json?v=20260428-1610`, { cache: "no-store" }); if (response.ok) return await response.json(); } catch (error) { return fallbackMessages[normalizedLang]; @@ -434,17 +459,20 @@ if (durationNode) durationNode.textContent = currentStreamingDuration; } - function formatTargetValue(value) { + function formatCountValue(value) { if (value === null || value === undefined || value === "") return "-"; const number = Number(value); if (Number.isFinite(number) && Number.isInteger(number)) return String(number); + if (Number.isFinite(number)) return String(Number(number.toFixed(2))); return String(value); } - function renderNextTargetValue(value) { - nextTargetValue = formatTargetValue(value); - const targetNode = document.querySelector("#nextTargetValue"); - if (targetNode) targetNode.textContent = nextTargetValue; + function renderCurrentGiftValue(value) { + currentGiftValue = formatCountValue(value === null || value === undefined || value === "" ? 0 : value); + const giftNode = document.querySelector("#currentGiftValue"); + const dailyGiftNode = document.querySelector("#dailyCurrentGift"); + if (giftNode) giftNode.textContent = currentGiftValue; + if (dailyGiftNode) dailyGiftNode.textContent = currentGiftValue; } function pickFirstMemberWorkTarget(body) { @@ -457,33 +485,79 @@ return target.acceptGiftValue ?? target.giftValue ?? target.giftScore ?? target.currentGiftValue ?? null; } - function pickDirectNextTargetValue(workTarget) { + function pickDailyTargets(workTarget) { const target = workTarget?.target || workTarget || {}; - return target.nextTarget ?? target.nextLevelTarget ?? target.nextTargetValue ?? workTarget?.nextTarget ?? null; + return Array.isArray(target.dailyTargets) ? target.dailyTargets : []; } - function pickPolicyRows(policyBody) { - if (Array.isArray(policyBody?.policy)) return policyBody.policy; - if (Array.isArray(policyBody?.policies)) return policyBody.policies; - return []; + function formatDateNumber(value) { + const text = String(value || ""); + if (/^\d{8}$/.test(text)) { + return `${text.slice(0, 4)}.${text.slice(4, 6)}.${text.slice(6, 8)}`; + } + return text || "-"; } - function calculateNextTargetValue(giftValue, policyRows) { - const giftNumber = Number(giftValue); - if (!Number.isFinite(giftNumber) || !policyRows.length) return null; + function createDailyRow(item) { + const row = document.createElement("div"); + row.className = "daily-row"; - const rows = policyRows - .map((row) => ({ - target: Number(row.target), - rawTarget: row.target - })) - .filter((row) => Number.isFinite(row.target)) - .sort((a, b) => a.target - b.target); + const date = document.createElement("div"); + date.className = "daily-date"; + date.textContent = formatDateNumber(item?.dateNumber); - if (!rows.length) return null; + const values = document.createElement("div"); + values.className = "daily-values"; - const next = rows.find((row) => giftNumber < row.target); - return next ? next.rawTarget : null; + const gift = document.createElement("div"); + gift.className = "daily-cell"; + gift.innerHTML = `${currentMessages.gift_points || fallbackMessages.en.gift_points}${formatCountValue(item?.acceptGiftValue ?? 0)}`; + + const online = document.createElement("div"); + online.className = "daily-cell"; + online.innerHTML = `${currentMessages.online_minutes || fallbackMessages.en.online_minutes}${formatCountValue(item?.onlineTime ?? 0)}`; + + values.appendChild(gift); + values.appendChild(online); + row.appendChild(date); + row.appendChild(values); + return row; + } + + function replaceNodeChildren(node, children) { + while (node.firstChild) node.removeChild(node.firstChild); + children.forEach((child) => node.appendChild(child)); + } + + function renderDailyTargets(targets = currentDailyTargets) { + currentDailyTargets = Array.isArray(targets) ? targets : []; + const list = document.querySelector("#dailyList"); + if (!list) return; + + if (!currentDailyTargets.length) { + const empty = document.createElement("div"); + empty.className = "daily-empty"; + empty.textContent = currentMessages.no_daily_data || fallbackMessages.en.no_daily_data; + replaceNodeChildren(list, [empty]); + return; + } + + replaceNodeChildren(list, currentDailyTargets.map(createDailyRow)); + } + + function renderMemberWorkSummary(memberWork) { + const workTarget = pickFirstMemberWorkTarget(memberWork); + renderStreamingDuration(pickStreamingDuration(memberWork)); + renderCurrentGiftValue(pickGiftValue(workTarget) ?? 0); + renderDailyTargets(pickDailyTargets(workTarget)); + } + + function setDailyModalOpen(open) { + const modal = document.querySelector("#dailyModal"); + if (!modal) return; + modal.hidden = !open; + document.body.classList.toggle("daily-modal-open", open); + if (open) renderDailyTargets(); } async function fetchUserProfile() { @@ -628,7 +702,7 @@ async function fetchStreamingDuration(memberId) { const memberWork = await fetchMemberWork(memberId); - renderStreamingDuration(pickStreamingDuration(memberWork)); + renderMemberWorkSummary(memberWork); return memberWork; } @@ -663,55 +737,6 @@ } } - async function fetchAnchorPolicyForTarget() { - const token = readRawParam("token"); - if (!token) { - console.warn("Missing token for /team/release/policy"); - return null; - } - - try { - const teamId = currentTeamId || await fetchTeamEntry(); - if (!teamId) { - console.warn("Missing teamId for /team/release/policy"); - return null; - } - - const url = new URL("/team/release/policy", `${apiBaseURL()}/`); - url.searchParams.set("id", teamId); - - const response = await fetch(url.toString(), { - cache: "no-store", - headers: authHeadersFromToken(token) - }); - const data = await response.json().catch(() => ({})); - if (!response.ok || data.status === false) { - throw new Error(data.errorMsg || data.message || `Request failed: ${response.status}`); - } - - return data.body || data.data || null; - } catch (error) { - console.error("Failed to load team policy for next target:", error); - return null; - } - } - - async function fetchNextTargetValue(memberId, memberWork = null) { - const work = memberWork || await fetchMemberWork(memberId); - const workTarget = pickFirstMemberWorkTarget(work); - if (!workTarget) { - renderNextTargetValue("-"); - return; - } - - const directNextTarget = pickDirectNextTargetValue(workTarget); - const giftValue = pickGiftValue(workTarget); - const policy = await fetchAnchorPolicyForTarget(); - const calculatedNextTarget = calculateNextTargetValue(giftValue, pickPolicyRows(policy)); - - renderNextTargetValue(calculatedNextTarget ?? directNextTarget ?? "-"); - } - function syncLocalizedLinks() { const nextParams = new URLSearchParams(params); const token = readRawParam("token"); @@ -776,6 +801,7 @@ syncPolicyLink(); renderProfile(currentProfile, messages); renderAgencyProfile(currentAgencyProfile, messages); + renderDailyTargets(); } document.querySelector(".language-button")?.addEventListener("click", (event) => { @@ -804,6 +830,20 @@ if (currentIdentity && shouldOpenJoinAgency(currentIdentity)) openJoinAgencyPage(); }); + document.querySelector(".gift-value")?.addEventListener("click", () => { + setDailyModalOpen(true); + }); + + document.querySelectorAll("[data-close-daily]").forEach((node) => { + node.addEventListener("click", () => { + setDailyModalOpen(false); + }); + }); + + document.addEventListener("keydown", (event) => { + if (event.key === "Escape") setDailyModalOpen(false); + }); + ensureAvatarFallback("Oscar"); applyLanguage(currentLang).then(async () => { @@ -818,8 +858,7 @@ fetchUserProfile().then(async (profile) => { const memberId = profile?.id || profile?.account; if (memberId) { - const memberWork = await fetchStreamingDuration(memberId); - fetchNextTargetValue(memberId, memberWork); + await fetchStreamingDuration(memberId); } }); fetchBankBalance(); diff --git a/h5/hyapp/host-center/style.css b/h5/hyapp/host-center/style.css index 80814ad..d7a1ebb 100644 --- a/h5/hyapp/host-center/style.css +++ b/h5/hyapp/host-center/style.css @@ -698,6 +698,159 @@ a { line-height: 1.2; } +.daily-modal[hidden] { + display: none; +} + +.daily-modal { + position: fixed; + z-index: 20; + inset: 0; + display: flex; + align-items: flex-end; + justify-content: center; +} + +.daily-backdrop { + position: absolute; + inset: 0; + background: rgba(15, 21, 28, 0.38); +} + +.daily-sheet { + position: relative; + width: min(430px, 100%); + max-height: 72vh; + overflow: hidden; + border-radius: 16px 16px 0 0; + background: #fff; + box-shadow: 0 -14px 34px rgba(23, 31, 42, 0.16); +} + +.daily-sheet-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + min-height: 58px; + padding: 16px 18px 12px; + border-bottom: 1px solid #eef0f2; +} + +.daily-sheet-head h2 { + margin: 0; + color: #24282e; + font-size: 18px; + font-weight: 950; + line-height: 1.2; +} + +.daily-close { + display: flex; + align-items: center; + justify-content: center; + width: 34px; + height: 34px; + border-radius: 50%; + background: #f4f6f7; + color: #50545b; + font-size: 25px; + font-weight: 500; + line-height: 1; +} + +.daily-summary { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + padding: 13px 18px; + border-bottom: 1px solid #f0f2f3; + color: #8b8d92; + font-size: 14px; + font-weight: 850; +} + +.daily-summary strong { + color: #24282e; + font-size: 20px; + font-weight: 950; + overflow-wrap: anywhere; +} + +.daily-list { + display: grid; + gap: 10px; + max-height: calc(72vh - 116px); + overflow-y: auto; + padding: 14px 18px max(18px, env(safe-area-inset-bottom)); + -webkit-overflow-scrolling: touch; +} + +.daily-row { + display: grid; + gap: 10px; + padding: 12px; + border: 1px solid #eef0f2; + border-radius: 8px; + background: #fbfcfc; +} + +.daily-date { + color: #24282e; + font-size: 15px; + font-weight: 950; + line-height: 1.2; +} + +.daily-values { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 10px; +} + +.daily-cell { + min-width: 0; +} + +.daily-cell span { + display: block; + overflow: hidden; + color: #96989d; + font-size: 12px; + font-weight: 800; + line-height: 1.2; + text-overflow: ellipsis; + white-space: nowrap; +} + +.daily-cell strong { + display: block; + margin-top: 4px; + overflow-wrap: anywhere; + color: #292d33; + font-size: 16px; + font-weight: 950; + line-height: 1.2; +} + +.daily-empty { + display: flex; + align-items: center; + justify-content: center; + min-height: 92px; + border: 1px dashed #e5e8ea; + border-radius: 8px; + color: #8b8d92; + font-size: 14px; + font-weight: 850; + text-align: center; +} + +.daily-modal-open { + overflow: hidden; +} + .home-indicator { position: absolute; left: 50%; @@ -755,6 +908,10 @@ a { text-align: left; } +[dir="rtl"] .daily-sheet { + direction: rtl; +} + @media (max-width: 360px) { .status-bar { padding-right: 22px;