From 60ad2535cc9c783397d1a3820c81aa36d3363d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Mon, 9 Feb 2026 12:59:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=86=E7=B1=BB=EF=BC=8C=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E5=92=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E6=95=B0=E6=8D=AE=E7=BB=9F?= =?UTF-8?q?=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods/index.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) 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() }