From df3be587d88a6e6588bfa1a8472adb324f5bb600 Mon Sep 17 00:00:00 2001
From: aaron <>
Date: Mon, 11 Aug 2025 10:42:22 +0800
Subject: [PATCH] update
---
public/css/admin.css | 64 ++++++++++++++++++++++++++++++++++++++++++++
public/js/admin.js | 42 +++++++++++++++++++++++++++++
server.js | 35 ++++++++++++++++++++++++
3 files changed, 141 insertions(+)
diff --git a/public/css/admin.css b/public/css/admin.css
index f071409..40e2475 100644
--- a/public/css/admin.css
+++ b/public/css/admin.css
@@ -1,5 +1,49 @@
/* 订单管理页面样式 */
+/* 管理页面头部样式 */
+header {
+ text-align: center;
+ padding: 40px 20px;
+ background: linear-gradient(145deg, #1a1a1a 0%, #2d2d2d 100%);
+ border-radius: 20px;
+ margin-bottom: 40px;
+ box-shadow:
+ 0 20px 40px rgba(0, 0, 0, 0.4),
+ inset 0 1px 0 rgba(255, 255, 255, 0.1);
+ border: 1px solid #333;
+ position: relative;
+ overflow: hidden;
+}
+
+header::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ height: 4px;
+ background: linear-gradient(90deg, #ffd700, #ffed4a, #ffd700);
+}
+
+header h1 {
+ font-size: 2.5em;
+ color: #ffffff;
+ margin-bottom: 10px;
+ font-weight: 700;
+ background: linear-gradient(45deg, #ffd700, #ffed4a);
+ -webkit-background-clip: text;
+ -webkit-text-fill-color: transparent;
+ background-clip: text;
+ text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
+}
+
+header p {
+ font-size: 1.1em;
+ color: #b0b0b0;
+ margin: 0;
+ font-weight: 400;
+}
+
/* 管理员导航 - 已移除 */
/* 统计卡片 */
@@ -257,6 +301,18 @@
box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}
+.btn-delete {
+ background: linear-gradient(135deg, #dc3545, #c82333);
+ color: #fff;
+ border: 1px solid #dc3545;
+}
+
+.btn-delete:hover {
+ background: linear-gradient(135deg, #c82333, #a71e2a);
+ transform: translateY(-1px);
+ box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
+}
+
/* 订单详情模态框 */
.order-detail-content {
color: #e0e0e0;
@@ -417,6 +473,14 @@
/* 响应式设计 */
@media (max-width: 768px) {
+ header h1 {
+ font-size: 2em;
+ }
+
+ header p {
+ font-size: 1em;
+ }
+
.stats-section {
grid-template-columns: repeat(2, 1fr);
}
diff --git a/public/js/admin.js b/public/js/admin.js
index b50b704..3a2532e 100644
--- a/public/js/admin.js
+++ b/public/js/admin.js
@@ -85,6 +85,9 @@ function updateOrdersTable(orders) {
+
`).join('');
@@ -427,6 +430,45 @@ function formatDate(dateString) {
});
}
+// 确认删除订单
+function confirmDeleteOrder(orderId) {
+ const order = currentOrders.find(o => o.order_id === orderId);
+ if (!order) {
+ alert('订单未找到');
+ return;
+ }
+
+ const confirmMessage = `确认删除以下订单吗?\n\n订单号:${orderId}\n客户:${order.customer_name}\n金额:$${order.total_amount.toFixed(2)} USDT\n\n⚠️ 此操作不可撤销!`;
+
+ if (confirm(confirmMessage)) {
+ deleteOrder(orderId);
+ }
+}
+
+// 删除订单
+async function deleteOrder(orderId) {
+ try {
+ const response = await fetch(`/api/admin/orders/${orderId}`, {
+ method: 'DELETE',
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ });
+
+ const result = await response.json();
+
+ if (response.ok) {
+ alert('订单已成功删除!');
+ loadOrders(); // 重新加载订单列表
+ } else {
+ throw new Error(result.error || '删除订单失败');
+ }
+ } catch (error) {
+ console.error('Delete order error:', error);
+ alert('删除订单失败: ' + error.message);
+ }
+}
+
// 键盘事件监听
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
diff --git a/server.js b/server.js
index fc86ca2..4efa365 100644
--- a/server.js
+++ b/server.js
@@ -411,6 +411,41 @@ app.put('/api/admin/orders/:order_id/shipping', (req, res) => {
);
});
+// 删除订单(管理员)
+app.delete('/api/admin/orders/:order_id', (req, res) => {
+ const { order_id } = req.params;
+
+ // 先查询订单是否存在
+ db.get('SELECT * FROM orders WHERE order_id = ?', [order_id], (err, order) => {
+ if (err) {
+ console.error('Query order error:', err);
+ return res.status(500).json({ error: '查询订单失败' });
+ }
+
+ if (!order) {
+ return res.status(404).json({ error: '订单未找到' });
+ }
+
+ // 删除订单
+ db.run('DELETE FROM orders WHERE order_id = ?', [order_id], function(err) {
+ if (err) {
+ console.error('Delete order error:', err);
+ return res.status(500).json({ error: '删除订单失败' });
+ }
+
+ if (this.changes === 0) {
+ return res.status(404).json({ error: '订单未找到' });
+ }
+
+ res.json({
+ success: true,
+ message: '订单已删除',
+ deleted_order_id: order_id
+ });
+ });
+ });
+});
+
app.listen(PORT, () => {
console.log(`服务器运行在 http://localhost:${PORT}`);
});
\ No newline at end of file