From bbf531f356690d1c244aa51d4be7066fa3bd29c5 Mon Sep 17 00:00:00 2001 From: Default User Date: Wed, 7 Jan 2026 16:30:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DautoOfflineTime=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=97=AE=E9=A2=98=EF=BC=9A=201.=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E7=BC=96=E8=BE=91API=E6=B7=BB=E5=8A=A0autoOfflineTime=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=9B=B4=E6=96=B0=202.=20=E4=BF=AE=E5=A4=8D=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=97=B6=E9=97=B4=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=88=E7=A7=BB=E9=99=A4=E9=94=99=E8=AF=AF=E7=9A=84+8?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E5=81=8F=E7=A7=BB=EF=BC=89=203.=20=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E8=BF=94=E5=9B=9E=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E5=8E=9F=E6=A0=B7=E4=B8=8D=E5=81=9A=E9=A2=9D?= =?UTF-8?q?=E5=A4=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reject.js | 5 +++-- supply.html | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Reject.js b/Reject.js index be708d7..e6b330e 100644 --- a/Reject.js +++ b/Reject.js @@ -1353,7 +1353,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { try { const connection = await pool.getConnection(); const productId = req.params.id; - const { productName, price, costprice, quantity, grossWeight, yolk, specification, supplyStatus, description, region, contactId, producting, imageUrls } = req.body; + const { productName, price, costprice, quantity, grossWeight, yolk, specification, supplyStatus, description, region, contactId, producting, imageUrls, autoOfflineTime } = req.body; // 开始事务 await connection.beginTransaction(); @@ -1463,7 +1463,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { SET productName = ?, price = ?, costprice = ?, quantity = ?, grossWeight = ?, yolk = ?, specification = ?, producting = ?, supplyStatus = ?, description = ?, region = ?, product_contact = ?, contact_phone = ?, imageUrls = ?, - autoOfflineHours = ?, updated_at = ? + autoOfflineTime = ?, autoOfflineHours = ?, updated_at = ? WHERE id = ? `; @@ -1471,6 +1471,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { productName, price.toString(), costprice || '', quantityValue, grossWeight, yolk, specification, producting, supplyStatus, description, region, productContact, contactPhone, JSON.stringify(uploadedImageUrls), + autoOfflineTime || null, // 自动下架时间 req.body.autoOfflineHours || 24, // 默认24小时 new Date(), // 更新updated_at字段 productId diff --git a/supply.html b/supply.html index 5354786..27c87bb 100644 --- a/supply.html +++ b/supply.html @@ -5944,6 +5944,13 @@ // 计算自动下架时间(当前时间 + 分钟数) const autoOfflineTime = new Date(); autoOfflineTime.setMinutes(autoOfflineTime.getMinutes() + minutes); + // 格式化为数据库存储的北京时间格式 (YYYY-MM-DD HH:mm:ss) + const autoOfflineTimeStr = autoOfflineTime.getFullYear() + '-' + + String(autoOfflineTime.getMonth() + 1).padStart(2, '0') + '-' + + String(autoOfflineTime.getDate()).padStart(2, '0') + ' ' + + String(autoOfflineTime.getHours()).padStart(2, '0') + ':' + + String(autoOfflineTime.getMinutes()).padStart(2, '0') + ':' + + String(autoOfflineTime.getSeconds()).padStart(2, '0'); const formData = { productName: document.getElementById('productName').value, @@ -5966,7 +5973,7 @@ sellerId: userInfo.userId, // 添加当前登录用户的userId作为sellerId autoOfflineDays: null, // 不再使用天数,设置为null autoOfflineHours: autoOfflineHours, - autoOfflineTime: autoOfflineTime.toISOString() + autoOfflineTime: autoOfflineTimeStr }; // 验证表单 @@ -7785,7 +7792,13 @@ // 计算自动下架时间(当前时间 + 分钟数) const autoOfflineTime = new Date(); autoOfflineTime.setMinutes(autoOfflineTime.getMinutes() + minutes); - const autoOfflineTimeISO = autoOfflineTime.toISOString(); + // 格式化为数据库存储的北京时间格式 (YYYY-MM-DD HH:mm:ss) + const autoOfflineTimeStr = autoOfflineTime.getFullYear() + '-' + + String(autoOfflineTime.getMonth() + 1).padStart(2, '0') + '-' + + String(autoOfflineTime.getDate()).padStart(2, '0') + ' ' + + String(autoOfflineTime.getHours()).padStart(2, '0') + ':' + + String(autoOfflineTime.getMinutes()).padStart(2, '0') + ':' + + String(autoOfflineTime.getSeconds()).padStart(2, '0'); const formData = { productName: document.getElementById('editProductName').value, @@ -7805,7 +7818,7 @@ contactId: document.getElementById('editContactId').value, freshness: document.getElementById('editFreshness').value, imageUrls: editCurrentImages, // 添加编辑后的图片列表 - autoOfflineTime: autoOfflineTimeISO, // 自动下架时间 + autoOfflineTime: autoOfflineTimeStr, // 自动下架时间 autoOfflineDays: null, // 不再使用天数,设置为null autoOfflineHours: autoOfflineHours // 自动下架小时数(分钟转换而来) };