Browse Source

Fix data loss issue in compare price modal by properly handling API response structure

pull/19/head
徐飞洋 1 month ago
parent
commit
e9a39ce353
  1. 6
      pages/goods-detail/goods-detail.js
  2. 7
      pages/index/index.js

6
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 = '';

7
pages/index/index.js

@ -71,12 +71,7 @@ Page({
id: 1,
imageUrl: '/images/1.jpg',
link: ''
},
{
id: 2,
imageUrl: '/images/2.jpg',
link: ''
},
}
],
// 侧边栏相关

Loading…
Cancel
Save