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' }