fix(shop): 修复购物车和收藏列表图片及价格显示问题

- 购物车上下文补全映射后端返回的 product 和 sku 嵌套对象字段
- 购物车页面商品图片资源回退增加 sku.image
- 添加 ensureFullUrl 辅助函数,完善图片 URL 完整性,增强图片压缩函数健壮性
- 收藏列表扩展 ShopGoodsFavorite 模型,支持嵌套商品详情字段
- 收藏列表图片、名称、价格显示逻辑升级,优先显示嵌套商品信息
- 购物车相关接口请求参数及方法调整,修正 PUT 请求路径和请求体字段
- 收藏列表列表项 key 使用 id 或 goodsId 避免重复Key警告
This commit is contained in:
2026-07-14 00:55:35 +08:00
parent 59ebef2f22
commit 711db25093
8 changed files with 135 additions and 22 deletions

View File

@@ -23,6 +23,12 @@
- 分类页和首页一样是 tabBar 页,三按钮全亮(好友/朋友圈/复制链接)
- 类型检查:零错误
## 修复收藏列表(图文不显示、价格不对)
- `src/api/shop/shopGoodsFavorite/model.ts`:扩展 `ShopGoodsFavorite` 接口,增加 `product?: { id, name, image, price, salePrice }` 嵌套字段(与秒杀/拼团模型一致)。后端 API 返回的嵌套商品数据会带 `product` 字段。
- `src/pages/user/favorite-list/index.tsx`
- 图片:`item.goodsImage``item.goodsImage || item.product?.image`
- 价格:`item.salePrice`(市场价)→ `item.product?.price || item.salePrice`(到手价),当市场价与到手价不同时再显示划掉的市场价
- 类型检查:零错误
## 修复订单列表看到他人订单
- `src/pages/order/list.tsx`:导入 `useUser`,请求参数加 `userId: user?.id`。原代码请求 `pageShopOrder` 时没传 `userId`,导致后端返回所有人订单。
- `ShopOrderParam` 接口已有 `userId` 字段(见 `src/api/shop/shopOrder/model/index.ts:225`),后端按此过滤——只需前端补传。