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