实现订单详情页面
This commit is contained in:
parent
fc428269ed
commit
99a544e643
|
@ -4,77 +4,97 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Order Information</title>
|
<title>Order Information</title>
|
||||||
|
<!-- 引入 Google Fonts 和 Bootstrap -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: 'Inter', sans-serif;
|
||||||
|
background: linear-gradient(135deg, #e0eafc, #cfdef3);
|
||||||
|
color: #333;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
}
|
||||||
.container {
|
.container {
|
||||||
width: 80%;
|
margin: 40px auto;
|
||||||
margin: 20px auto;
|
background: #ffffff;
|
||||||
background: #fff;
|
padding: 20px 30px;
|
||||||
padding: 20px;
|
border-radius: 12px;
|
||||||
border-radius: 8px;
|
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
max-width: 90%;
|
||||||
}
|
}
|
||||||
table {
|
h2 {
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
table th, table td {
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
padding: 8px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
table th {
|
|
||||||
background-color: #f2f2f2;
|
|
||||||
}
|
|
||||||
.pagination {
|
|
||||||
margin: 20px 0;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 30px;
|
||||||
}
|
}
|
||||||
.pagination button {
|
.table {
|
||||||
margin: 0 5px;
|
margin-top: 20px;
|
||||||
padding: 10px 20px;
|
|
||||||
border: none;
|
|
||||||
background-color: #007bff;
|
|
||||||
color: white;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
}
|
||||||
.pagination button[disabled] {
|
.table th, .table td {
|
||||||
background-color: #ccc;
|
vertical-align: middle;
|
||||||
cursor: not-allowed;
|
}
|
||||||
|
.table th {
|
||||||
|
background: #f7f9fc;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.pagination-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
.pagination-container span {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
transition: background-color 0.3s ease, transform 0.2s ease;
|
||||||
|
}
|
||||||
|
.btn:hover {
|
||||||
|
background-color: #0056b3;
|
||||||
|
transform: scale(1.05);
|
||||||
|
}
|
||||||
|
.loading {
|
||||||
|
display: none;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Order Information</h2>
|
<h2>Order Information</h2>
|
||||||
<table id="orderTable">
|
<div class="table-responsive">
|
||||||
<thead>
|
<table class="table table-striped table-bordered">
|
||||||
<tr>
|
<thead>
|
||||||
<th>Order ID</th>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Order ID</th>
|
||||||
<th>Phone</th>
|
<th>Name</th>
|
||||||
<th>Email</th>
|
<th>Phone</th>
|
||||||
<th>Quantity</th>
|
<th>Email</th>
|
||||||
<th>Payment Method</th>
|
<th>Quantity</th>
|
||||||
<th>From Address</th>
|
<th>Payment Method</th>
|
||||||
<th>Create Timestamp</th>
|
<th>From Address</th>
|
||||||
<th>Update Timestamp</th>
|
<th>Create Timestamp</th>
|
||||||
<th>Status</th>
|
<th>Update Timestamp</th>
|
||||||
</tr>
|
<th>Status</th>
|
||||||
</thead>
|
</tr>
|
||||||
<tbody>
|
</thead>
|
||||||
<!-- Orders will be dynamically inserted here -->
|
<tbody id="orderTableBody">
|
||||||
</tbody>
|
<!-- Orders will be dynamically inserted here -->
|
||||||
</table>
|
</tbody>
|
||||||
<div class="pagination">
|
</table>
|
||||||
<button id="prevPageBtn" disabled>Previous</button>
|
</div>
|
||||||
<button id="nextPageBtn">Next</button>
|
<div class="pagination-container">
|
||||||
|
<button class="btn btn-primary" id="prevPageBtn" disabled>Previous</button>
|
||||||
|
<span id="currentPage">Page: 1</span>
|
||||||
|
<button class="btn btn-primary" id="nextPageBtn">Next</button>
|
||||||
|
</div>
|
||||||
|
<div class="loading" id="loading">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
<span class="visually-hidden">Loading...</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -88,9 +108,12 @@
|
||||||
queryParams.page = queryParams.page || 1;
|
queryParams.page = queryParams.page || 1;
|
||||||
queryParams.pageSize = queryParams.pageSize || 10;
|
queryParams.pageSize = queryParams.pageSize || 10;
|
||||||
|
|
||||||
// 查询接口
|
|
||||||
const apiBaseUrl = 'http://127.0.0.1:5000';
|
const apiBaseUrl = 'http://127.0.0.1:5000';
|
||||||
|
|
||||||
async function queryOrder() {
|
async function queryOrder() {
|
||||||
|
const loading = document.getElementById('loading');
|
||||||
|
loading.style.display = 'block'; // 显示加载动画
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${apiBaseUrl}/queryOrder`, {
|
const response = await fetch(`${apiBaseUrl}/queryOrder`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -101,16 +124,19 @@
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Failed to query orders');
|
throw new Error('Failed to query orders');
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
renderTable(data.orders);
|
renderTable(data.orders);
|
||||||
updatePaginationButtons(data.totalOrders);
|
updatePaginationButtons(data.totalOrders);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Network or server error:', error);
|
console.error('Network or server error:', error);
|
||||||
|
} finally {
|
||||||
|
loading.style.display = 'none'; // 隐藏加载动画
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTable(orders) {
|
function renderTable(orders) {
|
||||||
const tbody = document.querySelector('#orderTable tbody');
|
const tbody = document.getElementById('orderTableBody');
|
||||||
tbody.innerHTML = ''; // 清空表格内容
|
tbody.innerHTML = ''; // 清空表格内容
|
||||||
orders.forEach(order => {
|
orders.forEach(order => {
|
||||||
const row = `
|
const row = `
|
||||||
|
@ -131,14 +157,13 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新分页按钮状态
|
|
||||||
function updatePaginationButtons(totalOrders) {
|
function updatePaginationButtons(totalOrders) {
|
||||||
const totalPages = Math.ceil(totalOrders / queryParams.pageSize);
|
const totalPages = Math.ceil(totalOrders / queryParams.pageSize);
|
||||||
document.getElementById('prevPageBtn').disabled = queryParams.page <= 1;
|
document.getElementById('prevPageBtn').disabled = queryParams.page <= 1;
|
||||||
document.getElementById('nextPageBtn').disabled = queryParams.page >= totalPages;
|
document.getElementById('nextPageBtn').disabled = queryParams.page >= totalPages;
|
||||||
|
document.getElementById('currentPage').textContent = `Page: ${queryParams.page}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 翻页操作
|
|
||||||
document.getElementById('prevPageBtn').addEventListener('click', () => {
|
document.getElementById('prevPageBtn').addEventListener('click', () => {
|
||||||
if (queryParams.page > 1) {
|
if (queryParams.page > 1) {
|
||||||
queryParams.page -= 1;
|
queryParams.page -= 1;
|
||||||
|
@ -151,7 +176,6 @@
|
||||||
queryOrder();
|
queryOrder();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 页面加载时查询第一页
|
|
||||||
queryOrder();
|
queryOrder();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue