feat: 添加钱包列表的标签切换功能,优化钱包展示逻辑和样式
This commit is contained in:
@@ -1,14 +1,30 @@
|
||||
<script lang='ts' setup>
|
||||
import { arrowDownOutline, arrowUpOutline, cardOutline, swapHorizontalOutline, syncOutline } from "ionicons/icons";
|
||||
|
||||
const baseWalletsCode = ["balance", "profit", "team", "check_in", "meeting_reward", "reform_pioneer_allowance", "reform_monthly_enjoy"];
|
||||
|
||||
const router = useRouter();
|
||||
const walletStore = useWalletStore();
|
||||
const { wallets } = storeToRefs(walletStore);
|
||||
const baseWallets = computed(() => wallets.value.filter(w => baseWalletsCode.includes(w.walletType.code)));
|
||||
const otherWallets = computed(() => wallets.value.filter(w => !baseWalletsCode.includes(w.walletType.code)));
|
||||
|
||||
// 当前激活的tab: base 基础资产, livelihood 七大民生保障
|
||||
const activeTab = ref<"base" | "livelihood">("base");
|
||||
|
||||
// 当前显示的钱包列表
|
||||
const displayWallets = computed(() => {
|
||||
return activeTab.value === "base" ? baseWallets.value : otherWallets.value;
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await walletStore.syncWallets();
|
||||
});
|
||||
|
||||
function switchTab(tab: typeof activeTab.value) {
|
||||
activeTab.value = tab;
|
||||
}
|
||||
|
||||
function formatAmount(amount: number | string) {
|
||||
const num = Number(amount);
|
||||
return num.toLocaleString("zh-CN", {
|
||||
@@ -69,10 +85,31 @@ function handleAction(actionId: string) {
|
||||
我的钱包
|
||||
</div>
|
||||
</div>
|
||||
<empty v-if="wallets.length === 0" class="my-10" />
|
||||
|
||||
<!-- Tab 切换栏 -->
|
||||
<div class="tab-bar">
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'base' }"
|
||||
@click="switchTab('base')"
|
||||
>
|
||||
<span>基础资产</span>
|
||||
<div v-if="activeTab === 'base'" class="tab-indicator" />
|
||||
</div>
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'livelihood' }"
|
||||
@click="switchTab('livelihood')"
|
||||
>
|
||||
<span>七大民生保障</span>
|
||||
<div v-if="activeTab === 'livelihood'" class="tab-indicator" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<empty v-if="displayWallets.length === 0" class="my-10" title="暂无钱包" />
|
||||
<div v-else class="wallet-grid">
|
||||
<div
|
||||
v-for="wallet in wallets"
|
||||
v-for="wallet in displayWallets"
|
||||
:key="wallet.id"
|
||||
class="wallet-card"
|
||||
>
|
||||
@@ -131,6 +168,50 @@ function handleAction(actionId: string) {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.tab-bar {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
margin-bottom: 16px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 12px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.tab-item.active {
|
||||
background: white;
|
||||
color: var(--ion-color-primary);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.tab-item:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.tab-indicator {
|
||||
position: absolute;
|
||||
bottom: 2px;
|
||||
width: 20px;
|
||||
height: 3px;
|
||||
background: var(--ion-color-primary);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.wallet-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user