diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index 17c43e9..3baa441 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -2936,10 +2936,10 @@ Page({ API.getProducts() .then(res => { console.log('获取首页商品数据成功:', res); - // API.getProducts()直接返回商品数组,而不是包含data字段的对象 - if (Array.isArray(res)) { + // API.getProducts()返回包含products字段的对象 + if (res && Array.isArray(res.products)) { // 为每个商品添加mediaItems字段和weightQuantityData字段,并过滤出与当前商品规格匹配的商品 - const processedGoods = res.map(goods => { + const processedGoods = res.products.map(goods => { // 处理每个首页商品的规格数据 let weightSpecString = ''; let quantityString = ''; diff --git a/pages/index/index.js b/pages/index/index.js index c865cc8..3166305 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -71,12 +71,7 @@ Page({ id: 1, imageUrl: '/images/1.jpg', link: '' - }, - { - id: 2, - imageUrl: '/images/2.jpg', - link: '' - }, + } ], // 侧边栏相关