|
@@ -131,6 +131,22 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
+ <div class="row mb-3">
|
|
|
|
+ <div class="col-12">
|
|
|
|
+ <div class="d-flex justify-content-between align-items-center">
|
|
|
|
+ <h5 id="currentDate" class="mb-0"></h5>
|
|
|
|
+ <div>
|
|
|
|
+ <button class="btn btn-outline-primary me-2" onclick="loadPreviousDay()">
|
|
|
|
+ <i class="bi bi-arrow-left"></i> 查看前一天
|
|
|
|
+ </button>
|
|
|
|
+ <button class="btn btn-outline-primary" onclick="loadNextDay()" id="nextDayBtn">
|
|
|
|
+ 查看后一天 <i class="bi bi-arrow-right"></i>
|
|
|
|
+ </button>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
<div class="card">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="card-header">
|
|
<span>交易记录</span>
|
|
<span>交易记录</span>
|
|
@@ -238,6 +254,7 @@
|
|
<script>
|
|
<script>
|
|
let currentPage = 1;
|
|
let currentPage = 1;
|
|
const pageSize = 10;
|
|
const pageSize = 10;
|
|
|
|
+ let currentDate = new Date();
|
|
|
|
|
|
// 获取URL参数
|
|
// 获取URL参数
|
|
function getUrlParams() {
|
|
function getUrlParams() {
|
|
@@ -247,6 +264,60 @@
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 格式化日期为 YYYY-MM-DD
|
|
|
|
+ function formatDate(date) {
|
|
|
|
+ const year = date.getFullYear();
|
|
|
|
+ const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
|
+ const day = String(date.getDate()).padStart(2, '0');
|
|
|
|
+ return `${year}-${month}-${day}`;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 检查是否是今天
|
|
|
|
+ function isToday(date) {
|
|
|
|
+ const today = new Date();
|
|
|
|
+ return date.getDate() === today.getDate() &&
|
|
|
|
+ date.getMonth() === today.getMonth() &&
|
|
|
|
+ date.getFullYear() === today.getFullYear();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新当前日期显示和按钮状态
|
|
|
|
+ function updateDateDisplay() {
|
|
|
|
+ const dateStr = formatDate(currentDate);
|
|
|
|
+ document.getElementById('currentDate').textContent = dateStr;
|
|
|
|
+
|
|
|
|
+ // 如果是今天,禁用"查看后一天"按钮
|
|
|
|
+ const nextDayBtn = document.getElementById('nextDayBtn');
|
|
|
|
+ if (isToday(currentDate)) {
|
|
|
|
+ nextDayBtn.disabled = true;
|
|
|
|
+ nextDayBtn.classList.add('disabled');
|
|
|
|
+ } else {
|
|
|
|
+ nextDayBtn.disabled = false;
|
|
|
|
+ nextDayBtn.classList.remove('disabled');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 加载前一天的账单
|
|
|
|
+ function loadPreviousDay() {
|
|
|
|
+ currentDate.setDate(currentDate.getDate() - 1);
|
|
|
|
+ updateDateDisplay();
|
|
|
|
+ loadTransactions(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 加载后一天的账单
|
|
|
|
+ function loadNextDay() {
|
|
|
|
+ const nextDate = new Date(currentDate);
|
|
|
|
+ nextDate.setDate(nextDate.getDate() + 1);
|
|
|
|
+
|
|
|
|
+ // 如果后一天超过今天,则不执行
|
|
|
|
+ if (nextDate > new Date()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ currentDate = nextDate;
|
|
|
|
+ updateDateDisplay();
|
|
|
|
+ loadTransactions(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
// 加载交易记录
|
|
// 加载交易记录
|
|
async function loadTransactions(page = 1) {
|
|
async function loadTransactions(page = 1) {
|
|
try {
|
|
try {
|
|
@@ -256,12 +327,7 @@
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- // 获取今天的日期(考虑时区)
|
|
|
|
- const today = new Date();
|
|
|
|
- const year = today.getFullYear();
|
|
|
|
- const month = String(today.getMonth() + 1).padStart(2, '0');
|
|
|
|
- const day = String(today.getDate()).padStart(2, '0');
|
|
|
|
- const startDate = `${year}-${month}-${day}`;
|
|
|
|
|
|
+ const startDate = formatDate(currentDate);
|
|
const endDate = startDate;
|
|
const endDate = startDate;
|
|
|
|
|
|
console.log('日期范围:', { startDate, endDate });
|
|
console.log('日期范围:', { startDate, endDate });
|
|
@@ -280,16 +346,16 @@
|
|
const data = await response.json();
|
|
const data = await response.json();
|
|
console.log('获取到的数据:', data);
|
|
console.log('获取到的数据:', data);
|
|
|
|
|
|
- // 过滤掉非今天的记录
|
|
|
|
- const todayTransactions = data.transactions.filter(transaction => {
|
|
|
|
|
|
+ // 过滤掉非当前日期的记录
|
|
|
|
+ const dayTransactions = data.transactions.filter(transaction => {
|
|
const transactionDate = new Date(transaction.time).toISOString().split('T')[0];
|
|
const transactionDate = new Date(transaction.time).toISOString().split('T')[0];
|
|
return transactionDate === startDate;
|
|
return transactionDate === startDate;
|
|
});
|
|
});
|
|
|
|
|
|
- console.log('今日交易记录:', todayTransactions);
|
|
|
|
|
|
+ console.log('当日交易记录:', dayTransactions);
|
|
|
|
|
|
- // 计算今日收入
|
|
|
|
- const todayIncome = todayTransactions.reduce((sum, transaction) => {
|
|
|
|
|
|
+ // 计算当日收入
|
|
|
|
+ const dayIncome = dayTransactions.reduce((sum, transaction) => {
|
|
if (transaction.type === 'deposit') {
|
|
if (transaction.type === 'deposit') {
|
|
return sum + parseFloat(transaction.amount);
|
|
return sum + parseFloat(transaction.amount);
|
|
}
|
|
}
|
|
@@ -298,17 +364,17 @@
|
|
|
|
|
|
// 更新统计数据
|
|
// 更新统计数据
|
|
const statistics = {
|
|
const statistics = {
|
|
- todayIncome: todayIncome,
|
|
|
|
- todayOrders: todayTransactions.length
|
|
|
|
|
|
+ todayIncome: dayIncome,
|
|
|
|
+ todayOrders: dayTransactions.length
|
|
};
|
|
};
|
|
|
|
|
|
- updateTransactionsList(todayTransactions);
|
|
|
|
- updatePagination(todayTransactions.length, page);
|
|
|
|
|
|
+ updateTransactionsList(dayTransactions);
|
|
|
|
+ updatePagination(dayTransactions.length, page);
|
|
updateStatistics(statistics);
|
|
updateStatistics(statistics);
|
|
|
|
|
|
// 使用最新一条记录的数据更新账单总结
|
|
// 使用最新一条记录的数据更新账单总结
|
|
- if (todayTransactions.length > 0) {
|
|
|
|
- const latestRecord = todayTransactions[0];
|
|
|
|
|
|
+ if (dayTransactions.length > 0) {
|
|
|
|
+ const latestRecord = dayTransactions[0];
|
|
console.log('最新记录:', latestRecord);
|
|
console.log('最新记录:', latestRecord);
|
|
|
|
|
|
const summary = {
|
|
const summary = {
|
|
@@ -316,14 +382,14 @@
|
|
totalWithdraw: latestRecord.totalWithdrawal,
|
|
totalWithdraw: latestRecord.totalWithdrawal,
|
|
totalUDeposit: latestRecord.totalUDeposit,
|
|
totalUDeposit: latestRecord.totalUDeposit,
|
|
totalUWithdrawal: latestRecord.totalUWithdrawal,
|
|
totalUWithdrawal: latestRecord.totalUWithdrawal,
|
|
- depositCount: todayTransactions.filter(t => t.type === 'deposit').length,
|
|
|
|
- withdrawCount: todayTransactions.filter(t => t.type === 'withdrawal').length
|
|
|
|
|
|
+ depositCount: dayTransactions.filter(t => t.type === 'deposit').length,
|
|
|
|
+ withdrawCount: dayTransactions.filter(t => t.type === 'withdrawal').length
|
|
};
|
|
};
|
|
|
|
|
|
console.log('账单总结数据:', summary);
|
|
console.log('账单总结数据:', summary);
|
|
updateSummary(summary);
|
|
updateSummary(summary);
|
|
} else {
|
|
} else {
|
|
- console.log('没有今日交易记录');
|
|
|
|
|
|
+ console.log('没有当日交易记录');
|
|
updateSummary({
|
|
updateSummary({
|
|
totalDeposit: 0,
|
|
totalDeposit: 0,
|
|
totalWithdraw: 0,
|
|
totalWithdraw: 0,
|
|
@@ -459,8 +525,11 @@
|
|
document.getElementById('balance').textContent = formatAmount(remainingWithdraw);
|
|
document.getElementById('balance').textContent = formatAmount(remainingWithdraw);
|
|
}
|
|
}
|
|
|
|
|
|
- // 页面加载时加载数据
|
|
|
|
- loadTransactions();
|
|
|
|
|
|
+ // 页面加载时初始化
|
|
|
|
+ document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
+ updateDateDisplay();
|
|
|
|
+ loadTransactions();
|
|
|
|
+ });
|
|
</script>
|
|
</script>
|
|
</body>
|
|
</body>
|
|
</html>
|
|
</html>
|