From e01ba296045d635d0936df685d68574884fcdb77 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 31 Jul 2026 16:52:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=B8=BF=E8=92=99=E5=85=BC=E5=AE=B9):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E9=AA=A8=E6=9E=B6=E5=B1=8F=E5=B8=B8=E9=A9=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 兼容后端不返回goods_promotion字段的场景,避免直接取值抛错 2. 替换鸿蒙元服务下不可靠的nextTick和延迟关闭逻辑,改为同步关闭骨架屏,解决数据返回后骨架屏常驻的问题 --- pages_goods/public/js/detail.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pages_goods/public/js/detail.js b/pages_goods/public/js/detail.js index 3ccc7dc..1d04d5d 100644 --- a/pages_goods/public/js/detail.js +++ b/pages_goods/public/js/detail.js @@ -181,7 +181,10 @@ export default { this.chatRoomParams = { sku_id: this.goodsSkuDetail.sku_id }; - let typeId = this.goodsSkuDetail.goods_promotion[0]; + // 鸿蒙兼容: 后端在部分场景下可能不返回 goods_promotion, 缺字段直接 .[0] 会抛 TypeError, + // 整个 onShow 走 catch 路径无法关闭骨架屏, 表现为"数据已回来但永远显示骨架屏" + const promotionList = this.goodsSkuDetail?.goods_promotion || []; + let typeId = promotionList.length > 0 ? promotionList[0] : undefined; if (typeId) { // 限时折扣 if (typeId.discount_id) { @@ -199,18 +202,21 @@ export default { // 兼容鸿蒙元服务: $nextTick 在某些 JSVM 实现下不可靠, 用 setTimeout 兜底 // #ifdef MP-HARMONY await new Promise(resolve => setTimeout(resolve, 16)); + // 修复鸿蒙元服务: 不依赖 setTimeout 关闭骨架屏. + // 鸿蒙 JSVM 在 onShow 早期窗口的 setTimeout 回调有时被推迟/丢弃, 表现为"数据已回来但永远显示骨架屏". + // 数据已赋值 + 首屏让步, 同步直接关闭骨架屏, 由 hasRealData 兜底避免空详情. + this.loading = false; // #endif // #ifndef MP-HARMONY await this.$nextTick(); - // #endif - // 关闭商品详情骨架屏: 在真实数据首屏渲染完成后再隐藏骨架屏, // 用户会看到骨架屏 → 真实详情 的清晰过渡 // 最短展示 300ms: 数据请求很快时也保留足够感知时间, 否则一闪而过用户根本看不到骨架屏 setTimeout(() => { this.loading = false; }, 300); + // #endif // 处理商品数据 (同步字段变换 + 后台并发 getGoodsForm) await this.handleGoodsSkuData();