From db372894f6a623a4630c923552b4a41d92fd3af3 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, 23 Feb 2026 11:19:30 +0800 Subject: [PATCH] =?UTF-8?q?bargaining=E5=8F=AF=E4=BB=A5=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=8C1=E4=B8=BA=E4=B8=8D=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E8=AE=B2=E4=BB=B7=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods-detail/goods-detail.wxml | 4 +-- pages/goods-update/goods-update.js | 26 ++++++++++++++++--- pages/goods-update/goods-update.wxss | 37 ++++++++++++++++++++++++++++ server-example/server-mysql.js | 7 +++++- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/pages/goods-detail/goods-detail.wxml b/pages/goods-detail/goods-detail.wxml index 0fb880c..82ead44 100644 --- a/pages/goods-detail/goods-detail.wxml +++ b/pages/goods-detail/goods-detail.wxml @@ -420,7 +420,7 @@ disabled="{{fromChatDetail}}" wx:if="{{goodsDetail.bargaining === 0 && goodsDetail.status !== 'sold_out' && goodsDetail.status !== 'sold' && goodsDetail.status !== 'out_of_stock' && !goodsDetail.supplyStatus.includes('售空')}}" > - 讲价 + 还价 diff --git a/pages/goods-update/goods-update.js b/pages/goods-update/goods-update.js index 847b7df..77df92f 100644 --- a/pages/goods-update/goods-update.js +++ b/pages/goods-update/goods-update.js @@ -368,7 +368,8 @@ Page({ yolk: '', spec: '', region: '', - grossWeight: '' + grossWeight: '', + bargaining: 1 }, // 图片缩放相关状态 scale: 1, // 当前缩放比例 @@ -1105,7 +1106,8 @@ Page({ grossWeight: goodsDetail.grossWeight || '', product_contact: goodsDetail.product_contact || '', contact_phone: goodsDetail.contact_phone || '', - description: goodsDetail.description || goodsDetail.remark || '' + description: goodsDetail.description || goodsDetail.remark || '', + bargaining: goodsDetail.bargaining !== undefined ? goodsDetail.bargaining : 1 }; // 保存原始规格和价格信息,用于比较差异 @@ -1128,11 +1130,28 @@ Page({ }); }, + // 切换讲价状态 + toggleBargain: function(e) { + const canBargain = e.currentTarget.dataset.canbargain === 'true'; + const newBargainingValue = canBargain ? 0 : 1; + console.log('【toggleBargain】canBargain:', canBargain); + console.log('【toggleBargain】newBargainingValue:', newBargainingValue); + this.setData({ + 'editSupply.bargaining': newBargainingValue + }); + // 打印更新后的值 + setTimeout(() => { + console.log('【toggleBargain】更新后的值:', this.data.editSupply.bargaining); + }, 100); + }, + // 保存编辑 saveEdit: function() { console.log('保存编辑'); const editSupply = this.data.editSupply; const goodsDetail = this.data.goodsDetail; + console.log('【saveEdit】editSupply完整对象:', JSON.stringify(editSupply, null, 2)); + console.log('【saveEdit】editSupply.bargaining:', editSupply.bargaining); // 处理价格字段,将价格数组合并成字符串 let priceStr = ''; @@ -1226,7 +1245,8 @@ Page({ price: priceStr, product_contact: editSupply.product_contact || '', contact_phone: editSupply.contact_phone || '', - description: editSupply.description || '' + description: editSupply.description || '', + bargaining: editSupply.bargaining !== undefined ? editSupply.bargaining : 0 }; console.log('【saveEdit】快速更新数据:', updateData); diff --git a/pages/goods-update/goods-update.wxss b/pages/goods-update/goods-update.wxss index de6c7b0..ab03b2b 100644 --- a/pages/goods-update/goods-update.wxss +++ b/pages/goods-update/goods-update.wxss @@ -1088,6 +1088,43 @@ video.slider-media .wx-video-volume-icon { font-family: inherit; } +/* 讲价按钮样式 */ +.bargain-buttons { + display: flex; + gap: 20rpx; + margin-bottom: 60rpx; + width: 100%; + position: relative; + z-index: 1; +} + +.bargain-button { + flex: 1; + height: 90rpx; + line-height: 90rpx; + font-size: 30rpx; + border: 2rpx solid #eee; + border-radius: 12rpx; + background: white; + color: #666; + padding: 0; + margin: 0; + font-family: inherit; + transition: all 0.3s ease; + position: relative; + z-index: 1; +} + +.bargain-button.active { + background: #07c160; + color: white; + border-color: #07c160; +} + +.bargain-button::after { + border: none; +} + /* 模态框样式 */ .modal { position: fixed; diff --git a/server-example/server-mysql.js b/server-example/server-mysql.js index 3e3044a..1b545a2 100644 --- a/server-example/server-mysql.js +++ b/server-example/server-mysql.js @@ -8688,7 +8688,7 @@ app.post('/api/products/update-contacts', async (req, res) => { app.post('/api/products/quick-update', async (req, res) => { console.log('【快速更新】收到请求:', req.body); try { - const { productId, price, product_contact, contact_phone, description } = req.body; + const { productId, price, product_contact, contact_phone, description, bargaining } = req.body; if (!productId) { return res.status(400).json({ @@ -8738,6 +8738,11 @@ app.post('/api/products/quick-update', async (req, res) => { updateFields.description = description; console.log('【快速更新】更新货源描述:', description); } + + if (bargaining !== undefined) { + updateFields.bargaining = bargaining; + console.log('【快速更新】更新讲价状态:', bargaining); + } // 执行更新 await Product.update(updateFields, {