From 5af37bfa51bff7cde7f3c67878019417201c96f8 Mon Sep 17 00:00:00 2001 From: clz Date: Mon, 27 Jul 2026 10:31:22 +0800 Subject: [PATCH] fix market ranking display fallbacks --- doc/market-ranking-known-issues.md | 14 +++++++++++--- .../MarketRankingNodeComponent.ets | 3 ++- .../clients/MarketRankingHqRequestClient.ets | 18 +++++++++++++++++- src/main/resources/base/element/color.json | 6 +++++- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/doc/market-ranking-known-issues.md b/doc/market-ranking-known-issues.md index 5b1433c..be4a972 100644 --- a/doc/market-ranking-known-issues.md +++ b/doc/market-ranking-known-issues.md @@ -47,16 +47,24 @@ 逐项验证涨幅、跌幅、1/5/10/15 分钟涨速和跌速、成交额、日增仓 Tab。预期每个 Tab 的 `sortid`、 排序方向、第三列字段和值均正确,不出现整列 `--` 或排序方向相反。 -### 2. 基准价计算 +### 2. 基准价计算(高风险) -`applyStandardPriceToTableData` 已接入,但需要确认传入的 `fieldIds` 是否包含宿主实现要求的全部字段, -特别是 `DATA_ID_ZD`、`DATA_ID_MARKET_OLD` 以及昨收、今开、昨结字段。 +`MarketRankingHqRequestClient` 已接入 `applyStandardPriceToTableData`,但当前传入的 `fieldIds` +与仓库内 `FirstPageSelfStockRequestClient` 的基准价必需字段存在差异。市场排名当前未包含 +`DATA_ID_ZD`、`DATA_ID_MARKET_OLD`,并且昨收、今开、昨结使用本地 `TableConstants` 字段, +没有使用 `StandardPriceTypeHelper.FIELD_ZUO_SHOU`、`FIELD_JIN_KAI`、`FIELD_ZUO_JIE`。 + +在无法查看宿主 `biz_quote` 和 `@b2c/lib_baseui` 实现的情况下,尚不能确认这些字段是否等价或可省略。 +如果宿主实现依赖上述完整字段,用户切换基准价后可能出现涨跌幅未更新、计算口径错误或整列显示 `--`。 +因此该项应按高风险处理,在字段要求得到确认并完成宿主验证前,不应认定市场排名的基准价功能可发布。 分别选择昨收、今开、昨结作为基准价,验证: - 最新价不变,涨跌幅按当前基准价重新计算。 - 页面隐藏后修改基准价,再返回首页会重新订阅并更新。 - 首包和后续实时推送采用相同计算口径。 +- 对照 `FirstPageSelfStockRequestClient` 确认必需字段集合,并优先复用宿主 + `TableConstants` / `StandardPriceTypeHelper`,避免维护重复字段 ID。 ### 3. HTTP 推荐合约接口 diff --git a/src/main/ets/market-ranking/MarketRankingNodeComponent.ets b/src/main/ets/market-ranking/MarketRankingNodeComponent.ets index 9b4c6fa..f5d9985 100644 --- a/src/main/ets/market-ranking/MarketRankingNodeComponent.ets +++ b/src/main/ets/market-ranking/MarketRankingNodeComponent.ets @@ -488,7 +488,8 @@ export struct MarketRankingNodeComponent { .height(30) .linearGradient({ angle: 90, - colors: [['#00FFFFFF', 0], [$r('app.color.surface_layer1_foreground'), 1]], + colors: [[$r('app.color.transparent_white'), 0], + [$r('app.color.surface_layer1_foreground'), 1]], }) .hitTestBehavior(HitTestMode.None) } diff --git a/src/main/ets/node/clients/MarketRankingHqRequestClient.ets b/src/main/ets/node/clients/MarketRankingHqRequestClient.ets index 8c2cc9c..c62c1e8 100644 --- a/src/main/ets/node/clients/MarketRankingHqRequestClient.ets +++ b/src/main/ets/node/clients/MarketRankingHqRequestClient.ets @@ -26,18 +26,21 @@ class MarketRankingTableRequestClient extends TableRequestClient { private requestParams: string; private fieldIds: number[]; private sortId: number; + private fallbackNames: Map; private listener: MarketRankingCardDataListener; constructor( requestParams: string, fieldIds: number[], sortId: number, + fallbackNames: Map, listener: MarketRankingCardDataListener, ) { super(FRAME_ID, PAGE_ID, [], null, undefined); this.requestParams = requestParams; this.fieldIds = fieldIds; this.sortId = sortId; + this.fallbackNames = fallbackNames; this.listener = listener; this.setSubscribeIds(fieldIds); } @@ -67,7 +70,7 @@ class MarketRankingTableRequestClient extends TableRequestClient { const item: RankItem = { code: `${codeValue}`, market: `${marketValue}`, - name: this.getString(row, TableConstants.DATA_ID_NAME), + name: this.getContractName(row, `${codeValue}`, `${marketValue}`), }; item.price = this.getNumber(row, TableConstants.DATA_ID_PRICE); item.price_chg = this.getNumber(row, TableConstants.DATA_ID_ZF); @@ -90,6 +93,14 @@ class MarketRankingTableRequestClient extends TableRequestClient { return value === undefined ? '' : `${value}`; } + private getContractName(row: RowData, code: string, market: string): string { + const hqName: string = this.getString(row, TableConstants.DATA_ID_NAME); + if (hqName !== '' && hqName !== '--') { + return hqName; + } + return this.fallbackNames.get(`${market}_${code}`) ?? ''; + } + private getNumber(row: RowData, fieldId: number): number | undefined { const value = row.originalData.get(fieldId); if (typeof value === 'number') { @@ -145,10 +156,15 @@ export class MarketRankingHqRequestClient { const requestParams: string = this.buildRequestParams(contracts, primaryIdx, sortId, fieldIds); + const fallbackNames: Map = new Map(); + contracts.forEach((contract: RecommendFuturesItem): void => { + fallbackNames.set(`${contract.market}_${contract.contract_code}`, contract.contract_name); + }); const requestClient = new MarketRankingTableRequestClient( requestParams, fieldIds, sortId, + fallbackNames, listener, ); requestClient.request(0, contracts.length); diff --git a/src/main/resources/base/element/color.json b/src/main/resources/base/element/color.json index 8957888..3437999 100644 --- a/src/main/resources/base/element/color.json +++ b/src/main/resources/base/element/color.json @@ -48,6 +48,10 @@ "name": "color_73ffffff", "value": "#73FFFFFF" }, + { + "name": "transparent_white", + "value": "#00FFFFFF" + }, { "name": "color_333333", "value": "#333333" @@ -120,4 +124,4 @@ "value": "#b341d9" } ] -} \ No newline at end of file +}