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

@@ -62,8 +62,8 @@ export async function addToCart(data: AddToCartParam) {
*/
export async function updateCartNum(data: UpdateCartNumParam) {
const res = await request.put<ApiResult<unknown>>(
'/shop/shop-cart/' + data.id,
{ quantity: data.num }
'/shop/shop-cart',
{ id: data.id, num: data.num }
);
if (res.code === 0) {
return res.message || '更新成功';
@@ -76,8 +76,8 @@ export async function updateCartNum(data: UpdateCartNumParam) {
*/
export async function updateCartChecked(id: number, checked: boolean) {
const res = await request.put<ApiResult<unknown>>(
'/shop/shop-cart/' + id,
{ selected: checked }
'/shop/shop-cart',
{ id, checked }
);
if (res.code === 0) {
return res.message || '更新成功';
@@ -89,9 +89,9 @@ export async function updateCartChecked(id: number, checked: boolean) {
* 全选/取消全选购物车
*/
export async function updateCartAllChecked(checked: boolean) {
const res = await request.put<ApiResult<unknown>>(
const res = await request.post<ApiResult<unknown>>(
'/shop/shop-cart/selected',
{ selected: checked }
{ checked }
);
if (res.code === 0) {
return res.message || '更新成功';

View File

@@ -1,11 +1,20 @@
export interface ShopGoodsFavorite {
favoriteId?: number
id?: number
userId?: number
goodsId?: number
createTime?: string
goodsName?: string
goodsImage?: string
salePrice?: string
price?: string | number
salePrice?: string | number
/** 嵌套商品详情 */
product?: {
id?: number
name?: string
image?: string
price?: string
salePrice?: string
}
}
export interface ShopGoodsFavoriteParam {