chatapp-h5/h5/hyapp/host-center/original-vue-logic.md
2026-04-27 23:27:06 +08:00

267 lines
7.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 原 Vue Host Center 逻辑清单
来源:
- `chatapp-h5/h5/js/index-CN7d9oZS-1776148658686.js`
- `chatapp-h5/h5/js/pageConfig-BUpLPO7w-1776148658686.js`
- `chatapp-h5/h5/js/teamBill-BWXvrc1S-1776148658686.js`
- `chatapp-h5/h5/js/index-CIAVq8iD-1776148658686.js`
- 后端参数定义参考 `chatapp3-java/rc-service`
## 页面初始化
- 初始化 i18n读取当前 locale并调用语言切换逻辑。
- 初始化路由对象。
- 初始化 identity store并设置身份为 `HOST`
- 清空 payee store。
- 使用 `usePageConfig("HOST_CENTER", { needsTeamInfo: true, forceRefresh: true, onDataLoaded })`
- 页面 mounted 后并发或顺序触发:
- 设置身份:`identity = "HOST"`
- 获取我的代理资料
- 清空收款人缓存
- 获取银行卡列表
- 获取提现/KYC 信息
- 获取主播工资提现是否可用
## 用户信息获取
- `usePageConfig` 内部优先读取缓存用户信息。
- 非强制刷新时读取本地缓存用户资料。
- 强制刷新时请求 `/team/member/profile`
- 页面展示用字段:
- `id`
- `account`
- `userNickname`
- `name`
- `userAvatar`
- `ownSpecialId.account`
- Host Center 当前代理/团长资料来自 `/team/team-own/profile`
- 展示名称:`userNickname || name`
- 展示 ID`ownSpecialId.account || account`
- 头像加载失败时走 `imageHandler` fallback。
## App 连接与请求头
- 判断是否在 App/WebView 环境。
- 若已连接且缓存有效,复用缓存请求头。
- 若未连接,调用 App bridge 获取 access origin 参数。
- 解析 App 返回参数后设置 HTTP 请求头。
- 关键请求头来源:
- `Authorization`
- `Req-Lang`
- `Req-App-Intel`
- `Req-Imei`
- `Req-Sys-Origin`
- 连接失败时可能跳转 `/not_app`
## 路由与身份守卫
- 请求 `/app/h5/identity` 获取身份。
- 根据身份字段计算 roles
- `freightAgent`
- `agent`
- `bdLeader`
- `bd`
- `anchor`
- `admin`
- 主角色权重:
- `guest`
- `anchor`
- `agent`
- `bd`
- `bdLeader`
- `freightAgent`
- `admin`
- 默认跳转页:
- `admin` -> `/admin-center`
- `freightAgent` -> `/coin-seller`
- `agent` -> `/agency-center`
- `bdLeader` -> `/bd-leader-center`
- `bd` -> `/bd-center`
- `anchor` -> `/host-center`
- `guest` -> `/apply`
- 当前用户没有 anchor 身份时跳到对应默认页。
## 收入/工资逻辑
- 可用工资来自 `usePageConfig``salaryInfo.currentSalary`
- `usePageConfig` 会请求 `/wallet/bank/balance`
- 响应 body 是 number 时展示 `body.toFixed(2)`
- 请求失败时 `currentSalary = 0` 并 toast`Failed to load balance. Please try again.`
- 原 Host Center 还请求 `/team/member-work`,用于获取历史工资和目标数据。
- `/team/member-work` 返回后:
- `historySalary` 写入本地变量
- 读取 `targets[0]`
- 结算状态映射:
- `SETTLED` -> `Completed`
- `UNPAID` -> `In Progress`
- `HANG_UP` -> `Out of account`
- `PAY_OUT` -> `Completed`
- 目标等级取 `target.settlementResult.level || target.level || "-"`
## 今日任务/直播数据逻辑
- `usePageConfig` 会请求 `/team/member/work/statistics-now`
- 请求参数:
- `dataType=DAILY`
- `memberId=<当前用户 id/account>`
- 展示逻辑:
- `anchorType = "Chat"`
- `minutesProgress = min(ownTime + otherTime, minutesTotal)`
- `minutesTotal = 120`
- `giftTask = acceptGiftValue || 0`
## 银行卡与提现信息逻辑
- 请求 `/wallet/bank-card/list` 获取银行卡列表。
-`body.find(item => item.use)` 作为当前使用银行卡。
- 请求 `/wallet/withdraw-info/list` 获取提现/KYC 信息。
-`body.length > 0`
- 取第一条
- `passportFrontUrl` 按 JSON 字符串解析成 `previewUrls`
- 合并到提现信息对象
- 请求 `/wallet/bank/host-salary/withdraw/enabled`
- `body` 转 Boolean 后控制是否展示 `Cash withdraw` 入口。
- 点击提现:
- 如果没有提现信息或没有当前使用银行卡,打开 `infoMissing` 弹窗。
- 否则跳转 `/cash-withdraw`
## 弹窗逻辑
- 弹窗状态:
- `infoMissing`
- `leave`
- `maskLayerShow = infoMissing || leave`
- 打开弹窗前先关闭其它弹窗。
- 点击遮罩关闭弹窗。
- `infoMissing` 弹窗:
- 标题:`prompt`
- 文案:`fill_info_tips`
- 辅助文案:`card_issue_tips`
- 按钮跳转 `/host-setting`
- `leave` 弹窗:
- 标题:`tips`
- 文案:`leave_agent_tips`
- 取消关闭弹窗
- 确认执行退出团队申请
## 退出团队逻辑
- 请求 `/team/user/apply`
- 方法:`POST`
- Body
- `reason: "QUIT"`
- `teamId: <当前团队 id>`
- `teamId` 来源:
- 原 Vue 使用 `pe()` 读取当前团队 id
- 静态实现里曾兼容读取 `teamInfo.id || agency.teamId || agency.id`
- 失败时 toast `errorMsg`
## 点击跳转
- 工资详情:`/history-salary`
- 平台政策:`/platform-policy?from=hostcenter`
- 主播设置/银行卡:`/host-setting`
- 兑换金币:`/exchange-gold-coins`
- 转账:`/transfer`
- 提现:`/cash-withdraw`
- 语言切换:`/language`
- 返回:
- App bridge `closePage`
- Flutter bridge `close_page`
- 浏览器 `history.back()`
## 原接口与可传参数
### GET `/team/member/profile`
- 用途:获取当前用户信息。
- 显式查询参数:无。
- 隐式参数App 请求头中用户、语言、来源等上下文。
### GET `/team/team-own/profile`
- 用途:获取我的团长/代理资料。
- 显式查询参数:无。
- 隐式参数App 请求头中的当前用户上下文。
### GET `/team/entry`
- 用途:获取当前用户团队入口信息。
- 显式查询参数:无。
- 返回中使用 `body.teamProfile || body` 作为团队信息。
### GET `/wallet/bank/balance`
- 用途:获取工资/银行卡余额。
- 显式查询参数:无。
- 返回可为数字,也可能为对象。
### GET `/team/member/work/statistics-now`
- 用途:获取成员当天目标/工作统计。
- 查询参数:
- `dataType`: `DAILY | MONTH`
- `memberId`: 成员 ID必传
- `size`: 数量,可选
- Host Center 使用:
- `dataType=DAILY`
- `memberId=<当前用户 id/account>`
### GET `/team/member-work`
- 用途:成员工资情况。
- 查询参数:
- `userId`: 用户 ID必传
- 返回使用:
- `historySalary`
- `targets`
- `targets[].status`
- `targets[].target.settlementResult.level`
- `targets[].target.level`
### GET `/wallet/bank-card/list`
- 用途:银行卡列表。
- 显式查询参数:无。
- 返回使用:
- `body[]`
- `item.use`
### GET `/wallet/withdraw-info/list`
- 用途:提现/KYC 信息列表。
- 显式查询参数:无。
- 返回使用:
- `body[0]`
- `body[0].passportFrontUrl`
### GET `/wallet/bank/host-salary/withdraw/enabled`
- 用途:主播工资是否允许提现。
- 显式查询参数:无。
- 返回使用:
- `body` boolean
### GET `/app/h5/identity`
- 用途:获取当前 H5 身份。
- 显式查询参数:无。
- 返回使用字段:
- `freightAgent`
- `agent`
- `bdLeader`
- `bd`
- `anchor`
- `admin`
### POST `/team/user/apply`
- 用途:用户申请加入或退出团队。
- Body
- `reason`: `JOIN | QUIT`
- `teamId`: 团队 ID必传
- `url`: 跳转 URL可选
- Host Center 退出团队使用:
- `reason: "QUIT"`
- `teamId: <当前团队 id>`