修改请求
This commit is contained in:
parent
775a5f4992
commit
64c2e569ed
@ -91,6 +91,7 @@
|
||||
- `/team/member-work` 返回后:
|
||||
- `historySalary` 写入本地变量
|
||||
- 读取 `targets[0]`
|
||||
- 当前 `hyapp/host-center` 的 Streaming Duration 使用 `targets[0].target.onlineTime` 作为总直播时长
|
||||
- 结算状态映射:
|
||||
- `SETTLED` -> `Completed`
|
||||
- `UNPAID` -> `In Progress`
|
||||
@ -100,15 +101,16 @@
|
||||
|
||||
## 今日任务/直播数据逻辑
|
||||
|
||||
- `usePageConfig` 会请求 `/team/member/work/statistics-now`。
|
||||
- 原 Vue `usePageConfig` 会请求 `/team/member/work/statistics-now`。
|
||||
- 请求参数:
|
||||
- `dataType=DAILY`
|
||||
- `memberId=<当前用户 id/account>`
|
||||
- 展示逻辑:
|
||||
- 原 Vue 今日任务展示逻辑:
|
||||
- `anchorType = "Chat"`
|
||||
- `minutesProgress = min(ownTime + otherTime, minutesTotal)`
|
||||
- `minutesTotal = 120`
|
||||
- `giftTask = acceptGiftValue || 0`
|
||||
- 当前 `hyapp/host-center` 的 Streaming Duration 不再用该接口,也不再限制 120;改用 `/team/member-work?userId=<当前用户 id>` 返回的 `targets[0].target.onlineTime` 总时长。
|
||||
|
||||
## 银行卡与提现信息逻辑
|
||||
|
||||
@ -235,7 +237,7 @@
|
||||
|
||||
### GET `/team/member/work/statistics-now`
|
||||
|
||||
- 用途:获取成员当天目标/工作统计。
|
||||
- 用途:原 Vue 获取成员当天目标/工作统计;当前 `hyapp/host-center` 不再用它展示 Streaming Duration。
|
||||
- 查询参数:
|
||||
- `dataType`: `DAILY | MONTH`
|
||||
- `memberId`: 成员 ID,必传
|
||||
@ -252,6 +254,7 @@
|
||||
- 返回使用:
|
||||
- `historySalary`
|
||||
- `targets`
|
||||
- `targets[0].target.onlineTime`,当前 `hyapp/host-center` 用作 Streaming Duration 总时长
|
||||
- `targets[].status`
|
||||
- `targets[].target.settlementResult.level`
|
||||
- `targets[].target.level`
|
||||
|
||||
@ -419,14 +419,13 @@
|
||||
function formatStreamingDuration(value) {
|
||||
const numericValue = Number(value);
|
||||
if (!Number.isFinite(numericValue)) return "0";
|
||||
const safeValue = Math.max(0, Math.min(numericValue, 120));
|
||||
const safeValue = Math.max(0, numericValue);
|
||||
return Number.isInteger(safeValue) ? String(safeValue) : String(Number(safeValue.toFixed(2)));
|
||||
}
|
||||
|
||||
function pickStreamingDuration(body) {
|
||||
const ownTime = Number(body?.ownTime) || 0;
|
||||
const otherTime = Number(body?.otherTime) || 0;
|
||||
return ownTime + otherTime;
|
||||
const workTarget = pickFirstMemberWorkTarget(body);
|
||||
return body?.onlineTime ?? body?.target?.onlineTime ?? workTarget?.target?.onlineTime ?? workTarget?.onlineTime ?? 0;
|
||||
}
|
||||
|
||||
function renderStreamingDuration(value) {
|
||||
@ -628,35 +627,9 @@
|
||||
}
|
||||
|
||||
async function fetchStreamingDuration(memberId) {
|
||||
const token = readRawParam("token");
|
||||
if (!token) {
|
||||
console.warn("Missing token for /team/member/work/statistics-now");
|
||||
return;
|
||||
}
|
||||
if (!memberId) {
|
||||
console.warn("Missing memberId for /team/member/work/statistics-now");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL("/team/member/work/statistics-now", `${apiBaseURL()}/`);
|
||||
url.searchParams.set("dataType", "DAILY");
|
||||
url.searchParams.set("memberId", String(memberId));
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
renderStreamingDuration(pickStreamingDuration(data.body ?? data.data));
|
||||
} catch (error) {
|
||||
console.error("Failed to load streaming duration:", error);
|
||||
renderStreamingDuration(0);
|
||||
}
|
||||
const memberWork = await fetchMemberWork(memberId);
|
||||
renderStreamingDuration(pickStreamingDuration(memberWork));
|
||||
return memberWork;
|
||||
}
|
||||
|
||||
async function fetchMemberWork(memberId) {
|
||||
@ -723,9 +696,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchNextTargetValue(memberId) {
|
||||
const memberWork = await fetchMemberWork(memberId);
|
||||
const workTarget = pickFirstMemberWorkTarget(memberWork);
|
||||
async function fetchNextTargetValue(memberId, memberWork = null) {
|
||||
const work = memberWork || await fetchMemberWork(memberId);
|
||||
const workTarget = pickFirstMemberWorkTarget(work);
|
||||
if (!workTarget) {
|
||||
renderNextTargetValue("-");
|
||||
return;
|
||||
@ -842,11 +815,11 @@
|
||||
|
||||
fetchAgencyProfile();
|
||||
fetchTeamEntry();
|
||||
fetchUserProfile().then((profile) => {
|
||||
fetchUserProfile().then(async (profile) => {
|
||||
const memberId = profile?.id || profile?.account;
|
||||
if (memberId) {
|
||||
fetchStreamingDuration(memberId);
|
||||
fetchNextTargetValue(memberId);
|
||||
const memberWork = await fetchStreamingDuration(memberId);
|
||||
fetchNextTargetValue(memberId, memberWork);
|
||||
}
|
||||
});
|
||||
fetchBankBalance();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user