2024-11-22 03:54:56 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Order Information</title>
|
2024-11-22 06:21:33 +00:00
|
|
|
<!-- 引入 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">
|
2024-11-22 03:54:56 +00:00
|
|
|
<style>
|
|
|
|
body {
|
2024-11-22 06:21:33 +00:00
|
|
|
font-family: 'Inter', sans-serif;
|
|
|
|
background: linear-gradient(135deg, #e0eafc, #cfdef3);
|
|
|
|
color: #333;
|
2024-11-22 03:54:56 +00:00
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
.container {
|
2024-11-22 06:21:33 +00:00
|
|
|
margin: 40px auto;
|
|
|
|
background: #ffffff;
|
|
|
|
padding: 20px 30px;
|
|
|
|
border-radius: 12px;
|
|
|
|
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
|
|
|
|
max-width: 90%;
|
2024-11-22 03:54:56 +00:00
|
|
|
}
|
2024-11-22 06:21:33 +00:00
|
|
|
h2 {
|
|
|
|
text-align: center;
|
|
|
|
font-weight: 700;
|
|
|
|
margin-bottom: 30px;
|
2024-11-22 03:54:56 +00:00
|
|
|
}
|
2024-11-22 06:21:33 +00:00
|
|
|
.table {
|
|
|
|
margin-top: 20px;
|
2024-11-22 03:54:56 +00:00
|
|
|
}
|
2024-11-22 06:21:33 +00:00
|
|
|
.table th, .table td {
|
|
|
|
vertical-align: middle;
|
2024-11-22 03:54:56 +00:00
|
|
|
}
|
2024-11-22 06:21:33 +00:00
|
|
|
.table th {
|
|
|
|
background: #f7f9fc;
|
|
|
|
font-weight: 600;
|
|
|
|
}
|
|
|
|
.pagination-container {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 20px;
|
2024-11-22 03:54:56 +00:00
|
|
|
}
|
2024-11-22 06:21:33 +00:00
|
|
|
.pagination-container span {
|
|
|
|
font-weight: 500;
|
|
|
|
color: #666;
|
2024-11-22 03:54:56 +00:00
|
|
|
}
|
2024-11-22 06:21:33 +00:00
|
|
|
.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;
|
2024-11-22 03:54:56 +00:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="container">
|
|
|
|
<h2>Order Information</h2>
|
2024-11-22 06:21:33 +00:00
|
|
|
<div class="table-responsive">
|
|
|
|
<table class="table table-striped table-bordered">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Order ID</th>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Phone</th>
|
|
|
|
<th>Email</th>
|
|
|
|
<th>Quantity</th>
|
|
|
|
<th>Payment Method</th>
|
|
|
|
<th>From Address</th>
|
|
|
|
<th>Create Timestamp</th>
|
|
|
|
<th>Update Timestamp</th>
|
|
|
|
<th>Status</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="orderTableBody">
|
|
|
|
<!-- Orders will be dynamically inserted here -->
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<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>
|
2024-11-22 03:54:56 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
const queryParams = JSON.parse(sessionStorage.getItem('queryParams'));
|
|
|
|
if (!queryParams) {
|
|
|
|
console.error('Query parameters not found.');
|
|
|
|
alert('No query parameters found. Please return to the index page.');
|
|
|
|
window.location.href = '/index.html';
|
|
|
|
}
|
|
|
|
queryParams.page = queryParams.page || 1;
|
|
|
|
queryParams.pageSize = queryParams.pageSize || 10;
|
|
|
|
|
|
|
|
const apiBaseUrl = 'http://127.0.0.1:5000';
|
2024-11-22 06:21:33 +00:00
|
|
|
|
2024-11-22 03:54:56 +00:00
|
|
|
async function queryOrder() {
|
2024-11-22 06:21:33 +00:00
|
|
|
const loading = document.getElementById('loading');
|
|
|
|
loading.style.display = 'block'; // 显示加载动画
|
|
|
|
|
2024-11-22 03:54:56 +00:00
|
|
|
try {
|
|
|
|
const response = await fetch(`${apiBaseUrl}/queryOrder`, {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {'Content-Type': 'application/json'},
|
|
|
|
body: JSON.stringify(queryParams)
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error('Failed to query orders');
|
|
|
|
}
|
2024-11-22 06:21:33 +00:00
|
|
|
|
2024-11-22 03:54:56 +00:00
|
|
|
const data = await response.json();
|
|
|
|
renderTable(data.orders);
|
|
|
|
updatePaginationButtons(data.totalOrders);
|
|
|
|
} catch (error) {
|
|
|
|
console.error('Network or server error:', error);
|
2024-11-22 06:21:33 +00:00
|
|
|
} finally {
|
|
|
|
loading.style.display = 'none'; // 隐藏加载动画
|
2024-11-22 03:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderTable(orders) {
|
2024-11-22 06:21:33 +00:00
|
|
|
const tbody = document.getElementById('orderTableBody');
|
2024-11-22 03:54:56 +00:00
|
|
|
tbody.innerHTML = ''; // 清空表格内容
|
|
|
|
orders.forEach(order => {
|
|
|
|
const row = `
|
|
|
|
<tr>
|
|
|
|
<td>${order[0]}</td>
|
|
|
|
<td>${order[1]}</td>
|
|
|
|
<td>${order[2]}</td>
|
|
|
|
<td>${order[3]}</td>
|
|
|
|
<td>${order[4]}</td>
|
|
|
|
<td>${order[5]}</td>
|
|
|
|
<td>${order[6]}</td>
|
|
|
|
<td>${order[7]}</td>
|
|
|
|
<td>${order[8]}</td>
|
|
|
|
<td>${order[9]}</td>
|
|
|
|
</tr>
|
|
|
|
`;
|
|
|
|
tbody.insertAdjacentHTML('beforeend', row);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function updatePaginationButtons(totalOrders) {
|
|
|
|
const totalPages = Math.ceil(totalOrders / queryParams.pageSize);
|
|
|
|
document.getElementById('prevPageBtn').disabled = queryParams.page <= 1;
|
|
|
|
document.getElementById('nextPageBtn').disabled = queryParams.page >= totalPages;
|
2024-11-22 06:21:33 +00:00
|
|
|
document.getElementById('currentPage').textContent = `Page: ${queryParams.page}`;
|
2024-11-22 03:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById('prevPageBtn').addEventListener('click', () => {
|
|
|
|
if (queryParams.page > 1) {
|
|
|
|
queryParams.page -= 1;
|
|
|
|
queryOrder();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById('nextPageBtn').addEventListener('click', () => {
|
|
|
|
queryParams.page += 1;
|
|
|
|
queryOrder();
|
|
|
|
});
|
|
|
|
|
|
|
|
queryOrder();
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|