This commit is contained in:
oneao committed 2026-01-29 22:54:15 +08:00
1 parent 295b3306a3
commit c62c9d080b
8 files changed
+878 -136

No files matched your search

+76 -80
View File
@@ -1,91 +1,87 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>全局底部导航 Demo</title>
<style>
body {
margin: 0;
font-family: sans-serif;
background-color: #f0f2f5;
display: flex;
justify-content: center;
align-items: flex-end;
height: 100vh;
}
/* 弹出面板 */
.bottom-panel {
width: 100%;
max-width: 400px;
background: white;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
padding: 16px;
box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
}
/* 每个导航 item */
.nav-item {
background: #f9f9f9;
border-radius: 16px;
padding: 16px 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
cursor: pointer;
transition: transform 0.2s, background 0.2s;
text-align: center;
}
.nav-item:hover {
background: #e0e0ff;
transform: translateY(-3px) scale(1.05);
}
.nav-icon {
font-size: 28px;
margin-bottom: 6px;
}
.nav-name {
font-size: 14px;
font-weight: 600;
}
</style>
<title>财务分析 Demo</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 p-4">
<body>
<!-- Header: 收支切换 -->
<div class="flex justify-center gap-4 mb-4">
<button id="expenseBtn" class="px-4 py-2 rounded-full bg-blue-500 text-white font-semibold">支出</button>
<button id="incomeBtn" class="px-4 py-2 rounded-full bg-gray-200 text-gray-700 font-semibold">收入</button>
</div>
<div class="bottom-panel">
<div class="nav-item" onclick="alert('跳转到首页')">
<div class="nav-icon">🏠</div>
<div class="nav-name">首页</div>
</div>
<div class="nav-item" onclick="alert('跳转到记账')">
<div class="nav-icon">📝</div>
<div class="nav-name">记账</div>
</div>
<div class="nav-item" onclick="alert('跳转到分类')">
<div class="nav-icon">📂</div>
<div class="nav-name">分类</div>
</div>
<div class="nav-item" onclick="alert('跳转到分析')">
<div class="nav-icon">📊</div>
<div class="nav-name">分析</div>
</div>
<div class="nav-item" onclick="alert('跳转到设置')">
<div class="nav-icon">⚙️</div>
<div class="nav-name">设置</div>
<!-- 时间维度选择 -->
<div class="flex justify-center gap-2 mb-4">
<button class="timeBtn px-3 py-1 rounded-full bg-blue-500 text-white font-medium" data-type="month">按月</button>
<button class="timeBtn px-3 py-1 rounded-full bg-gray-200 text-gray-700 font-medium" data-type="year">按年</button>
<button class="timeBtn px-3 py-1 rounded-full bg-gray-200 text-gray-700 font-medium" data-type="custom">自定义</button>
</div>
<!-- 日期选择 -->
<div id="datePickerContainer" class="flex justify-center mb-4">
<!-- 默认显示按月日期选择 -->
<input type="month" id="monthInput" class="p-2 rounded border border-gray-300">
<input type="month" id="yearInput" class="p-2 rounded border border-gray-300 hidden">
<div id="customInput" class="flex gap-2 hidden">
<input type="date" id="startDate" class="p-2 rounded border border-gray-300">
<span class="self-center">~</span>
<input type="date" id="endDate" class="p-2 rounded border border-gray-300">
</div>
</div>
</body>
<!-- 示例图表区域 -->
<div class="bg-white p-4 rounded shadow text-center">
<p class="text-gray-500">这里显示图表或分析结果</p>
</div>
</html>
<script>
const expenseBtn = document.getElementById('expenseBtn')
const incomeBtn = document.getElementById('incomeBtn')
const timeBtns = document.querySelectorAll('.timeBtn')
const monthInput = document.getElementById('monthInput')
const yearInput = document.getElementById('yearInput')
const customInput = document.getElementById('customInput')
// 收支切换逻辑
expenseBtn.addEventListener('click', () => {
expenseBtn.classList.add('bg-blue-500', 'text-white')
expenseBtn.classList.remove('bg-gray-200', 'text-gray-700')
incomeBtn.classList.add('bg-gray-200', 'text-gray-700')
incomeBtn.classList.remove('bg-blue-500', 'text-white')
})
incomeBtn.addEventListener('click', () => {
incomeBtn.classList.add('bg-blue-500', 'text-white')
incomeBtn.classList.remove('bg-gray-200', 'text-gray-700')
expenseBtn.classList.add('bg-gray-200', 'text-gray-700')
expenseBtn.classList.remove('bg-blue-500', 'text-white')
})
// 时间维度切换逻辑
timeBtns.forEach(btn => {
btn.addEventListener('click', () => {
timeBtns.forEach(b => {
b.classList.remove('bg-blue-500', 'text-white')
b.classList.add('bg-gray-200', 'text-gray-700')
})
btn.classList.add('bg-blue-500', 'text-white')
btn.classList.remove('bg-gray-200', 'text-gray-700')
// 显示对应日期选择控件
const type = btn.dataset.type
monthInput.classList.add('hidden')
yearInput.classList.add('hidden')
customInput.classList.add('hidden')
if (type === 'month') monthInput.classList.remove('hidden')
if (type === 'year') yearInput.classList.remove('hidden')
if (type === 'custom') customInput.classList.remove('hidden')
})
})
</script>
</body>
</html>