Browse Source

bargaining可以正常更新,1为不展示讲价按钮

Xfy
徐飞洋 2 weeks ago
parent
commit
db372894f6
  1. 4
      pages/goods-detail/goods-detail.wxml
  2. 26
      pages/goods-update/goods-update.js
  3. 37
      pages/goods-update/goods-update.wxss
  4. 7
      server-example/server-mysql.js

4
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('售空')}}"
>
</button>
<button
class="chat-button bottom-button"
@ -428,7 +428,7 @@
data-id="{{goodsDetail.id}}"
disabled="{{fromChatDetail}}"
>
💬 咨询
💬 留言
</button>
</view>
<!-- 返回按钮区域(仅在seller页面查看时显示) -->

26
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);

37
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;

7
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, {

Loading…
Cancel
Save