|
|
@ -2936,10 +2936,10 @@ Page({ |
|
|
API.getProducts() |
|
|
API.getProducts() |
|
|
.then(res => { |
|
|
.then(res => { |
|
|
console.log('获取首页商品数据成功:', res); |
|
|
console.log('获取首页商品数据成功:', res); |
|
|
// API.getProducts()直接返回商品数组,而不是包含data字段的对象
|
|
|
// API.getProducts()返回包含products字段的对象
|
|
|
if (Array.isArray(res)) { |
|
|
if (res && Array.isArray(res.products)) { |
|
|
// 为每个商品添加mediaItems字段和weightQuantityData字段,并过滤出与当前商品规格匹配的商品
|
|
|
// 为每个商品添加mediaItems字段和weightQuantityData字段,并过滤出与当前商品规格匹配的商品
|
|
|
const processedGoods = res.map(goods => { |
|
|
const processedGoods = res.products.map(goods => { |
|
|
// 处理每个首页商品的规格数据
|
|
|
// 处理每个首页商品的规格数据
|
|
|
let weightSpecString = ''; |
|
|
let weightSpecString = ''; |
|
|
let quantityString = ''; |
|
|
let quantityString = ''; |
|
|
|