added gholak

This commit is contained in:
2026-08-03 22:36:23 +03:30
parent d6608283f6
commit 46807e3089
6 changed files with 383 additions and 262 deletions
+161 -92
View File
@@ -1,60 +1,94 @@
<template>
<div class="piggy-page">
<header class="piggy-topbar">
<button type="button" class="piggy-icon-btn" aria-label="بازگشت" @click="goBack">
<header class="piggy-bar">
<button type="button" class="piggy-bar__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" />
<h1 class="piggy-bar__title">قلک‌ها</h1>
<button type="button" class="piggy-bar__btn piggy-bar__btn--primary" aria-label="قلک جدید" @click="goAdd">
<BasicIcon icon="vuesax-linear:add" size="20" />
</button>
</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" />
<section class="piggy-summary">
<div class="piggy-summary__card">
<div class="piggy-summary__row">
<div>
<p class="piggy-summary__label">جمع موجودی داخل قلک‌ها</p>
<p class="piggy-summary__value" dir="ltr">
{{ formatPiggyAmount(totalGold) }}
<span class="piggy-summary__unit">گرم</span>
</p>
</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 class="piggy-summary__badge">
<BasicIcon icon="vuesax-linear:safe-home" size="22" />
</div>
</button>
</div>
<div class="piggy-summary__meta">
<span>{{ rows.length }} قلک</span>
<span class="piggy-summary__dot" />
<span>{{ groups.length }} محصول</span>
</div>
</div>
<BasicButton class="!w-full mt-5" type="primary" size="middle" block @click="goAdd">
<BasicButton class="!w-full mt-3" 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>
<span>{{ rows.length ? 'افزودن قلک' : 'ساخت اولین قلک' }}</span>
</div>
</BasicButton>
</section>
<section class="piggy-body">
<div v-if="!rows.length" class="piggy-empty">
<div class="piggy-empty__icon">
<BasicIcon icon="vuesax-linear:safe-home" size="36" />
</div>
<p class="piggy-empty__title">قلکی ندارید</p>
<p class="piggy-empty__desc">
برای جدا کردن بخشی از موجودی هر محصول (مثلاً آبشده یا سکه) یک قلک بسازید.
</p>
</div>
<div v-else class="piggy-groups">
<div v-for="group in groups" :key="group.productId" class="piggy-group">
<div class="piggy-group__head">
<div class="min-w-0">
<p class="piggy-group__name">{{ group.productTitle }}</p>
<p class="piggy-group__count">{{ group.funds.length }} قلک</p>
</div>
<p class="piggy-group__total" dir="ltr">
{{ formatPiggyAmount(group.totalGold) }}
<span>گرم</span>
</p>
</div>
<div class="piggy-group__list">
<button
v-for="item in group.funds"
:key="item.id"
type="button"
class="piggy-row"
@click="openInfo(item.id!)"
>
<div class="piggy-row__icon">
<BasicIcon :icon="piggyIconName(item.title)" size="20" />
</div>
<div class="piggy-row__main">
<div class="piggy-row__title">{{ item.title || 'بدون عنوان' }}</div>
<div class="piggy-row__sub">کد {{ item.id }}</div>
</div>
<div class="piggy-row__amount" dir="ltr">
<strong>{{ formatPiggyAmount(fundWalletGold(item)) }}</strong>
<span>گرم</span>
</div>
<BasicIcon class="piggy-row__chevron" icon="vuesax-linear:arrow-left-1" size="16" />
</button>
</div>
</div>
</div>
</section>
</a-spin>
</div>
</template>
@@ -66,21 +100,19 @@ 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,
groupFundsByProduct,
piggyIconName,
} from './piggyIcons'
const fundStore = useFundUserStore()
const settingsStore = useSettingsStore()
const busy = ref(false)
const heroImg = cashImg
const rows = computed(() => (fundStore.myPiggyFunds?.rows ?? []) as Fund[])
const groups = computed(() => groupFundsByProduct(rows.value))
const totalGold = computed(() => rows.value.reduce((sum, item) => sum + fundWalletGold(item), 0))
function goBack() {
@@ -111,77 +143,114 @@ onMounted(async () => {
<style scoped>
.piggy-page {
@apply min-h-full pb-28;
background: linear-gradient(180deg, #f3efe8 0%, #f8fafc 42%, #f8fafc 100%);
@apply relative min-h-full bg-gray-50 pb-24;
}
.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-bar {
@apply sticky top-0 z-20 flex items-center justify-between bg-white px-3 py-3;
box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}
.piggy-topbar__title {
.piggy-bar__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-bar__btn {
@apply flex h-9 w-9 items-center justify-center rounded-full border-none bg-gray-100 text-gray-800;
}
.piggy-hero {
@apply relative flex items-end justify-between gap-3 overflow-hidden px-5 pb-8 pt-2;
.piggy-bar__btn--primary {
@apply bg-primary text-white;
}
.piggy-hero__label {
@apply m-0 text-sm text-gray-600;
.piggy-summary {
@apply px-4 pt-4;
}
.piggy-hero__value {
@apply m-0 mt-1 flex items-baseline gap-2 text-3xl font-bold text-gray-900;
.piggy-summary__card {
@apply rounded-2xl bg-primary p-4 text-white;
}
.piggy-hero__unit {
@apply text-sm font-bold text-gray-500;
.piggy-summary__row {
@apply flex items-start justify-between gap-3;
}
.piggy-hero__hint {
@apply m-0 mt-2 text-xs text-gray-500;
.piggy-summary__label {
@apply m-0 text-sm text-white/80;
}
.piggy-hero__art {
@apply h-28 w-28 shrink-0 object-contain;
.piggy-summary__value {
@apply m-0 mt-1 flex items-baseline gap-2 text-3xl font-bold;
}
.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-summary__unit {
@apply text-sm font-medium text-white/75;
}
.piggy-grid {
@apply grid grid-cols-2 gap-3;
.piggy-summary__badge {
@apply flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-white/15;
}
.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-summary__meta {
@apply mt-4 flex items-center gap-2 text-xs text-white/75;
}
.piggy-tile__icon-wrap {
@apply mb-2 flex h-20 w-full items-center justify-center rounded-xl bg-sky-50;
.piggy-summary__dot {
@apply h-1 w-1 rounded-full bg-white/50;
}
.piggy-tile__icon {
@apply h-16 w-16 object-contain;
.piggy-body {
@apply px-4 pt-4;
}
.piggy-tile__title {
@apply w-full truncate text-sm font-bold text-gray-900;
.piggy-groups {
@apply flex flex-col gap-4;
}
.piggy-tile__product {
@apply mt-0.5 w-full truncate text-[11px] text-gray-500;
.piggy-group {
@apply overflow-hidden rounded-2xl bg-white;
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.piggy-tile__amount {
@apply mt-2 flex items-baseline justify-center gap-1 text-sm font-bold text-primary;
.piggy-group__head {
@apply flex items-center justify-between gap-3 border-0 border-b border-solid border-gray-100 px-4 py-3;
}
.piggy-tile__unit {
.piggy-group__name {
@apply m-0 truncate text-sm font-bold text-gray-900;
}
.piggy-group__count {
@apply m-0 mt-0.5 text-[11px] text-gray-500;
}
.piggy-group__total {
@apply m-0 flex shrink-0 items-baseline gap-1 text-sm font-bold text-primary;
}
.piggy-group__total span {
@apply text-[11px] font-medium text-gray-500;
}
.piggy-empty {
@apply flex flex-col items-center px-4 py-10 text-center;
.piggy-group__list {
@apply flex flex-col;
}
.piggy-empty__img {
@apply mb-3 h-28 w-28 object-contain opacity-90;
.piggy-row {
@apply flex w-full items-center gap-3 border-0 border-b border-solid border-gray-50 bg-transparent px-3 py-3 text-right last:border-b-0;
}
.piggy-row__icon {
@apply flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-gray-50 text-primary;
}
.piggy-row__main {
@apply min-w-0 flex-1;
}
.piggy-row__title {
@apply truncate text-sm font-bold text-gray-900;
}
.piggy-row__sub {
@apply mt-0.5 text-[11px] text-gray-400;
}
.piggy-row__amount {
@apply flex shrink-0 flex-col items-end leading-tight;
}
.piggy-row__amount strong {
@apply text-sm font-bold text-gray-900;
}
.piggy-row__amount span {
@apply text-[11px] text-gray-500;
}
.piggy-row__chevron {
@apply shrink-0 text-gray-300;
}
.piggy-empty {
@apply rounded-2xl bg-white px-5 py-10 text-center;
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.piggy-empty__icon {
@apply mx-auto mb-3 flex h-16 w-16 items-center justify-center rounded-2xl bg-gray-50 text-primary;
}
.piggy-empty__title {
@apply m-0 text-base font-bold text-gray-800;
@apply m-0 text-base font-bold text-gray-900;
}
.piggy-empty__desc {
@apply m-0 mt-2 text-sm text-gray-500;
@apply m-0 mt-2 text-sm leading-6 text-gray-500;
}
</style>