From a28db56a6b0b505da3931000a68b5464e8babb00 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: Sun, 22 Feb 2026 17:24:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=97=E6=AE=B5bargaining?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods-detail/goods-detail.js | 4 ++-- pages/goods-detail/goods-detail.wxml | 2 +- server-example/server-mysql.js | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index d71d059..a24a461 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -2124,8 +2124,8 @@ Page({ region: region, // 添加价格波动信息 specPriceChanges: specPriceChanges, - // 添加讲价字段 - bargaining: product.bargaining !== undefined ? product.bargaining : 0 + // 添加讲价字段,确保为数字类型 + bargaining: product.bargaining !== undefined ? Number(product.bargaining) : 0 }; // 调试:打印formattedGoods的imageUrls和mediaItems diff --git a/pages/goods-detail/goods-detail.wxml b/pages/goods-detail/goods-detail.wxml index 2582332..0fb880c 100644 --- a/pages/goods-detail/goods-detail.wxml +++ b/pages/goods-detail/goods-detail.wxml @@ -418,7 +418,7 @@ bindtap="showBargainModal" data-id="{{goodsDetail.id}}" disabled="{{fromChatDetail}}" - wx:if="{{goodsDetail.bargaining == 0 && goodsDetail.status !== 'sold_out' && goodsDetail.status !== 'sold' && goodsDetail.status !== 'out_of_stock' && !goodsDetail.supplyStatus.includes('售空')}}" + wx:if="{{goodsDetail.bargaining === 0 && goodsDetail.status !== 'sold_out' && goodsDetail.status !== 'sold' && goodsDetail.status !== 'out_of_stock' && !goodsDetail.supplyStatus.includes('售空')}}" > 讲价 diff --git a/server-example/server-mysql.js b/server-example/server-mysql.js index 09b4020..3e3044a 100644 --- a/server-example/server-mysql.js +++ b/server-example/server-mysql.js @@ -1766,6 +1766,13 @@ Product.init({ allowNull: true, comment: '规格状态', defaultValue: '0' + }, + // 讲价字段 + bargaining: { + type: DataTypes.INTEGER, + defaultValue: 0, + allowNull: false, + comment: '是否允许讲价,0允许,1不允许' } }, { sequelize, @@ -5511,7 +5518,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', 'producting', 'product_contact', 'contact_phone', 'region', 'freshness', 'costprice','description', 'frequency', 'product_log', 'spec_status', 'status', 'label'], + attributes: ['productId', 'productName', 'price', 'quantity', 'grossWeight', 'imageUrls', 'created_at', 'specification', 'yolk', 'sourceType', 'supplyStatus', 'producting', 'product_contact', 'contact_phone', 'region', 'freshness', 'costprice','description', 'frequency', 'product_log', 'spec_status', 'status', 'label', 'bargaining'], where: { productId, status: { [Sequelize.Op.not]: 'hidden' }