diff --git a/pages/goods/index.js b/pages/goods/index.js index ec49f14..1f7b7b1 100644 --- a/pages/goods/index.js +++ b/pages/goods/index.js @@ -109,15 +109,9 @@ Page({ console.log('小品种创建者:', smallCreators) console.log('大贸易创建者:', largeCreators) - // 如果从数据库获取失败,使用默认数据 - let finalSmallCreators = smallCreators - let finalLargeCreators = largeCreators - - if (smallCreators.length === 0 || largeCreators.length === 0) { - console.log('从数据库获取数据失败,使用默认数据') - finalSmallCreators = ['何佳芹', '李真音', '王磊'] // 小品种创建者 - finalLargeCreators = ['吴海燕', '陈骏', '刘琴', '杨率', '汤敏'] // 大贸易创建者 - } + // 直接使用数据库返回的数据,不使用默认数据 + const finalSmallCreators = smallCreators + const finalLargeCreators = largeCreators // 更新filterConfig this.setData({ @@ -138,19 +132,18 @@ Page({ this.loadGoodsList() } catch (err) { console.error('加载goods_root数据失败:', err) - // 使用默认数据作为fallback - console.log('API调用失败,使用默认数据') + // 即使获取失败,也使用空数组,不使用默认数据 this.setData({ filterConfig: { - small: ['何佳芹', '李真音', '王磊'], // 小品种创建者 - large: ['吴海燕', '陈骏', '刘琴', '杨率', '汤敏'] // 大贸易创建者 + small: [], // 小品种创建者 + large: [] // 大贸易创建者 }, // 清除缓存,确保重新加载商品列表时使用新的filterConfig 'cache.publishedGoods': [], 'cache.soldOutGoods': [], 'cache.timestamp': 0 }) - console.log('使用默认数据更新filterConfig成功:', this.data.filterConfig) + console.log('API调用失败,使用空数组更新filterConfig:', this.data.filterConfig) // 即使获取失败,也继续加载商品列表 this.loadGoodsList() }