Files
tonghuashun_CardDemo/entry/src/main/ets/market-ranking/MarketRankingModels.ets
T

85 lines
2.6 KiB
Plaintext
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.
// ============ 视图数据类型(合并接口 + 行情后,供 View 消费) ============
// 保留原始字段,不在数据层预先格式化/预先判断涨跌色;HTTP 占位行允许行情字段暂缺。
export interface RankItem {
code: string;
market: string;
name: string;
price?: number;
// 涨跌幅(%数值,如 3.21 表示 +3.21%)。行情推送里固定字段,任何 Tab 下都存在,
// 用于「最新价」列的取色,也是 涨幅/跌幅 Tab 第三列的数据来源。
price_chg?: number;
// 涨速/跌速(%数值)。仅 riseSpeed/fallSpeed Tab 下有值。
chg_speed?: number;
// 成交额(原始数值,未换算单位)。仅 turnOver Tab 下有值。
turnover?: number;
// 日增仓(原始数值,未换算单位)。仅 increPosit Tab 下有值。
incre_posit?: number;
}
// 当前市场排名卡片的完整展示数据;网络/行情更新后整体替换以触发 UI 刷新。
export interface CardData {
tableList: RankItem[];
}
export type MarketRankingHqValue = string | number;
// 对齐真实鸿蒙行情返回行:通过行情字段 ID 获取当前合约的值。
export class MarketRankingTableRow {
private values: Map<number, MarketRankingHqValue> =
new Map<number, MarketRankingHqValue>();
set(fieldId: number, value: MarketRankingHqValue): void {
this.values.set(fieldId, value);
}
get(fieldId: number): MarketRankingHqValue | undefined {
return this.values.get(fieldId);
}
}
// 对齐真实鸿蒙行情 TableData:每个 tableRows 元素代表一份合约行情。
export class MarketRankingTableData {
tableRows: MarketRankingTableRow[] = [];
addRow(row: MarketRankingTableRow): void {
this.tableRows.push(row);
}
}
export interface MarketRankingHqRequestParams {
protocolId: string;
pageId: string;
onlineId: string;
columnOrder: string;
requestDic: string;
}
export interface TabMetric {
id: string;
label: ResourceStr;
api: string; // HTTP 接口 quote_type 参数用
hqId: number; // 行情订阅 sortid 用
hasChildren: boolean; // Vue 用 children 数组本身判断,这里简化为布尔标记
}
export interface PeriodRange {
id: string;
label: ResourceStr;
api: string;
hqId: number;
}
// ============ 后端接口原始响应类型(recommend_futures ============
// 对应 docs/cards/interfaces.md「一、HTTP 接口 - 1. 市场排名列表」
export interface RecommendFuturesItem {
contract_code: string;
contract_name: string;
market: string;
}
export interface RecommendFuturesResponse {
code: number;
data: RecommendFuturesItem[];
}