fix some bugs

This commit is contained in:
2026-08-03 11:52:44 +03:30
parent e41a898686
commit d6608283f6
13 changed files with 1016 additions and 53 deletions
+187
View File
@@ -0,0 +1,187 @@
<template>
<div class="piggy-page">
<header class="piggy-topbar">
<button type="button" class="piggy-icon-btn" aria-label="بازگشت" @click="goBack">
<BasicIcon icon="vuesax-linear:arrow-right-1" size="22" />
</button>
<h1 class="piggy-topbar__title">قلک</h1>
<span class="w-9" />
</header>
<a-spin :spinning="busy">
<section class="piggy-hero">
<div class="piggy-hero__text">
<p class="piggy-hero__label">موجودی قلک‌ها</p>
<p class="piggy-hero__value" dir="ltr">
<span>{{ formatPiggyAmount(totalGold) }}</span>
<span class="piggy-hero__unit">گرم</span>
</p>
<p class="piggy-hero__hint">{{ rows.length }} قلک فعال</p>
</div>
<img class="piggy-hero__art" :src="heroImg" alt="" />
</section>
<section class="piggy-sheet">
<div v-if="!rows.length" class="piggy-empty">
<img :src="emptyImg" alt="" class="piggy-empty__img" />
<p class="piggy-empty__title">هنوز قلکی نساخته‌اید</p>
<p class="piggy-empty__desc">موجودی هر محصول را در قلک‌های جدا نگه دارید</p>
</div>
<div v-else class="piggy-grid">
<button
v-for="item in rows"
:key="item.id"
type="button"
class="piggy-tile"
@click="openInfo(item.id!)"
>
<div class="piggy-tile__icon-wrap">
<img :src="piggyIconForTitle(item.title)" alt="" class="piggy-tile__icon" />
</div>
<div class="piggy-tile__title">{{ item.title || 'بدون عنوان' }}</div>
<div class="piggy-tile__product">{{ fundProductLabel(item) }}</div>
<div class="piggy-tile__amount" dir="ltr">
{{ formatPiggyAmount(fundWalletGold(item)) }}
<span class="piggy-tile__unit">گرم</span>
</div>
</button>
</div>
<BasicButton class="!w-full mt-5" type="primary" size="middle" block @click="goAdd">
<div class="flex items-center justify-center gap-2">
<BasicIcon icon="vuesax-linear:add-circle" size="18" />
<span>افزودن قلک</span>
</div>
</BasicButton>
</section>
</a-spin>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import router from '@/router'
import { useFundUserStore } from '@/store/fundStore'
import { useSettingsStore } from '@/store/settingsStore'
import { message } from 'ant-design-vue'
import type { Fund } from '@/models/fund'
import cashImg from '@/assets/img/cash_img.svg'
import emptyImg from '@/assets/img/cash_empty.svg'
import {
formatPiggyAmount,
fundProductLabel,
fundWalletGold,
piggyIconForTitle,
} from './piggyIcons'
const fundStore = useFundUserStore()
const settingsStore = useSettingsStore()
const busy = ref(false)
const heroImg = cashImg
const rows = computed(() => (fundStore.myPiggyFunds?.rows ?? []) as Fund[])
const totalGold = computed(() => rows.value.reduce((sum, item) => sum + fundWalletGold(item), 0))
function goBack() {
router.back()
}
function goAdd() {
router.push({ name: 'piggy_add' })
}
function openInfo(id: number) {
router.push({ name: 'piggy_info', params: { id: String(id) } })
}
onMounted(async () => {
await settingsStore.fetchSettings()
if (!settingsStore.isSettingTruthy('enable_product_funds')) {
message.warning('قابلیت قلک غیرفعال است')
router.replace({ name: 'user' })
return
}
try {
busy.value = true
await fundStore.getMyPiggyFunds()
} finally {
busy.value = false
}
})
</script>
<style scoped>
.piggy-page {
@apply min-h-full pb-28;
background: linear-gradient(180deg, #f3efe8 0%, #f8fafc 42%, #f8fafc 100%);
}
.piggy-topbar {
@apply sticky top-0 z-20 flex items-center justify-between px-3 py-3;
background: rgba(243, 239, 232, 0.92);
backdrop-filter: blur(8px);
}
.piggy-topbar__title {
@apply m-0 text-base font-bold text-gray-900;
}
.piggy-icon-btn {
@apply flex h-9 w-9 items-center justify-center rounded-full border-none bg-white/80 text-gray-800;
}
.piggy-hero {
@apply relative flex items-end justify-between gap-3 overflow-hidden px-5 pb-8 pt-2;
}
.piggy-hero__label {
@apply m-0 text-sm text-gray-600;
}
.piggy-hero__value {
@apply m-0 mt-1 flex items-baseline gap-2 text-3xl font-bold text-gray-900;
}
.piggy-hero__unit {
@apply text-sm font-bold text-gray-500;
}
.piggy-hero__hint {
@apply m-0 mt-2 text-xs text-gray-500;
}
.piggy-hero__art {
@apply h-28 w-28 shrink-0 object-contain;
}
.piggy-sheet {
@apply relative z-10 -mt-2 rounded-t-3xl bg-white px-4 pb-6 pt-5 shadow-sm;
min-height: 55vh;
}
.piggy-grid {
@apply grid grid-cols-2 gap-3;
}
.piggy-tile {
@apply flex flex-col items-center rounded-2xl border-none bg-gray-50 p-3 text-center;
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.piggy-tile__icon-wrap {
@apply mb-2 flex h-20 w-full items-center justify-center rounded-xl bg-sky-50;
}
.piggy-tile__icon {
@apply h-16 w-16 object-contain;
}
.piggy-tile__title {
@apply w-full truncate text-sm font-bold text-gray-900;
}
.piggy-tile__product {
@apply mt-0.5 w-full truncate text-[11px] text-gray-500;
}
.piggy-tile__amount {
@apply mt-2 flex items-baseline justify-center gap-1 text-sm font-bold text-primary;
}
.piggy-tile__unit {
@apply text-[11px] font-medium text-gray-500;
}
.piggy-empty {
@apply flex flex-col items-center px-4 py-10 text-center;
}
.piggy-empty__img {
@apply mb-3 h-28 w-28 object-contain opacity-90;
}
.piggy-empty__title {
@apply m-0 text-base font-bold text-gray-800;
}
.piggy-empty__desc {
@apply m-0 mt-2 text-sm text-gray-500;
}
</style>