diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index c59b7d5..0cbfc9a 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -320,6 +320,7 @@ Page({ // 合并预加载数据中的字段 ...(preloadedData || {}), // 添加产品包装字段(放在product之后,确保不被覆盖) + // 修复:使用正确的数据库字段名producting producting: product.producting || '', // 直接使用数据库字段名,确保与表结构完全一致,放在后面覆盖前面的值 product_contact: contactName, @@ -332,7 +333,7 @@ Page({ product_contact: formattedGoods.product_contact, contact_phone: formattedGoods.contact_phone, region: formattedGoods.region, - producting: formattedGoods.producting + packaging: formattedGoods.packaging }); // 保存预加载数据中的isFavorite状态,确保是布尔值 diff --git a/server-example/server-mysql.js b/server-example/server-mysql.js index ee23be9..02cd7e4 100644 --- a/server-example/server-mysql.js +++ b/server-example/server-mysql.js @@ -1937,7 +1937,8 @@ app.post('/api/product/list', async (req, res) => { 'region', // 【新增】确保返回地区字段 'sourceType', // 【新增】确保返回货源类型字段 'supplyStatus', // 【新增】确保返回供应状态字段 - 'category' // 【新增】确保返回商品种类字段 + 'category', // 【新增】确保返回商品种类字段 + 'producting' // 【新增】确保返回产品包装字段 ] }, order: [['created_at', 'DESC']], @@ -3771,7 +3772,7 @@ app.post('/api/products/detail', async (req, res) => { // 查询商品详情 - 排除hidden状态商品,直接使用Product表中的reservedCount字段 const product = await Product.findOne({ - attributes: ['productId', 'productName', 'price', 'quantity', 'grossWeight', 'imageUrls', 'created_at', 'specification', 'yolk', 'sourceType', 'supplyStatus'], + attributes: ['productId', 'productName', 'price', 'quantity', 'grossWeight', 'imageUrls', 'created_at', 'specification', 'yolk', 'sourceType', 'supplyStatus', 'producting'], where: { productId, status: { [Sequelize.Op.not]: 'hidden' } @@ -3848,6 +3849,7 @@ app.post('/api/products/detail', async (req, res) => { console.log('商品详情 - 最终返回的毛重值:', updatedProduct.grossWeight, '类型:', typeof updatedProduct.grossWeight); console.log('商品详情 - 返回的收藏人数:', updatedProduct.reservedCount, '类型:', typeof updatedProduct.reservedCount); + console.log('商品详情 - producting字段:', updatedProduct.producting, '类型:', typeof updatedProduct.producting); res.json({ success: true, diff --git a/utils/api.js b/utils/api.js index 9088fc7..d3dece3 100644 --- a/utils/api.js +++ b/utils/api.js @@ -3481,6 +3481,8 @@ module.exports = { console.log('- 是否包含contact_phone:', 'contact_phone' in data.data); console.log('- product_contact值:', data.data.product_contact); console.log('- contact_phone值:', data.data.contact_phone); + console.log('- 是否包含producting字段:', 'producting' in data.data); + console.log('- producting值:', data.data.producting); console.log('- 完整字段:', Object.keys(data.data)); } return data;