Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21472823b4 | ||
|
|
7e6f1603a2 | ||
|
|
2296d36eed | ||
|
|
b03808c442 | ||
|
|
cec78883a2 | ||
|
|
76bd8c0666 | ||
|
|
744065cd12 | ||
|
|
d6a2caffe0 | ||
|
|
2977b479dd | ||
|
|
036184c68b | ||
|
|
cabce85e11 | ||
|
|
3036324509 | ||
|
|
187fda391f | ||
|
|
0547b9ebaa | ||
|
|
0f50ec315c | ||
|
|
ae01f6c8d6 | ||
|
|
5596fc75d0 | ||
|
|
c21738950d | ||
|
|
47d4fb44df | ||
|
|
a19f3072f0 | ||
|
|
5d3d7c4ed7 | ||
|
|
24a98b5448 | ||
|
|
e08af043e0 | ||
|
|
0fba52f3e7 | ||
|
|
f6fdce4c20 | ||
|
|
0de5b0dcb7 | ||
|
|
adaf0a087b | ||
|
|
2f64c26251 | ||
|
|
20c871e66c | ||
|
|
819e007e60 | ||
|
|
2048680d7a | ||
|
|
7626453def | ||
|
|
5e181fdae9 | ||
|
|
9487490981 | ||
|
|
cf8a46ec9c | ||
|
|
ab22c4dd63 | ||
|
|
282c0fe09a | ||
|
|
0a3a5d7c82 | ||
|
|
5920866a95 |
@@ -0,0 +1,177 @@
|
|||||||
|
---
|
||||||
|
description: دستورالعمل اجباری AI — پروژه ابشوده/خانگی (توکن کم، پچ محدود)
|
||||||
|
alwaysApply: true
|
||||||
|
---
|
||||||
|
# دستورالعمل اجباری برای هوش مصنوعی — پروژه ابشوده / خانگی
|
||||||
|
|
||||||
|
این فایل را کامل به AI بده (Project Rules / Custom Instructions / System prompt).
|
||||||
|
هدف: **توکن کمتر، یادگیری پایدار، حل سریع اصل کار، بدون تغییر الکی.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۱) با هر پرامپت کاربر — همین ترتیب
|
||||||
|
|
||||||
|
1. اصل قضیه را **یک خط** مشخص کن (یک باگ / یک UI / یک فیچر).
|
||||||
|
2. مسیر را از **نقشه و یادداشت** بگیر — کل ریپو را سرچ نکن.
|
||||||
|
3. فقط **۱ تا ۳ فایل** مربوط را باز/پچ کن.
|
||||||
|
4. تمام کن؛ جواب کوتاه بده.
|
||||||
|
5. یک خط **یادداشت بخش** بنویس (پایین ببین) تا دفعهٔ بعد فراموش نشود.
|
||||||
|
|
||||||
|
```
|
||||||
|
پرامپت → اصل کار → نقشه/یادداشت → Grep فقط همان پوشه → پچ محدود → یادداشت → تمام
|
||||||
|
```
|
||||||
|
|
||||||
|
### ممنوع (سوخت توکن)
|
||||||
|
|
||||||
|
- دوباره پیدا کردن فایلی که در نقشه/یادداشت هست
|
||||||
|
- explore / گشت سراسری برای «X کجاست؟»
|
||||||
|
- خواندن کل فایل بلند وقتی چند ده خط کافی است
|
||||||
|
- refactor یا «درست کردن» فایلهای همجوار بدون درخواست
|
||||||
|
- کپی پچ به سیستم/اپ دیگر «برای کامل بودن»
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۲) محدودهٔ تغییر — حساس
|
||||||
|
|
||||||
|
- **فقط** همان چیزی که کاربر گفته؛ جای بیربط را دست نزن.
|
||||||
|
- مبهم بود (هدف، اپ، برنچ، سیستم حسابداری) → **بپرس**؛ حدس نزن.
|
||||||
|
- روی **برنچ فعلی** بمان؛ checkout/merge به برنچ دیگر بدون اجازه ممنوع.
|
||||||
|
- هر زیرپروژه git جدا دارد؛ فقط همان ریپوی مربوط را عوض کن.
|
||||||
|
|
||||||
|
| کار | فقط این ریپو |
|
||||||
|
|-----|----------------|
|
||||||
|
| ادمین | `khaneghi_admin` |
|
||||||
|
| API / SQL | `khaneghi_server` |
|
||||||
|
| اپ کاربر | `khaneghi_user` + تم + `ghatreh_user` (هر سه اگر رفتاری است) |
|
||||||
|
| سوپرادمین | `controlpanel_server` / `controlpanel_user` |
|
||||||
|
| بورس مس | فقط با درخواست صریح |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۳) حسابداری — قانون سخت
|
||||||
|
|
||||||
|
سیستمها **جدا** هستند: زرین (`zarin`) / تهحساب (`tahesab`) / پرگار (`pargar`).
|
||||||
|
|
||||||
|
1. اگر گفت حسابداری/سند/سینک مشتری و **نام نبرد** → اول بپرس کدام؟
|
||||||
|
2. تا جواب ندادی کد نزن و فایل سیستم دیگر را باز نکن.
|
||||||
|
3. پچ یک سیستم را به بقیه کپی نکن مگر در همان پیام صریح بگوید.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۴) یادگیری قوی — یادداشت بخشها
|
||||||
|
|
||||||
|
هر کار تمامشده را در دفتر پروژه ثبت کن (اگر در این ریپو هست:
|
||||||
|
`.cursor/skills/abshode-domain-lookup/learned-notes.md`):
|
||||||
|
|
||||||
|
```
|
||||||
|
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
|
||||||
|
```
|
||||||
|
|
||||||
|
قبل از هر Grep سراسری: **یادداشتها را بخوان.**
|
||||||
|
اگر مسیر آنجا بود، دوباره سرچ نکن.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۵) نقشهٔ سریع مسیرها
|
||||||
|
|
||||||
|
| موضوع | کجا |
|
||||||
|
|-------|-----|
|
||||||
|
| تنظیمات ادمین | `khaneghi_admin/src/pages/menuPages/configuration/` |
|
||||||
|
| فلگ منو از settings | `khaneghi_admin/src/utils/config.ts` |
|
||||||
|
| مشتریان | `khaneghi_admin/src/pages/menuPages/customers/` |
|
||||||
|
| همگام تهحساب | `…/accounting/components/TahesabCustomerSync.vue`, `TahesabWalletBulkSync.vue` |
|
||||||
|
| کد حساب همکار | `…/colleagueOrders/components/ColleagueAccountingAccounts.vue` |
|
||||||
|
| API تهحساب (فرانت) | `khaneghi_admin/src/api/tahesab.ts` |
|
||||||
|
| تنظیمات سرور / overlay سوپرادمین | `SuperAdminProgramSettingsOverlay`, `SettingsController` |
|
||||||
|
| deploy settings | `khaneghi_server/database/sql/deploy_settings_const.sql` — **value موجود را UPDATE نکن** |
|
||||||
|
| قیمت ویژه مشتری | `customer_special_pricing` + منوی `customers/special-price` |
|
||||||
|
|
||||||
|
نقشهٔ کاملتر (اگر موجود): `.cursor/skills/abshode-domain-lookup/project-map.md`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۶) فرانت — زیاد از Ant + UnoCSS + lodash استفاده کن
|
||||||
|
|
||||||
|
اولویت:
|
||||||
|
|
||||||
|
1. **BasicPacks** پروژه (دکمه/آیکون/اینپوت/مدال) اگر هست
|
||||||
|
2. **Ant Design Vue** (`a-button`, `a-input`, `a-table`, `a-spin`, `a-form`, …)
|
||||||
|
3. **UnoCSS** برای layout و فاصله (`flex`, `grid`, `gap-*`, `w-full`, `min-w-0`, `sm:`)
|
||||||
|
4. **lodash** برای داده (`get`, `debounce`, `cloneDeep`, `isEmpty`, …) — helper تکراری ننویس
|
||||||
|
5. CSS/`<style>` فقط وقتی utility کافی نیست (توکن تم، انیمیشن خاص)
|
||||||
|
|
||||||
|
```text
|
||||||
|
❌ button خام + CSS بزرگ برای layout
|
||||||
|
✅ Ant/Basic + کلاسهای Uno روی تمپلیت + lodash برای منطق داده
|
||||||
|
```
|
||||||
|
|
||||||
|
- `BasicButton` را با `:deep` برای عوض کردن layout داخلی خراب نکن.
|
||||||
|
- رنگ: توکن تم؛ از `bg-primary/10` روی CSS variable پرهیز کن (اغلب میشکند).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۷) UI حرفهای — عینک گرافیککار
|
||||||
|
|
||||||
|
- هر بلوک جدید: **عنوان + یک خط راهنما** (این کار چیست / دکمه کی زده شود).
|
||||||
|
- **باکسبندی خوب است؛ فضای مرده بد است** — کارت عریض با محتوا فقط در یک گوشه ممنوع.
|
||||||
|
- یا `sm:grid-cols-2` / `flex` تا پر شود، یا عرض باکس را محدود کن.
|
||||||
|
- موبایل: اکشن **زیر** توضیح (`flex-col`).
|
||||||
|
- دسکتاپ: کنار یا ستون دوم پر (`sm:flex-row` / `sm:grid`).
|
||||||
|
- **نسبت سرچ و دکمه:**
|
||||||
|
- موبایل: سرچ `w-full`؛ بعد دکمهها با عرض مساوی (`grid` / `1fr`).
|
||||||
|
- اینپوت باریک کنار دکمهٔ پهن در یک ردیف wrap = زشت → ممنوع.
|
||||||
|
- بنر گرادیان جیغ و دکمهٔ `block` تمامعرض الکی ممنوع مگر اکشن اصلی صفحه باشد.
|
||||||
|
- فشرده باش: `p-2.5` / `gap-2`؛ عدد و padding غولپیکر نگذار.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۸) مهندسی بکاند / فرانت — بدون باگ الکی
|
||||||
|
|
||||||
|
- یک مسئولیت در هر کامپوننت / متد / سرویس؛ خدا-فایل نساز.
|
||||||
|
- UI نازک؛ منطق سنگین در composable یا Service.
|
||||||
|
- Controller نازک → Service؛ SQL و business را قاطی نکن.
|
||||||
|
- خطا، خالی، timeout، دوبار کلیک / race را طراحی کن (`running` قفل، early return).
|
||||||
|
- الگوی همان پوشه را کپی کن؛ اختراع ساختار جدید نکن مگر لازم باشد.
|
||||||
|
- نامگذاری گویا؛ قرارداد API فرانت و بک یکی باشد.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۹) سوپرادمین / تنظیمات دسترسی
|
||||||
|
|
||||||
|
- کلیدهای دسترسی مشتری (`customer_special_pricing`, `has_page_*`, …) مال سوپرادمیناند؛ در پنل خانگی معمولاً فقطخواندنی.
|
||||||
|
- منوی وابسته به فلگ باید از `get_settings` / overlay زنده بیاید؛ کش کهنه برای این کلیدها مطلوب نیست.
|
||||||
|
- دکمهٔ بروزرسانی تنظیمات پیشرفته باید همگام زنده از سوپرادمین را هم بزند اگر فلگ منو میخواهد عوض شود.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۱۰) چک قبل از اتمام
|
||||||
|
|
||||||
|
- [ ] diff فقط به درخواست مربوط است؟
|
||||||
|
- [ ] سیستم حسابداری / اپ / برنچ اشتباه درگیر نشده؟
|
||||||
|
- [ ] اگر مبهم بود سؤال شد؟
|
||||||
|
- [ ] یادداشت یکخطی نوشته شد؟
|
||||||
|
- [ ] UI: راهنما + بدون فضای مرده + نسبت سرچ/دکمه درست؟
|
||||||
|
- [ ] Ant / Uno / lodash بهجای reinvent؟
|
||||||
|
- [ ] جواب کوتاه است؛ توضیح اضافه نداری؟
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۱۱) نمونهٔ رفتار درست / غلط
|
||||||
|
|
||||||
|
```text
|
||||||
|
❌ «همگامسازی مشتری خراب» → هر سه زرین/تهحساب/پرگار را عوض کند
|
||||||
|
✅ بپرسد کدام؟ بعد فقط همان
|
||||||
|
|
||||||
|
❌ UI یک کارت → کل صفحه accounting را redesign کند
|
||||||
|
✅ فقط همان کارت / همان فایل
|
||||||
|
|
||||||
|
❌ هر بار از صفر Grep مونوریپو
|
||||||
|
✅ learned-notes + project-map → مستقیم فایل
|
||||||
|
|
||||||
|
❌ CSS سفارشی ۵۰ خط برای flex ساده
|
||||||
|
✅ class="flex flex-col gap-2 sm:grid sm:grid-cols-2"
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**پایان.** این سند را بهروز نگه دار؛ نکات جدید حساس را همینجا یا در `learned-notes.md` اضافه کن.
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
# یادداشتهای یادگیری — abshode-domain-lookup
|
||||||
|
|
||||||
|
- 2026-11-10 | مدال احراز کاربر جدید | `RequiredKycModal.vue` | شرط نمایش اشتباهی همیشه false بود؛ برای is_legal=0 دوباره باز میشود، قفل مسیر در setupRouter نیست
|
||||||
|
- 2026-11-10 | قفل منو بعد از احراز | `setupRouter.ts` + `RequiredKycModal.vue` | گارد فقط home/user و مدال سراسری برداشته شد؛ احراز روی معامله/واریز/هدیه ماند
|
||||||
|
- 2026-11-10 | مدال موفقیت ثبتنام خالی | `DialogVantOneButton.vue` | تم لاگین `color:#fff`؛ بدون teleport متن سفید روی دیالوگ سفید — مثل `DialogVant` با teleport+رنگ تیره
|
||||||
|
- 2026-11-10 | خانه خالی بدون KYC | `RequiredKycModal` + `HomeLayoutRenderer` | v-model:open روی computed فقطخواندنی؛ تشخیص احراز با `isCustomerIdentityVerified`؛ skeleton هنگام lazy layout
|
||||||
|
|
||||||
|
فرمت هر خط:
|
||||||
|
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
|
||||||
|
|
||||||
|
- 2026-11-09 | FAB ثبت کارت هدیه | `App.vue` `#gift-card-button` | مثل پشتیبانی؛ `has_page_gift_card` + لاگین؛ کلیک → `giftCard`؛ موقعیت پیشفرض بالای دکمه پشتیبانی
|
||||||
|
- 2026-11-09 | ترتیب منوی کاربر | `useUserPage.ts` `menuActions` | موبایل+دسکتاپ یکسان؛ اول giftCard… بعد password؛ خروج جدا؛ هشدار قیمت دیگر فقط موبایل نیست
|
||||||
|
- 2026-11-09 | وضعیت تاریخچه واریز کیف پول | `wallet/components/Item.vue` + `resolveTransactionStatusLabel` | قبلاً فقط `transaction[0]` → ناموفق؛ واریز pending باید «در انتظار تایید» مثل تب تراکنشها
|
||||||
|
|
||||||
|
- 2026-10-25 | انتخاب روش واریز | `WalletDepositMethodModal.vue` بعد از دکمهٔ واحد واریز | آنی = `INSTANT_DEPOSIT_PAYMENT_URL`؛ حساب = مودال کارت/شبا
|
||||||
|
- 2026-10-22 | addon اینپوت | `assets/css/main.less` | پسزمینه addon = secondary تم، نه primary (سبز tenant)
|
||||||
|
- 2026-10-21 | نمودار خانه = لندینگ | `LandingLiveChartMain.vue` + `useLandingLiveChart` + `zaarboxPriceHistory`؛ جایگزین `PriceChart` در PriceChartSection/DesktopChart* | همان `dlanding-live__main` SVG؛ داده از zaarbox + `/api/price/last`
|
||||||
|
- 2026-10-20 | ظاهر خرید اقساطی | `views/base/installment/InstallmentPanel.vue` | دسکتاپ کلاسهای `dgift` مثل کارت هدیه؛ موبایل کارت `rounded-xl` و توضیح بالای فرم
|
||||||
|
- 2026-10-20 | خرید اقساطی دیجیپی | سرور `DigipayInstallmentService` + تنظیمات `enable_digipay_installment`/`digipay_*`؛ اپ `views/base/installment`؛ ادمین `customers/digipayInstallment` | لینک احراز در تنظیمات؛ مانده اعتبار را ادمین با موبایل مینویسد؛ خرید مس را به کیف gold مینشاند
|
||||||
|
- 2026-10-20 | پاپآپ احراز عملیات | واریز/برداشت `useWalletPage.ensureIdentity`؛ هدیه `useGiftCardPage`؛ خرید/فروش دیالوگ `noCompleteVisible` در gold / copper&silver / DealProduct روی mount اگر is_legal=0 | همه هست؛ معامله با ورود صفحه نه با کلیک ثبت
|
||||||
|
- 2026-10-20 | هشدار قیمت موبایل | `useUserPage.ts` منوی `notifyTrigger` | فقط موبایل و با فلگ `has_page_price_trigger`؛ دسکتاپ همان سایدبار
|
||||||
|
- 2026-10-20 | آیکون درباره ما | `assets/img/boursecu-about-icon.png` + `getBoursecuActionIconSrc('about')` در `navigation.ts` و `useUserPage.ts` | آدمک حباب گفتار جایگزین info-circle در سایدبار و منوی امکانات بیشتر
|
||||||
|
- 2026-10-19 | قفل احراز واریز/هدیه | `useWalletPage` + `useGiftCardPage` + `assertCustomerIdentityVerified` روی withdraw و giftcard/use | is_legal=0 دیالوگ میدهد و API هم رد میکند
|
||||||
|
- 2026-10-19 | آیکون پشتیبانی/هشدار/قوانین | `assets/img/boursecu-support-icon.png` + `price-trigger` + `rules` و `navigation.ts` / `useUserPage.ts` | آدمک=پشتیبانی، زنگ دلار=هشدار قیمت سایدبار، برگه=قوانین
|
||||||
|
- 2026-09-08 | لیست کارت هدیه کاربر | `views/base/giftCard/` + `api/giftCard.ts` + سرور `GiftCardController::mine` / `GET customer/giftcard/mine` | زیر فرم: available (اختصاصی + عمومی use_once=0 تککد) و history؛ تخفیف فقط نمایش/سبد نه giftcard/use
|
||||||
|
- 2026-09-08 | تب کارت هدیه/تخفیف در تراکنشها | `transactions/config/boursecuTabs.ts` + `useTransactionsPageData.ts` + `Item.vue` | fetchMode giftcard/discount از historyِ mine؛ واحد تخفیف٪/طلا در Item
|
||||||
|
- 2026-09-08 | گیر کردن در لاگین بعد رفرش | `app/authBoot.ts` + `setupRouter.ts` | finger unlock در sessionStorage؛ بعد ۳دقیقه fingerprintChecked ریست؛ لاگین بدون userInfo نرود home
|
||||||
|
- 2026-09-08 | حذف دکمه قلک از خانه | `BoursecuQuickActionsSection.vue` + دسکتاپ quick actions + `useHomePage.ts` | دیگر با enable_product_funds به گرید اضافه نمیشود
|
||||||
|
- 2026-09-08 | پشتیبانی در تنظیمات → چت | `user/composables/useUserPage.ts` | دکمه پشتیبانی مستقیم `router.push({ name: 'support' })` نه منوی پیامرسان
|
||||||
|
- 2026-09-08 | چت دسکتاپ کنار منو | `views/support/index.vue` + `desktop-layout.less` | از ۷۶۸px شل دسکتاپ؛ کارت چت inset با radius ۲۸ کنار سایدبار
|
||||||
|
- 2026-09-08 | چت+سایدبار اجباری | `support/index.vue` + router `hideMenu` | سایدبار داخل صفحه چت وقتی isDesktop؛ شل بیرونی سایدبار ندارد تا دوبل نشود
|
||||||
|
- 2026-09-08 | دسکتاپ از ۶۰۰px | `layouts/constants.ts` + shell/frame + `support/index.vue` | آستانه ۷۶۸→۶۰۰؛ سایدبار چت همیشه در DOM و با @media نمایش
|
||||||
|
- 2026-09-09 | آستانه دسکتاپ ۷۶۸ | `layouts/constants.ts` + shell/frame + `support/index.vue` | از عرض >۷۶۷ (min-width: 768) سایدبار دسکتاپ
|
||||||
|
- 2026-09-09 | لوگوی هدر پشتیبانی | `SupportChatHeader.vue` | بهجای config.avatar از `getProjectSplashLogo()` (لوگوی محلی اپ)
|
||||||
|
- 2026-09-09 | هدر دسکتاپ اعلانها | `DesktopAppNotificationsView.vue` | قبلاً topbar نداشت؛ `DesktopPageTopbar` مثل کیفپول/تراکنشها
|
||||||
|
- 2026-09-09 | جزئیات اعلان دسکتاپ | `appNotifications/index.vue` | دسکتاپ `BasicModal`؛ موبایل `BasicActionSheet`
|
||||||
|
- 2026-09-09 | بازگشت چت پشتیبانی | `SupportChatHeader.vue` | تایماوت ۸۰ms با beforeEach تداخل داشت؛ `push(back)` یا `replace(user)`
|
||||||
|
- 2026-09-09 | دکمه ارسال چت | `SupportChatComposer.vue` + `support/index.vue` | BasicButton فقط `disabledB`؛ متن فقط بعد موفقیت پاک شود + toast خطا
|
||||||
|
- 2026-09-09 | عرض چت موبایل/دسکتاپ | `support/index.vue` + `App.vue` | زیر ۷۶۸ fullbleed؛ دسکتاپ با کلاس isDesktop سایدبار؛ بدون float credit روی پشتیبانی
|
||||||
|
- 2026-09-09 | چت زیر آستانه | `support/index.vue` | max-width 767 منو مخفی + w-full؛ از ۷۶۸ flex width:0 برای پر کردن باقیمانده
|
||||||
|
- 2026-09-09 | دکمه ریپلای چت | `SupportChatMessages.vue` | native button + همیشه pointer-events؛ فوکوس composer بعد از reply
|
||||||
|
- 2026-09-09 | قلک دسکتاپ | `piggy/` desktop+mobile + `usePiggyPage` | مثل fund/wallet: topbar + خلاصه + لیست گروهها
|
||||||
|
- 2026-09-09 | زیرصفحات قلک دسکتاپ | `piggy/new` + `piggy/info` + create/info composable | ساخت/ویرایش و جزئیات با DesktopPageTopbar و گرید دوستونه
|
||||||
|
- 2026-09-09 | عرض قلک دسکتاپ | `desktop-piggy-create.less` | کانتینر ساخت هم max-width ۱۱۸۰ مثل لیست/جزئیات/کیفپول
|
||||||
|
- 2026-09-09 | نام منوی کاربر | `navigation.ts` + `MobileBottomNav.vue` | «تنظیمات» → «امکانات بیشتر» (دسکتاپ+موبایل)
|
||||||
|
- 2026-09-12 | دکمه داراییها خانه | `boursecuQuickActions` + `useHomePage.openAssetsSheet` | قبلاً `fund` میرفت و با خاموش بودن قلک گارد بیصدا برمیگرداند؛ حالا شیت BalanceSheet
|
||||||
|
- 2026-09-09 | ماشین حساب | `useUserPage.ts` + `GoldDayCalculatorModal.vue` | «قیمت روز طلا» → «ماشین حساب»؛ برچسب فلز/واحد از settingsStore (metalTypeLabel + tradeWeightUnit) نه هاردکد طلا/گرم
|
||||||
|
- 2026-10-05 | ????? ????? ??????? | desktop/components/DesktopAuthShell.vue + desktop/styles/desktop-auth.less | ????? stretch? ??? ???????? bleed? tagline ? form-links ?? margin-top:auto ???????? support ??? ???? ?? __top
|
||||||
|
- 2026-10-05 | نمای کلی پروژه | `boursecu/BOURSECU.md` | چهار ریپو: user:3100، admin:3600، server:8000، landing:3200؛ فلز مس از settings
|
||||||
|
- 2026-10-17 | کلیک کارت محصول دسکتاپ | `products/index.vue` + `DesktopProductCard.vue` + `useProductsPage.ts` | کاتد مس: `isMeltedTradeGroup` → indexGold در مدال؛ رویداد `select`؛ بسته بودن معامله با `shouldBlockStoreTrading`
|
||||||
|
- 2026-10-05 | ???? ????? ????? | DesktopAuthShell.vue + desktop-auth.less | status ???? form-column__foot ??? ???????? body/top ?? margin-top:auto ???????? tagline ??????? foot
|
||||||
|
- 2026-10-05 | ??? ????? ?????? | home/components/AppHeader.vue + guestHome.ts | ???? ????? ???? ?????login? ????????? ????? ?????/??/???? ?? guest ????
|
||||||
|
- 2026-10-05 | FAB ???????? ????? ?????? | DesktopAuthShell.vue + useDraggableFloatingButton | ??????: ????? ???? ????????? ??????: ???? inline ??? ????
|
||||||
|
- 2026-10-05 | ?????? ?? ??? ????? | boutUs/components/AboutUsContentPanel.vue | ??? ?????? ???? ??? ???? ?? ????? ???? ?? ??? ??
|
||||||
|
- 2026-10-06 | بیلد آموزش ENOENT 1.png | EducateContentPanel.vue + assets/img/1.png,2.png,4.png + banner1/2 | فایلها در گیت بودند و از دیسک پاک شده بودند؛ git restore
|
||||||
|
- 2026-10-17 | باز/بسته خرید فروش محصول | `utils/productTradeOpen.ts` + `gold/index.vue` | `open_buy`/`open_sell`؛ بدون ProductItem هر دو باز
|
||||||
|
- 2026-10-17 | نمودار مهمان ۴۰۱ | `usePriceChart.ts` + `api/home.ts` + سرور `routes/api.php` `POST /api/price/all` | مهمان product/list نمیزند؛ تاریخچه نمودار از `/api/price/all` (همان priceData)
|
||||||
|
- 2026-10-17 | قیمت زنده مهمان | `bootstrap.ts` + `priceSocket.ts` + سرور `/api/price/stream` بدون auth | SSE بدون توکن؛ polling پشتیبان product/list فقط با توکن
|
||||||
|
- 2026-10-21 | نمودار خانه = کارت لندینگ | `home/components/LandingLiveChartMain.vue` + `useLandingLiveChart.ts` + `styles/landing-live-chart-main.less` | موبایل PriceChartSection و دسکتاپ DesktopChartSection/Panel همین کارت؛ استایل از main.less
|
||||||
|
- 2026-10-21 | چیدمان کارت نمودار خانه | همان دو فایل vue/less | هدر: نام+وضعیت راست، تب محصول چپ؛ قیمت راست و تغییر چپ؛ تب بازه کنار عنوان نمودار
|
||||||
|
- 2026-10-21 | تب نمودار = محصول فعال | `useLandingLiveChart.ts` + `LandingLiveChartMain.vue` | تب از کاتالوگ `active && show`؛ داده با `price_offset_percent` همان محصول
|
||||||
|
- 2026-11-01 | درخواست تبدیل سیم | `convert/CopperConvertCalculator.vue` + `useCopperConvertPage.ts` + سرور `CopperConvertRequestService` + ادمین `hesabKetab.ts` فرزند `copperConvertMain` | حلقه صحیح؛ منوی ادمین زیر حساب کتاب نه منوی اصلی
|
||||||
|
- 2026-11-01 | ۵۰۰ لیست تبدیل | `2026_11_01_000001_create_copper_convert_requests_table.php` | git pull کافی نیست؛ بدون `php artisan migrate` جدول نیست و GET ادمین ۵۰۰ میدهد
|
||||||
|
- 2026-11-01 | جدول درخواست تبدیل | ادمین `copperConvert/components/table.vue` | دسکتاپ BaseTable؛ موبایل `CopperConvertMobileCardList` مثل بقیه صفحات
|
||||||
|
- 2026-11-01 | ترتیب ۱.۵ و mm² | `convert/components/CopperConvertCalculator.vue` | صفحه rtl است؛ نشان و برچسب سیم با `dir="ltr"` تا اول مقطع بیاید بعد mm²
|
||||||
|
- 2026-11-01 | جای واحد و عدد در تبدیل | `CopperConvertCalculator.vue` + `useCopperConvertPage.ts` | ریال/کیلو/عدد با `bdi` داخل `measure` قبل از عدد؛ باکس مقدار `dir=ltr`
|
||||||
|
- 2026-11-01 | ماشینحساب اجرت/سود/مالیات | `components/GoldDayCalculatorModal.vue` | اجرت ساخت مفتول؛ سود مورد انتظار جدا؛ مالیات ارزش افزوده روی (هزینه+اجرت+سود)
|
||||||
|
- 2026-11-01 | پلیسهولدر هشدار قیمت | user `priceTrigger/components/PriceTriggerForm.vue` + admin `priceTriggers/components/PriceTriggerEditorFormBody.vue` | «آبشده، سکه، نقره و ...» → «کاتد مس، مفتول مس و...»
|
||||||
|
- 2026-11-02 | هشدار کاتد→طلا | user `priceTrigger/` + `BasicSelect.vue` + server `Customer/PriceTriggerController.php` | شناسه عددی محصول ارسال شود؛ fallback عنوان «طلا» نباشد. محصول پیشفرض const برابر id=1 است
|
||||||
|
- 2026-11-02 | زبانه تبدیل کشیدنی | `convert/components/CopperConvertCalculator.vue` | `dragHandleOnly` در capture؛ لمس ریل مقدار را جابهجا نمیکند، فقط کشیدن دستگیره
|
||||||
|
- 2026-11-02 | سه زبانه تبدیل از اول | همان `CopperConvertCalculator.vue` | زبانه ۱.۵ و ۲.۵ دیگر پشت `remainderAmount > 0` نیستند؛ زیر زبانه مقدار، قبل از نتیجه
|
||||||
|
- 2026-11-02 | زبانه سیم مکمل | `useCopperConvertPage.ts` | بودجه = ارزش مقدار انتخابشده؛ نصف به ۱.۵ و بقیه به ۲.۵؛ جابهجایی یکی دیگری را پر میکند
|
||||||
|
- 2026-11-01 | تاریخچه برداشت کیف پول | `wallet/mobile/MobileWalletView.vue` + `desktop/DesktopWalletView.vue` + `useWalletPageData.ts` | `walletWithdrawItems` از قبل لود میشد؛ زیر راهنمای برداشت و زیر حسابهای دسکتاپ نشان داده میشود
|
||||||
|
- 2026-11-03 | تاریخچه تبدیل کاربر | `convert/components/CopperConvertHistory.vue` + `useCopperConvertPage.ts` + سرور `Customer/CopperConvertRequestController@index` | GET `/customer/copper-convert-request` فقط ردیفهای همان مشتری؛ زیر فرم موبایل و دسکتاپ
|
||||||
|
- 2026-11-03 | ویرایش/حذف تبدیل در انتظار | همان تاریخچه + `CopperConvertRequestService::update/remove` | فقط status=pending؛ ویرایش فرم را با همان حلقهها پر میکند و PUT میزند
|
||||||
|
- 2026-11-03 | چیدمان دسکتاپ تبدیل | `convert/desktop/DesktopConvertView.vue` | مثل کیف پول: `dwallet-grid`؛ فرم راست، تاریخچه چپ با `variant=side`
|
||||||
|
- 2026-11-03 | مداد ویرایش تبدیل | `convert/components/CopperConvertHistory.vue` | فقط pending؛ آیکون `vuesax-linear:edit` کنار وضعیت، همان `beginEdit`
|
||||||
|
- 2026-11-03 | چهار قیمت هیرو خانه | `home/desktop/components/DesktopLivePrice.vue` + سرور `ZaarboxPriceService::copperDollarReferences` | مس جهانی=کلید `basemetal_london_copper`، دلار آزاد=`tgju_usd`؛ تن=ضرب، کیلو=تقسیم بر ۱۰۰۰
|
||||||
|
- 2026-11-03 | چهار قیمت موبایل خانه | `home/components/CurrentPrice.vue` + `composables/useHomeQuoteRows.ts` | همان چهار ردیف دسکتاپ؛ منطق مشترک در useHomeQuoteRows
|
||||||
|
- 2026-11-03 | هاور نمودار دارایی | `assets/index.vue` + `useAssetsPortfolioChart.ts` + `chartAreaPaths.ts` | نزدیکترین نقطهٔ رسمشده؛ مقدار همان نمونهٔ دارایی، نه قیمت مس
|
||||||
|
- 2026-11-04 | لینک دعوتنامه | `utils/referralShare.ts` + لندینگ `pages/login.vue` | `%لینک` = `/login?register=true&id=`؛ لندینگ با `id` به ثبتنام اپ ریدایرکت میکند
|
||||||
|
- 2026-11-04 | دکمه ثبتنام آیفون | `login/desktop/styles/desktop-auth.less` + `login/index.vue` | موبایل height:auto و اسکرول؛ بنر نصب پایین تا روی دکمه ننشیند
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
# دستورالعمل اجباری برای هوش مصنوعی — پروژه ابشوده / خانگی
|
||||||
|
|
||||||
|
این فایل را کامل به AI بده (Project Rules / Custom Instructions / System prompt).
|
||||||
|
هدف: **توکن کمتر، یادگیری پایدار، حل سریع اصل کار، بدون تغییر الکی.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۱) با هر پرامپت کاربر — همین ترتیب
|
||||||
|
|
||||||
|
1. اصل قضیه را **یک خط** مشخص کن (یک باگ / یک UI / یک فیچر).
|
||||||
|
2. مسیر را از **نقشه و یادداشت** بگیر — کل ریپو را سرچ نکن.
|
||||||
|
3. فقط **۱ تا ۳ فایل** مربوط را باز/پچ کن.
|
||||||
|
4. تمام کن؛ جواب کوتاه بده.
|
||||||
|
5. یک خط **یادداشت بخش** بنویس (پایین ببین) تا دفعهٔ بعد فراموش نشود.
|
||||||
|
|
||||||
|
```
|
||||||
|
پرامپت → اصل کار → نقشه/یادداشت → Grep فقط همان پوشه → پچ محدود → یادداشت → تمام
|
||||||
|
```
|
||||||
|
|
||||||
|
### ممنوع (سوخت توکن)
|
||||||
|
|
||||||
|
- دوباره پیدا کردن فایلی که در نقشه/یادداشت هست
|
||||||
|
- explore / گشت سراسری برای «X کجاست؟»
|
||||||
|
- خواندن کل فایل بلند وقتی چند ده خط کافی است
|
||||||
|
- refactor یا «درست کردن» فایلهای همجوار بدون درخواست
|
||||||
|
- کپی پچ به سیستم/اپ دیگر «برای کامل بودن»
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۲) محدودهٔ تغییر — حساس
|
||||||
|
|
||||||
|
- **فقط** همان چیزی که کاربر گفته؛ جای بیربط را دست نزن.
|
||||||
|
- مبهم بود (هدف، اپ، برنچ، سیستم حسابداری) → **بپرس**؛ حدس نزن.
|
||||||
|
- روی **برنچ فعلی** بمان؛ checkout/merge به برنچ دیگر بدون اجازه ممنوع.
|
||||||
|
- هر زیرپروژه git جدا دارد؛ فقط همان ریپوی مربوط را عوض کن.
|
||||||
|
|
||||||
|
| کار | فقط این ریپو |
|
||||||
|
|-----|----------------|
|
||||||
|
| ادمین | `khaneghi_admin` |
|
||||||
|
| API / SQL | `khaneghi_server` |
|
||||||
|
| اپ کاربر | `khaneghi_user` + تم + `ghatreh_user` (هر سه اگر رفتاری است) |
|
||||||
|
| سوپرادمین | `controlpanel_server` / `controlpanel_user` |
|
||||||
|
| بورس مس | فقط با درخواست صریح |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۳) حسابداری — قانون سخت
|
||||||
|
|
||||||
|
سیستمها **جدا** هستند: زرین (`zarin`) / تهحساب (`tahesab`) / پرگار (`pargar`).
|
||||||
|
|
||||||
|
1. اگر گفت حسابداری/سند/سینک مشتری و **نام نبرد** → اول بپرس کدام؟
|
||||||
|
2. تا جواب ندادی کد نزن و فایل سیستم دیگر را باز نکن.
|
||||||
|
3. پچ یک سیستم را به بقیه کپی نکن مگر در همان پیام صریح بگوید.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۴) یادگیری قوی — یادداشت بخشها
|
||||||
|
|
||||||
|
هر کار تمامشده را در دفتر پروژه ثبت کن (اگر در این ریپو هست:
|
||||||
|
`.cursor/skills/abshode-domain-lookup/learned-notes.md`):
|
||||||
|
|
||||||
|
```
|
||||||
|
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
|
||||||
|
```
|
||||||
|
|
||||||
|
قبل از هر Grep سراسری: **یادداشتها را بخوان.**
|
||||||
|
اگر مسیر آنجا بود، دوباره سرچ نکن.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۵) نقشهٔ سریع مسیرها
|
||||||
|
|
||||||
|
| موضوع | کجا |
|
||||||
|
|-------|-----|
|
||||||
|
| تنظیمات ادمین | `khaneghi_admin/src/pages/menuPages/configuration/` |
|
||||||
|
| فلگ منو از settings | `khaneghi_admin/src/utils/config.ts` |
|
||||||
|
| مشتریان | `khaneghi_admin/src/pages/menuPages/customers/` |
|
||||||
|
| همگام تهحساب | `…/accounting/components/TahesabCustomerSync.vue`, `TahesabWalletBulkSync.vue` |
|
||||||
|
| کد حساب همکار | `…/colleagueOrders/components/ColleagueAccountingAccounts.vue` |
|
||||||
|
| API تهحساب (فرانت) | `khaneghi_admin/src/api/tahesab.ts` |
|
||||||
|
| تنظیمات سرور / overlay سوپرادمین | `SuperAdminProgramSettingsOverlay`, `SettingsController` |
|
||||||
|
| deploy settings | `khaneghi_server/database/sql/deploy_settings_const.sql` — **value موجود را UPDATE نکن** |
|
||||||
|
| قیمت ویژه مشتری | `customer_special_pricing` + منوی `customers/special-price` |
|
||||||
|
|
||||||
|
نقشهٔ کاملتر (اگر موجود): `.cursor/skills/abshode-domain-lookup/project-map.md`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۶) فرانت — زیاد از Ant + UnoCSS + lodash استفاده کن
|
||||||
|
|
||||||
|
اولویت:
|
||||||
|
|
||||||
|
1. **BasicPacks** پروژه (دکمه/آیکون/اینپوت/مدال) اگر هست
|
||||||
|
2. **Ant Design Vue** (`a-button`, `a-input`, `a-table`, `a-spin`, `a-form`, …)
|
||||||
|
3. **UnoCSS** برای layout و فاصله (`flex`, `grid`, `gap-*`, `w-full`, `min-w-0`, `sm:`)
|
||||||
|
4. **lodash** برای داده (`get`, `debounce`, `cloneDeep`, `isEmpty`, …) — helper تکراری ننویس
|
||||||
|
5. CSS/`<style>` فقط وقتی utility کافی نیست (توکن تم، انیمیشن خاص)
|
||||||
|
|
||||||
|
```text
|
||||||
|
❌ button خام + CSS بزرگ برای layout
|
||||||
|
✅ Ant/Basic + کلاسهای Uno روی تمپلیت + lodash برای منطق داده
|
||||||
|
```
|
||||||
|
|
||||||
|
- `BasicButton` را با `:deep` برای عوض کردن layout داخلی خراب نکن.
|
||||||
|
- رنگ: توکن تم؛ از `bg-primary/10` روی CSS variable پرهیز کن (اغلب میشکند).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۷) UI حرفهای — عینک گرافیککار
|
||||||
|
|
||||||
|
- هر بلوک جدید: **عنوان + یک خط راهنما** (این کار چیست / دکمه کی زده شود).
|
||||||
|
- **باکسبندی خوب است؛ فضای مرده بد است** — کارت عریض با محتوا فقط در یک گوشه ممنوع.
|
||||||
|
- یا `sm:grid-cols-2` / `flex` تا پر شود، یا عرض باکس را محدود کن.
|
||||||
|
- موبایل: اکشن **زیر** توضیح (`flex-col`).
|
||||||
|
- دسکتاپ: کنار یا ستون دوم پر (`sm:flex-row` / `sm:grid`).
|
||||||
|
- **نسبت سرچ و دکمه:**
|
||||||
|
- موبایل: سرچ `w-full`؛ بعد دکمهها با عرض مساوی (`grid` / `1fr`).
|
||||||
|
- اینپوت باریک کنار دکمهٔ پهن در یک ردیف wrap = زشت → ممنوع.
|
||||||
|
- بنر گرادیان جیغ و دکمهٔ `block` تمامعرض الکی ممنوع مگر اکشن اصلی صفحه باشد.
|
||||||
|
- فشرده باش: `p-2.5` / `gap-2`؛ عدد و padding غولپیکر نگذار.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۸) مهندسی بکاند / فرانت — بدون باگ الکی
|
||||||
|
|
||||||
|
- یک مسئولیت در هر کامپوننت / متد / سرویس؛ خدا-فایل نساز.
|
||||||
|
- UI نازک؛ منطق سنگین در composable یا Service.
|
||||||
|
- Controller نازک → Service؛ SQL و business را قاطی نکن.
|
||||||
|
- خطا، خالی، timeout، دوبار کلیک / race را طراحی کن (`running` قفل، early return).
|
||||||
|
- الگوی همان پوشه را کپی کن؛ اختراع ساختار جدید نکن مگر لازم باشد.
|
||||||
|
- نامگذاری گویا؛ قرارداد API فرانت و بک یکی باشد.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۹) سوپرادمین / تنظیمات دسترسی
|
||||||
|
|
||||||
|
- کلیدهای دسترسی مشتری (`customer_special_pricing`, `has_page_*`, …) مال سوپرادمیناند؛ در پنل خانگی معمولاً فقطخواندنی.
|
||||||
|
- منوی وابسته به فلگ باید از `get_settings` / overlay زنده بیاید؛ کش کهنه برای این کلیدها مطلوب نیست.
|
||||||
|
- دکمهٔ بروزرسانی تنظیمات پیشرفته باید همگام زنده از سوپرادمین را هم بزند اگر فلگ منو میخواهد عوض شود.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۱۰) چک قبل از اتمام
|
||||||
|
|
||||||
|
- [ ] diff فقط به درخواست مربوط است؟
|
||||||
|
- [ ] سیستم حسابداری / اپ / برنچ اشتباه درگیر نشده؟
|
||||||
|
- [ ] اگر مبهم بود سؤال شد؟
|
||||||
|
- [ ] یادداشت یکخطی نوشته شد؟
|
||||||
|
- [ ] UI: راهنما + بدون فضای مرده + نسبت سرچ/دکمه درست؟
|
||||||
|
- [ ] Ant / Uno / lodash بهجای reinvent؟
|
||||||
|
- [ ] جواب کوتاه است؛ توضیح اضافه نداری؟
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ۱۱) نمونهٔ رفتار درست / غلط
|
||||||
|
|
||||||
|
```text
|
||||||
|
❌ «همگامسازی مشتری خراب» → هر سه زرین/تهحساب/پرگار را عوض کند
|
||||||
|
✅ بپرسد کدام؟ بعد فقط همان
|
||||||
|
|
||||||
|
❌ UI یک کارت → کل صفحه accounting را redesign کند
|
||||||
|
✅ فقط همان کارت / همان فایل
|
||||||
|
|
||||||
|
❌ هر بار از صفر Grep مونوریپو
|
||||||
|
✅ learned-notes + project-map → مستقیم فایل
|
||||||
|
|
||||||
|
❌ CSS سفارشی ۵۰ خط برای flex ساده
|
||||||
|
✅ class="flex flex-col gap-2 sm:grid sm:grid-cols-2"
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**پایان.** این سند را بهروز نگه دار؛ نکات جدید حساس را همینجا یا در `learned-notes.md` اضافه کن.
|
||||||
@@ -44,6 +44,7 @@ declare module 'vue' {
|
|||||||
BasicToggleTwoItem: typeof import('./src/components/BasicPacks/BasicToggleTwoItem.vue')['default']
|
BasicToggleTwoItem: typeof import('./src/components/BasicPacks/BasicToggleTwoItem.vue')['default']
|
||||||
Bg_main: typeof import('./src/components/bg_main.vue')['default']
|
Bg_main: typeof import('./src/components/bg_main.vue')['default']
|
||||||
Bordered: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/bordered.vue')['default']
|
Bordered: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/bordered.vue')['default']
|
||||||
|
CopperConvertModal: typeof import('./src/components/CopperConvertModal.vue')['default']
|
||||||
DateRender: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/date-render.vue')['default']
|
DateRender: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/date-render.vue')['default']
|
||||||
Demo: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/index.vue')['default']
|
Demo: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/index.vue')['default']
|
||||||
DialogVant: typeof import('./src/components/DialogVant.vue')['default']
|
DialogVant: typeof import('./src/components/DialogVant.vue')['default']
|
||||||
@@ -56,6 +57,7 @@ declare module 'vue' {
|
|||||||
Format: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/format.vue')['default']
|
Format: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/format.vue')['default']
|
||||||
GoldDayCalculatorModal: typeof import('./src/components/GoldDayCalculatorModal.vue')['default']
|
GoldDayCalculatorModal: typeof import('./src/components/GoldDayCalculatorModal.vue')['default']
|
||||||
GoldLoading: typeof import('./src/components/GoldLoading.vue')['default']
|
GoldLoading: typeof import('./src/components/GoldLoading.vue')['default']
|
||||||
|
IdentityRequiredDialog: typeof import('./src/components/IdentityRequiredDialog.vue')['default']
|
||||||
InstallButton: typeof import('./src/components/InstallButton.vue')['default']
|
InstallButton: typeof import('./src/components/InstallButton.vue')['default']
|
||||||
ListAnim: typeof import('./src/components/ListAnim.vue')['default']
|
ListAnim: typeof import('./src/components/ListAnim.vue')['default']
|
||||||
Mode: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/mode.vue')['default']
|
Mode: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/mode.vue')['default']
|
||||||
@@ -66,6 +68,7 @@ declare module 'vue' {
|
|||||||
PwaInstallGuideModal: typeof import('./src/components/pwa/PwaInstallGuideModal.vue')['default']
|
PwaInstallGuideModal: typeof import('./src/components/pwa/PwaInstallGuideModal.vue')['default']
|
||||||
PwaInstallStepIllustration: typeof import('./src/components/pwa/PwaInstallStepIllustration.vue')['default']
|
PwaInstallStepIllustration: typeof import('./src/components/pwa/PwaInstallStepIllustration.vue')['default']
|
||||||
RangePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/range-picker.vue')['default']
|
RangePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/range-picker.vue')['default']
|
||||||
|
RequiredKycModal: typeof import('./src/components/RequiredKycModal.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
SelectInRange: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/select-in-range.vue')['default']
|
SelectInRange: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/select-in-range.vue')['default']
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
if('serviceWorker' in navigator) navigator.serviceWorker.register('/dev-sw.js?dev-sw', { scope: '/', type: 'classic' })
|
if('serviceWorker' in navigator) navigator.serviceWorker.register('/dev-sw.js?dev-sw', { scope: '/', type: 'module' })
|
||||||
@@ -30,9 +30,35 @@
|
|||||||
<component :is="Component" :key="route.fullPath" />
|
<component :is="Component" :key="route.fullPath" />
|
||||||
</router-view>
|
</router-view>
|
||||||
</div>
|
</div>
|
||||||
|
<RequiredKycModal v-if="!showSplash && !isTvBoardRoute && !isLoginRoute" />
|
||||||
</AConfigProvider>
|
</AConfigProvider>
|
||||||
<div
|
<div
|
||||||
v-if="showSupportButton && !showSplash && route.name !== 'support' && !isTvBoardRoute"
|
v-if="showGiftCardButton"
|
||||||
|
id="gift-card-button"
|
||||||
|
class="fixed z-[5095] cursor-grab select-none rounded-full"
|
||||||
|
:class="{ 'cursor-grabbing': giftCardDragging }"
|
||||||
|
:style="giftCardButtonStyle"
|
||||||
|
title="ثبت کارت هدیه"
|
||||||
|
@pointerdown="onGiftCardPointerDown"
|
||||||
|
@pointermove="onGiftCardPointerMove"
|
||||||
|
@pointerup="handleGiftCardPointerUp"
|
||||||
|
@pointercancel="onGiftCardPointerCancel"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="relative inline-flex items-center gap-2 rounded-full bg-white border border-solid border-gray-200 shadow-[0_6px_20px_rgba(15,23,42,0.14)] px-3.5 py-[9px] text-slate-800 text-[13px] font-600 leading-none transition-all duration-200"
|
||||||
|
:class="{ 'shadow-[0_10px_28px_rgba(15,23,42,0.22)]': giftCardDragging }"
|
||||||
|
>
|
||||||
|
<BasicIcon
|
||||||
|
icon="vuesax-linear:gift"
|
||||||
|
size="18"
|
||||||
|
:color="giftCardFabAccent"
|
||||||
|
class="shrink-0"
|
||||||
|
/>
|
||||||
|
<span class="whitespace-nowrap">ثبت کارت هدیه</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="showSupportButton && !showSplash && route.name !== 'support' && route.name !== 'login' && !isTvBoardRoute && !isKycRequired"
|
||||||
id="support-button"
|
id="support-button"
|
||||||
ref="supportButtonEl"
|
ref="supportButtonEl"
|
||||||
class="fixed z-[5100] cursor-grab select-none rounded-full"
|
class="fixed z-[5100] cursor-grab select-none rounded-full"
|
||||||
@@ -71,19 +97,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="!showSplash && !isDesktop && !isTvBoardRoute"
|
v-if="!showSplash && !isDesktop && !isTvBoardRoute && !isLoginRoute"
|
||||||
class="app-credit-footer app-credit-footer--mobile"
|
class="app-credit-footer app-credit-footer--mobile"
|
||||||
:class="{ 'app-credit-footer--login': isLoginRoute }"
|
:class="{ 'app-credit-footer--login': showLoginCreditExtras }"
|
||||||
>
|
>
|
||||||
<EnamadBadge v-if="isLoginRoute" size="sm" />
|
<EnamadBadge v-if="showLoginCreditExtras" size="sm" />
|
||||||
<AppCreditLink variant="mobile" />
|
<AppCreditLink variant="mobile" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="!showSplash && showDesktopFloatingCredit && !isTvBoardRoute"
|
v-if="!showSplash && showDesktopFloatingCredit && !isTvBoardRoute"
|
||||||
class="app-credit-footer app-credit-footer--desktop-float"
|
class="app-credit-footer app-credit-footer--desktop-float"
|
||||||
:class="{ 'app-credit-footer--login': isLoginRoute }"
|
:class="{ 'app-credit-footer--login': showLoginCreditExtras }"
|
||||||
>
|
>
|
||||||
<EnamadBadge v-if="isLoginRoute" size="sm" />
|
<EnamadBadge v-if="showLoginCreditExtras" size="sm" />
|
||||||
<AppCreditLink variant="float" />
|
<AppCreditLink variant="float" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -126,12 +152,13 @@ import { useDraggableFloatingButton } from '@/utils/useDraggableFloatingButton'
|
|||||||
import AppCreditLink from '@/components/AppCreditLink.vue'
|
import AppCreditLink from '@/components/AppCreditLink.vue'
|
||||||
import EnamadBadge from '@/components/EnamadBadge.vue'
|
import EnamadBadge from '@/components/EnamadBadge.vue'
|
||||||
import SupportMessengerPicker from '@/components/SupportMessengerPicker.vue'
|
import SupportMessengerPicker from '@/components/SupportMessengerPicker.vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { recoverMobileViewportAfterAuth } from '@/layouts/composables/useMobileScrollReset'
|
import { recoverMobileViewportAfterAuth } from '@/layouts/composables/useMobileScrollReset'
|
||||||
import { usePwaInstall } from '@/composables/usePwaInstall'
|
import { usePwaInstall } from '@/composables/usePwaInstall'
|
||||||
import PwaInstallBanner from '@/components/pwa/PwaInstallBanner.vue'
|
import PwaInstallBanner from '@/components/pwa/PwaInstallBanner.vue'
|
||||||
import PwaInstallGuideModal from '@/components/pwa/PwaInstallGuideModal.vue'
|
import PwaInstallGuideModal from '@/components/pwa/PwaInstallGuideModal.vue'
|
||||||
import GoldDayCalculatorModal from '@/components/GoldDayCalculatorModal.vue'
|
import GoldDayCalculatorModal from '@/components/GoldDayCalculatorModal.vue'
|
||||||
|
import RequiredKycModal from '@/components/RequiredKycModal.vue'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import { useSettingsStore } from '@/store/settingsStore'
|
import { useSettingsStore } from '@/store/settingsStore'
|
||||||
import {
|
import {
|
||||||
@@ -142,6 +169,7 @@ import {
|
|||||||
useChatService,
|
useChatService,
|
||||||
} from '@/utils/chat'
|
} from '@/utils/chat'
|
||||||
import { getToken } from '@/utils'
|
import { getToken } from '@/utils'
|
||||||
|
import { isCustomerIdentityVerified } from '@/utils/customerIdentity'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import { showBrowserNotification } from '@/utils/browserNotification'
|
import { showBrowserNotification } from '@/utils/browserNotification'
|
||||||
|
|
||||||
@@ -153,9 +181,13 @@ useApplyDesktopLayoutClass()
|
|||||||
|
|
||||||
const isDesktop = useDesktopBreakpoint()
|
const isDesktop = useDesktopBreakpoint()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
const showDesktopFloatingCredit = computed(() => {
|
const showDesktopFloatingCredit = computed(() => {
|
||||||
if (!isDesktop.value) return false
|
if (!isDesktop.value) return false
|
||||||
return route.name === 'login' || !!route.meta.hideMenu
|
// پشتیبانی خودش سایدبار دارد؛ float روی دکمه ارسال میافتد
|
||||||
|
if (route.name === 'support') return false
|
||||||
|
if (route.name === 'login') return false
|
||||||
|
return !!route.meta.hideMenu
|
||||||
})
|
})
|
||||||
const isLoginRoute = computed(() => route.name === 'login')
|
const isLoginRoute = computed(() => route.name === 'login')
|
||||||
|
|
||||||
@@ -297,6 +329,52 @@ watch(
|
|||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
|
const isKycRequired = computed(
|
||||||
|
() =>
|
||||||
|
Boolean(getToken()) &&
|
||||||
|
Boolean(userStore.userInfo) &&
|
||||||
|
!isCustomerIdentityVerified(userStore.userInfo?.is_legal),
|
||||||
|
)
|
||||||
|
|
||||||
|
const giftCardFabAccent = computed(
|
||||||
|
() => config.config?.color || getProjectPrimaryColor() || '#334155',
|
||||||
|
)
|
||||||
|
|
||||||
|
const showGiftCardButton = computed(() => {
|
||||||
|
if (showSplash.value) return false
|
||||||
|
if (isTvBoardRoute.value || isLoginRoute.value || isKycRequired.value) return false
|
||||||
|
if (route.name === 'giftCard') return false
|
||||||
|
if (!getToken()) return false
|
||||||
|
return settingsStore.isSettingTruthy('has_page_gift_card')
|
||||||
|
})
|
||||||
|
|
||||||
|
const {
|
||||||
|
dragging: giftCardDragging,
|
||||||
|
fabStyle: giftCardButtonStyle,
|
||||||
|
handlePointerDown: onGiftCardPointerDown,
|
||||||
|
handlePointerMove: onGiftCardPointerMove,
|
||||||
|
handlePointerUp: giftCardPointerUp,
|
||||||
|
handlePointerCancel: onGiftCardPointerCancel,
|
||||||
|
} = useDraggableFloatingButton('boursecu_gift_card_button_position_v1', {
|
||||||
|
width: 148,
|
||||||
|
height: 42,
|
||||||
|
defaultBottomGap: 62,
|
||||||
|
defaultRightOffset: 16,
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleGiftCardPointerUp(event: PointerEvent) {
|
||||||
|
const clicked = giftCardPointerUp(event)
|
||||||
|
if (!clicked) return
|
||||||
|
event.stopPropagation()
|
||||||
|
void router.push({ name: 'giftCard' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const showLoginCreditExtras = computed(() => {
|
||||||
|
if (!isLoginRoute.value) return false
|
||||||
|
const href = String(settingsStore.getSettingByKey('enamad_url') ?? '').trim()
|
||||||
|
const src = String(settingsStore.getSettingByKey('enamad_logo') ?? '').trim()
|
||||||
|
return Boolean(href && src)
|
||||||
|
})
|
||||||
const { latestIncomingNotification } = useChatService()
|
const { latestIncomingNotification } = useChatService()
|
||||||
let lastConnectedChatSessionKey = ''
|
let lastConnectedChatSessionKey = ''
|
||||||
let lastSupportToastAt = 0
|
let lastSupportToastAt = 0
|
||||||
@@ -424,13 +502,14 @@ watch(latestIncomingNotification, (payload) => {
|
|||||||
min-height: var(--app-credit-bar-inner);
|
min-height: var(--app-credit-bar-inner);
|
||||||
padding: 4px 0 var(--app-safe-bottom);
|
padding: 4px 0 var(--app-safe-bottom);
|
||||||
background: #fff;
|
background: #fff;
|
||||||
box-shadow: 0 -2px 4px -2px #0000001a;
|
box-shadow: 0 3.75px 16px 0 rgba(0, 0, 0, 0.43);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
font-size: 9px;
|
font-size: 9px;
|
||||||
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-credit-footer--login.app-credit-footer--mobile {
|
.app-credit-footer--login.app-credit-footer--mobile {
|
||||||
@@ -461,6 +540,7 @@ watch(latestIncomingNotification, (payload) => {
|
|||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
opacity: 0.85;
|
opacity: 0.85;
|
||||||
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__text {
|
&__text {
|
||||||
@@ -470,13 +550,19 @@ watch(latestIncomingNotification, (payload) => {
|
|||||||
|
|
||||||
&__logo {
|
&__logo {
|
||||||
width: auto;
|
width: auto;
|
||||||
|
height: 12px;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--mobile {
|
&--mobile {
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
color: inherit;
|
color: #000;
|
||||||
|
|
||||||
|
.app-credit-link__text {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
.app-credit-link__logo {
|
.app-credit-link__logo {
|
||||||
height: 12px;
|
height: 12px;
|
||||||
@@ -577,14 +663,15 @@ html.project-boursecu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 426px) and (max-width: 767.98px) {
|
@media screen and (min-width: 426px) and (max-width: 767.98px) {
|
||||||
.desktopConfig {
|
html:not(.app-layout--desktop) .desktopConfig {
|
||||||
width: 426px;
|
width: 426px;
|
||||||
position: relative !important;
|
position: relative !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
html.app-layout--desktop {
|
html.app-layout--desktop {
|
||||||
#support-button {
|
#support-button,
|
||||||
|
#gift-card-button {
|
||||||
bottom: 12px;
|
bottom: 12px;
|
||||||
right: calc(var(--app-desktop-sidebar-width, 260px) + 20px);
|
right: calc(var(--app-desktop-sidebar-width, 260px) + 20px);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import useAxios from '@/utils/useAxios'
|
||||||
|
import type { CopperConvertSource } from '@/utils/copperWireConvert'
|
||||||
|
|
||||||
|
export interface CopperConvertHistoryRow {
|
||||||
|
id: number
|
||||||
|
status: string
|
||||||
|
source: string
|
||||||
|
asset_unit: string
|
||||||
|
consumed_amount: number
|
||||||
|
leftover_amount: number
|
||||||
|
wire15_rings: number
|
||||||
|
wire25_rings: number
|
||||||
|
created_at?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createCopperConvertRequest(payload: {
|
||||||
|
source: CopperConvertSource
|
||||||
|
rings15: number
|
||||||
|
rings25: number
|
||||||
|
}) {
|
||||||
|
return useAxios.post('/customer/copper-convert-request', payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCopperConvertRequests() {
|
||||||
|
return useAxios.get<CopperConvertHistoryRow[]>('/customer/copper-convert-request')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateCopperConvertRequest(
|
||||||
|
id: number,
|
||||||
|
payload: {
|
||||||
|
source: CopperConvertSource
|
||||||
|
rings15: number
|
||||||
|
rings25: number
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
return useAxios.put(`/customer/copper-convert-request/${id}`, payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteCopperConvertRequest(id: number) {
|
||||||
|
return useAxios.delete(`/customer/copper-convert-request/${id}`)
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import useAxios from '@/utils/useAxios'
|
||||||
|
|
||||||
|
export interface DigipayInstallmentStatus {
|
||||||
|
enabled: boolean
|
||||||
|
status: 'none' | 'pending' | 'active' | string
|
||||||
|
plan4_remaining_toman: number
|
||||||
|
plan12_remaining_toman: number
|
||||||
|
gram_price_rial: number
|
||||||
|
config: {
|
||||||
|
onboarding_url: string
|
||||||
|
fee_shop_percent: number
|
||||||
|
fee_gateway_percent: number
|
||||||
|
fee_extra_percent: number
|
||||||
|
plan4_cap_toman: number
|
||||||
|
plan12_cap_toman: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const fetchDigipayInstallment = () =>
|
||||||
|
useAxios.get<DigipayInstallmentStatus>('/customer/digipay_installment')
|
||||||
|
|
||||||
|
export const startDigipayInstallment = () =>
|
||||||
|
useAxios.post<DigipayInstallmentStatus>('/customer/digipay_installment/start')
|
||||||
|
|
||||||
|
export const buyDigipayInstallment = (plan: 4 | 12, amountToman: number) =>
|
||||||
|
useAxios.post('/customer/digipay_installment/buy', { plan, amount_toman: amountToman })
|
||||||
@@ -1,5 +1,27 @@
|
|||||||
import useAxios from "@/utils/useAxios";
|
import useAxios from "@/utils/useAxios";
|
||||||
|
|
||||||
|
export interface CustomerGiftCardItem {
|
||||||
|
id: number
|
||||||
|
giftcard_id: number
|
||||||
|
code: string
|
||||||
|
name: string | null
|
||||||
|
description: string | null
|
||||||
|
amount: number | string | null
|
||||||
|
unit: number
|
||||||
|
kind: 'gift' | 'discount'
|
||||||
|
scope: 'personal' | 'public'
|
||||||
|
sts: number
|
||||||
|
expiry_date: string | null
|
||||||
|
used_at: string | null
|
||||||
|
}
|
||||||
|
|
||||||
//customer
|
export interface CustomerGiftCardMineResponse {
|
||||||
export const registerCodeGiftCard = async (code: string) => await useAxios.post(`/customer/giftcard/use`, {code:code})
|
available: CustomerGiftCardItem[]
|
||||||
|
history: CustomerGiftCardItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const registerCodeGiftCard = async (code: string) =>
|
||||||
|
await useAxios.post(`/customer/giftcard/use`, { code })
|
||||||
|
|
||||||
|
export const fetchMyGiftCards = async () =>
|
||||||
|
await useAxios.get<CustomerGiftCardMineResponse>(`/customer/giftcard/mine`)
|
||||||
|
|||||||
@@ -9,3 +9,6 @@ export const getPrice = async () => await useAxios.get<Price>(`/api/price/up`)
|
|||||||
export const getLastPrice = async () => await useAxios.get<Price>(`/api/price/last`)
|
export const getLastPrice = async () => await useAxios.get<Price>(`/api/price/last`)
|
||||||
|
|
||||||
export const getAllPrices = async () => await useAxios.post('/customer/prices/all')
|
export const getAllPrices = async () => await useAxios.post('/customer/prices/all')
|
||||||
|
|
||||||
|
/** نمودار مهمان — همان بدنهٔ prices/all، بدون توکن مشتری */
|
||||||
|
export const getPublicChartPrices = async () => await useAxios.post('/api/price/all')
|
||||||
@@ -5,12 +5,14 @@ import type {Ref, UnwrapRef} from "vue";
|
|||||||
import type {Transaction} from "@/models/transaction";
|
import type {Transaction} from "@/models/transaction";
|
||||||
import {useUserStore} from "@/store/userStore";
|
import {useUserStore} from "@/store/userStore";
|
||||||
|
|
||||||
const userStore = useUserStore()
|
function customerOrderBase() {
|
||||||
|
return `/customer${useUserStore().isSingle ? '/single' : ''}/order`
|
||||||
|
}
|
||||||
|
|
||||||
export const createOrder = async (obj: Order): Promise<any> => {
|
export const createOrder = async (obj: Order): Promise<any> => {
|
||||||
return await useAxios.post<Order>(`/customer${!userStore.isSingle ? '' : '/single'}/order`, obj)
|
return await useAxios.post<Order>(customerOrderBase(), obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getOrders = async (tbl: Ref<UnwrapRef<TableInput>>): Promise<TableOutput<Transaction>> => {
|
export const getOrders = async (tbl: Ref<UnwrapRef<TableInput>>): Promise<TableOutput<Transaction>> => {
|
||||||
return await useAxios.post<TableOutput<Order>>(`/customer${!userStore.isSingle ? '' : '/single'}/order/table`, tbl)
|
return await useAxios.post<TableOutput<Order>>(`${customerOrderBase()}/table`, tbl)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ export const deposit = async (obj: Transaction): Promise<any> => {
|
|||||||
return await useAxios.post<Transaction>(`/customer/charge_account`, obj)
|
return await useAxios.post<Transaction>(`/customer/charge_account`, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const submitDepositRequest = async (formData: FormData): Promise<any> => {
|
||||||
|
return await useAxios.postForm(`/customer/wallet/deposit_request`, formData)
|
||||||
|
}
|
||||||
|
|
||||||
export const createCard = async (obj: Card): Promise<any> => {
|
export const createCard = async (obj: Card): Promise<any> => {
|
||||||
return await useAxios.post<Transaction>(`/customer/account`, obj)
|
return await useAxios.post<Transaction>(`/customer/account`, obj)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/** تاریخچه قیمت عمومی بورس کالا (بدون توکن) — کاتد مس */
|
||||||
|
|
||||||
|
export const ZAANBOX_COPPER_CTHD_ID = '8c19e06a-446e-3d56-9cc0-750f7c6cd767'
|
||||||
|
|
||||||
|
export const ZAANBOX_HISTORY_URL = `https://price.zaarbox.ir/api/history/${ZAANBOX_COPPER_CTHD_ID}`
|
||||||
|
|
||||||
|
export type ZaanboxHistoryPoint = {
|
||||||
|
time: string
|
||||||
|
price: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ZaanboxHistoryResponse = {
|
||||||
|
history?: ZaanboxHistoryPoint[]
|
||||||
|
data?: { history?: ZaanboxHistoryPoint[] }
|
||||||
|
}
|
||||||
|
|
||||||
|
export type LandingHistoryRange = 'DAILY' | 'WEEKLY' | 'MONTHLY'
|
||||||
|
|
||||||
|
export type LandingHistorySample = {
|
||||||
|
timeMs: number
|
||||||
|
price: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const RANGE_MS: Record<LandingHistoryRange, number> = {
|
||||||
|
DAILY: 1 * 24 * 60 * 60 * 1000,
|
||||||
|
WEEKLY: 7 * 24 * 60 * 60 * 1000,
|
||||||
|
MONTHLY: 30 * 24 * 60 * 60 * 1000,
|
||||||
|
}
|
||||||
|
|
||||||
|
const HISTORY_LIMIT = 1_000_000_000
|
||||||
|
|
||||||
|
function resolveHistoryRows(payload: unknown): ZaanboxHistoryPoint[] {
|
||||||
|
if (!payload || typeof payload !== 'object') return []
|
||||||
|
const body = payload as ZaanboxHistoryResponse
|
||||||
|
if (Array.isArray(body.history)) return body.history
|
||||||
|
if (Array.isArray(body.data?.history)) return body.data!.history!
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchZaanboxPriceHistory(
|
||||||
|
range: LandingHistoryRange,
|
||||||
|
now = new Date(),
|
||||||
|
): Promise<LandingHistorySample[]> {
|
||||||
|
const end = now
|
||||||
|
const start = new Date(end.getTime() - RANGE_MS[range])
|
||||||
|
const url = new URL(ZAANBOX_HISTORY_URL)
|
||||||
|
url.searchParams.set('start', start.toISOString())
|
||||||
|
url.searchParams.set('end', end.toISOString())
|
||||||
|
url.searchParams.set('limit', String(HISTORY_LIMIT))
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
method: 'GET',
|
||||||
|
headers: { Accept: 'application/json' },
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Zaanbox history HTTP ${response.status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = (await response.json()) as unknown
|
||||||
|
const rows = resolveHistoryRows(payload)
|
||||||
|
|
||||||
|
return rows
|
||||||
|
.map((row) => {
|
||||||
|
const timeMs = Date.parse(String(row.time ?? ''))
|
||||||
|
const price = Number(row.price)
|
||||||
|
return { timeMs, price }
|
||||||
|
})
|
||||||
|
.filter((point) => Number.isFinite(point.timeMs) && Number.isFinite(point.price) && point.price > 0)
|
||||||
|
.sort((a, b) => a.timeMs - b.timeMs)
|
||||||
|
}
|
||||||
@@ -1,17 +1,49 @@
|
|||||||
|
const FINGER_SESSION_KEY = 'boursecu_finger_session_ok'
|
||||||
|
|
||||||
let fingerPosition = false
|
let fingerPosition = false
|
||||||
|
|
||||||
|
function readPersistedFingerSession(): boolean {
|
||||||
|
try {
|
||||||
|
return sessionStorage.getItem(FINGER_SESSION_KEY) === '1'
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function writePersistedFingerSession(value: boolean) {
|
||||||
|
try {
|
||||||
|
if (value) {
|
||||||
|
sessionStorage.setItem(FINGER_SESSION_KEY, '1')
|
||||||
|
} else {
|
||||||
|
sessionStorage.removeItem(FINGER_SESSION_KEY)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// ignore quota / private mode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function setTruth() {
|
export function setTruth() {
|
||||||
fingerPosition = true
|
fingerPosition = true
|
||||||
|
writePersistedFingerSession(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setEnableAuthenticate() {
|
export function setEnableAuthenticate() {
|
||||||
fingerPosition = false
|
fingerPosition = false
|
||||||
|
writePersistedFingerSession(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFingerPosition() {
|
export function getFingerPosition() {
|
||||||
return fingerPosition
|
if (fingerPosition) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (readPersistedFingerSession()) {
|
||||||
|
fingerPosition = true
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setFingerPosition(value: boolean) {
|
export function setFingerPosition(value: boolean) {
|
||||||
fingerPosition = value
|
fingerPosition = value
|
||||||
|
writePersistedFingerSession(value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { initPriceRealtimeChannel } from '@/utils/priceSocket'
|
|||||||
import { initMobileScrollRestoration } from '@/layouts/composables/useMobileScrollReset'
|
import { initMobileScrollRestoration } from '@/layouts/composables/useMobileScrollReset'
|
||||||
import { initMobileInputKeyboardScroll } from '@/utils/mobileInputKeyboardScroll'
|
import { initMobileInputKeyboardScroll } from '@/utils/mobileInputKeyboardScroll'
|
||||||
import { isServerUnavailableError } from '@/utils/serverUnavailable'
|
import { isServerUnavailableError } from '@/utils/serverUnavailable'
|
||||||
|
import { isGuestHomeQuery } from '@/utils/guestHome'
|
||||||
|
|
||||||
type BootWindow = Window & {
|
type BootWindow = Window & {
|
||||||
__BOOT_TIMEOUT__?: number
|
__BOOT_TIMEOUT__?: number
|
||||||
@@ -116,9 +117,7 @@ export async function bootstrapApp() {
|
|||||||
|
|
||||||
await withTimeout(settingsStore.fetchSettings(), 45000, 'Settings loading timeout')
|
await withTimeout(settingsStore.fetchSettings(), 45000, 'Settings loading timeout')
|
||||||
|
|
||||||
if (getToken()) {
|
|
||||||
initPriceRealtimeChannel((key) => settingsStore.getSettingByKey(key))
|
initPriceRealtimeChannel((key) => settingsStore.getSettingByKey(key))
|
||||||
}
|
|
||||||
|
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
await withTimeout(userStore.getMyInfo(), 45000, 'User session loading timeout')
|
await withTimeout(userStore.getMyInfo(), 45000, 'User session loading timeout')
|
||||||
@@ -132,7 +131,15 @@ export async function bootstrapApp() {
|
|||||||
|
|
||||||
await router.isReady()
|
await router.isReady()
|
||||||
|
|
||||||
if (!getToken() && router.currentRoute.value.name !== 'login' && router.currentRoute.value.name !== 'tvMonitor' && router.currentRoute.value.name !== 'aboutSoftware') {
|
const bootRoute = router.currentRoute.value
|
||||||
|
const guestHomeBoot = bootRoute.name === 'home' && isGuestHomeQuery(bootRoute.query)
|
||||||
|
if (
|
||||||
|
!getToken()
|
||||||
|
&& bootRoute.name !== 'login'
|
||||||
|
&& bootRoute.name !== 'tvMonitor'
|
||||||
|
&& bootRoute.name !== 'aboutSoftware'
|
||||||
|
&& !guestHomeBoot
|
||||||
|
) {
|
||||||
await router.replace({ name: 'login' })
|
await router.replace({ name: 'login' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,16 @@ import type { NavigationGuardNext } from 'vue-router'
|
|||||||
import { useAuthStore } from '@/store/useAuthStore'
|
import { useAuthStore } from '@/store/useAuthStore'
|
||||||
import { recoverMobileViewportAfterAuth } from '@/layouts/composables/useMobileScrollReset'
|
import { recoverMobileViewportAfterAuth } from '@/layouts/composables/useMobileScrollReset'
|
||||||
import { getFingerPosition, setFingerPosition } from '@/app/authBoot'
|
import { getFingerPosition, setFingerPosition } from '@/app/authBoot'
|
||||||
|
import { isGuestHomeQuery } from '@/utils/guestHome'
|
||||||
|
import type { RouteLocationNormalized } from 'vue-router'
|
||||||
|
|
||||||
const PUBLIC_ROUTE_NAMES = ['login', '404', 'educate', 'aboutUs', 'aboutSoftware', 'tvMonitor'] as const
|
const PUBLIC_ROUTE_NAMES = ['login', '404', 'educate', 'aboutUs', 'aboutSoftware', 'tvMonitor'] as const
|
||||||
|
|
||||||
function isPublicRoute(name: string | symbol | null | undefined) {
|
function isPublicRoute(to: RouteLocationNormalized) {
|
||||||
return PUBLIC_ROUTE_NAMES.includes(name as (typeof PUBLIC_ROUTE_NAMES)[number])
|
if (to.name === 'home' && isGuestHomeQuery(to.query)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return PUBLIC_ROUTE_NAMES.includes(to.name as (typeof PUBLIC_ROUTE_NAMES)[number])
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToLogin(next: NavigationGuardNext) {
|
function goToLogin(next: NavigationGuardNext) {
|
||||||
@@ -71,7 +76,7 @@ export function setupRouterGuards() {
|
|||||||
const authenticated = await resolveSession()
|
const authenticated = await resolveSession()
|
||||||
|
|
||||||
if (!authenticated) {
|
if (!authenticated) {
|
||||||
if (isPublicRoute(to.name)) {
|
if (isPublicRoute(to)) {
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
return goToLogin(next)
|
return goToLogin(next)
|
||||||
@@ -88,6 +93,17 @@ export function setupRouterGuards() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (to.name === 'installment') {
|
||||||
|
const { useSettingsStore } = await import('@/store/settingsStore')
|
||||||
|
const settingsStore = useSettingsStore()
|
||||||
|
if (!settingsStore.loaded) {
|
||||||
|
await settingsStore.fetchSettings()
|
||||||
|
}
|
||||||
|
if (!settingsStore.isSettingTruthy('enable_digipay_installment')) {
|
||||||
|
return next({ name: (from.name as string) || 'user' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (to.name === 'giftCard') {
|
if (to.name === 'giftCard') {
|
||||||
const { useSettingsStore } = await import('@/store/settingsStore')
|
const { useSettingsStore } = await import('@/store/settingsStore')
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
@@ -160,6 +176,8 @@ export function setupRouterGuards() {
|
|||||||
timeoutId = setTimeout(() => {
|
timeoutId = setTimeout(() => {
|
||||||
if (hasFingerPrint) {
|
if (hasFingerPrint) {
|
||||||
setFingerPosition(false)
|
setFingerPosition(false)
|
||||||
|
// بعد از انقضا دوباره WebAuthn بخواهد؛ مستقیم لاگین اجباری نکند
|
||||||
|
fingerprintChecked = false
|
||||||
}
|
}
|
||||||
}, 180000)
|
}, 180000)
|
||||||
}
|
}
|
||||||
@@ -190,7 +208,11 @@ export async function ensureAuthenticatedRoute() {
|
|||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
userStore.userInfo = undefined
|
userStore.userInfo = undefined
|
||||||
if (router.currentRoute.value.name !== 'login') {
|
const current = router.currentRoute.value
|
||||||
|
if (current.name === 'home' && isGuestHomeQuery(current.query)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (current.name !== 'login') {
|
||||||
await router.replace({ name: 'login' })
|
await router.replace({ name: 'login' })
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ html.project-boursecu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ant-input-group-addon {
|
.ant-input-group-addon {
|
||||||
background-color: @secondary-color !important;
|
background-color: #e0be7f !important;
|
||||||
color: @App-primary-color !important;
|
color: #0a1b37 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-red,
|
.text-red,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
@import (less) '../../views/base/rules/desktop/styles/desktop-rules.less';
|
@import (less) '../../views/base/rules/desktop/styles/desktop-rules.less';
|
||||||
@import (less) '../../views/base/rules/permissions/desktop/styles/desktop-permissions.less';
|
@import (less) '../../views/base/rules/permissions/desktop/styles/desktop-permissions.less';
|
||||||
@import (less) '../../views/base/giftCard/desktop/styles/desktop-gift-card.less';
|
@import (less) '../../views/base/giftCard/desktop/styles/desktop-gift-card.less';
|
||||||
|
@import (less) '../../views/base/home/styles/landing-live-chart-main.less';
|
||||||
@import (less) '../../views/base/address/desktop/styles/desktop-address.less';
|
@import (less) '../../views/base/address/desktop/styles/desktop-address.less';
|
||||||
@import (less) '../../views/base/educate/desktop/styles/desktop-educate.less';
|
@import (less) '../../views/base/educate/desktop/styles/desktop-educate.less';
|
||||||
@import (less) '../../views/base/aboutUs/desktop/styles/desktop-about-us.less';
|
@import (less) '../../views/base/aboutUs/desktop/styles/desktop-about-us.less';
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
@import (less) '../../views/base/fund/desktop/styles/desktop-fund.less';
|
@import (less) '../../views/base/fund/desktop/styles/desktop-fund.less';
|
||||||
@import (less) '../../views/base/gold/desktop/styles/desktop-gold.less';
|
@import (less) '../../views/base/gold/desktop/styles/desktop-gold.less';
|
||||||
@import (less) './mobile-keyboard-scroll.less';
|
@import (less) './mobile-keyboard-scroll.less';
|
||||||
|
@import (less) '../../styles/app-premium-modal.less';
|
||||||
|
|
||||||
html {
|
html {
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
@@ -449,8 +451,8 @@ body:has(.ant-modal-root .ant-modal-wrap:not([style*='display: none'])) {
|
|||||||
color:@App-primary-color !important;
|
color:@App-primary-color !important;
|
||||||
}
|
}
|
||||||
.ant-input-group-addon{
|
.ant-input-group-addon{
|
||||||
background-color: @App-primary-color !important;
|
background-color: #e0be7f !important;
|
||||||
color: @secondary-color !important;
|
color: #0a1b37 !important;
|
||||||
}
|
}
|
||||||
.ant-slider-track{
|
.ant-slider-track{
|
||||||
background-color:@App-primary-color !important;
|
background-color:@App-primary-color !important;
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 176 KiB |
|
Before Width: | Height: | Size: 830 KiB |
|
Before Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 912 KiB |
|
Before Width: | Height: | Size: 929 KiB |
|
Before Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 16 KiB |
@@ -7,11 +7,16 @@
|
|||||||
:class="`app-credit-link--${variant}`"
|
:class="`app-credit-link--${variant}`"
|
||||||
>
|
>
|
||||||
<span class="app-credit-link__text">توسعه و طراحی توسط</span>
|
<span class="app-credit-link__text">توسعه و طراحی توسط</span>
|
||||||
<img src="/logo-montzar.png" alt="montzar" class="app-credit-link__logo" />
|
<img :src="logoSrc" alt="montzar" class="app-credit-link__logo" />
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
const logoSrc = `${import.meta.env.BASE_URL || '/'}logo-montzar.png`.replace(
|
||||||
|
/([^:]\/)\/+/g,
|
||||||
|
'$1',
|
||||||
|
)
|
||||||
|
|
||||||
withDefaults(
|
withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
variant?: 'mobile' | 'sidebar' | 'float' | 'tv'
|
variant?: 'mobile' | 'sidebar' | 'float' | 'tv'
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<AButton :disabled="props.disabledB" :type="props.type" :size="props.size" :class="[prefixCls, _class]" :loading="props.loading">
|
<AButton
|
||||||
|
:disabled="props.disabledB"
|
||||||
|
:type="props.type"
|
||||||
|
:size="props.size"
|
||||||
|
:class="[prefixCls, _class]"
|
||||||
|
:loading="props.loading"
|
||||||
|
:html-type="props.htmlType"
|
||||||
|
@click="onClick"
|
||||||
|
>
|
||||||
<!-- py-1 px-2-->
|
<!-- py-1 px-2-->
|
||||||
<div
|
<div
|
||||||
class="flex items-center gap-1 justify-center flex-row-reverse gap-2 py-1 px-2"
|
class="flex items-center gap-1 justify-center flex-row-reverse gap-2 py-1 px-2"
|
||||||
@@ -28,7 +36,7 @@ interface Props {
|
|||||||
size?: string
|
size?: string
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
disabledB?:boolean
|
disabledB?:boolean
|
||||||
|
htmlType?: 'button' | 'submit' | 'reset'
|
||||||
// prefixIcon?: string
|
// prefixIcon?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,8 +59,17 @@ const { prefixCls } = usePrefix('base-button')
|
|||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
iconSize: baseButtonIconSize,
|
iconSize: baseButtonIconSize,
|
||||||
// iconLeft: false,
|
// iconLeft: false,
|
||||||
iconClass: ''
|
iconClass: '',
|
||||||
|
htmlType: 'submit',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
click: [event: MouseEvent]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
function onClick(event: MouseEvent) {
|
||||||
|
emit('click', event)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
|||||||
@@ -33,10 +33,12 @@ const color = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.size) {
|
if (props.size && refIcon.value) {
|
||||||
const svg: SVGElement = refIcon.value?.children[0] as SVGElement
|
const svg = refIcon.value.children?.[0] as SVGElement | undefined
|
||||||
svg.setAttribute('width', props.size as string)
|
if (svg && typeof svg.setAttribute === 'function') {
|
||||||
svg.setAttribute('height', props.size as string)
|
svg.setAttribute('width', String(props.size))
|
||||||
|
svg.setAttribute('height', String(props.size))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ interface Prop {
|
|||||||
placeHolder?: String
|
placeHolder?: String
|
||||||
}
|
}
|
||||||
|
|
||||||
const addonBgColor = computed(() => props.addonBgColor)
|
|
||||||
const addonTextColor = computed(() => props.addonTextColor)
|
|
||||||
//emits
|
//emits
|
||||||
const localValue = computed({
|
const localValue = computed({
|
||||||
set(value) {
|
set(value) {
|
||||||
@@ -132,8 +130,8 @@ const {prefixCls} = usePrefix('input')
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ant-input-group-addon {
|
.ant-input-group-addon {
|
||||||
background-color: v-bind(addonBgColor);
|
background-color: #e0be7f !important;
|
||||||
color: v-bind(addonTextColor);
|
color: #0a1b37 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -13,10 +13,13 @@
|
|||||||
:width="props.width"
|
:width="props.width"
|
||||||
:ok-text="props.okText"
|
:ok-text="props.okText"
|
||||||
:cancel-text="props.cancelText"
|
:cancel-text="props.cancelText"
|
||||||
:wrapClassName="props.wrapClassName"
|
:wrapClassName="mergedWrapClassName"
|
||||||
:closable="props.closable"
|
:closable="props.closable"
|
||||||
:destroy-on-close="props.destroyOnClose"
|
:destroy-on-close="props.destroyOnClose"
|
||||||
>
|
>
|
||||||
|
<template v-if="$slots.title" #title>
|
||||||
|
<slot name="title" />
|
||||||
|
</template>
|
||||||
<template v-if="props.customFooter" #footer> <slot name="footer" /></template>
|
<template v-if="props.customFooter" #footer> <slot name="footer" /></template>
|
||||||
<a-spin :spinning="props.loading">
|
<a-spin :spinning="props.loading">
|
||||||
<div class="overflow-y-auto py-2 px-1 relative max-h-[83vh]" id="body">
|
<div class="overflow-y-auto py-2 px-1 relative max-h-[83vh]" id="body">
|
||||||
@@ -60,6 +63,11 @@ const props = withDefaults(defineProps<Prop>(), {
|
|||||||
zIndex: APP_Z_MODAL,
|
zIndex: APP_Z_MODAL,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const mergedWrapClassName = computed(() => {
|
||||||
|
const extra = (props.wrapClassName ?? '').trim()
|
||||||
|
return extra ? `app-premium-modal ${extra}` : 'app-premium-modal'
|
||||||
|
})
|
||||||
|
|
||||||
const localValue = computed({
|
const localValue = computed({
|
||||||
get() {
|
get() {
|
||||||
return props.visible
|
return props.visible
|
||||||
@@ -67,13 +75,6 @@ const localValue = computed({
|
|||||||
|
|
||||||
set(value) {
|
set(value) {
|
||||||
emits('update:visible', value)
|
emits('update:visible', value)
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
.ant-modal-content {
|
|
||||||
border-radius: 0.6rem;
|
|
||||||
padding-top: 0.5rem;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -23,8 +23,9 @@
|
|||||||
<div class="w-full text-center font-bold">{{ noData }}</div>
|
<div class="w-full text-center font-bold">{{ noData }}</div>
|
||||||
</template>
|
</template>
|
||||||
<a-select-option
|
<a-select-option
|
||||||
:label="val[props.valueName]"
|
|
||||||
v-for="val in props.items"
|
v-for="val in props.items"
|
||||||
|
:key="val[props.keyName]"
|
||||||
|
:label="val[props.valueName]"
|
||||||
:value="val[props.keyName]"
|
:value="val[props.keyName]"
|
||||||
>
|
>
|
||||||
<a-tooltip v-if="props.hasTooltip" placement="left" class="cursor-pointer">
|
<a-tooltip v-if="props.hasTooltip" placement="left" class="cursor-pointer">
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-model:visible="visible"
|
||||||
|
width="460px"
|
||||||
|
destroy-on-close
|
||||||
|
custom-footer
|
||||||
|
title="تبدیل محصول"
|
||||||
|
wrap-class-name="app-premium-modal--scroll-tall"
|
||||||
|
@close="closeCopperConvert"
|
||||||
|
>
|
||||||
|
<CopperConvertCalculator />
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<BasicButton
|
||||||
|
type="primary"
|
||||||
|
class="app-premium-modal__btn-primary !w-full"
|
||||||
|
size="middle"
|
||||||
|
@click="closeCopperConvert"
|
||||||
|
>
|
||||||
|
بستن
|
||||||
|
</BasicButton>
|
||||||
|
</template>
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { watch } from 'vue'
|
||||||
|
import BasicModal from '@/components/BasicPacks/BasicModal.vue'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import CopperConvertCalculator from '@/views/base/convert/components/CopperConvertCalculator.vue'
|
||||||
|
import {
|
||||||
|
closeCopperConvert,
|
||||||
|
copperConvertModalVisible,
|
||||||
|
} from '@/composables/useCopperConvertModal'
|
||||||
|
import { useCopperConvertPage } from '@/views/base/convert/composables/useCopperConvertPage'
|
||||||
|
|
||||||
|
const visible = copperConvertModalVisible
|
||||||
|
const { refreshLivePrices, stopLivePrices } = useCopperConvertPage()
|
||||||
|
|
||||||
|
watch(visible, async (open) => {
|
||||||
|
if (open) {
|
||||||
|
await refreshLivePrices()
|
||||||
|
} else {
|
||||||
|
stopLivePrices()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -1,61 +1,71 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- <div v-if="modelValue">-->
|
<van-dialog
|
||||||
<van-dialog class="oneButtonDialog">
|
v-model:show="show"
|
||||||
<div class="my-4">
|
class="oneButtonDialog"
|
||||||
|
teleport="body"
|
||||||
|
:close-on-click-overlay="closeOnClickOverlay"
|
||||||
|
:z-index="zIndex"
|
||||||
|
v-bind="$attrs"
|
||||||
|
>
|
||||||
|
<div class="oneButtonDialog__body my-4 text-slate-800">
|
||||||
<div class="w-full flex justify-center">
|
<div class="w-full flex justify-center">
|
||||||
<slot name="img">{{ text2 }}</slot>
|
<slot name="img">{{ text2 }}</slot>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full flex justify-center text-[18px] font-semibold">
|
<div class="w-full flex justify-center text-[18px] font-semibold text-slate-800">
|
||||||
<slot name="title">{{ text1 }}</slot>
|
<slot name="title">{{ text1 }}</slot>
|
||||||
</div>
|
</div>
|
||||||
<div class=" border-t border-solid border-[#E5E7EB] pt-4 mx-2 mt-6 font-semibold text-[15px]">
|
<div
|
||||||
|
class="border-t border-solid border-[#E5E7EB] pt-4 mx-2 mt-6 font-semibold text-[15px] text-slate-800"
|
||||||
|
>
|
||||||
<slot name="button">{{ text3 }}</slot>
|
<slot name="button">{{ text3 }}</slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</van-dialog>
|
</van-dialog>
|
||||||
<!-- <van-dialog style="background-color: #2b3f6e" show-cancel-button cancelButtonText="بیخیال" confirmButtonText="بله" cancelButtonColor="">-->
|
|
||||||
<!-- <div class="w-full mt-6 text-white ">-->
|
|
||||||
<!-- <div class="w-full flex mb-[10px] ">-->
|
|
||||||
<!-- <Icon icon="vuesax-linear:info-circle" class="mx-4" size="25"/>-->
|
|
||||||
<!-- <span class="text-lg flex-1">-->
|
|
||||||
<!-- <slot name="title">{{text1}}</slot>-->
|
|
||||||
<!-- </span>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="flex justify-start mb-6 mt-8" style="font-weight:700;">-->
|
|
||||||
<!-- <slot name="button">{{text2}}</slot>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </van-dialog>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { computed, watch } from 'vue'
|
||||||
|
import { APP_Z_MODAL } from '@/utils/zIndex'
|
||||||
|
|
||||||
// import Icon from "/@/assets/icons/Icon.vue";
|
defineOptions({ inheritAttrs: false })
|
||||||
import {ref, watch} from 'vue';
|
|
||||||
|
|
||||||
const show = ref(true);
|
const props = withDefaults(
|
||||||
const props = withDefaults(defineProps<{
|
defineProps<{
|
||||||
// modelValue: boolean,
|
show?: boolean
|
||||||
timeOut: number,
|
timeOut?: number
|
||||||
text1?: string,
|
text1?: string
|
||||||
text2?: string,
|
text2?: string
|
||||||
text3?: string
|
text3?: string
|
||||||
// top?: string,
|
closeOnClickOverlay?: boolean
|
||||||
|
zIndex?: number
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
show: false,
|
||||||
|
timeOut: 3000,
|
||||||
|
closeOnClickOverlay: true,
|
||||||
|
zIndex: APP_Z_MODAL,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
}>(), {})
|
const emit = defineEmits<{
|
||||||
const emit = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>()
|
(e: 'update:show', value: boolean): void
|
||||||
watch(() => props.modelValue, (value) => {
|
}>()
|
||||||
if (props.timeOut !== -1) showNotify()
|
|
||||||
|
const show = computed({
|
||||||
|
get: () => props.show,
|
||||||
|
set: (value: boolean) => emit('update:show', value),
|
||||||
})
|
})
|
||||||
const showNotify = () => {
|
|
||||||
console.log('notify', show.value)
|
watch(
|
||||||
|
() => props.show,
|
||||||
|
(value) => {
|
||||||
|
if (value && props.timeOut !== -1) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
emit('update:modelValue', false)
|
emit('update:show', false)
|
||||||
}, props.timeOut);
|
}, props.timeOut)
|
||||||
};
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
@@ -67,17 +77,13 @@ const showNotify = () => {
|
|||||||
animation: notify-in 0.2s reverse;
|
animation: notify-in 0.2s reverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oneButtonDialog .van-dialog__confirm, .van-dialog__cancel {
|
.oneButtonDialog .van-dialog__confirm,
|
||||||
|
.oneButtonDialog .van-dialog__cancel {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.van-dialog__confirm, .van-dialog__cancel {
|
|
||||||
//background-color: ;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oneButtonDialog .van-dialog__confirm .van-button__text {
|
.oneButtonDialog .van-dialog__confirm .van-button__text {
|
||||||
color: #1C2D56;
|
color: #1c2d56;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
@@ -87,4 +93,8 @@ const showNotify = () => {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.oneButtonDialog__body {
|
||||||
|
color: #1e293b;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,19 +4,23 @@
|
|||||||
width="400px"
|
width="400px"
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
custom-footer
|
custom-footer
|
||||||
wrap-class-name="gold-day-calc-modal"
|
wrap-class-name="app-premium-modal--scroll-tall"
|
||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div class="gold-day-calc-modal__title">
|
<div class="app-premium-modal__title">
|
||||||
<BasicIcon icon="vuesax-linear:chart-2" size="20" class="gold-day-calc-modal__title-icon" />
|
<BasicIcon icon="vuesax-linear:calculator" size="20" class="app-premium-modal__title-icon" />
|
||||||
<span>محاسبهگر طلای شما</span>
|
<span>ماشین حساب</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div class="gold-day-calc" dir="rtl">
|
<div class="gold-day-calc" dir="rtl">
|
||||||
|
<p class="gold-day-calc__hint text-xs text-gray-500">
|
||||||
|
وزن مورد نظر را وارد کنید تا ارزش آن بر اساس قیمت لحظهای محاسبه شود.
|
||||||
|
</p>
|
||||||
|
|
||||||
<BasicInput
|
<BasicInput
|
||||||
v-model:value="weight"
|
v-model:value="weight"
|
||||||
title="وزن طلا (گرم)"
|
:title="`وزن ${metalTypeLabel} (${weightUnit})`"
|
||||||
type="tel"
|
type="tel"
|
||||||
place-holder="مثلاً ۱۰.۵"
|
place-holder="مثلاً ۱۰.۵"
|
||||||
inputmode="decimal"
|
inputmode="decimal"
|
||||||
@@ -24,7 +28,7 @@
|
|||||||
|
|
||||||
<BasicInput
|
<BasicInput
|
||||||
:value="unitPriceInput"
|
:value="unitPriceInput"
|
||||||
title="قیمت روز طلا"
|
:title="`قیمت روز ${metalTypeLabel}`"
|
||||||
type="tel"
|
type="tel"
|
||||||
disabled
|
disabled
|
||||||
addon-before="ریال"
|
addon-before="ریال"
|
||||||
@@ -33,17 +37,25 @@
|
|||||||
|
|
||||||
<BasicInput
|
<BasicInput
|
||||||
v-model:value="feePercent"
|
v-model:value="feePercent"
|
||||||
title="اجرت ساخت (%)"
|
title="اجرت ساخت مفتول (%)"
|
||||||
type="tel"
|
type="tel"
|
||||||
place-holder="مثلاً ۷"
|
place-holder="مثلاً ۷"
|
||||||
inputmode="decimal"
|
inputmode="decimal"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<BasicInput
|
<BasicInput
|
||||||
v-model:value="taxPercent"
|
v-model:value="profitPercent"
|
||||||
title="سود و مالیات (%)"
|
title="سود مورد انتظار (%)"
|
||||||
type="tel"
|
type="tel"
|
||||||
place-holder="مثلاً ۹"
|
place-holder="مثلاً ۵"
|
||||||
|
inputmode="decimal"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<BasicInput
|
||||||
|
v-model:value="taxPercent"
|
||||||
|
title="مالیات ارزش افزوده (%)"
|
||||||
|
type="tel"
|
||||||
|
place-holder="مثلاً ۱۰"
|
||||||
inputmode="decimal"
|
inputmode="decimal"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -55,15 +67,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-2 flex flex-col gap-1 text-xs text-gray-600">
|
<div class="mt-2 flex flex-col gap-1 text-xs text-gray-600">
|
||||||
<div class="flex justify-between gap-2">
|
<div class="flex justify-between gap-2">
|
||||||
<span>هزینه طلا</span>
|
<span>هزینه {{ metalTypeLabel }}</span>
|
||||||
<span class="gold-day-calc__num">{{ formatRial(breakdown.goldCost) }}</span>
|
<span class="gold-day-calc__num">{{ formatRial(breakdown.goldCost) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between gap-2">
|
<div class="flex justify-between gap-2">
|
||||||
<span>اجرت</span>
|
<span>اجرت ساخت مفتول</span>
|
||||||
<span class="gold-day-calc__num">{{ formatRial(breakdown.feeCost) }}</span>
|
<span class="gold-day-calc__num">{{ formatRial(breakdown.feeCost) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between gap-2">
|
<div class="flex justify-between gap-2">
|
||||||
<span>سود و مالیات</span>
|
<span>سود مورد انتظار</span>
|
||||||
|
<span class="gold-day-calc__num">{{ formatRial(breakdown.profitCost) }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-between gap-2">
|
||||||
|
<span>مالیات ارزش افزوده</span>
|
||||||
<span class="gold-day-calc__num">{{ formatRial(breakdown.taxCost) }}</span>
|
<span class="gold-day-calc__num">{{ formatRial(breakdown.taxCost) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,7 +87,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<BasicButton type="primary" class="!w-full" size="middle" @click="recalculate">
|
<BasicButton type="primary" class="app-premium-modal__btn-primary !w-full" size="middle" @click="recalculate">
|
||||||
محاسبه مجدد
|
محاسبه مجدد
|
||||||
</BasicButton>
|
</BasicButton>
|
||||||
</template>
|
</template>
|
||||||
@@ -95,11 +111,17 @@ import {
|
|||||||
import { getPriceDisplayState, NO_QUOTE_MESSAGE } from '@/utils/storeHours'
|
import { getPriceDisplayState, NO_QUOTE_MESSAGE } from '@/utils/storeHours'
|
||||||
import { usePriceWithoutType } from '@/utils/usePrice'
|
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||||
import { persianToEnglishDigits } from '@/utils/persianDigits'
|
import { persianToEnglishDigits } from '@/utils/persianDigits'
|
||||||
|
import { useSettingsStore } from '@/store/settingsStore'
|
||||||
|
|
||||||
const visible = goldDayCalculatorVisible
|
const visible = goldDayCalculatorVisible
|
||||||
|
const settingsStore = useSettingsStore()
|
||||||
|
|
||||||
|
const metalTypeLabel = computed(() => settingsStore.metalTypeLabel)
|
||||||
|
const weightUnit = computed(() => settingsStore.tradeWeightUnit)
|
||||||
|
|
||||||
const weight = ref<string | number>('')
|
const weight = ref<string | number>('')
|
||||||
const feePercent = ref<string | number>('')
|
const feePercent = ref<string | number>('')
|
||||||
|
const profitPercent = ref<string | number>('')
|
||||||
const taxPercent = ref<string | number>('')
|
const taxPercent = ref<string | number>('')
|
||||||
const tick = ref(0)
|
const tick = ref(0)
|
||||||
|
|
||||||
@@ -130,13 +152,16 @@ const breakdown = computed(() => {
|
|||||||
void tick.value
|
void tick.value
|
||||||
const w = parseNum(weight.value)
|
const w = parseNum(weight.value)
|
||||||
const fee = parseNum(feePercent.value)
|
const fee = parseNum(feePercent.value)
|
||||||
|
const profit = parseNum(profitPercent.value)
|
||||||
const tax = parseNum(taxPercent.value)
|
const tax = parseNum(taxPercent.value)
|
||||||
const unit = liveUnitPrice.value
|
const unit = liveUnitPrice.value
|
||||||
const goldCost = w * unit
|
const goldCost = w * unit
|
||||||
const feeCost = goldCost * (fee / 100)
|
const feeCost = goldCost * (fee / 100)
|
||||||
const taxCost = (goldCost + feeCost) * (tax / 100)
|
const afterFee = goldCost + feeCost
|
||||||
const total = goldCost + feeCost + taxCost
|
const profitCost = afterFee * (profit / 100)
|
||||||
return { goldCost, feeCost, taxCost, total }
|
const taxCost = (afterFee + profitCost) * (tax / 100)
|
||||||
|
const total = afterFee + profitCost + taxCost
|
||||||
|
return { goldCost, feeCost, profitCost, taxCost, total }
|
||||||
})
|
})
|
||||||
|
|
||||||
const formattedTotal = computed(() => formatRial(breakdown.value.total))
|
const formattedTotal = computed(() => formatRial(breakdown.value.total))
|
||||||
@@ -186,6 +211,11 @@ watch(visible, async (open) => {
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gold-day-calc__hint {
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
.gold-day-calc__result {
|
.gold-day-calc__result {
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
@@ -205,99 +235,3 @@ watch(visible, async (open) => {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style lang="less">
|
|
||||||
.gold-day-calc-modal {
|
|
||||||
.ant-modal-content {
|
|
||||||
direction: rtl;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
max-height: min(88dvh, 640px);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-modal-header {
|
|
||||||
flex-shrink: 0;
|
|
||||||
direction: rtl;
|
|
||||||
text-align: right;
|
|
||||||
padding-left: 2.75rem;
|
|
||||||
padding-right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-modal-title {
|
|
||||||
text-align: right;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gold-day-calc-modal__title {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-start;
|
|
||||||
gap: 0.5rem;
|
|
||||||
direction: rtl;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gold-day-calc-modal__title-icon {
|
|
||||||
flex-shrink: 0;
|
|
||||||
color: var(--App-secondary-color, #c9a062);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-modal-close {
|
|
||||||
inset-inline-start: 0 !important;
|
|
||||||
inset-inline-end: auto !important;
|
|
||||||
right: auto !important;
|
|
||||||
left: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-modal-body {
|
|
||||||
flex: 1 1 auto;
|
|
||||||
min-height: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
padding-bottom: 0.25rem;
|
|
||||||
max-height: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#body {
|
|
||||||
max-height: min(48dvh, 360px) !important;
|
|
||||||
overflow-y: auto !important;
|
|
||||||
overscroll-behavior: contain;
|
|
||||||
-webkit-overflow-scrolling: touch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-modal-footer {
|
|
||||||
flex-shrink: 0;
|
|
||||||
margin-top: 0;
|
|
||||||
padding-top: 0.75rem;
|
|
||||||
border-top: 1px solid rgba(148, 163, 184, 0.25);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 767.98px) {
|
|
||||||
.gold-day-calc-modal {
|
|
||||||
.ant-modal {
|
|
||||||
max-width: calc(100vw - 1.5rem);
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-modal-content {
|
|
||||||
max-height: min(86dvh, 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
#body {
|
|
||||||
max-height: min(42dvh, 280px) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-modal-body {
|
|
||||||
padding-top: 0.25rem;
|
|
||||||
padding-bottom: 0.25rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 400px) {
|
|
||||||
.gold-day-calc-modal #body {
|
|
||||||
max-height: min(38dvh, 240px) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<template>
|
||||||
|
<van-dialog
|
||||||
|
v-model:show="open"
|
||||||
|
class="completeButtonStyle"
|
||||||
|
confirm-button-text="تکمیل اطلاعات"
|
||||||
|
show-confirm-button
|
||||||
|
@confirm="goProfile"
|
||||||
|
>
|
||||||
|
<div class="flex flex-col items-center p-2">
|
||||||
|
<BasicIcon color="orange" icon="vuesax-linear:info-circle" size="50" />
|
||||||
|
<div class="mt-2 text-center">{{ message }}</div>
|
||||||
|
</div>
|
||||||
|
</van-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
show?: boolean
|
||||||
|
action?: string
|
||||||
|
}>(),
|
||||||
|
{ show: false, action: 'این کار' },
|
||||||
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:show': [value: boolean]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const open = computed({
|
||||||
|
get: () => props.show,
|
||||||
|
set: (value: boolean) => emit('update:show', value),
|
||||||
|
})
|
||||||
|
|
||||||
|
const message = computed(
|
||||||
|
() =>
|
||||||
|
`برای ${props.action}، لطفا اطلاعات خود را تکمیل کنید یا در صورت تکمیل اطلاعات، منتظر تایید اطلاعات خود بمانید.`,
|
||||||
|
)
|
||||||
|
|
||||||
|
function goProfile() {
|
||||||
|
router.push({ name: 'user' })
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-model:visible="visible"
|
||||||
|
custom-footer
|
||||||
|
:closable="false"
|
||||||
|
:width="modalWidth"
|
||||||
|
wrap-class-name="required-kyc-modal-wrap"
|
||||||
|
:z-index="99999"
|
||||||
|
>
|
||||||
|
<div class="kyc-modal-content text-center py-2" dir="rtl">
|
||||||
|
<!-- Icon with soft glowing background -->
|
||||||
|
<div class="inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-amber-50 text-amber-600 border border-amber-200 mb-4 shadow-sm">
|
||||||
|
<BasicIcon icon="vuesax-linear:security-user" size="36" color="#d97706" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Title -->
|
||||||
|
<h2 class="text-base font-bold text-slate-800 mb-2">
|
||||||
|
احراز هویت الزامی است
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<!-- Description: شیک، کوتاه، مختصر و مفید -->
|
||||||
|
<p class="text-xs text-slate-600 leading-6 max-w-xs mx-auto mb-5">
|
||||||
|
کاربر گرامی، جهت استفاده از کلیه امکانات سامانه و شروع معاملات، لطفاً ابتدا فرایند احراز هویت خود را تکمیل فرمایید.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Tip info box -->
|
||||||
|
<div class="bg-amber-50/70 border border-amber-200/80 rounded-xl p-3 text-right text-xs text-amber-900 mb-5 space-y-1.5">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<BasicIcon icon="vuesax-linear:tick-circle" size="16" color="#d97706" class="shrink-0" />
|
||||||
|
<span>استعلام و تایید آنی مشخصات از طریق سامانه ثبت احوال</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<BasicIcon icon="vuesax-linear:tick-circle" size="16" color="#d97706" class="shrink-0" />
|
||||||
|
<span>کد ملی وارد شده باید متعلق به مالک شماره موبایل باشد</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action buttons -->
|
||||||
|
<div class="flex flex-col gap-2.5">
|
||||||
|
<BasicButton
|
||||||
|
type="primary"
|
||||||
|
class="w-full h-11 text-sm font-semibold !rounded-xl flex items-center justify-center gap-2"
|
||||||
|
@click="goToKyc"
|
||||||
|
>
|
||||||
|
<span>تکمیل و احراز هویت</span>
|
||||||
|
<BasicIcon icon="vuesax-linear:arrow-left" size="16" />
|
||||||
|
</BasicButton>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="text-xs text-red-600 hover:text-red-700 flex items-center justify-center gap-1.5 py-1.5 cursor-pointer transition-colors"
|
||||||
|
@click="onLogout"
|
||||||
|
>
|
||||||
|
<BasicIcon icon="vuesax-linear:logout" size="14" color="#dc2626" />
|
||||||
|
<span>خروج از حساب کاربری</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, onMounted, ref, watch } from 'vue'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import BasicModal from '@/components/BasicPacks/BasicModal.vue'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import { useUserStore } from '@/store/userStore'
|
||||||
|
import { getToken } from '@/utils'
|
||||||
|
import { performUserLogout } from '@/utils/authSession'
|
||||||
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
|
import { isCustomerIdentityVerified } from '@/utils/customerIdentity'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const isDesktop = useDesktopBreakpoint()
|
||||||
|
|
||||||
|
const modalWidth = computed(() => (isDesktop.value ? '420px' : '90vw'))
|
||||||
|
|
||||||
|
const isKycRequired = computed(() => {
|
||||||
|
if (!getToken()) return false
|
||||||
|
if (route.name === 'login' || route.name === 'tvMonitor' || route.name === 'aboutSoftware' || route.name === 'user') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const info = userStore.userInfo
|
||||||
|
if (!info) return false
|
||||||
|
return !isCustomerIdentityVerified(info.is_legal)
|
||||||
|
})
|
||||||
|
|
||||||
|
const visible = ref(false)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
isKycRequired,
|
||||||
|
(val) => {
|
||||||
|
visible.value = Boolean(val)
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (getToken() && !userStore.userInfo) {
|
||||||
|
try {
|
||||||
|
await userStore.getMyInfo()
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
visible.value = Boolean(isKycRequired.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
function goToKyc() {
|
||||||
|
visible.value = false
|
||||||
|
void router.push({ name: 'user', query: { showEdit: 'true' } })
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onLogout() {
|
||||||
|
visible.value = false
|
||||||
|
await performUserLogout()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less">
|
||||||
|
.required-kyc-modal-wrap {
|
||||||
|
.ant-modal-content {
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.kyc-modal-content {
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="trade-fee-summary">
|
<div class="trade-fee-summary">
|
||||||
<div class="trade-fee-summary__quote">
|
<div class="trade-fee-summary__quote">
|
||||||
<div class="trade-fee-summary__label">مظنه هر {{ weightUnit }}</div>
|
<div class="trade-fee-summary__label">قیمت هر {{ weightUnit }}</div>
|
||||||
<div class="trade-fee-summary__value trade-fee-summary__value--strong">
|
<div class="trade-fee-summary__value trade-fee-summary__value--strong">
|
||||||
<span>{{ formattedUnitPrice }}</span>
|
<span>{{ formattedUnitPrice }}</span>
|
||||||
<span class="trade-fee-summary__unit">ریال</span>
|
<span class="trade-fee-summary__unit">ریال</span>
|
||||||
@@ -101,6 +101,8 @@ const breakdown = computed(() =>
|
|||||||
payablePrice: props.payablePrice,
|
payablePrice: props.payablePrice,
|
||||||
unitPriceRial: props.unitPriceRial,
|
unitPriceRial: props.unitPriceRial,
|
||||||
sellGoldDebit: props.sellGoldDebit,
|
sellGoldDebit: props.sellGoldDebit,
|
||||||
|
metalName: 'مس',
|
||||||
|
weightUnit: props.weightUnit || 'کیلوگرم',
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -20,11 +20,17 @@ const emit = defineEmits<{
|
|||||||
close: []
|
close: []
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const activePlatform = ref<PwaPlatform>(props.platform ?? getDefaultPwaPlatform())
|
function normalizePlatform(value?: string | null): PwaPlatform {
|
||||||
|
return value === 'ios' || value === 'android' ? value : getDefaultPwaPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
const activePlatform = ref<PwaPlatform>(normalizePlatform(props.platform))
|
||||||
const stepIndex = ref(0)
|
const stepIndex = ref(0)
|
||||||
|
|
||||||
const guide = computed(() => PWA_INSTALL_GUIDE[activePlatform.value])
|
const guide = computed(
|
||||||
const currentStep = computed(() => guide.value.steps[stepIndex.value])
|
() => PWA_INSTALL_GUIDE[normalizePlatform(activePlatform.value)] ?? PWA_INSTALL_GUIDE.android,
|
||||||
|
)
|
||||||
|
const currentStep = computed(() => guide.value.steps[stepIndex.value] ?? guide.value.steps[0])
|
||||||
const totalSteps = computed(() => guide.value.steps.length)
|
const totalSteps = computed(() => guide.value.steps.length)
|
||||||
const isFirstStep = computed(() => stepIndex.value === 0)
|
const isFirstStep = computed(() => stepIndex.value === 0)
|
||||||
const isLastStep = computed(() => stepIndex.value === totalSteps.value - 1)
|
const isLastStep = computed(() => stepIndex.value === totalSteps.value - 1)
|
||||||
@@ -34,7 +40,7 @@ watch(
|
|||||||
() => props.open,
|
() => props.open,
|
||||||
(visible) => {
|
(visible) => {
|
||||||
if (!visible) return
|
if (!visible) return
|
||||||
activePlatform.value = props.platform ?? getDefaultPwaPlatform()
|
activePlatform.value = normalizePlatform(props.platform)
|
||||||
stepIndex.value = 0
|
stepIndex.value = 0
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -42,7 +48,7 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.platform,
|
() => props.platform,
|
||||||
(value) => {
|
(value) => {
|
||||||
if (value) activePlatform.value = value
|
if (value) activePlatform.value = normalizePlatform(value)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,8 +58,9 @@ function close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function selectPlatform(next: PwaPlatform) {
|
function selectPlatform(next: PwaPlatform) {
|
||||||
if (activePlatform.value === next) return
|
const platform = normalizePlatform(next)
|
||||||
activePlatform.value = next
|
if (activePlatform.value === platform) return
|
||||||
|
activePlatform.value = platform
|
||||||
stepIndex.value = 0
|
stepIndex.value = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
export const copperConvertModalVisible = ref(false)
|
||||||
|
|
||||||
|
export function openCopperConvert() {
|
||||||
|
copperConvertModalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
export function closeCopperConvert() {
|
||||||
|
copperConvertModalVisible.value = false
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
import type { PwaPlatform } from '@/modules/pwa/pwaInstallGuideSteps'
|
import type { PwaPlatform } from '@/modules/pwa/pwaInstallGuideSteps'
|
||||||
import {
|
import {
|
||||||
getDefaultPwaPlatform,
|
getDefaultPwaPlatform,
|
||||||
@@ -77,7 +78,10 @@ export function usePwaInstall() {
|
|||||||
// فقط وقتی واقعاً داخل PWA/TWA هستیم راهنما را نشان نده
|
// فقط وقتی واقعاً داخل PWA/TWA هستیم راهنما را نشان نده
|
||||||
if (isStandalonePwa() || isTWA()) return
|
if (isStandalonePwa() || isTWA()) return
|
||||||
consumeInstallBanner()
|
consumeInstallBanner()
|
||||||
platform.value = nextPlatform ?? getDefaultPwaPlatform()
|
const next = nextPlatform === 'ios' || nextPlatform === 'android'
|
||||||
|
? nextPlatform
|
||||||
|
: getDefaultPwaPlatform()
|
||||||
|
platform.value = next
|
||||||
guideOpen.value = true
|
guideOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,16 +112,24 @@ export function usePwaInstall() {
|
|||||||
|
|
||||||
/** نصب مستقیم مرورگر؛ اگر ممکن نبود مدال آموزش. */
|
/** نصب مستقیم مرورگر؛ اگر ممکن نبود مدال آموزش. */
|
||||||
async function tryInstallOrOpenGuide(nextPlatform?: PwaPlatform) {
|
async function tryInstallOrOpenGuide(nextPlatform?: PwaPlatform) {
|
||||||
|
ensureListener()
|
||||||
refreshOfferInstall()
|
refreshOfferInstall()
|
||||||
if (isStandalonePwa() || isTWA()) return false
|
|
||||||
|
if (isStandalonePwa() || isTWA()) {
|
||||||
|
message.info('نسخه وباپ از قبل نصب شده است')
|
||||||
|
offerInstall.value = false
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
const installed = await triggerNativePwaInstall()
|
const installed = await triggerNativePwaInstall()
|
||||||
if (installed) {
|
if (installed) {
|
||||||
offerInstall.value = false
|
offerInstall.value = false
|
||||||
consumeInstallBanner()
|
consumeInstallBanner()
|
||||||
|
message.success('نصب وباپ آغاز شد')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Chrome روی HTTP/IP یا Safari معمولاً prompt بومی ندارد — راهنما را باز کن
|
||||||
openGuide(nextPlatform)
|
openGuide(nextPlatform)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { isGuestHomeActive } from '@/utils/guestHome'
|
||||||
|
|
||||||
export function useAppNavigation() {
|
export function useAppNavigation() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -7,7 +8,7 @@ export function useAppNavigation() {
|
|||||||
|
|
||||||
const popVisible = ref(false)
|
const popVisible = ref(false)
|
||||||
const currentRoute = computed(() => route.name)
|
const currentRoute = computed(() => route.name)
|
||||||
const hideMenu = computed(() => !!route.meta.hideMenu)
|
const hideMenu = computed(() => !!route.meta.hideMenu || isGuestHomeActive(route))
|
||||||
/** فقط ناو پایین موبایل — سایدبار دسکتاپ را مخفی نمیکند */
|
/** فقط ناو پایین موبایل — سایدبار دسکتاپ را مخفی نمیکند */
|
||||||
const hideBottomNav = computed(
|
const hideBottomNav = computed(
|
||||||
() => !!route.meta.hideBottomNav || !!route.meta.hideMenu,
|
() => !!route.meta.hideBottomNav || !!route.meta.hideMenu,
|
||||||
|
|||||||
@@ -50,16 +50,34 @@ const BOURSECU_PRIMARY_NAV: AppNavItem[] = [
|
|||||||
{
|
{
|
||||||
id: 'user',
|
id: 'user',
|
||||||
routeName: 'user',
|
routeName: 'user',
|
||||||
label: 'تنظیمات',
|
label: 'امکانات بیشتر',
|
||||||
icon: 'vuesax-linear:setting-2',
|
icon: 'vuesax-linear:setting-2',
|
||||||
iconSrc: getBoursecuActionIconSrc('settings'),
|
iconSrc: getBoursecuActionIconSrc('settings'),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export const SECONDARY_NAV: AppNavItem[] = [
|
export const SECONDARY_NAV: AppNavItem[] = [
|
||||||
{ id: 'notifyTrigger', routeName: 'notifyTrigger', label: 'هشدار قیمت', icon: 'vuesax-linear:bill' },
|
{
|
||||||
{ id: 'about', routeName: 'about', label: 'درباره ما', icon: 'vuesax-linear:info-circle' },
|
id: 'notifyTrigger',
|
||||||
{ id: 'rules', routeName: 'rules', label: 'قوانین و مقررات', icon: 'vuesax-linear:task' },
|
routeName: 'notifyTrigger',
|
||||||
|
label: 'هشدار قیمت',
|
||||||
|
icon: 'vuesax-linear:bill',
|
||||||
|
iconSrc: getBoursecuActionIconSrc('priceTrigger'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'about',
|
||||||
|
routeName: 'about',
|
||||||
|
label: 'درباره ما',
|
||||||
|
icon: 'vuesax-linear:info-circle',
|
||||||
|
iconSrc: getBoursecuActionIconSrc('about'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'rules',
|
||||||
|
routeName: 'rules',
|
||||||
|
label: 'قوانین و مقررات',
|
||||||
|
icon: 'vuesax-linear:task',
|
||||||
|
iconSrc: getBoursecuActionIconSrc('rules'),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export function getPrimaryNavItems(): AppNavItem[] {
|
export function getPrimaryNavItems(): AppNavItem[] {
|
||||||
|
|||||||
@@ -27,6 +27,11 @@
|
|||||||
background: @prefixCls-background-color;
|
background: @prefixCls-background-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.desktop-app-layout__content.support-page {
|
||||||
|
overflow: hidden;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.desktop-sidebar {
|
.desktop-sidebar {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: var(--app-desktop-sidebar-width, 260px);
|
width: var(--app-desktop-sidebar-width, 260px);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
class="tab__icon-image"
|
class="tab__icon-image"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs mt-1 font-bold">تنظیمات</div>
|
<div class="text-xs mt-1 font-bold">امکانات بیشتر</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* Mobile shell width rules.
|
* Mobile shell width rules.
|
||||||
* Below 426px: full viewport (phones).
|
* Below 426px: full viewport (phones).
|
||||||
* 426px–767px: centered 426px frame (tablet-ish mobile).
|
* 426px–767px: centered 426px frame (tablet-ish mobile).
|
||||||
|
* از ۷۶۸px شل دسکتاپ (سایدبار) فعال میشود.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
html:not(.app-layout--desktop) {
|
html:not(.app-layout--desktop) {
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ export interface Price {
|
|||||||
main_product?: number
|
main_product?: number
|
||||||
montzar?: number
|
montzar?: number
|
||||||
zaarbox?: number
|
zaarbox?: number
|
||||||
/** montzar | zaarbox | main_product | store = مظنه زنده، database_last = آخرین قیمت ذخیرهشده */
|
/** montzar | zaarbox | main_product | store = قیمت زنده، database_last = آخرین قیمت ذخیرهشده */
|
||||||
price_source?: string | null
|
price_source?: string | null
|
||||||
last_historical?: number
|
last_historical?: number
|
||||||
|
copper_world?: number
|
||||||
|
dollar_free?: number
|
||||||
|
copper_ton?: string
|
||||||
|
copper_kilo?: string
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,9 @@ export interface Transaction {
|
|||||||
value?: number
|
value?: number
|
||||||
sts_str?: string
|
sts_str?: string
|
||||||
order?: Order
|
order?: Order
|
||||||
withdraw?: Order
|
withdraw?: Withdraw
|
||||||
|
sts?: number
|
||||||
|
transaction?: unknown[]
|
||||||
card_id?: number|string
|
card_id?: number|string
|
||||||
eaj?: string
|
eaj?: string
|
||||||
end_at?: string
|
end_at?: string
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ export function initPwaInstallPromptListener() {
|
|||||||
if (installListenerInitialized || typeof window === 'undefined') return
|
if (installListenerInitialized || typeof window === 'undefined') return
|
||||||
installListenerInitialized = true
|
installListenerInitialized = true
|
||||||
|
|
||||||
|
window.addEventListener('beforeinstallprompt', (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
deferredInstallPrompt = e as BeforeInstallPromptEvent
|
||||||
|
})
|
||||||
|
|
||||||
window.addEventListener(PWA_MANIFEST_READY_EVENT, (event) => {
|
window.addEventListener(PWA_MANIFEST_READY_EVENT, (event) => {
|
||||||
const installEvent = (event as CustomEvent<{ installEvent?: Event | null }>).detail?.installEvent
|
const installEvent = (event as CustomEvent<{ installEvent?: Event | null }>).detail?.installEvent
|
||||||
|
|
||||||
@@ -103,6 +108,10 @@ export function initPwaInstallPromptListener() {
|
|||||||
deferredInstallPrompt = installEvent as BeforeInstallPromptEvent
|
deferredInstallPrompt = installEvent as BeforeInstallPromptEvent
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
window.addEventListener('appinstalled', () => {
|
||||||
|
deferredInstallPrompt = null
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function triggerNativePwaInstall() {
|
export async function triggerNativePwaInstall() {
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ const router = createRouter({
|
|||||||
name: 'wallet',
|
name: 'wallet',
|
||||||
component: () => import('../views/base/wallet/index.vue')
|
component: () => import('../views/base/wallet/index.vue')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'assets',
|
||||||
|
name: 'assets',
|
||||||
|
component: () => import('../views/base/assets/index.vue')
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'user',
|
path: 'user',
|
||||||
name: 'user',
|
name: 'user',
|
||||||
@@ -70,7 +75,7 @@ const router = createRouter({
|
|||||||
{
|
{
|
||||||
path: 'support',
|
path: 'support',
|
||||||
name: 'support',
|
name: 'support',
|
||||||
meta: { hideBottomNav: true },
|
meta: { hideMenu: true, hideBottomNav: true },
|
||||||
component: () => import('@/views/support/index.vue')
|
component: () => import('@/views/support/index.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -128,6 +133,16 @@ const router = createRouter({
|
|||||||
name: 'giftCard',
|
name: 'giftCard',
|
||||||
component: () => import('@/views/base/giftCard/index.vue')
|
component: () => import('@/views/base/giftCard/index.vue')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'convert',
|
||||||
|
name: 'convert',
|
||||||
|
component: () => import('@/views/base/convert/index.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'installment',
|
||||||
|
name: 'installment',
|
||||||
|
component: () => import('@/views/base/installment/index.vue')
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'recoverySites',
|
path: 'recoverySites',
|
||||||
name: 'recoverySites',
|
name: 'recoverySites',
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export const useConfigStore = defineStore('config', () => {
|
|||||||
|
|
||||||
async function getConfigData() {
|
async function getConfigData() {
|
||||||
config.value = window.__APP_CONFIG__?.user
|
config.value = window.__APP_CONFIG__?.user
|
||||||
console.log(config.value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { useWalletStore } from '@/store/walletStore'
|
|||||||
import { useSettingsStore } from '@/store/settingsStore'
|
import { useSettingsStore } from '@/store/settingsStore'
|
||||||
import { setFingerPrint } from '@/utils'
|
import { setFingerPrint } from '@/utils'
|
||||||
import type { PWallet } from '@/models/wallet'
|
import type { PWallet } from '@/models/wallet'
|
||||||
|
import { replaceMazanehTerminology } from '@/utils/persianTerminology'
|
||||||
|
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', () => {
|
export const useUserStore = defineStore('user', () => {
|
||||||
@@ -32,7 +33,10 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
const item = userInfo.value?.settings?.find(obj => obj.key === keyName)
|
const item = userInfo.value?.settings?.find(obj => obj.key === keyName)
|
||||||
|
|
||||||
// اگر آیتم پیدا شد، فیلد value را برگردان، در غیر این صورت null
|
// اگر آیتم پیدا شد، فیلد value را برگردان، در غیر این صورت null
|
||||||
return item ? item.value : null
|
if (!item) return null
|
||||||
|
const value = item.value
|
||||||
|
if (typeof value === 'string') return replaceMazanehTerminology(value)
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeInformation() {
|
function removeInformation() {
|
||||||
|
|||||||
@@ -0,0 +1,198 @@
|
|||||||
|
/** تم یکسان مدالهای boursecu user — لوکس / پریمیوم */
|
||||||
|
|
||||||
|
.app-premium-modal.ant-modal-wrap {
|
||||||
|
backdrop-filter: blur(2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-premium-modal {
|
||||||
|
.ant-modal-content {
|
||||||
|
direction: rtl;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
max-height: min(92dvh, 720px);
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0 !important;
|
||||||
|
border-radius: 1.125rem;
|
||||||
|
border: 1px solid rgba(201, 160, 98, 0.35);
|
||||||
|
box-shadow:
|
||||||
|
0 24px 48px rgba(15, 39, 68, 0.28),
|
||||||
|
0 0 0 1px rgba(255, 255, 255, 0.04) inset;
|
||||||
|
background: #fff;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-header {
|
||||||
|
flex-shrink: 0;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
margin: 0;
|
||||||
|
min-height: 3.25rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
padding: 0.875rem 1rem 0.875rem 3rem;
|
||||||
|
direction: rtl;
|
||||||
|
text-align: right;
|
||||||
|
background: linear-gradient(180deg, #faf8f5 0%, #fff 100%);
|
||||||
|
border-bottom: 1px solid rgba(201, 160, 98, 0.2);
|
||||||
|
border-radius: 1.125rem 1.125rem 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-title {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
line-height: 1.45;
|
||||||
|
text-align: right;
|
||||||
|
font-size: 1.0625rem;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #0f2744;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-premium-modal__title {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
gap: 0.5rem;
|
||||||
|
direction: rtl;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-premium-modal__title-icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: var(--App-secondary-color, #c9a062);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-close {
|
||||||
|
position: absolute;
|
||||||
|
inset-inline-start: 0.75rem !important;
|
||||||
|
inset-inline-end: auto !important;
|
||||||
|
left: 0.75rem !important;
|
||||||
|
right: auto !important;
|
||||||
|
top: 0.875rem !important;
|
||||||
|
margin: 0;
|
||||||
|
width: 2rem;
|
||||||
|
height: 2rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(15, 39, 68, 0.06);
|
||||||
|
color: #0f2744;
|
||||||
|
transition: background 0.2s ease;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 2;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(15, 39, 68, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-close-x {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
line-height: 1;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-body {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 0.75rem 1.125rem 0.5rem;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#body {
|
||||||
|
max-height: min(56dvh, 440px);
|
||||||
|
overflow-y: auto !important;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
padding: 0.35rem 0.125rem 0.5rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-footer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.75rem 1.125rem 1rem;
|
||||||
|
border-top: 1px solid rgba(15, 39, 68, 0.08);
|
||||||
|
background: #faf8f5;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-footer .ant-btn {
|
||||||
|
min-height: 2.5rem;
|
||||||
|
border-radius: 0.75rem !important;
|
||||||
|
font-weight: 700;
|
||||||
|
padding-inline: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-footer .ant-btn-primary,
|
||||||
|
.app-premium-modal__btn-primary {
|
||||||
|
border: none !important;
|
||||||
|
background: linear-gradient(135deg, #0f2744 0%, #1a365d 55%, #234876 100%) !important;
|
||||||
|
box-shadow: 0 8px 20px rgba(15, 39, 68, 0.22);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-footer .ant-btn-default {
|
||||||
|
border-color: rgba(15, 39, 68, 0.15) !important;
|
||||||
|
color: #0f2744 !important;
|
||||||
|
background: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.app-premium-modal--no-header {
|
||||||
|
.ant-modal-header {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-close {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-modal-body {
|
||||||
|
padding-top: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.app-premium-modal--scroll-tall #body {
|
||||||
|
max-height: min(58dvh, 480px) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.app-premium-modal--fluid-body #body {
|
||||||
|
max-height: none !important;
|
||||||
|
overflow: visible !important;
|
||||||
|
padding-top: 0 !important;
|
||||||
|
padding-bottom: 0.25rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.app-premium-modal--wide-panel {
|
||||||
|
.ant-modal-body {
|
||||||
|
padding-inline: 1.5rem;
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#body {
|
||||||
|
max-height: calc(100dvh - 12rem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 767.98px) {
|
||||||
|
.app-premium-modal {
|
||||||
|
.ant-modal {
|
||||||
|
max-width: calc(100vw - 1rem);
|
||||||
|
margin: 0 auto;
|
||||||
|
top: 1.5vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.app-premium-modal--scroll-tall #body {
|
||||||
|
max-height: min(52dvh, 420px) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import router from '@/router'
|
||||||
|
import { removeToken } from '@/utils'
|
||||||
|
import { useUserStore } from '@/store/userStore'
|
||||||
|
import { useWalletStore } from '@/store/walletStore'
|
||||||
|
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||||
|
import { resetHomePageData } from '@/views/base/home/composables/useHomePageData'
|
||||||
|
import { resetWalletPageData } from '@/views/base/wallet/composables/useWalletPageData'
|
||||||
|
import { resetAddressPageData } from '@/views/base/address/composables/useAddressPageData'
|
||||||
|
import { resetTransactionsPageData } from '@/views/base/transactions/composables/useTransactionsPageData'
|
||||||
|
import { resetProductsPageData } from '@/views/base/products/composables/useProductsPageData'
|
||||||
|
|
||||||
|
export async function performUserLogout() {
|
||||||
|
try {
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const walletStore = useWalletStore()
|
||||||
|
userStore.userInfo = undefined
|
||||||
|
walletStore.walletInfo = undefined
|
||||||
|
try {
|
||||||
|
const { clearWalletAssets } = useWalletAssets()
|
||||||
|
clearWalletAssets()
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
try { resetHomePageData() } catch {}
|
||||||
|
try { resetWalletPageData() } catch {}
|
||||||
|
try { resetAddressPageData() } catch {}
|
||||||
|
try { resetTransactionsPageData() } catch {}
|
||||||
|
try { resetProductsPageData() } catch {}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Logout cleanup error:', e)
|
||||||
|
}
|
||||||
|
|
||||||
|
removeToken()
|
||||||
|
|
||||||
|
try {
|
||||||
|
await router.push({ name: 'login' })
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ interface BankDefinition {
|
|||||||
aliases: string[]
|
aliases: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const bankLogoModules = import.meta.glob<string>('@/assets/img/banks/*.{png,svg}', {
|
const bankLogoModules = import.meta.glob<string>('../assets/img/banks/*.{png,svg}', {
|
||||||
eager: true,
|
eager: true,
|
||||||
import: 'default',
|
import: 'default',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
export type ChartSeriesPoint = {
|
||||||
|
timeMs: number
|
||||||
|
value: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ChartPlotSample = {
|
||||||
|
x: number
|
||||||
|
y: number
|
||||||
|
value: number
|
||||||
|
timeMs: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const CHART_PAD_Y = 14
|
||||||
|
const DEFAULT_MAX_POINTS = 22
|
||||||
|
|
||||||
|
function downsampleSeries(points: ChartSeriesPoint[], maxPoints: number): ChartSeriesPoint[] {
|
||||||
|
if (points.length <= maxPoints) return points
|
||||||
|
const result: ChartSeriesPoint[] = []
|
||||||
|
const lastIndex = points.length - 1
|
||||||
|
for (let i = 0; i < maxPoints; i += 1) {
|
||||||
|
const index = Math.round((i / (maxPoints - 1)) * lastIndex)
|
||||||
|
result.push(points[index])
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
function smoothSeries(points: ChartSeriesPoint[], window = 3): ChartSeriesPoint[] {
|
||||||
|
if (points.length < window) return points
|
||||||
|
const half = Math.floor(window / 2)
|
||||||
|
return points.map((point, index) => {
|
||||||
|
let sum = 0
|
||||||
|
let count = 0
|
||||||
|
for (let i = index - half; i <= index + half; i += 1) {
|
||||||
|
if (i < 0 || i >= points.length) continue
|
||||||
|
sum += points[i].value
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
timeMs: point.timeMs,
|
||||||
|
value: count ? sum / count : point.value,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildSmoothLinePath(plot: Array<{ x: number; y: number }>): string {
|
||||||
|
if (plot.length < 2) return ''
|
||||||
|
if (plot.length === 2) {
|
||||||
|
return `M${plot[0].x.toFixed(2)} ${plot[0].y.toFixed(2)} L${plot[1].x.toFixed(2)} ${plot[1].y.toFixed(2)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = `M${plot[0].x.toFixed(2)} ${plot[0].y.toFixed(2)}`
|
||||||
|
for (let i = 0; i < plot.length - 1; i += 1) {
|
||||||
|
const p0 = plot[i - 1] ?? plot[i]
|
||||||
|
const p1 = plot[i]
|
||||||
|
const p2 = plot[i + 1]
|
||||||
|
const p3 = plot[i + 2] ?? p2
|
||||||
|
const cp1x = p1.x + (p2.x - p0.x) / 6
|
||||||
|
const cp1y = p1.y + (p2.y - p0.y) / 6
|
||||||
|
const cp2x = p2.x - (p3.x - p1.x) / 6
|
||||||
|
const cp2y = p2.y - (p3.y - p1.y) / 6
|
||||||
|
path += ` C${cp1x.toFixed(2)} ${cp1y.toFixed(2)} ${cp2x.toFixed(2)} ${cp2y.toFixed(2)} ${p2.x.toFixed(2)} ${p2.y.toFixed(2)}`
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildSeriesChartPaths(
|
||||||
|
points: ChartSeriesPoint[],
|
||||||
|
width = 560,
|
||||||
|
height = 160,
|
||||||
|
options?: { maxPoints?: number; smooth?: boolean },
|
||||||
|
) {
|
||||||
|
const empty = {
|
||||||
|
hasData: false,
|
||||||
|
linePath: '',
|
||||||
|
areaPath: '',
|
||||||
|
endDot: null as { x: number; y: number } | null,
|
||||||
|
samples: [] as ChartPlotSample[],
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
}
|
||||||
|
if (points.length < 2) return empty
|
||||||
|
|
||||||
|
const maxPoints = options?.maxPoints ?? DEFAULT_MAX_POINTS
|
||||||
|
const useSmooth = options?.smooth ?? true
|
||||||
|
|
||||||
|
const sampled = downsampleSeries(points, maxPoints)
|
||||||
|
const series = useSmooth ? smoothSeries(sampled, 3) : sampled
|
||||||
|
|
||||||
|
const values = series.map((point) => point.value)
|
||||||
|
let min = Math.min(...values)
|
||||||
|
let max = Math.max(...values)
|
||||||
|
const span = max - min || max * 0.02 || 1
|
||||||
|
const pad = span * 0.12
|
||||||
|
min -= pad
|
||||||
|
max += pad
|
||||||
|
const range = max - min
|
||||||
|
const usableHeight = height - CHART_PAD_Y * 2
|
||||||
|
|
||||||
|
const plot = series.map((point, index) => {
|
||||||
|
const x = (index / (series.length - 1)) * width
|
||||||
|
const y = CHART_PAD_Y + (1 - (point.value - min) / range) * usableHeight
|
||||||
|
return { x, y }
|
||||||
|
})
|
||||||
|
|
||||||
|
const linePath = buildSmoothLinePath(plot)
|
||||||
|
const areaPath = `${linePath} L${width} ${height} L0 ${height} Z`
|
||||||
|
const last = plot[plot.length - 1]
|
||||||
|
const samples = plot.map((point, index) => ({
|
||||||
|
x: point.x,
|
||||||
|
y: point.y,
|
||||||
|
value: sampled[index]?.value ?? series[index].value,
|
||||||
|
timeMs: sampled[index]?.timeMs ?? series[index].timeMs,
|
||||||
|
}))
|
||||||
|
|
||||||
|
return {
|
||||||
|
hasData: true,
|
||||||
|
linePath,
|
||||||
|
areaPath,
|
||||||
|
endDot: last ? { x: last.x, y: last.y } : null,
|
||||||
|
samples,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,10 @@ import boursecuBuySellIcon from '@/assets/img/boursecu-buy-sell-icon.png'
|
|||||||
import boursecuAssetsIcon from '@/assets/img/boursecu-assets-icon.png'
|
import boursecuAssetsIcon from '@/assets/img/boursecu-assets-icon.png'
|
||||||
import boursecuHomeIcon from '@/assets/img/boursecu-home-icon.png'
|
import boursecuHomeIcon from '@/assets/img/boursecu-home-icon.png'
|
||||||
import boursecuSettingsIcon from '@/assets/img/boursecu-settings-icon.png'
|
import boursecuSettingsIcon from '@/assets/img/boursecu-settings-icon.png'
|
||||||
|
import boursecuSupportIcon from '@/assets/img/boursecu-support-icon.png'
|
||||||
|
import boursecuAboutIcon from '@/assets/img/boursecu-about-icon.png'
|
||||||
|
import boursecuPriceTriggerIcon from '@/assets/img/boursecu-price-trigger-icon.png'
|
||||||
|
import boursecuRulesIcon from '@/assets/img/boursecu-rules-icon.png'
|
||||||
|
|
||||||
export function getConfigApp(key: string) {
|
export function getConfigApp(key: string) {
|
||||||
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user : {}
|
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user : {}
|
||||||
@@ -31,6 +35,13 @@ export function isBazretalaProject() {
|
|||||||
|
|
||||||
const WALLET_DEPOSIT_QUICK_AMOUNTS_RIAL = [10_000_000, 50_000_000, 100_000_000] as const
|
const WALLET_DEPOSIT_QUICK_AMOUNTS_RIAL = [10_000_000, 50_000_000, 100_000_000] as const
|
||||||
|
|
||||||
|
/** آدرس صفحهٔ پرداخت آنی واریز. خالی بماند تا لینک درگاه آماده شود. */
|
||||||
|
export const INSTANT_DEPOSIT_PAYMENT_URL = ''
|
||||||
|
|
||||||
|
export function getInstantDepositPaymentUrl(): string {
|
||||||
|
return INSTANT_DEPOSIT_PAYMENT_URL.trim()
|
||||||
|
}
|
||||||
|
|
||||||
export function getWalletDepositQuickAmountsRial(): readonly number[] {
|
export function getWalletDepositQuickAmountsRial(): readonly number[] {
|
||||||
return WALLET_DEPOSIT_QUICK_AMOUNTS_RIAL
|
return WALLET_DEPOSIT_QUICK_AMOUNTS_RIAL
|
||||||
}
|
}
|
||||||
@@ -77,6 +88,10 @@ export function getBoursecuActionIconSrc(actionId: string): string | undefined {
|
|||||||
convert: boursecuConvertIcon,
|
convert: boursecuConvertIcon,
|
||||||
home: boursecuHomeIcon,
|
home: boursecuHomeIcon,
|
||||||
settings: boursecuSettingsIcon,
|
settings: boursecuSettingsIcon,
|
||||||
|
support: boursecuSupportIcon,
|
||||||
|
about: boursecuAboutIcon,
|
||||||
|
priceTrigger: boursecuPriceTriggerIcon,
|
||||||
|
rules: boursecuRulesIcon,
|
||||||
}
|
}
|
||||||
|
|
||||||
return icons[actionId]
|
return icons[actionId]
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/** فرمول تبدیل کارفرما — اکسل «تبدیل کاتد و مفتول به سیم ۱.۵–۲.۵» */
|
||||||
|
|
||||||
|
export type CopperConvertSource = 'katod' | 'maftoul' | 'shamsh'
|
||||||
|
|
||||||
|
export interface CopperConvertPrices {
|
||||||
|
katodPerKg: number
|
||||||
|
maftoulPerKg: number
|
||||||
|
shamshPerKg: number
|
||||||
|
/** قیمت هر حلقه سیم ۱.۵ (ریال) */
|
||||||
|
wireRing15: number
|
||||||
|
/** قیمت هر حلقه سیم ۲.۵ (ریال) */
|
||||||
|
wireRing25: number
|
||||||
|
/** وزن هر حلقه ۱.۵ — گرم (ستون اکسل) */
|
||||||
|
wireWeightGrams15: number
|
||||||
|
/** وزن هر حلقه ۲.۵ — گرم؛ اگر صفر باشد فقط محاسبه ارزشی */
|
||||||
|
wireWeightGrams25: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CopperConvertResult {
|
||||||
|
totalValueRial: number
|
||||||
|
equivalentMaftoulKg: number
|
||||||
|
/** ارزش ÷ قیمت حلقه (شیت مفتول→سیم) */
|
||||||
|
rings15ByValue: number
|
||||||
|
rings25ByValue: number
|
||||||
|
/** مفتول معادل ÷ وزن حلقه */
|
||||||
|
rings15ByWeight: number | null
|
||||||
|
rings25ByWeight: number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** مقادیر نمونه اکسل — وقتی محصول سیم در لیست نیست */
|
||||||
|
export const COPPER_CONVERT_WIRE_FALLBACK = {
|
||||||
|
wireRing15: 36_000_000,
|
||||||
|
wireRing25: 38_000_000,
|
||||||
|
wireWeightGrams15: 2777,
|
||||||
|
wireWeightGrams25: 0,
|
||||||
|
} as const
|
||||||
|
|
||||||
|
function sourcePricePerKg(source: CopperConvertSource, prices: CopperConvertPrices): number {
|
||||||
|
if (source === 'katod') return prices.katodPerKg
|
||||||
|
if (source === 'maftoul') return prices.maftoulPerKg
|
||||||
|
return prices.shamshPerKg
|
||||||
|
}
|
||||||
|
|
||||||
|
function ringsByWeight(maftoulKg: number, gramsPerRing: number): number | null {
|
||||||
|
if (maftoulKg <= 0 || gramsPerRing <= 0) return null
|
||||||
|
return (maftoulKg * 1000) / gramsPerRing
|
||||||
|
}
|
||||||
|
|
||||||
|
export function calcCopperWireConvert(
|
||||||
|
inputKg: number,
|
||||||
|
source: CopperConvertSource,
|
||||||
|
prices: CopperConvertPrices,
|
||||||
|
): CopperConvertResult | null {
|
||||||
|
if (!Number.isFinite(inputKg) || inputKg <= 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const perKg = sourcePricePerKg(source, prices)
|
||||||
|
if (perKg <= 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalValueRial = inputKg * perKg
|
||||||
|
const equivalentMaftoulKg =
|
||||||
|
prices.maftoulPerKg > 0 ? totalValueRial / prices.maftoulPerKg : 0
|
||||||
|
|
||||||
|
const rings15ByValue = prices.wireRing15 > 0 ? totalValueRial / prices.wireRing15 : 0
|
||||||
|
const rings25ByValue = prices.wireRing25 > 0 ? totalValueRial / prices.wireRing25 : 0
|
||||||
|
|
||||||
|
return {
|
||||||
|
totalValueRial,
|
||||||
|
equivalentMaftoulKg,
|
||||||
|
rings15ByValue,
|
||||||
|
rings25ByValue,
|
||||||
|
rings15ByWeight: ringsByWeight(equivalentMaftoulKg, prices.wireWeightGrams15),
|
||||||
|
rings25ByWeight: ringsByWeight(equivalentMaftoulKg, prices.wireWeightGrams25),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/** احراز نشده = is_legal صفر. ۱ و ۲ یعنی اطلاعات ثبت شده و معامله مجاز است. */
|
||||||
|
export function isCustomerIdentityVerified(isLegal: unknown): boolean {
|
||||||
|
return Number(isLegal ?? 0) !== 0
|
||||||
|
}
|
||||||
@@ -18,10 +18,10 @@ export const DEFAULT_DEPOSIT_SUPPORT_MESSAGE_TEXT =
|
|||||||
'باسلام، %نام هستم. کدپیگیری و مبلغ واریزی من:'
|
'باسلام، %نام هستم. کدپیگیری و مبلغ واریزی من:'
|
||||||
|
|
||||||
/** الگوی متغیر نام — ٪نام / %نام / % نام / %نام% */
|
/** الگوی متغیر نام — ٪نام / %نام / % نام / %نام% */
|
||||||
const NAME_PLACEHOLDER_RE = /[%٪]\s*نام(?:\s*[%٪])?/gu
|
const NAME_PLACEHOLDER_RE = /[%٪]\s*نام[%٪]?/gu
|
||||||
const CARD_PLACEHOLDER_RE = /[%٪]\s*کارت(?:\s*[%٪])?/gu
|
const CARD_PLACEHOLDER_RE = /[%٪]\s*کارت[%٪]?/gu
|
||||||
const ACCOUNT_PLACEHOLDER_RE = /[%٪]\s*حساب(?:\s*[%٪])?/gu
|
const ACCOUNT_PLACEHOLDER_RE = /[%٪]\s*حساب[%٪]?/gu
|
||||||
const SHEBA_PLACEHOLDER_RE = /[%٪]\s*شبا(?:\s*[%٪])?/gu
|
const SHEBA_PLACEHOLDER_RE = /[%٪]\s*شبا[%٪]?/gu
|
||||||
|
|
||||||
export function getCustomerNameFromUser(): string {
|
export function getCustomerNameFromUser(): string {
|
||||||
try {
|
try {
|
||||||
@@ -47,21 +47,72 @@ export function renderDepositSupportMessageText(
|
|||||||
return template.replace(NAME_PLACEHOLDER_RE, name)
|
return template.replace(NAME_PLACEHOLDER_RE, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** جایگزینی متغیرها در متن راهنمای واریز — ٪نام / %نام، ٪کارت / %کارت، ٪حساب / %حساب، ٪شبا / %شبا */
|
/**
|
||||||
|
* حذف شمارههای حساب، شبا و کارت و همچنین ارقام زائد از متن راهنما؛
|
||||||
|
* این اطلاعات در ردیفهای اختصاصی مودال با دکمه کپی نمایش داده میشوند.
|
||||||
|
*/
|
||||||
|
function stripDepositGuideNumbers(text: string, vars?: DepositGuideVars): string {
|
||||||
|
let cleaned = text
|
||||||
|
|
||||||
|
if (vars) {
|
||||||
|
const rawValues = [
|
||||||
|
vars.sheba,
|
||||||
|
vars.sheba ? vars.sheba.replace(/^IR/i, '').trim() : '',
|
||||||
|
vars.sheba ? vars.sheba.replace(/^IR/i, '').replace(/\s+/g, '') : '',
|
||||||
|
vars.sheba ? formatDepositSheba(vars.sheba) : '',
|
||||||
|
vars.cardNumber,
|
||||||
|
vars.cardNumber ? vars.cardNumber.replace(/\s+/g, '') : '',
|
||||||
|
vars.cardNumber ? formatDepositCardNumber(vars.cardNumber) : '',
|
||||||
|
vars.accountNumber,
|
||||||
|
vars.accountNumber ? vars.accountNumber.replace(/\s+/g, '') : '',
|
||||||
|
]
|
||||||
|
.map((v) => String(v ?? '').trim())
|
||||||
|
.filter((v) => v.length >= 6)
|
||||||
|
|
||||||
|
rawValues.sort((a, b) => b.length - a.length)
|
||||||
|
for (const val of rawValues) {
|
||||||
|
if (!val) continue
|
||||||
|
const escaped = val.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||||
|
cleaned = cleaned.replace(new RegExp(escaped, 'gi'), '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// حذف توالیهای رقمی ۵ رقم یا بیشتر (فارسی و انگلیسی با فاصله یا خط تیره بین ارقام)
|
||||||
|
cleaned = cleaned.replace(/(?:^|[^\w\d۰-۹])[\d۰-۹][\d۰-۹\s-]{3,}[\d۰-۹](?=[^\w\d۰-۹]|$)/gu, '')
|
||||||
|
|
||||||
|
// پالایش خطوط: حذف خطوطی که صرفاً از رقم/فاصله/علائم تشکیل شدهاند یا برچسبهای مرده
|
||||||
|
const lines = cleaned.split('\n')
|
||||||
|
const filteredLines = lines
|
||||||
|
.map((line) => {
|
||||||
|
const withoutDigitsAndPunct = line.replace(/[\d۰-۹\s.,:;–—/\\()-]/g, '')
|
||||||
|
if (withoutDigitsAndPunct.length === 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
const trimmed = line.trim()
|
||||||
|
if (/^(?:شماره\s*(?:شبا|حساب|کارت)|شبا|حساب|کارت)\s*[::-]?$/u.test(trimmed)) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
return trimmed
|
||||||
|
})
|
||||||
|
.filter((line) => line.length > 0)
|
||||||
|
|
||||||
|
return filteredLines.join('\n').trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** جایگزینی متغیرها در متن راهنمای واریز — ٪نام / %نام (کارت، حساب و شبا چون ردیف جداگانه دارند حذف میشوند) */
|
||||||
export function renderDepositGuideText(
|
export function renderDepositGuideText(
|
||||||
template: string,
|
template: string,
|
||||||
vars: DepositGuideVars,
|
vars: DepositGuideVars,
|
||||||
): string {
|
): string {
|
||||||
const accountHolder = String(vars.accountHolder ?? '').trim()
|
const accountHolder = String(vars.accountHolder ?? '').trim()
|
||||||
const cardNumber = String(vars.cardNumber ?? '').trim()
|
|
||||||
const accountNumber = String(vars.accountNumber ?? '').trim()
|
|
||||||
const sheba = String(vars.sheba ?? '').trim()
|
|
||||||
|
|
||||||
return template
|
let text = template
|
||||||
.replace(SHEBA_PLACEHOLDER_RE, sheba)
|
.replace(SHEBA_PLACEHOLDER_RE, '')
|
||||||
.replace(ACCOUNT_PLACEHOLDER_RE, accountNumber)
|
.replace(ACCOUNT_PLACEHOLDER_RE, '')
|
||||||
.replace(CARD_PLACEHOLDER_RE, cardNumber)
|
.replace(CARD_PLACEHOLDER_RE, '')
|
||||||
.replace(NAME_PLACEHOLDER_RE, accountHolder)
|
.replace(NAME_PLACEHOLDER_RE, accountHolder)
|
||||||
|
|
||||||
|
return stripDepositGuideNumbers(text, vars)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDepositGuideVarsFromSettings(): DepositGuideVars {
|
export function getDepositGuideVarsFromSettings(): DepositGuideVars {
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { getToken } from '@/utils'
|
||||||
|
import router from '@/router'
|
||||||
|
import type { LocationQuery, RouteLocationNormalizedLoaded } from 'vue-router'
|
||||||
|
|
||||||
|
export const GUEST_HOME_QUERY = { guest: '1' } as const
|
||||||
|
|
||||||
|
export function isGuestHomeQuery(query: LocationQuery | Record<string, unknown>) {
|
||||||
|
const value = query.guest
|
||||||
|
return value === '1' || value === 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isGuestHomeActive(route?: RouteLocationNormalizedLoaded) {
|
||||||
|
const current = route ?? router.currentRoute.value
|
||||||
|
return current.name === 'home' && isGuestHomeQuery(current.query) && !getToken()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function guestHomeRoute() {
|
||||||
|
return { name: 'home' as const, query: { ...GUEST_HOME_QUERY } }
|
||||||
|
}
|
||||||
@@ -152,7 +152,6 @@ export const justNumber = () => {
|
|||||||
message: 'لطفا اطلاعات را به صورت عدد و نقطه وارد کنید'
|
message: 'لطفا اطلاعات را به صورت عدد و نقطه وارد کنید'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const walletCash = useWalletStore()
|
|
||||||
let priceP = 0
|
let priceP = 0
|
||||||
let methodP = 'cash'
|
let methodP = 'cash'
|
||||||
let amountP =0
|
let amountP =0
|
||||||
@@ -173,7 +172,7 @@ const checkNumber = async (_rule: Rule, value: number | string) => {
|
|||||||
return Promise.reject('استفاده از اعداد اعشاری مجاز نمی باشد')
|
return Promise.reject('استفاده از اعداد اعشاری مجاز نمی باشد')
|
||||||
}
|
}
|
||||||
if (isBuyP){
|
if (isBuyP){
|
||||||
const availableCash = getCashWalletBalance(walletCash?.walletInfo)
|
const availableCash = getCashWalletBalance(useWalletStore().walletInfo)
|
||||||
if (!availableCash && isCashLikeDealMethod(methodP)){
|
if (!availableCash && isCashLikeDealMethod(methodP)){
|
||||||
return Promise.reject(getInsufficientCashWalletMessage(groupTypeP))
|
return Promise.reject(getInsufficientCashWalletMessage(groupTypeP))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export function shouldNormalizeInputDigits(_options?: {
|
|||||||
type?: string
|
type?: string
|
||||||
inputmode?: string
|
inputmode?: string
|
||||||
}): boolean {
|
}): boolean {
|
||||||
// همیشه ارقام فارسی/عربی → انگلیسی (لاگین، گرم، تعداد، مظنه، …)
|
// همیشه ارقام فارسی/عربی → انگلیسی (لاگین، گرم، تعداد، قیمت، …)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/** جایگزینی «مظنه» و شکلهای وابسته با «قیمت» در متنهای نمایشی به مشتری */
|
||||||
|
|
||||||
|
const MAZANEH_TO_PRICE: Array<[RegExp, string]> = [
|
||||||
|
[/مظنههای/g, 'قیمتهای'],
|
||||||
|
[/مظنهها/g, 'قیمتها'],
|
||||||
|
[/مظنهای/g, 'قیمتی'],
|
||||||
|
[/مظنهای/g, 'قیمتی'],
|
||||||
|
[/مظنهٔ/g, 'قیمت'],
|
||||||
|
[/مظنه/g, 'قیمت'],
|
||||||
|
]
|
||||||
|
|
||||||
|
export function replaceMazanehTerminology(text: string): string {
|
||||||
|
let result = text
|
||||||
|
for (const [pattern, replacement] of MAZANEH_TO_PRICE) {
|
||||||
|
result = result.replace(pattern, replacement)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
export function polishUserFacingCopy(text: unknown): string {
|
||||||
|
if (typeof text !== 'string') return ''
|
||||||
|
const trimmed = text.trim()
|
||||||
|
if (!trimmed) return ''
|
||||||
|
return replaceMazanehTerminology(trimmed)
|
||||||
|
}
|
||||||
@@ -18,11 +18,11 @@ let lastSubscribers = 0
|
|||||||
/** @deprecated از lastPrice استفاده کنید — برای سازگاری با کد قدیمی sync میشود */
|
/** @deprecated از lastPrice استفاده کنید — برای سازگاری با کد قدیمی sync میشود */
|
||||||
export const price = ref<Price>()
|
export const price = ref<Price>()
|
||||||
export const lastPrice = ref<Price>()
|
export const lastPrice = ref<Price>()
|
||||||
/** حداقل یک بار تلاش برای گرفتن مظنه تمام شده (موفق یا ناموفق) */
|
/** حداقل یک بار تلاش برای گرفتن قیمت تمام شده (موفق یا ناموفق) */
|
||||||
export const lastPriceReady = ref(false)
|
export const lastPriceReady = ref(false)
|
||||||
/**
|
/**
|
||||||
* بعد از اولین پاسخ خالی/no_quote، چند لحظه صبر میکنیم تا تیک SSE/زنده برسد
|
* بعد از اولین پاسخ خالی/no_quote، چند لحظه صبر میکنیم تا تیک SSE/زنده برسد
|
||||||
* و «مظنه در دسترس نیست» زودهنگام نشان داده نشود.
|
* و «قیمت در دسترس نیست» زودهنگام نشان داده نشود.
|
||||||
*/
|
*/
|
||||||
export const lastPriceSettleGeneration = ref(0)
|
export const lastPriceSettleGeneration = ref(0)
|
||||||
export const olderPrice = ref<number | undefined>(0)
|
export const olderPrice = ref<number | undefined>(0)
|
||||||
@@ -92,7 +92,7 @@ function markLastPriceReady() {
|
|||||||
scheduleQuoteAbsenceSettle()
|
scheduleQuoteAbsenceSettle()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** قیمت آمده، بسته قطعی است، یا پنجرهٔ انتظارِ مظنه خالی تمام شده */
|
/** قیمت آمده، بسته قطعی است، یا پنجرهٔ انتظارِ قیمت خالی تمام شده */
|
||||||
export function isLastPriceAbsenceSettled(): boolean {
|
export function isLastPriceAbsenceSettled(): boolean {
|
||||||
void lastPriceSettleGeneration.value
|
void lastPriceSettleGeneration.value
|
||||||
if (!lastPriceReady.value) return false
|
if (!lastPriceReady.value) return false
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const STREAM_CONNECTING = 0
|
|||||||
const STREAM_OPEN = 1
|
const STREAM_OPEN = 1
|
||||||
const STREAM_CLOSED = 2
|
const STREAM_CLOSED = 2
|
||||||
|
|
||||||
/** EventSource نمیتواند Authorization بفرستد؛ استریم همچنان auth:customer میخواهد. */
|
/** fetch + ReadableStream — با توکن اختلاف قیمت ویژه؛ بدون توکن همان قیمت عمومی (مهمان). */
|
||||||
class AuthPriceStream extends EventTarget {
|
class AuthPriceStream extends EventTarget {
|
||||||
readyState = STREAM_CONNECTING
|
readyState = STREAM_CONNECTING
|
||||||
onopen: (() => void) | null = null
|
onopen: (() => void) | null = null
|
||||||
@@ -46,7 +46,7 @@ class AuthPriceStream extends EventTarget {
|
|||||||
onmessage: (() => void) | null = null
|
onmessage: (() => void) | null = null
|
||||||
private abort = new AbortController()
|
private abort = new AbortController()
|
||||||
|
|
||||||
constructor(url: string, token: string) {
|
constructor(url: string, token?: string) {
|
||||||
super()
|
super()
|
||||||
void this.start(url, token)
|
void this.start(url, token)
|
||||||
}
|
}
|
||||||
@@ -56,13 +56,18 @@ class AuthPriceStream extends EventTarget {
|
|||||||
this.abort.abort()
|
this.abort.abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
private async start(url: string, token: string) {
|
private async start(url: string, token?: string) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, {
|
const headers: Record<string, string> = {
|
||||||
headers: {
|
|
||||||
Accept: 'text/event-stream',
|
Accept: 'text/event-stream',
|
||||||
Authorization: `Bearer ${token}`,
|
}
|
||||||
},
|
const bearer = String(token ?? '').trim()
|
||||||
|
if (bearer) {
|
||||||
|
headers.Authorization = `Bearer ${bearer}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(url, {
|
||||||
|
headers,
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
signal: this.abort.signal,
|
signal: this.abort.signal,
|
||||||
})
|
})
|
||||||
@@ -191,10 +196,6 @@ function resolveStreamUrl(): string | null {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!findStoredAuthToken()) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const base = String(getConfigApp('node_server') || window.location.origin).replace(/\/$/, '')
|
const base = String(getConfigApp('node_server') || window.location.origin).replace(/\/$/, '')
|
||||||
return `${base}${resolveStreamPath()}`
|
return `${base}${resolveStreamPath()}`
|
||||||
}
|
}
|
||||||
@@ -301,10 +302,12 @@ async function runFallbackPoll() {
|
|||||||
'@/views/base/products/composables/useProductsPageData'
|
'@/views/base/products/composables/useProductsPageData'
|
||||||
)
|
)
|
||||||
|
|
||||||
const [priceResult] = await Promise.allSettled([
|
const pollTasks: Promise<unknown>[] = [getLastPrices()]
|
||||||
getLastPrices(),
|
if (findStoredAuthToken()) {
|
||||||
refreshProductsPageData(),
|
pollTasks.push(refreshProductsPageData())
|
||||||
])
|
}
|
||||||
|
|
||||||
|
const [priceResult] = await Promise.allSettled(pollTasks)
|
||||||
|
|
||||||
const priceOk =
|
const priceOk =
|
||||||
priceResult.status === 'fulfilled'
|
priceResult.status === 'fulfilled'
|
||||||
@@ -643,7 +646,7 @@ function connect() {
|
|||||||
|
|
||||||
const url = resolveStreamUrl()
|
const url = resolveStreamUrl()
|
||||||
const token = findStoredAuthToken()
|
const token = findStoredAuthToken()
|
||||||
if (!url || !token) {
|
if (!url) {
|
||||||
priceSocketConnected.value = false
|
priceSocketConnected.value = false
|
||||||
priceStreamLifecycle.value = 'closed'
|
priceStreamLifecycle.value = 'closed'
|
||||||
clearConnectingLifecycle()
|
clearConnectingLifecycle()
|
||||||
@@ -661,7 +664,7 @@ function connect() {
|
|||||||
markConnectingLifecycle()
|
markConnectingLifecycle()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
eventSource = new AuthPriceStream(url, token)
|
eventSource = new AuthPriceStream(url, token ?? undefined)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Price SSE connect failed', error)
|
console.warn('Price SSE connect failed', error)
|
||||||
handleStreamLost()
|
handleStreamLost()
|
||||||
@@ -824,10 +827,6 @@ export function isPriceWebSocketEnabled(settingGetter: (key: string) => unknown)
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!findStoredAuthToken()) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolveStreamUrl() !== null
|
return resolveStreamUrl() !== null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,14 @@ function sumBoursecuHomeProductInventories(
|
|||||||
return sum
|
return sum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resolveBoursecuCopperUnit(unit?: string | null): string {
|
||||||
|
const trimmed = (unit ?? '').trim()
|
||||||
|
if (!trimmed || trimmed === 'گرم' || trimmed === 'gram' || trimmed === 'g') {
|
||||||
|
return 'کیلوگرم'
|
||||||
|
}
|
||||||
|
return trimmed
|
||||||
|
}
|
||||||
|
|
||||||
function findMetalTotalById(metalTotals: WalletMetalTotal[], metalId: number) {
|
function findMetalTotalById(metalTotals: WalletMetalTotal[], metalId: number) {
|
||||||
return metalTotals.find((metal) => metal.metal_id === metalId)
|
return metalTotals.find((metal) => metal.metal_id === metalId)
|
||||||
}
|
}
|
||||||
@@ -195,7 +203,8 @@ function formatBoursecuMetalRowValue(metal: WalletMetalTotal): string {
|
|||||||
if (metal.metal_id === METAL_GOLD) {
|
if (metal.metal_id === METAL_GOLD) {
|
||||||
return `${amount} عدد`
|
return `${amount} عدد`
|
||||||
}
|
}
|
||||||
return `${amount}${metal.unit ?? ''}`
|
const unit = metal.metal_id === METAL_COPPER ? resolveBoursecuCopperUnit(metal.unit) : (metal.unit ?? 'کیلوگرم')
|
||||||
|
return `${amount} ${unit}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatRialNumber(value: number): string {
|
function formatRialNumber(value: number): string {
|
||||||
@@ -237,8 +246,11 @@ function buildBoursecuCopperPopupLines(summary: {
|
|||||||
const metalTotals = summary.metal_totals ?? []
|
const metalTotals = summary.metal_totals ?? []
|
||||||
const copperMetal = findMetalTotalById(metalTotals, METAL_COPPER)
|
const copperMetal = findMetalTotalById(metalTotals, METAL_COPPER)
|
||||||
const shamshMetal = findMetalTotalById(metalTotals, METAL_GOLD)
|
const shamshMetal = findMetalTotalById(metalTotals, METAL_GOLD)
|
||||||
const weightUnit = copperMetal?.unit || 'کیلوگرم'
|
const weightUnit = resolveBoursecuCopperUnit(copperMetal?.unit)
|
||||||
const totalWeight = sumBoursecuHomeProductInventories(inventoryCards, countProducts)
|
const totalWeight =
|
||||||
|
copperMetal != null && Number(copperMetal.total_weight ?? 0) > 0
|
||||||
|
? Number(copperMetal.total_weight)
|
||||||
|
: sumBoursecuHomeProductInventories(inventoryCards, countProducts)
|
||||||
|
|
||||||
const katodCard = findBoursecuProductCard(inventoryCards, countProducts, isBoursecuKatodCard)
|
const katodCard = findBoursecuProductCard(inventoryCards, countProducts, isBoursecuKatodCard)
|
||||||
const maftolCard = findBoursecuProductCard(inventoryCards, countProducts, isBoursecuMaftolCard)
|
const maftolCard = findBoursecuProductCard(inventoryCards, countProducts, isBoursecuMaftolCard)
|
||||||
@@ -319,10 +331,10 @@ export function buildBoursecuHomeAssetRows(
|
|||||||
const countProducts = summary.count_products ?? []
|
const countProducts = summary.count_products ?? []
|
||||||
const metalTotals = summary.metal_totals ?? []
|
const metalTotals = summary.metal_totals ?? []
|
||||||
const copperMetal = findMetalTotalById(metalTotals, METAL_COPPER)
|
const copperMetal = findMetalTotalById(metalTotals, METAL_COPPER)
|
||||||
const weightUnit = copperMetal?.unit || 'کیلوگرم'
|
const weightUnit = resolveBoursecuCopperUnit(copperMetal?.unit)
|
||||||
const totalCopperWeight =
|
const totalCopperWeight =
|
||||||
copperMetal != null
|
copperMetal != null && Number(copperMetal.total_weight ?? 0) > 0
|
||||||
? Number(copperMetal.total_weight ?? 0)
|
? Number(copperMetal.total_weight)
|
||||||
: sumBoursecuHomeProductInventories(inventoryCards, countProducts)
|
: sumBoursecuHomeProductInventories(inventoryCards, countProducts)
|
||||||
|
|
||||||
const cash = Number(summary.cash_wallet ?? 0)
|
const cash = Number(summary.cash_wallet ?? 0)
|
||||||
@@ -387,7 +399,7 @@ export function resolveSummaryMetalWeight(
|
|||||||
|
|
||||||
/** متن توضیح مودال دارایی فلزی — بر اساس metal_totals سرور، بدون هاردکد طلا */
|
/** متن توضیح مودال دارایی فلزی — بر اساس metal_totals سرور، بدون هاردکد طلا */
|
||||||
export function formatMetalAssetsInfoText(metal: WalletMetalTotal): string {
|
export function formatMetalAssetsInfoText(metal: WalletMetalTotal): string {
|
||||||
const unit = metal.unit || 'گرم'
|
const unit = metal.metal_id === METAL_COPPER ? resolveBoursecuCopperUnit(metal.unit) : (metal.unit || 'کیلوگرم')
|
||||||
return `${metal.label}: مجموع کیف محصولات (${metal.product_weight} ${unit}) + موجودی کیف اصلی (${metal.melted_weight} ${unit})`
|
return `${metal.label}: مجموع کیف محصولات (${metal.product_weight} ${unit}) + موجودی کیف اصلی (${metal.melted_weight} ${unit})`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,7 +522,7 @@ export function computeMetalRialValue(
|
|||||||
const metalId = Number(metal.metal_id ?? 0)
|
const metalId = Number(metal.metal_id ?? 0)
|
||||||
const unitPrice =
|
const unitPrice =
|
||||||
livePricesByMetal?.[metalId] ??
|
livePricesByMetal?.[metalId] ??
|
||||||
(metalId === METAL_GOLD ? liveGoldPrice : 0)
|
(metalId === METAL_COPPER || metalId === METAL_GOLD ? liveGoldPrice : 0)
|
||||||
|
|
||||||
return sum + weight * unitPrice
|
return sum + weight * unitPrice
|
||||||
}, 0)
|
}, 0)
|
||||||
@@ -534,7 +546,7 @@ export function formatInventoryCardValue(card: {
|
|||||||
display_type?: string
|
display_type?: string
|
||||||
}): string {
|
}): string {
|
||||||
const quantity = Number(card.quantity ?? 0)
|
const quantity = Number(card.quantity ?? 0)
|
||||||
const unit = card.unit ?? (card.display_type === 'count' ? 'عدد' : 'گرم')
|
const unit = card.unit ?? (card.display_type === 'count' ? 'عدد' : 'کیلوگرم')
|
||||||
const formatted =
|
const formatted =
|
||||||
card.display_type === 'count'
|
card.display_type === 'count'
|
||||||
? usePriceWithoutType(quantity, false)
|
? usePriceWithoutType(quantity, false)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import type { Product } from '@/models/products'
|
||||||
|
|
||||||
|
type TradeOpenProduct = Pick<Product, 'open_buy' | 'open_sell'> | null | undefined
|
||||||
|
|
||||||
|
function asBool(value: boolean | number | null | undefined) {
|
||||||
|
return value === true || Number(value) === 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isProductBuyOpen(product: TradeOpenProduct) {
|
||||||
|
if (!product) return true
|
||||||
|
return asBool(product.open_buy)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isProductSellOpen(product: TradeOpenProduct) {
|
||||||
|
if (!product) return true
|
||||||
|
return asBool(product.open_sell)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isProductTradeOpen(product: TradeOpenProduct, isBuy: boolean) {
|
||||||
|
return isBuy ? isProductBuyOpen(product) : isProductSellOpen(product)
|
||||||
|
}
|
||||||
@@ -39,10 +39,12 @@ export function renderInviteLinkText(
|
|||||||
.replace(/[%٪]\s*نام/gu, userName)
|
.replace(/[%٪]\s*نام/gu, userName)
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveReferralLoginLink(referralId?: string | number | null): string {
|
function resolveReferralRegisterLink(referralId?: string | number | null): string {
|
||||||
const id = String(referralId ?? '').trim()
|
const id = String(referralId ?? '').trim()
|
||||||
if (!id) return ''
|
if (!id) return ''
|
||||||
|
|
||||||
|
const query = `register=true&id=${encodeURIComponent(id)}`
|
||||||
|
|
||||||
let base = ''
|
let base = ''
|
||||||
try {
|
try {
|
||||||
base = String(useSettingsStore().getSettingByKey('app_url') ?? '').trim()
|
base = String(useSettingsStore().getSettingByKey('app_url') ?? '').trim()
|
||||||
@@ -51,14 +53,14 @@ function resolveReferralLoginLink(referralId?: string | number | null): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (base) {
|
if (base) {
|
||||||
return `${base.replace(/\/+$/, '')}/login?id=${encodeURIComponent(id)}`
|
return `${base.replace(/\/+$/, '')}/login?${query}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window !== 'undefined' && window.location?.origin) {
|
if (typeof window !== 'undefined' && window.location?.origin) {
|
||||||
return `${window.location.origin}/login?id=${encodeURIComponent(id)}`
|
return `${window.location.origin}/login?${query}`
|
||||||
}
|
}
|
||||||
|
|
||||||
return `/login?id=${encodeURIComponent(id)}`
|
return `/login?${query}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReferralShareText(options: {
|
export function getReferralShareText(options: {
|
||||||
@@ -67,7 +69,7 @@ export function getReferralShareText(options: {
|
|||||||
referralId?: string | number | null
|
referralId?: string | number | null
|
||||||
}) {
|
}) {
|
||||||
const userName = options.userName ?? ''
|
const userName = options.userName ?? ''
|
||||||
const link = resolveReferralLoginLink(options.referralId)
|
const link = resolveReferralRegisterLink(options.referralId)
|
||||||
return renderInviteLinkText(getInviteLinkTemplate(), { userName, link })
|
return renderInviteLinkText(getInviteLinkTemplate(), { userName, link })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,53 +33,22 @@ export function formatTradeGramDisplay(grams?: number | null): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function feeRate() {
|
function feeRate() {
|
||||||
return normalizeServiceFeeRatio(Number(serviceFeePercentage.value))
|
|
||||||
}
|
|
||||||
|
|
||||||
/** نسبت کارمزد (۰٫۰۱ = ۱٪). مقدار ≥۱ یعنی درصد انسانی اشتباه وارد شده. */
|
|
||||||
export function normalizeServiceFeeRatio(value: number): number {
|
|
||||||
if (!Number.isFinite(value) || value <= 0) {
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if (value >= 1) {
|
|
||||||
return value / 100
|
/** نسبت کارمزد — در بورس مس کارمزد روی قیمت اعلامی لحاظ شده است و کارمزد جداگانه صفر است */
|
||||||
}
|
export function normalizeServiceFeeRatio(value: number): number {
|
||||||
return value
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadServiceFeeFromSettings() {
|
export async function loadServiceFeeFromSettings() {
|
||||||
try {
|
// در بورس مس کارمزد روی قیمت اعلامی لحاظ شده و کارمزد مجزا وجود ندارد
|
||||||
const settingsStore = useSettingsStore()
|
serviceFeePercentage.value = 0
|
||||||
if (!settingsStore.loaded) {
|
|
||||||
await settingsStore.fetchSettings()
|
|
||||||
}
|
|
||||||
const settings = settingsStore.settings
|
|
||||||
if (settings?.length) {
|
|
||||||
const feeSetting = settings.find(
|
|
||||||
(s) => s?.key === 'fee_service_charge_percentage' && s?.is_active === true
|
|
||||||
)
|
|
||||||
if (feeSetting?.value !== undefined && feeSetting?.value !== null) {
|
|
||||||
const raw = String(feeSetting.value).trim()
|
|
||||||
serviceFeePercentage.value = raw === '' ? 0 : normalizeServiceFeeRatio(Number(raw))
|
|
||||||
}
|
|
||||||
|
|
||||||
const feeModeSetting = settings.find(
|
|
||||||
(s) => s?.key === 'fee_deduct_from_gold' && s?.is_active === true
|
|
||||||
)
|
|
||||||
if (feeModeSetting?.value !== undefined && feeModeSetting?.value !== null) {
|
|
||||||
const raw = String(feeModeSetting.value).trim().toLowerCase()
|
|
||||||
feeDeductFromGold.value = raw === 'true' || raw === '1'
|
|
||||||
} else {
|
|
||||||
feeDeductFromGold.value = false
|
feeDeductFromGold.value = false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function calcFeeInGrams(goldValue?: number | null) {
|
export function calcFeeInGrams(goldValue?: number | null) {
|
||||||
return parseFloat(((goldValue ?? 0) * feeRate()).toFixed(4))
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/** گرم معادل برای دریافت دقیق مبلغ ریالی در فروش */
|
/** گرم معادل برای دریافت دقیق مبلغ ریالی در فروش */
|
||||||
@@ -253,7 +222,7 @@ export interface TradeConfirmBreakdown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hasTradeFee(feeInGrams: number, feeInRial: number) {
|
function hasTradeFee(feeInGrams: number, feeInRial: number) {
|
||||||
return feeInGrams > 0 || feeInRial > 0
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function grossGoldFromRial(rial: number, unitPriceRial: number) {
|
function grossGoldFromRial(rial: number, unitPriceRial: number) {
|
||||||
@@ -263,9 +232,7 @@ function grossGoldFromRial(rial: number, unitPriceRial: number) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* جزئیات مدال تأیید — دو بخش «کسر از کیف» و «واریز به کیف».
|
* جزئیات مدال تأیید — دو بخش «کسر از کیف» و «واریز به کیف».
|
||||||
* فقط بر پایهٔ قفل ورودی تصمیم میگیرد:
|
* در بورس مس قیمت نهایی است و کارمزد مجزا وجود ندارد.
|
||||||
* • ریال قفل → مبلغ دقیق، کارمزد از طلا.
|
|
||||||
* • گرم قفل → وزن دقیق، کارمزد از ریال.
|
|
||||||
*/
|
*/
|
||||||
export function buildTradeConfirmBreakdown(params: {
|
export function buildTradeConfirmBreakdown(params: {
|
||||||
isBuy: boolean
|
isBuy: boolean
|
||||||
@@ -276,126 +243,42 @@ export function buildTradeConfirmBreakdown(params: {
|
|||||||
payablePrice: number
|
payablePrice: number
|
||||||
unitPriceRial: number
|
unitPriceRial: number
|
||||||
sellGoldDebit?: number
|
sellGoldDebit?: number
|
||||||
|
metalName?: string
|
||||||
|
weightUnit?: string
|
||||||
}): TradeConfirmBreakdown {
|
}): TradeConfirmBreakdown {
|
||||||
const {
|
const {
|
||||||
isBuy,
|
isBuy,
|
||||||
inputLock,
|
|
||||||
orderGoldAmount,
|
|
||||||
feeInGrams,
|
|
||||||
feeInRial,
|
|
||||||
payablePrice,
|
payablePrice,
|
||||||
unitPriceRial,
|
orderGoldAmount,
|
||||||
sellGoldDebit,
|
|
||||||
} = params
|
} = params
|
||||||
const hasFee = hasTradeFee(feeInGrams, feeInRial)
|
const metal = params.metalName ?? 'مس'
|
||||||
const rialLocked = isRialLocked(inputLock)
|
const unit = params.weightUnit ?? 'کیلوگرم'
|
||||||
const weight = orderGoldAmount
|
const weight = orderGoldAmount
|
||||||
|
|
||||||
if (!isBuy) {
|
if (!isBuy) {
|
||||||
if (rialLocked) {
|
|
||||||
const debit = sellGoldDebit ?? parseFloat((weight + feeInGrams).toFixed(4))
|
|
||||||
const goldRows: TradeConfirmRow[] = hasFee
|
|
||||||
? [
|
|
||||||
{ label: 'وزن معادل مبلغ', gram: weight },
|
|
||||||
{ label: 'کارمزد', gram: feeInGrams, minus: true },
|
|
||||||
{ label: 'جمع کسر از کیف طلا', gram: debit, bold: true, dividerBefore: true },
|
|
||||||
]
|
|
||||||
: [{ label: 'وزن فروش', gram: weight, bold: true }]
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sections: [
|
sections: [
|
||||||
{ heading: 'از کیف طلا کسر میشود', rows: goldRows },
|
{ heading: `از کیف ${metal} کسر میشود`, rows: [{ label: 'وزن فروش', gram: weight, bold: true }] },
|
||||||
{
|
{
|
||||||
heading: 'به کیف پول واریز میشود',
|
heading: 'به کیف پول واریز میشود',
|
||||||
rows: [{ label: 'مبلغ دریافتی', rial: payablePrice, bold: true }],
|
rows: [{ label: 'مبلغ دریافتی', rial: payablePrice, bold: true }],
|
||||||
footnote: hasFee
|
|
||||||
? 'دقیقاً همان مبلغی که وارد کردید واریز میشود؛ کارمزد فقط از طلای کیف کسر میشود.'
|
|
||||||
: undefined,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
formHint: hasFee
|
formHint: `${formatTradeGramDisplay(weight)} ${unit} فروش — ${payablePrice.toLocaleString('fa-IR')} ریال به کیف پول`,
|
||||||
? `${payablePrice.toLocaleString('fa-IR')} ریال دریافت — ${formatTradeGramDisplay(debit)} گرم از کیف کسر میشود (شامل ${formatTradeGramDisplay(feeInGrams)} گرم کارمزد)`
|
|
||||||
: `${payablePrice.toLocaleString('fa-IR')} ریال دریافت`,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const grossSellRial = Math.round(weight * unitPriceRial)
|
|
||||||
const cashRows: TradeConfirmRow[] = hasFee
|
|
||||||
? [
|
|
||||||
{ label: 'ارزش فروش', rial: grossSellRial },
|
|
||||||
{ label: 'کارمزد', rial: feeInRial, minus: true },
|
|
||||||
{ label: 'خالص دریافتی', rial: payablePrice, bold: true, dividerBefore: true },
|
|
||||||
]
|
|
||||||
: [{ label: 'مبلغ دریافتی', rial: payablePrice, bold: true }]
|
|
||||||
|
|
||||||
return {
|
|
||||||
sections: [
|
|
||||||
{ heading: 'از کیف طلا کسر میشود', rows: [{ label: 'وزن فروش', gram: weight, bold: true }] },
|
|
||||||
{
|
|
||||||
heading: 'به کیف پول واریز میشود',
|
|
||||||
rows: cashRows,
|
|
||||||
footnote: hasFee ? 'کارمزد از مبلغ ریالی دریافتی کم شده است.' : undefined,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
formHint: hasFee
|
|
||||||
? `${formatTradeGramDisplay(weight)} گرم فروش — ${feeInRial.toLocaleString('fa-IR')} ریال کارمزد از مبلغ دریافتی کسر میشود`
|
|
||||||
: `${formatTradeGramDisplay(weight)} گرم فروش — ${payablePrice.toLocaleString('fa-IR')} ریال به کیف پول`,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rialLocked) {
|
|
||||||
const grossGram = grossGoldFromRial(payablePrice, unitPriceRial)
|
|
||||||
const feeGram = parseFloat(Math.max(0, grossGram - weight).toFixed(4))
|
|
||||||
const goldRows: TradeConfirmRow[] = hasFee
|
|
||||||
? [
|
|
||||||
{ label: 'معادل طلای خام', gram: grossGram },
|
|
||||||
{ label: 'کارمزد', gram: feeGram, minus: true },
|
|
||||||
{ label: 'خالص واریزی به کیف طلا', gram: weight, bold: true, dividerBefore: true },
|
|
||||||
]
|
|
||||||
: [{ label: 'واریزی به کیف طلا', gram: weight, bold: true }]
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sections: [
|
sections: [
|
||||||
{
|
{
|
||||||
heading: 'از کیف پول کسر میشود',
|
heading: 'از کیف پول کسر میشود',
|
||||||
rows: [{ label: 'مبلغ پرداختی', rial: payablePrice, bold: true }],
|
rows: [{ label: 'مبلغ پرداختی', rial: payablePrice, bold: true }],
|
||||||
footnote: 'دقیقاً همان مبلغی که وارد کردید؛ کارمزد جداگانه اضافه نمیشود.',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
heading: 'به کیف طلا واریز میشود',
|
heading: `به کیف ${metal} واریز میشود`,
|
||||||
rows: goldRows,
|
rows: [{ label: 'مقدار واریزی', gram: weight, bold: true }],
|
||||||
footnote: hasFee ? 'کارمزد از وزن طلای دریافتی کسر شده است.' : undefined,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
formHint: hasFee
|
formHint: `${payablePrice.toLocaleString('fa-IR')} ریال پرداخت — ${formatTradeGramDisplay(weight)} ${unit} واریز`,
|
||||||
? `${payablePrice.toLocaleString('fa-IR')} ریال پرداخت — ${formatTradeGramDisplay(weight)} گرم واریز (کارمزد از طلا کسر شد)`
|
|
||||||
: `${payablePrice.toLocaleString('fa-IR')} ریال پرداخت`,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const basePriceRial = calcTradeBasePriceRial(weight, unitPriceRial)
|
|
||||||
const cashRows: TradeConfirmRow[] = hasFee
|
|
||||||
? [
|
|
||||||
{ label: `ارزش ${formatTradeGramDisplay(weight)} گرم`, rial: basePriceRial },
|
|
||||||
{ label: 'کارمزد', rial: feeInRial, plus: true },
|
|
||||||
{ label: 'جمع پرداختی', rial: payablePrice, bold: true, dividerBefore: true },
|
|
||||||
]
|
|
||||||
: [{ label: 'مبلغ پرداختی', rial: payablePrice, bold: true }]
|
|
||||||
|
|
||||||
return {
|
|
||||||
sections: [
|
|
||||||
{
|
|
||||||
heading: 'از کیف پول کسر میشود',
|
|
||||||
rows: cashRows,
|
|
||||||
footnote: hasFee ? 'کارمزد به مبلغ پرداختی اضافه شده است.' : undefined,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
heading: 'به کیف طلا واریز میشود',
|
|
||||||
rows: [{ label: 'دقیقاً', gram: weight, bold: true }],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
formHint: hasFee
|
|
||||||
? `${payablePrice.toLocaleString('fa-IR')} ریال (شامل ${feeInRial.toLocaleString('fa-IR')} ریال کارمزد) — ${formatTradeGramDisplay(weight)} گرم واریز`
|
|
||||||
: `${payablePrice.toLocaleString('fa-IR')} ریال پرداخت`,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useSettingsStore } from '@/store/settingsStore'
|
import { useSettingsStore } from '@/store/settingsStore'
|
||||||
import { isLastPriceAbsenceSettled, lastPrice, lastPriceReady } from '@/utils/price'
|
import { isLastPriceAbsenceSettled, lastPrice, lastPriceReady } from '@/utils/price'
|
||||||
|
import { replaceMazanehTerminology } from '@/utils/persianTerminology'
|
||||||
|
|
||||||
export interface StoreTradingHours {
|
export interface StoreTradingHours {
|
||||||
start: string
|
start: string
|
||||||
@@ -243,7 +244,7 @@ export function hasLivePriceQuote(): boolean {
|
|||||||
export function isStoreClosed(): boolean {
|
export function isStoreClosed(): boolean {
|
||||||
void productTradingHoursVersion.value
|
void productTradingHoursVersion.value
|
||||||
|
|
||||||
if (lastPrice.value?.closed === true) {
|
if (lastPrice.value?.closed === true || lastPrice.value?.status === 'closed') {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +254,7 @@ export function isStoreClosed(): boolean {
|
|||||||
export const STORE_CLOSED_TITLE = 'فروشگاه بسته است'
|
export const STORE_CLOSED_TITLE = 'فروشگاه بسته است'
|
||||||
|
|
||||||
export function stripHtmlMessage(message: string): string {
|
export function stripHtmlMessage(message: string): string {
|
||||||
return message.replace(/<[^>]*>/g, '').trim()
|
return replaceMazanehTerminology(message.replace(/<[^>]*>/g, '').trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStoreClosedHint(customMessage?: unknown): string {
|
export function getStoreClosedHint(customMessage?: unknown): string {
|
||||||
@@ -283,7 +284,7 @@ export function shouldBlockStoreTrading(): boolean {
|
|||||||
|
|
||||||
export type PriceDisplayState = 'open' | 'closed' | 'no_quote'
|
export type PriceDisplayState = 'open' | 'closed' | 'no_quote'
|
||||||
|
|
||||||
export const NO_QUOTE_MESSAGE = 'مظنه در دسترس نیست'
|
export const NO_QUOTE_MESSAGE = 'قیمت در دسترس نیست'
|
||||||
|
|
||||||
/** سوییچ: خارج از ساعت کاری هم قیمت صفحه اصلی نشان داده شود */
|
/** سوییچ: خارج از ساعت کاری هم قیمت صفحه اصلی نشان داده شود */
|
||||||
export function shouldShowHomePriceWhenClosed(): boolean {
|
export function shouldShowHomePriceWhenClosed(): boolean {
|
||||||
@@ -294,7 +295,7 @@ export function shouldShowLastSavedPrice(): boolean {
|
|||||||
return useSettingsStore().isSettingTruthy('show_last_price')
|
return useSettingsStore().isSettingTruthy('show_last_price')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** فقط این منابع «آخرین قیمت ذخیرهشده» هستند؛ باقی price_source مظنهٔ زنده است */
|
/** فقط این منابع «آخرین قیمت ذخیرهشده» هستند؛ باقی price_source قیمت زنده است */
|
||||||
const STORED_PRICE_SOURCES = ['database_last']
|
const STORED_PRICE_SOURCES = ['database_last']
|
||||||
|
|
||||||
function hasShowableHomePrice(p = lastPrice.value): boolean {
|
function hasShowableHomePrice(p = lastPrice.value): boolean {
|
||||||
@@ -319,7 +320,7 @@ function hasLiveQuote(p = lastPrice.value): boolean {
|
|||||||
/**
|
/**
|
||||||
* وضعیت نمایش قیمت در صفحه اصلی — همان منطق بکاند:
|
* وضعیت نمایش قیمت در صفحه اصلی — همان منطق بکاند:
|
||||||
* خارج از ساعت کاری (close_price روشن) → show_home_price_when_closed روشن: آخرین قیمت؛ خاموش: closed
|
* خارج از ساعت کاری (close_price روشن) → show_home_price_when_closed روشن: آخرین قیمت؛ خاموش: closed
|
||||||
* داخل ساعت کاری → مظنه زنده: open ؛ وگرنه فقط با show_last_price آخرین قیمت؛ وگرنه no_quote
|
* داخل ساعت کاری → قیمت زنده: open ؛ وگرنه فقط با show_last_price آخرین قیمت؛ وگرنه no_quote
|
||||||
*/
|
*/
|
||||||
export function getPriceDisplayState(): PriceDisplayState {
|
export function getPriceDisplayState(): PriceDisplayState {
|
||||||
void productTradingHoursVersion.value
|
void productTradingHoursVersion.value
|
||||||
@@ -348,7 +349,7 @@ export function getPriceDisplayState(): PriceDisplayState {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* اسکلتون تا وقتی قیمت قابلنمایش برسد، یا وضعیت بسته قطعی شود،
|
* اسکلتون تا وقتی قیمت قابلنمایش برسد، یا وضعیت بسته قطعی شود،
|
||||||
* یا بعد از اولین پاسخ خالی پنجرهٔ settle تمام شود (مظنه واقعاً نیست).
|
* یا بعد از اولین پاسخ خالی پنجرهٔ settle تمام شود (قیمت واقعاً نیست).
|
||||||
*/
|
*/
|
||||||
export function isHomeQuotePending(): boolean {
|
export function isHomeQuotePending(): boolean {
|
||||||
const settings = useSettingsStore()
|
const settings = useSettingsStore()
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ type DraggableFloatingOptions = {
|
|||||||
/** فاصله از پایینِ نوار منو + montzar (px) — مثل تصویر */
|
/** فاصله از پایینِ نوار منو + montzar (px) — مثل تصویر */
|
||||||
defaultBottomGap?: number
|
defaultBottomGap?: number
|
||||||
defaultRightOffset?: number
|
defaultRightOffset?: number
|
||||||
|
/** عرض کل پنجره بهجای فریم موبایل ۴۲۶ */
|
||||||
|
fullViewport?: boolean
|
||||||
|
/** نوار پایین اپ را در موقعیت پیشفرض لحاظ نکن */
|
||||||
|
ignoreBottomChrome?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
function readBottomChromeHeight(): number {
|
function readBottomChromeHeight(): number {
|
||||||
@@ -49,6 +53,8 @@ export function useDraggableFloatingButton(
|
|||||||
const height = options.height ?? 44
|
const height = options.height ?? 44
|
||||||
const defaultBottomGap = options.defaultBottomGap ?? 12
|
const defaultBottomGap = options.defaultBottomGap ?? 12
|
||||||
const defaultRightOffset = options.defaultRightOffset ?? 16
|
const defaultRightOffset = options.defaultRightOffset ?? 16
|
||||||
|
const fullViewport = options.fullViewport === true
|
||||||
|
const ignoreBottomChrome = options.ignoreBottomChrome === true
|
||||||
|
|
||||||
const pos = ref<FabPosition>({ x: 0, y: 0 })
|
const pos = ref<FabPosition>({ x: 0, y: 0 })
|
||||||
const dragging = ref(false)
|
const dragging = ref(false)
|
||||||
@@ -68,6 +74,7 @@ export function useDraggableFloatingButton(
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
function getViewportWidth() {
|
function getViewportWidth() {
|
||||||
|
if (fullViewport) return window.innerWidth
|
||||||
return Math.min(window.innerWidth, 426)
|
return Math.min(window.innerWidth, 426)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,11 +85,16 @@ export function useDraggableFloatingButton(
|
|||||||
return Math.max(0, (vw - contentWidth) / 2)
|
return Math.max(0, (vw - contentWidth) / 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBottomChrome() {
|
||||||
|
if (ignoreBottomChrome) return 0
|
||||||
|
return readBottomChromeHeight()
|
||||||
|
}
|
||||||
|
|
||||||
function getDefaultPosition(): FabPosition {
|
function getDefaultPosition(): FabPosition {
|
||||||
const vh = window.innerHeight
|
const vh = window.innerHeight
|
||||||
const offsetX = getHorizontalOffset()
|
const offsetX = getHorizontalOffset()
|
||||||
const contentWidth = getViewportWidth()
|
const contentWidth = getViewportWidth()
|
||||||
const bottomChrome = readBottomChromeHeight()
|
const bottomChrome = getBottomChrome()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x: offsetX + contentWidth - width - defaultRightOffset,
|
x: offsetX + contentWidth - width - defaultRightOffset,
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ export function isKilogramUnit(unit?: string | null) {
|
|||||||
return value === TRADE_WEIGHT_UNIT_KILOGRAM || value === 'kilogram' || value === 'kg'
|
return value === TRADE_WEIGHT_UNIT_KILOGRAM || value === 'kilogram' || value === 'kg'
|
||||||
}
|
}
|
||||||
|
|
||||||
/** واحد نمایش از ستینگ — خالی یا نامعتبر = گرم */
|
/** واحد نمایش از ستینگ — در بورس مس پیشفرض همیشه کیلوگرم است */
|
||||||
export function resolveTradeWeightUnit(settingValue?: string | number | null) {
|
export function resolveTradeWeightUnit(settingValue?: string | number | null) {
|
||||||
|
if (!settingValue) {
|
||||||
|
return TRADE_WEIGHT_UNIT_KILOGRAM
|
||||||
|
}
|
||||||
return isKilogramUnit(settingValue?.toString()) ? TRADE_WEIGHT_UNIT_KILOGRAM : TRADE_WEIGHT_UNIT_GRAM
|
return isKilogramUnit(settingValue?.toString()) ? TRADE_WEIGHT_UNIT_KILOGRAM : TRADE_WEIGHT_UNIT_GRAM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export function getDefaultAboutSoftwareText(projectName: string) {
|
export function getDefaultAboutSoftwareText(projectName: string) {
|
||||||
const name = projectName.trim() || 'این نرمافزار'
|
const name = projectName.trim() || 'این نرمافزار'
|
||||||
return `${name} بستری امن و آنلاین برای خرید و فروش طلا فراهم کرده تا کاربران بتوانند سرمایههای خود را بهسادگی مدیریت کنند.\n\nهدف ما ارائه تجربهای سریع، شفاف و کاربرپسند در معاملات طلا است.`
|
return `${name} بستری امن و آنلاین برای خرید و فروش مس فراهم کرده تا کاربران بتوانند سرمایههای خود را بهسادگی مدیریت کنند.\n\nهدف ما ارائه تجربهای سریع، شفاف و کاربرپسند در معاملات مس است.`
|
||||||
}
|
}
|
||||||
|
|
||||||
function looksLikeHtml(value: string) {
|
function looksLikeHtml(value: string) {
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
<h2 :class="variant === 'desktop' ? 'daboutus-content__title' : 'text-base font-bold mb-3'">درباره ما</h2>
|
<h2 :class="variant === 'desktop' ? 'daboutus-content__title' : 'text-base font-bold mb-3'">درباره ما</h2>
|
||||||
|
|
||||||
<div :class="variant === 'desktop' ? 'daboutus-content__paragraph' : 'mt-3'">
|
<div :class="variant === 'desktop' ? 'daboutus-content__paragraph' : 'mt-3'">
|
||||||
گروسی گالری بستری امن و آنلاین برای خرید و فروش طلای آبشده فراهم کرده تا کاربران بتوانند سرمایههای خرد خود را به راحتی پسانداز و مدیریت کنند.
|
بورس مس بستری امن و آنلاین برای خرید و فروش مس فراهم کرده تا کاربران بتوانند معاملات کاتد، مفتول و سیم کابل را ساده، سریع و قابل اعتماد انجام دهند.
|
||||||
</div>
|
</div>
|
||||||
<div :class="variant === 'desktop' ? 'daboutus-content__paragraph' : 'mt-3'">
|
<div :class="variant === 'desktop' ? 'daboutus-content__paragraph' : 'mt-3'">
|
||||||
هدف ما ایجاد تجربهای سریع، شفاف و کاربرپسند در معاملات طلای آبشده است.
|
هدف ما ایجاد تجربهای شفاف و کاربرپسند در معاملات مس، با پشتوانه تولیدکنندگان واقعی است.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="dapp-notif">
|
<div class="dapp-notif">
|
||||||
|
<div class="dapp-notif__container">
|
||||||
|
<DesktopPageTopbar
|
||||||
|
eyebrow="اعلانها"
|
||||||
|
title="پیامهای مدیریت"
|
||||||
|
subtitle="اعلانهای ارسالشده از طرف مدیریت را اینجا ببینید"
|
||||||
|
/>
|
||||||
|
|
||||||
<BrowserNotificationPermissionBanner class="mb-4 max-w-3xl w-full" />
|
<BrowserNotificationPermissionBanner class="mb-4 max-w-3xl w-full" />
|
||||||
|
|
||||||
<div v-if="loading && !items.length" class="app-page-content-loading">
|
<div v-if="loading && !items.length" class="app-page-content-loading">
|
||||||
@@ -26,10 +33,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
|
||||||
import AppNotificationCard from '../components/AppNotificationCard.vue'
|
import AppNotificationCard from '../components/AppNotificationCard.vue'
|
||||||
import BrowserNotificationPermissionBanner from '../components/BrowserNotificationPermissionBanner.vue'
|
import BrowserNotificationPermissionBanner from '../components/BrowserNotificationPermissionBanner.vue'
|
||||||
import { useAppNotificationsPageContext } from '../composables/useAppNotificationsPage'
|
import { useAppNotificationsPageContext } from '../composables/useAppNotificationsPage'
|
||||||
@@ -39,7 +48,10 @@ const { loading, items, openItem } = useAppNotificationsPageContext()
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.dapp-notif {
|
.dapp-notif {
|
||||||
@apply p-6 min-h-full;
|
@apply min-h-full;
|
||||||
|
}
|
||||||
|
.dapp-notif__container {
|
||||||
|
@apply mx-auto w-full max-w-5xl p-6;
|
||||||
}
|
}
|
||||||
.dapp-notif__empty {
|
.dapp-notif__empty {
|
||||||
@apply flex flex-col items-center gap-2 text-gray-500;
|
@apply flex flex-col items-center gap-2 text-gray-500;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<MobileAppNotificationsView v-else />
|
<MobileAppNotificationsView v-else />
|
||||||
|
|
||||||
<BasicActionSheet
|
<BasicActionSheet
|
||||||
|
v-if="!isDesktop"
|
||||||
v-model:show="detailVisible"
|
v-model:show="detailVisible"
|
||||||
:title="selectedItem?.title || 'جزئیات اعلان'"
|
:title="selectedItem?.title || 'جزئیات اعلان'"
|
||||||
width="32rem"
|
width="32rem"
|
||||||
@@ -27,11 +28,38 @@
|
|||||||
<p class="app-notif-detail__body">{{ selectedItem.body }}</p>
|
<p class="app-notif-detail__body">{{ selectedItem.body }}</p>
|
||||||
</div>
|
</div>
|
||||||
</BasicActionSheet>
|
</BasicActionSheet>
|
||||||
|
|
||||||
|
<BasicModal
|
||||||
|
v-else
|
||||||
|
v-model:visible="detailVisible"
|
||||||
|
:title="selectedItem?.title || 'جزئیات اعلان'"
|
||||||
|
width="520px"
|
||||||
|
custom-footer
|
||||||
|
destroy-on-close
|
||||||
|
@close="closeDetail"
|
||||||
|
>
|
||||||
|
<div v-if="selectedItem" class="app-notif-detail">
|
||||||
|
<div class="app-notif-detail__meta">
|
||||||
|
<span
|
||||||
|
class="app-notif-detail__badge"
|
||||||
|
:class="`app-notif-detail__badge--${selectedItem.severity}`"
|
||||||
|
>
|
||||||
|
{{ severityLabel(selectedItem.severity) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p class="app-notif-detail__body">{{ selectedItem.body }}</p>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<BasicButton class="w-full" @click="closeDetail">بستن</BasicButton>
|
||||||
|
</template>
|
||||||
|
</BasicModal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import BasicModal from '@/components/BasicPacks/BasicModal.vue'
|
||||||
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
import { useAppNotificationsPage } from './composables/useAppNotificationsPage'
|
import { useAppNotificationsPage } from './composables/useAppNotificationsPage'
|
||||||
import { severityLabel } from './composables/notificationDisplay'
|
import { severityLabel } from './composables/notificationDisplay'
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
import { computed, ref, watch, type ComputedRef } from 'vue'
|
||||||
|
import {
|
||||||
|
fetchZaanboxPriceHistory,
|
||||||
|
type LandingHistoryRange,
|
||||||
|
} from '@/api/zaarboxPriceHistory'
|
||||||
|
import { buildSeriesChartPaths } from '@/utils/chartAreaPaths'
|
||||||
|
import { usePrice } from '@/utils/usePrice'
|
||||||
|
const CHART_RANGE_OPTIONS = [
|
||||||
|
{ value: 'DAILY' as const, shortLabel: '۲۴ ساعت', label: 'ارزش دارایی — ۲۴ ساعت گذشته' },
|
||||||
|
{ value: 'WEEKLY' as const, shortLabel: 'هفته', label: 'ارزش دارایی — هفته گذشته' },
|
||||||
|
{ value: 'MONTHLY' as const, shortLabel: 'ماه', label: 'ارزش دارایی — ماه گذشته' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export function useAssetsPortfolioChart(
|
||||||
|
cashRial: ComputedRef<number>,
|
||||||
|
metalRial: ComputedRef<number>,
|
||||||
|
) {
|
||||||
|
const chartRange = ref<LandingHistoryRange>('MONTHLY')
|
||||||
|
const chartDrawn = ref(false)
|
||||||
|
const chartLoading = ref(false)
|
||||||
|
const priceHistory = ref<Array<{ timeMs: number; price: number }>>([])
|
||||||
|
|
||||||
|
async function loadChartHistory(range: LandingHistoryRange) {
|
||||||
|
chartLoading.value = true
|
||||||
|
try {
|
||||||
|
priceHistory.value = await fetchZaanboxPriceHistory(range)
|
||||||
|
} catch {
|
||||||
|
priceHistory.value = []
|
||||||
|
} finally {
|
||||||
|
chartLoading.value = false
|
||||||
|
chartDrawn.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setChartRange(range: LandingHistoryRange) {
|
||||||
|
chartHover.value = null
|
||||||
|
chartRange.value = range
|
||||||
|
void loadChartHistory(range)
|
||||||
|
}
|
||||||
|
|
||||||
|
const portfolioSeries = computed(() => {
|
||||||
|
const cash = Math.max(0, cashRial.value)
|
||||||
|
const metal = Math.max(0, metalRial.value)
|
||||||
|
const prices = priceHistory.value
|
||||||
|
|
||||||
|
if (prices.length < 2) {
|
||||||
|
const total = cash + metal
|
||||||
|
if (total <= 0) return []
|
||||||
|
return prices.map((point) => ({ timeMs: point.timeMs, value: total }))
|
||||||
|
}
|
||||||
|
|
||||||
|
const refPrice = prices[prices.length - 1]?.price
|
||||||
|
if (!refPrice || metal <= 0) {
|
||||||
|
const total = cash + metal
|
||||||
|
return prices.map((point) => ({ timeMs: point.timeMs, value: total }))
|
||||||
|
}
|
||||||
|
|
||||||
|
return prices.map((point) => ({
|
||||||
|
timeMs: point.timeMs,
|
||||||
|
value: Math.round(cash + metal * (point.price / refPrice)),
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const portfolioChart = computed(() => buildSeriesChartPaths(portfolioSeries.value))
|
||||||
|
|
||||||
|
const chartHover = ref<{
|
||||||
|
xPercent: number
|
||||||
|
yPercent: number
|
||||||
|
valueLabel: string
|
||||||
|
timeLabel: string
|
||||||
|
} | null>(null)
|
||||||
|
|
||||||
|
function formatChartTimeLabel(timeMs: number) {
|
||||||
|
try {
|
||||||
|
return new Intl.DateTimeFormat('fa-IR', {
|
||||||
|
timeZone: 'Asia/Tehran',
|
||||||
|
month: 'short',
|
||||||
|
day: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
}).format(new Date(timeMs))
|
||||||
|
} catch {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onChartPointerMove(event: PointerEvent) {
|
||||||
|
const chart = portfolioChart.value
|
||||||
|
if (!chart.hasData || chart.samples.length < 2) {
|
||||||
|
chartHover.value = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const target = event.currentTarget as HTMLElement | null
|
||||||
|
if (!target) return
|
||||||
|
const rect = target.getBoundingClientRect()
|
||||||
|
if (rect.width <= 0 || rect.height <= 0) return
|
||||||
|
const ratio = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width))
|
||||||
|
const index = Math.round(ratio * (chart.samples.length - 1))
|
||||||
|
const sample = chart.samples[index]
|
||||||
|
if (!sample) return
|
||||||
|
chartHover.value = {
|
||||||
|
xPercent: (sample.x / chart.width) * 100,
|
||||||
|
yPercent: (sample.y / chart.height) * 100,
|
||||||
|
valueLabel: usePrice(sample.value),
|
||||||
|
timeLabel: formatChartTimeLabel(sample.timeMs),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onChartPointerLeave() {
|
||||||
|
chartHover.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => cashRial.value + metalRial.value,
|
||||||
|
(total) => {
|
||||||
|
if (total > 0 && priceHistory.value.length === 0) {
|
||||||
|
void loadChartHistory(chartRange.value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ flush: 'post' },
|
||||||
|
)
|
||||||
|
|
||||||
|
async function initAssetsPortfolioChart() {
|
||||||
|
await loadChartHistory(chartRange.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
chartRange,
|
||||||
|
chartRangeOptions: CHART_RANGE_OPTIONS,
|
||||||
|
chartDrawn,
|
||||||
|
chartLoading,
|
||||||
|
portfolioChart,
|
||||||
|
chartHover,
|
||||||
|
onChartPointerMove,
|
||||||
|
onChartPointerLeave,
|
||||||
|
setChartRange,
|
||||||
|
initAssetsPortfolioChart,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,706 @@
|
|||||||
|
<template>
|
||||||
|
<div class="assets-page" :class="{ 'assets-page--desktop': isDesktop }">
|
||||||
|
<MobilePageHeader v-if="!isDesktop" title="داراییها" show-back />
|
||||||
|
|
||||||
|
<div class="assets-page__shell">
|
||||||
|
<DesktopPageTopbar
|
||||||
|
v-if="isDesktop"
|
||||||
|
eyebrow="دارایی"
|
||||||
|
title="داراییها"
|
||||||
|
subtitle="خلاصه و جزئیات دارایی"
|
||||||
|
show-back
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="assets-page__body" :class="{ 'mpage-content': !isDesktop }">
|
||||||
|
<section class="assets-top">
|
||||||
|
<div class="assets-chart-block">
|
||||||
|
<article class="assets-card assets-chart">
|
||||||
|
<div
|
||||||
|
class="assets-chart__plot"
|
||||||
|
:class="{ 'is-drawn': chartDrawn }"
|
||||||
|
@pointermove="onChartPointerMove"
|
||||||
|
@pointerleave="onChartPointerLeave"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
v-if="portfolioChart.hasData"
|
||||||
|
class="assets-chart__svg"
|
||||||
|
viewBox="0 0 560 160"
|
||||||
|
preserveAspectRatio="none"
|
||||||
|
>
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="assetsLiveFill" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0%" stop-color="#c98a5f" stop-opacity="0.3" />
|
||||||
|
<stop offset="100%" stop-color="#c98a5f" stop-opacity="0" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<path class="assets-chart__area" :d="portfolioChart.areaPath" fill="url(#assetsLiveFill)" />
|
||||||
|
<path
|
||||||
|
class="assets-chart__line"
|
||||||
|
:d="portfolioChart.linePath"
|
||||||
|
pathLength="1"
|
||||||
|
fill="none"
|
||||||
|
stroke="#c98a5f"
|
||||||
|
stroke-width="3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
<g v-if="portfolioChart.endDot" class="assets-chart__endpoint">
|
||||||
|
<circle :cx="portfolioChart.endDot.x" :cy="portfolioChart.endDot.y" r="5" fill="#c98a5f" />
|
||||||
|
<circle
|
||||||
|
:cx="portfolioChart.endDot.x"
|
||||||
|
:cy="portfolioChart.endDot.y"
|
||||||
|
r="10"
|
||||||
|
fill="#c98a5f"
|
||||||
|
fill-opacity="0.2"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
<p v-else class="assets-chart__empty">نمودار ارزش دارایی در دسترس نیست</p>
|
||||||
|
<template v-if="chartHover">
|
||||||
|
<div
|
||||||
|
class="assets-chart__crosshair"
|
||||||
|
:style="{ left: `${chartHover.xPercent}%` }"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="assets-chart__dot"
|
||||||
|
:style="{
|
||||||
|
left: `${chartHover.xPercent}%`,
|
||||||
|
top: `${chartHover.yPercent}%`,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="assets-chart__tip"
|
||||||
|
:class="{
|
||||||
|
'is-near-end': chartHover.xPercent > 68,
|
||||||
|
'is-near-start': chartHover.xPercent < 22,
|
||||||
|
}"
|
||||||
|
:style="{ left: `${chartHover.xPercent}%` }"
|
||||||
|
>
|
||||||
|
<strong>{{ chartHover.valueLabel }}</strong>
|
||||||
|
<span v-if="chartHover.timeLabel">{{ chartHover.timeLabel }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class="assets-chart__ranges">
|
||||||
|
<button
|
||||||
|
v-for="option in chartRangeOptions"
|
||||||
|
:key="option.value"
|
||||||
|
type="button"
|
||||||
|
:class="{ 'is-active': chartRange === option.value }"
|
||||||
|
@click="setChartRange(option.value)"
|
||||||
|
>
|
||||||
|
{{ option.shortLabel }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<nav class="assets-actions" aria-label="عملیات دارایی">
|
||||||
|
<button
|
||||||
|
v-for="action in assetActionItems"
|
||||||
|
:key="action.id"
|
||||||
|
type="button"
|
||||||
|
:class="{ 'is-main': action.primary }"
|
||||||
|
@click="go(action.routeName, action.query)"
|
||||||
|
>
|
||||||
|
<span v-if="action.iconSrc" class="assets-actions__icon">
|
||||||
|
<img :src="action.iconSrc" alt="" />
|
||||||
|
</span>
|
||||||
|
<span class="assets-actions__label">{{ action.label }}</span>
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<article class="assets-card assets-balance">
|
||||||
|
<span class="assets-balance__label">ارزش کل دارایی</span>
|
||||||
|
<strong class="assets-balance__value">{{ usePrice(totalRialValue) }}</strong>
|
||||||
|
<span class="assets-balance__profit" :class="profitClass">{{ profitSheetLabel }}</span>
|
||||||
|
<span class="assets-balance__hint">سود / زیان تحققنیافته</span>
|
||||||
|
|
||||||
|
<div class="assets-facts">
|
||||||
|
<div v-for="item in summaryItems" :key="item.label" class="assets-facts__row">
|
||||||
|
<span>{{ item.label }}</span>
|
||||||
|
<strong>{{ item.value }}</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<button type="button" class="assets-banner-slot" @click="go('buyProduct')">
|
||||||
|
<img
|
||||||
|
:src="assetsCopperBanner"
|
||||||
|
alt="مس، قدم بعدی سبد دارایی شما — خرید و فروش شمش مس، ساده و آنلاین"
|
||||||
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<section class="assets-card assets-table-wrap">
|
||||||
|
<div class="assets-table-wrap__head">
|
||||||
|
<h2>داراییها</h2>
|
||||||
|
<p>موجودی هر دارایی و ارزش ریالی آن</p>
|
||||||
|
</div>
|
||||||
|
<div class="assets-table">
|
||||||
|
<div class="assets-table__row assets-table__row--head">
|
||||||
|
<span>دارایی</span>
|
||||||
|
<span>موجودی</span>
|
||||||
|
<span>ارزش ریالی</span>
|
||||||
|
<span>تغییرات</span>
|
||||||
|
</div>
|
||||||
|
<div v-for="row in assetRows" :key="row.key" class="assets-table__row">
|
||||||
|
<span class="assets-table__name">{{ row.name }}</span>
|
||||||
|
<span>{{ row.balance }}</span>
|
||||||
|
<span>{{ row.rial }}</span>
|
||||||
|
<span :class="row.changeClass">{{ row.change }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="!assetRows.length" class="assets-table__empty">داراییای برای نمایش نیست.</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onMounted } from 'vue'
|
||||||
|
import router from '@/router'
|
||||||
|
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||||
|
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
|
||||||
|
import { useDesktopBreakpoint } from '@/layouts/composables/useResponsiveLayout'
|
||||||
|
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||||
|
import { usePrice } from '@/utils/usePrice'
|
||||||
|
import { getTradeBuyPrice, lastPrice } from '@/utils/price'
|
||||||
|
import {
|
||||||
|
assetSheetInventoryCards,
|
||||||
|
formatInventoryCardValue,
|
||||||
|
formatPortfolioProfitPercent,
|
||||||
|
formatPortfolioProfitText,
|
||||||
|
resolveAssetsRialValue,
|
||||||
|
resolveBoursecuCopperUnit,
|
||||||
|
resolveMetalAssetsDisplayLabel,
|
||||||
|
} from '@/utils/productAssets'
|
||||||
|
import { formatWeightAmount } from '@/utils/usePrice'
|
||||||
|
import type { WalletMetalTotal } from '@/models/walletAssets'
|
||||||
|
import { useAssetsPortfolioChart } from './composables/useAssetsPortfolioChart'
|
||||||
|
import assetsCopperBanner from '@/assets/img/assets-copper-banner.webp'
|
||||||
|
import { getBoursecuActionIconSrc } from '@/utils/config'
|
||||||
|
|
||||||
|
type AssetActionItem = {
|
||||||
|
id: string
|
||||||
|
label: string
|
||||||
|
routeName: string
|
||||||
|
query?: Record<string, string>
|
||||||
|
primary?: boolean
|
||||||
|
iconSrc?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const assetActionItems: AssetActionItem[] = [
|
||||||
|
{
|
||||||
|
id: 'deposit',
|
||||||
|
label: 'واریز',
|
||||||
|
routeName: 'wallet',
|
||||||
|
query: { state: 'deposit' },
|
||||||
|
primary: true,
|
||||||
|
iconSrc: getBoursecuActionIconSrc('wallet'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'withdraw',
|
||||||
|
label: 'برداشت',
|
||||||
|
routeName: 'wallet',
|
||||||
|
query: { state: 'withdraw' },
|
||||||
|
iconSrc: getBoursecuActionIconSrc('wallet'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'trade',
|
||||||
|
label: 'معامله',
|
||||||
|
routeName: 'buyProduct',
|
||||||
|
iconSrc: getBoursecuActionIconSrc('buySell'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'transactions',
|
||||||
|
label: 'تراکنشها',
|
||||||
|
routeName: 'transactions',
|
||||||
|
iconSrc: getBoursecuActionIconSrc('transactions'),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const isDesktop = useDesktopBreakpoint()
|
||||||
|
const { assetsSummary, loadWalletAssets } = useWalletAssets()
|
||||||
|
|
||||||
|
const inventoryCards = computed(() => assetsSummary.value?.inventory_cards ?? [])
|
||||||
|
const metalTotals = computed(() => assetsSummary.value?.metal_totals ?? [])
|
||||||
|
const cashWallet = computed(() => assetsSummary.value?.cash_wallet ?? 0)
|
||||||
|
const metalRialValue = computed(() => {
|
||||||
|
const fromSummary = Number(assetsSummary.value?.assets_rial_value ?? 0)
|
||||||
|
if (fromSummary > 0) return fromSummary
|
||||||
|
return resolveAssetsRialValue(assetsSummary.value, getTradeBuyPrice(lastPrice.value))
|
||||||
|
})
|
||||||
|
const totalRialValue = computed(() => {
|
||||||
|
const fromSummary = Number(assetsSummary.value?.total_rial_value ?? 0)
|
||||||
|
if (fromSummary > 0) return fromSummary
|
||||||
|
return cashWallet.value + metalRialValue.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const {
|
||||||
|
chartRange,
|
||||||
|
chartRangeOptions,
|
||||||
|
chartDrawn,
|
||||||
|
portfolioChart,
|
||||||
|
chartHover,
|
||||||
|
onChartPointerMove,
|
||||||
|
onChartPointerLeave,
|
||||||
|
setChartRange,
|
||||||
|
initAssetsPortfolioChart,
|
||||||
|
} = useAssetsPortfolioChart(cashWallet, metalRialValue)
|
||||||
|
const portfolioInsight = computed(() => assetsSummary.value?.portfolio)
|
||||||
|
|
||||||
|
const profitSheetLabel = computed(() => {
|
||||||
|
const profit = portfolioInsight.value?.unrealized_profit_rial
|
||||||
|
if (profit == null) return '—'
|
||||||
|
const pct = formatPortfolioProfitPercent(portfolioInsight.value?.unrealized_profit_percent)
|
||||||
|
return `${formatPortfolioProfitText(profit)}${pct ? ` (${pct})` : ''}`
|
||||||
|
})
|
||||||
|
|
||||||
|
const profitClass = computed(() => {
|
||||||
|
const profit = portfolioInsight.value?.unrealized_profit_rial
|
||||||
|
if (profit == null || profit === 0) return ''
|
||||||
|
return profit > 0 ? 'is-profit' : 'is-loss'
|
||||||
|
})
|
||||||
|
|
||||||
|
const summaryItems = computed(() => {
|
||||||
|
const items = metalTotals.value.map((metal) => {
|
||||||
|
const unit = metal.metal_id === 3 ? resolveBoursecuCopperUnit(metal.unit) : (metal.unit || 'کیلوگرم')
|
||||||
|
return {
|
||||||
|
label: assetsMetalLabel(metal),
|
||||||
|
value: `${formatWeightAmount(Number(metal.total_weight ?? 0))} ${unit}`,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
items.push(
|
||||||
|
{ label: 'کیف پول ریالی', value: usePrice(cashWallet.value) },
|
||||||
|
{ label: 'ارزش ریالی مس', value: usePrice(metalRialValue.value) },
|
||||||
|
)
|
||||||
|
if (portfolioInsight.value?.average_buy_price != null) {
|
||||||
|
items.push({
|
||||||
|
label: 'میانگین خرید',
|
||||||
|
value: usePrice(portfolioInsight.value.average_buy_price ?? 0),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return items
|
||||||
|
})
|
||||||
|
|
||||||
|
const assetRows = computed(() => {
|
||||||
|
const pct = formatPortfolioProfitPercent(portfolioInsight.value?.unrealized_profit_percent)
|
||||||
|
const profit = portfolioInsight.value?.unrealized_profit_rial
|
||||||
|
const changeClass = profit == null || profit === 0 ? '' : profit > 0 ? 'is-profit' : 'is-loss'
|
||||||
|
const rows = metalTotals.value.flatMap((metal) => {
|
||||||
|
const unit = metal.metal_id === 3 ? resolveBoursecuCopperUnit(metal.unit) : (metal.unit || 'کیلوگرم')
|
||||||
|
const head = {
|
||||||
|
key: `metal-${metal.metal_id}`,
|
||||||
|
name: assetsMetalLabel(metal),
|
||||||
|
balance: `${formatWeightAmount(Number(metal.total_weight ?? 0))} ${unit}`,
|
||||||
|
rial: usePrice(metalRialValue.value),
|
||||||
|
change: pct || '—',
|
||||||
|
changeClass,
|
||||||
|
}
|
||||||
|
const cards = assetSheetInventoryCards(inventoryCards.value, metal.metal_id).map((card) => ({
|
||||||
|
key: `card-${card.product_id}`,
|
||||||
|
name: assetsDisplayText(card.title),
|
||||||
|
balance: formatInventoryCardValue(card),
|
||||||
|
rial: '—',
|
||||||
|
change: '—',
|
||||||
|
changeClass: '',
|
||||||
|
}))
|
||||||
|
return [head, ...cards]
|
||||||
|
})
|
||||||
|
rows.push({
|
||||||
|
key: 'cash',
|
||||||
|
name: 'کیف پول ریالی',
|
||||||
|
balance: usePrice(cashWallet.value),
|
||||||
|
rial: usePrice(cashWallet.value),
|
||||||
|
change: '—',
|
||||||
|
changeClass: '',
|
||||||
|
})
|
||||||
|
return rows
|
||||||
|
})
|
||||||
|
|
||||||
|
function assetsDisplayText(text: string | null | undefined): string {
|
||||||
|
return String(text ?? '').replace(/طلا/g, 'مس')
|
||||||
|
}
|
||||||
|
|
||||||
|
function assetsMetalLabel(metal: WalletMetalTotal): string {
|
||||||
|
return assetsDisplayText(resolveMetalAssetsDisplayLabel(metal))
|
||||||
|
}
|
||||||
|
|
||||||
|
function go(name: string, query?: Record<string, string>) {
|
||||||
|
router.push(query ? { name, query } : { name })
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadWalletAssets(true)
|
||||||
|
await initAssetsPortfolioChart()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.assets-page {
|
||||||
|
--assets-line: @App-primary-color;
|
||||||
|
--assets-line-soft: color-mix(in srgb, @App-primary-color 65%, #c9a062);
|
||||||
|
min-height: 100%;
|
||||||
|
padding-bottom: 1.5rem;
|
||||||
|
color: inherit;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-page--desktop {
|
||||||
|
background: #f6f7f9;
|
||||||
|
color: #111827;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-page--desktop .assets-page__shell {
|
||||||
|
max-width: 1180px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 28px 36px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-page__body {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
|
max-width: 1100px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-page:not(.assets-page--desktop) .assets-page__body {
|
||||||
|
padding-top: var(--mpage-header-offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-page--desktop .assets-page__body {
|
||||||
|
max-width: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-top {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart-block {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.55rem;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.assets-top {
|
||||||
|
grid-template-columns: 1.15fr 0.85fr;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-banner-slot {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 22px;
|
||||||
|
overflow: hidden;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-banner-slot img {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-card {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid color-mix(in srgb, @App-primary-color 14%, #fff);
|
||||||
|
border-radius: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.35rem;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 0.85rem 0.75rem 0.75rem;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__plot {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 168px;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__svg {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__line {
|
||||||
|
stroke-dasharray: 1;
|
||||||
|
stroke-dashoffset: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__area,
|
||||||
|
.assets-chart__endpoint {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__plot.is-drawn .assets-chart__line {
|
||||||
|
animation: assets-chart-draw 1.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__plot.is-drawn .assets-chart__area {
|
||||||
|
animation: assets-chart-fade 0.55s ease-out 0.85s forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__plot.is-drawn .assets-chart__endpoint {
|
||||||
|
animation: assets-chart-fade 0.35s ease-out 1.35s forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes assets-chart-draw {
|
||||||
|
to {
|
||||||
|
stroke-dashoffset: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes assets-chart-fade {
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.assets-chart__empty {
|
||||||
|
margin: 3rem 0;
|
||||||
|
text-align: center;
|
||||||
|
opacity: 0.55;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__crosshair {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 1px;
|
||||||
|
background: rgba(201, 138, 95, 0.45);
|
||||||
|
pointer-events: none;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__dot {
|
||||||
|
position: absolute;
|
||||||
|
width: 11px;
|
||||||
|
height: 11px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #c98a5f;
|
||||||
|
box-shadow: 0 0 0 5px rgba(201, 138, 95, 0.2);
|
||||||
|
pointer-events: none;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__tip {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
z-index: 4;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(26, 43, 71, 0.94);
|
||||||
|
color: #fff;
|
||||||
|
box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
|
||||||
|
pointer-events: none;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
&.is-near-end {
|
||||||
|
transform: translateX(-100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-near-start {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
direction: ltr;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
color: rgba(255, 255, 255, 0.78);
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__ranges {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__ranges button,
|
||||||
|
.assets-actions button {
|
||||||
|
border: 1px solid color-mix(in srgb, @App-primary-color 16%, #fff);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: color-mix(in srgb, @App-primary-color 6%, #fff);
|
||||||
|
color: inherit;
|
||||||
|
padding: 0.45rem 0.85rem;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-chart__ranges button.is-active,
|
||||||
|
.assets-actions button.is-main {
|
||||||
|
background: @App-primary-color;
|
||||||
|
border-color: @App-primary-color;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-balance {
|
||||||
|
padding: 1rem 1rem 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-balance__label,
|
||||||
|
.assets-balance__hint,
|
||||||
|
.assets-facts__row span,
|
||||||
|
.assets-table-wrap__head p {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
opacity: 0.62;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-balance__value {
|
||||||
|
display: block;
|
||||||
|
margin: 0.25rem 0;
|
||||||
|
font-size: 1.7rem;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-balance__profit {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-balance__profit.is-profit,
|
||||||
|
.assets-table__row .is-profit {
|
||||||
|
color: #1f8a4c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-balance__profit.is-loss,
|
||||||
|
.assets-table__row .is-loss {
|
||||||
|
color: #ff6b6b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-facts {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.35rem;
|
||||||
|
margin-top: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-facts__row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding-top: 0.35rem;
|
||||||
|
border-top: 1px solid color-mix(in srgb, @App-primary-color 12%, #fff);
|
||||||
|
font-size: 0.78rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-actions {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
gap: 0.45rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-actions button {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.35rem;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-actions__icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-actions__icon img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
transform: scale(2.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-actions button.is-main .assets-actions__icon {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 999px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-actions__label {
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-table-wrap {
|
||||||
|
padding: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-table-wrap__head h2 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-table-wrap__head p {
|
||||||
|
margin: 0.15rem 0 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-table__row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1.3fr 1fr 1.2fr 0.7fr;
|
||||||
|
gap: 0.35rem;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0.6rem 0;
|
||||||
|
border-top: 1px solid color-mix(in srgb, @App-primary-color 12%, #fff);
|
||||||
|
font-size: 0.78rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-table__row--head {
|
||||||
|
border-top: 0;
|
||||||
|
opacity: 0.55;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-table__name {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.assets-table__empty {
|
||||||
|
padding: 1rem 0;
|
||||||
|
text-align: center;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,609 @@
|
|||||||
|
<template>
|
||||||
|
<div class="copper-convert" data-convert-form dir="rtl">
|
||||||
|
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<section class="copper-convert__panel" aria-label="قیمتهای مبنا">
|
||||||
|
<p v-if="!result && amountAttempted && !loading" class="copper-convert__warn">
|
||||||
|
مقدار معتبر وارد کنید و از فعال بودن قیمت کاتد/مفتول در سامانه مطمئن شوید.
|
||||||
|
</p>
|
||||||
|
<div class="copper-convert__panel-head">
|
||||||
|
<span class="copper-convert__panel-kicker">قیمت لحظهای</span>
|
||||||
|
<span class="copper-convert__panel-title">مبنای محاسبه</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="copper-convert__price-group">
|
||||||
|
<span class="copper-convert__group-label">مواد اولیه (هر کیلوگرم)</span>
|
||||||
|
<ul class="copper-convert__price-grid m-0 p-0 list-none">
|
||||||
|
<li
|
||||||
|
v-for="row in metalPriceRows"
|
||||||
|
:key="row.label"
|
||||||
|
class="copper-convert__chip"
|
||||||
|
:class="{ 'copper-convert__chip--muted': row.missing }"
|
||||||
|
>
|
||||||
|
<span class="copper-convert__chip-label">{{ row.label }}</span>
|
||||||
|
<span class="copper-convert__measure">
|
||||||
|
<bdi v-if="row.unit">{{ row.unit }}</bdi>
|
||||||
|
<bdi>{{ row.value }}</bdi>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="copper-convert__price-group copper-convert__price-group--wire">
|
||||||
|
<span class="copper-convert__group-label">سیم (هر حلقه)</span>
|
||||||
|
<ul class="copper-convert__price-grid copper-convert__price-grid--wire m-0 p-0 list-none">
|
||||||
|
<li
|
||||||
|
v-for="row in wirePriceRows"
|
||||||
|
:key="row.label"
|
||||||
|
class="copper-convert__chip copper-convert__chip--accent"
|
||||||
|
>
|
||||||
|
<span class="copper-convert__chip-label">{{ row.label }}</span>
|
||||||
|
<span class="copper-convert__measure">
|
||||||
|
<bdi v-if="row.unit">{{ row.unit }}</bdi>
|
||||||
|
<bdi>{{ row.value }}</bdi>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="copper-convert__form">
|
||||||
|
<label class="copper-convert__field-label">نوع دارایی</label>
|
||||||
|
<div class="copper-convert__pills" role="tablist">
|
||||||
|
<button
|
||||||
|
v-for="opt in sourceOptions"
|
||||||
|
:key="opt.value"
|
||||||
|
type="button"
|
||||||
|
role="tab"
|
||||||
|
class="copper-convert__pill"
|
||||||
|
:class="{ 'copper-convert__pill--active': source === opt.value }"
|
||||||
|
:aria-selected="source === opt.value"
|
||||||
|
@click="source = opt.value"
|
||||||
|
>
|
||||||
|
{{ opt.label }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="copper-convert__weight">
|
||||||
|
<label class="copper-convert__field-label">مقدار</label>
|
||||||
|
<div class="copper-convert__weight-wrap" dir="ltr">
|
||||||
|
<span class="copper-convert__weight-value">{{ formatAssetAmount(sliderAmount) }}</span>
|
||||||
|
<span class="copper-convert__weight-unit">{{ assetUnit }}</span>
|
||||||
|
</div>
|
||||||
|
<p class="copper-convert__asset-hint">
|
||||||
|
<template v-if="assetAmount > 0">از دارایی شما؛ انتهای زبانه <span class="copper-convert__measure"><bdi>{{ assetUnit }}</bdi><bdi>{{ formatAssetAmount(assetAmount) }}</bdi></span> است</template>
|
||||||
|
<template v-else>موجودی این دارایی صفر است.</template>
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
class="app-touch-slider copper-convert__slider"
|
||||||
|
@mousedown.capture="dragHandleOnly"
|
||||||
|
@touchstart.capture="dragHandleOnly"
|
||||||
|
>
|
||||||
|
<a-slider
|
||||||
|
v-model:value="sliderAmount"
|
||||||
|
:min="0"
|
||||||
|
:max="assetAmount > 0 ? assetAmount : 1"
|
||||||
|
:step="sliderStep"
|
||||||
|
:disabled="assetAmount <= 0"
|
||||||
|
:tip-formatter="sliderTip"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="copper-convert__slider-scale">
|
||||||
|
<span>۰</span>
|
||||||
|
<span class="copper-convert__measure"><bdi>{{ assetUnit }}</bdi><bdi>{{ formatAssetAmount(assetAmount) }}</bdi></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="copper-convert__asset-hint">
|
||||||
|
با این مقدار میتوانید <bdi>{{ wire15Rings }}</bdi> حلقه سیم ۱.۵ و <bdi>{{ wire25Rings }}</bdi> حلقه سیم ۲.۵ ببرید. این دو زبانه مکملاند و با هم روی همین مقدار تنظیم میشوند.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="copper-convert__weight">
|
||||||
|
<label class="copper-convert__field-label">سیم <span dir="ltr">۱.۵ mm²</span></label>
|
||||||
|
<div class="copper-convert__weight-wrap" dir="ltr">
|
||||||
|
<span class="copper-convert__weight-value">{{ wire15Rings }}</span>
|
||||||
|
<span class="copper-convert__weight-unit">عدد حلقه</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="app-touch-slider copper-convert__slider"
|
||||||
|
@mousedown.capture="dragHandleOnly"
|
||||||
|
@touchstart.capture="dragHandleOnly"
|
||||||
|
>
|
||||||
|
<a-slider
|
||||||
|
v-model:value="wire15Rings"
|
||||||
|
:min="0"
|
||||||
|
:max="maxRings15 > 0 ? maxRings15 : 1"
|
||||||
|
:step="1"
|
||||||
|
:disabled="maxRings15 <= 0"
|
||||||
|
:tip-formatter="ringTip"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="copper-convert__slider-scale">
|
||||||
|
<span>۰</span>
|
||||||
|
<span class="copper-convert__measure"><bdi>عدد حلقه</bdi><bdi>{{ maxRings15 }}</bdi></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="copper-convert__weight">
|
||||||
|
<label class="copper-convert__field-label">سیم <span dir="ltr">۲.۵ mm²</span></label>
|
||||||
|
<div class="copper-convert__weight-wrap" dir="ltr">
|
||||||
|
<span class="copper-convert__weight-value">{{ wire25Rings }}</span>
|
||||||
|
<span class="copper-convert__weight-unit">عدد حلقه</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="app-touch-slider copper-convert__slider"
|
||||||
|
@mousedown.capture="dragHandleOnly"
|
||||||
|
@touchstart.capture="dragHandleOnly"
|
||||||
|
>
|
||||||
|
<a-slider
|
||||||
|
v-model:value="wire25Rings"
|
||||||
|
:min="0"
|
||||||
|
:max="maxRings25 > 0 ? maxRings25 : 1"
|
||||||
|
:step="1"
|
||||||
|
:disabled="maxRings25 <= 0"
|
||||||
|
:tip-formatter="ringTip"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="copper-convert__slider-scale">
|
||||||
|
<span>۰</span>
|
||||||
|
<span class="copper-convert__measure"><bdi>عدد حلقه</bdi><bdi>{{ maxRings25 }}</bdi></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section v-if="result" class="copper-convert__result">
|
||||||
|
<div class="copper-convert__result-head">
|
||||||
|
<span class="copper-convert__result-kicker">خروجی</span>
|
||||||
|
<span class="copper-convert__result-title">نتیجه تبدیل</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="copper-convert__rings">
|
||||||
|
<article class="copper-convert__ring-card">
|
||||||
|
<span class="copper-convert__ring-badge" dir="ltr">۱.۵ mm²</span>
|
||||||
|
<p class="copper-convert__ring-count" dir="ltr">{{ wire15Rings }}</p>
|
||||||
|
<p class="copper-convert__ring-caption">حلقه میتوانید ببرید</p>
|
||||||
|
</article>
|
||||||
|
<article class="copper-convert__ring-card">
|
||||||
|
<span class="copper-convert__ring-badge" dir="ltr">۲.۵ mm²</span>
|
||||||
|
<p class="copper-convert__ring-count" dir="ltr">{{ wire25Rings }}</p>
|
||||||
|
<p class="copper-convert__ring-caption">حلقه میتوانید ببرید</p>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="copper-convert__summary">
|
||||||
|
<div class="copper-convert__summary-row">
|
||||||
|
<span>ارزش معادل</span>
|
||||||
|
<strong class="copper-convert__measure"><small>ریال</small><bdi>{{ formatRial(result.totalValueRial) }}</bdi></strong>
|
||||||
|
</div>
|
||||||
|
<div class="copper-convert__summary-row">
|
||||||
|
<span>معادل مفتول</span>
|
||||||
|
<strong class="copper-convert__measure"><small>کیلو</small><bdi>{{ formatKg(result.equivalentMaftoulKg) }}</bdi></strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="copper-convert__split">
|
||||||
|
<p class="copper-convert__asset-hint">
|
||||||
|
از مقدار انتخابشده، <span class="copper-convert__measure"><bdi>{{ assetUnit }}</bdi><bdi>{{ formatAssetAmount(leftoverAmount) }}</bdi></span> به حلقهٔ کامل نمیرسد و در دارایی میماند. باقی دارایی که روی زبانه انتخاب نشده هم دستنخورده میماند.
|
||||||
|
</p>
|
||||||
|
<p v-if="editingId" class="copper-convert__asset-hint">
|
||||||
|
در حال ویرایش درخواست در انتظار تایید. ذخیره، همان درخواست را بهروز میکند.
|
||||||
|
</p>
|
||||||
|
<div :class="editingId ? 'grid grid-cols-2 gap-2' : ''">
|
||||||
|
<BasicButton
|
||||||
|
type="primary"
|
||||||
|
class="!w-full"
|
||||||
|
html-type="button"
|
||||||
|
:loading="submitting"
|
||||||
|
:disabledB="wire15Rings + wire25Rings < 1"
|
||||||
|
@click="submitRequest"
|
||||||
|
>
|
||||||
|
{{ editingId ? 'ذخیره ویرایش' : 'ثبت درخواست تبدیل' }}
|
||||||
|
</BasicButton>
|
||||||
|
<BasicButton v-if="editingId" class="!w-full" html-type="button" :disabledB="submitting" @click="cancelEdit">
|
||||||
|
انصراف
|
||||||
|
</BasicButton>
|
||||||
|
</div>
|
||||||
|
<p class="copper-convert__asset-hint">
|
||||||
|
درخواست برای ادمین میرود. بعد از تأیید، همان مقدار دارایی فروخته و حلقههای انتخابشده خریده میشود.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import { useCopperConvertPageContext } from '../composables/useCopperConvertPage'
|
||||||
|
import type { CopperConvertSource } from '@/utils/copperWireConvert'
|
||||||
|
|
||||||
|
const {
|
||||||
|
loading,
|
||||||
|
source,
|
||||||
|
assetAmount,
|
||||||
|
assetUnit,
|
||||||
|
sliderAmount,
|
||||||
|
sliderStep,
|
||||||
|
maxRings15,
|
||||||
|
maxRings25,
|
||||||
|
wire15Rings,
|
||||||
|
wire25Rings,
|
||||||
|
leftoverAmount,
|
||||||
|
submitting,
|
||||||
|
submitRequest,
|
||||||
|
editingId,
|
||||||
|
cancelEdit,
|
||||||
|
result,
|
||||||
|
priceRows,
|
||||||
|
} = useCopperConvertPageContext()
|
||||||
|
|
||||||
|
const amountAttempted = computed(() => sliderAmount.value > 0)
|
||||||
|
|
||||||
|
function dragHandleOnly(event: Event) {
|
||||||
|
const target = event.target
|
||||||
|
if (target instanceof Element && target.closest('.ant-slider-handle')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
event.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
const sourceOptions = computed(() => [
|
||||||
|
{ label: 'کاتد', value: 'katod' as CopperConvertSource },
|
||||||
|
{ label: 'مفتول', value: 'maftoul' as CopperConvertSource },
|
||||||
|
{ label: 'شمش', value: 'shamsh' as CopperConvertSource },
|
||||||
|
])
|
||||||
|
|
||||||
|
const metalPriceRows = computed(() => priceRows.value.slice(0, 3))
|
||||||
|
const wirePriceRows = computed(() => priceRows.value.slice(3))
|
||||||
|
|
||||||
|
function formatAssetAmount(value: number) {
|
||||||
|
if (!Number.isFinite(value)) return '0'
|
||||||
|
const rounded = Math.round(value * 1000) / 1000
|
||||||
|
if (Number.isInteger(rounded)) return rounded.toLocaleString('en-US')
|
||||||
|
return rounded.toLocaleString('en-US', { maximumFractionDigits: 3 })
|
||||||
|
}
|
||||||
|
|
||||||
|
function sliderTip(value?: number) {
|
||||||
|
return `${assetUnit.value} ${formatAssetAmount(Number(value ?? 0))}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function ringTip(value?: number) {
|
||||||
|
return `عدد حلقه ${Math.floor(Number(value ?? 0))}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatRial(value: number) {
|
||||||
|
return Math.round(value).toLocaleString('en-US')
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatKg(value: number) {
|
||||||
|
if (value >= 100) return value.toFixed(1)
|
||||||
|
if (value >= 10) return value.toFixed(2)
|
||||||
|
return value.toFixed(3)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.copper-convert {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
|
text-align: right;
|
||||||
|
color: #334155;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__lead {
|
||||||
|
margin: 0 0 0.125rem;
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
line-height: 1.65;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__panel,
|
||||||
|
.copper-convert__form,
|
||||||
|
.copper-convert__result,
|
||||||
|
.copper-convert__split {
|
||||||
|
padding: 0.875rem;
|
||||||
|
border-radius: 0.875rem;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__panel-head {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.15rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__panel-kicker,
|
||||||
|
.copper-convert__result-kicker {
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--colorPrimary, #2563eb);
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__panel-title,
|
||||||
|
.copper-convert__result-title {
|
||||||
|
font-size: 0.9375rem;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__price-group {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
margin-bottom: 0.65rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__price-group--wire {
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding-top: 0.65rem;
|
||||||
|
border-top: 1px solid #f1f5f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__group-label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 0.45rem;
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__price-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__price-grid--wire {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__chip {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.2rem;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 0.45rem 0.5rem;
|
||||||
|
border-radius: 0.65rem;
|
||||||
|
background: #f8fafc;
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__chip--accent {
|
||||||
|
background: #eff5f3;
|
||||||
|
border-color: #d4e3de;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__chip-label {
|
||||||
|
font-size: 0.625rem;
|
||||||
|
line-height: 1.45;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__chip-value,
|
||||||
|
.copper-convert__price-grid .copper-convert__measure {
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #0f172a;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__measure {
|
||||||
|
display: inline-flex;
|
||||||
|
direction: ltr;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__chip--muted .copper-convert__measure {
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__form,
|
||||||
|
.copper-convert__split {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.65rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__field-label {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #334155;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__pills {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 0.35rem;
|
||||||
|
padding: 0.25rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #eef2f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__pill {
|
||||||
|
appearance: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 0.5rem 0.35rem;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #64748b;
|
||||||
|
background: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__pill--active {
|
||||||
|
color: var(--colorPrimary, #2563eb);
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__weight-wrap {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin-top: 0.35rem;
|
||||||
|
padding: 0.55rem 0.75rem;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid rgba(15, 39, 68, 0.12);
|
||||||
|
box-shadow: inset 0 1px 2px rgba(15, 39, 68, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__weight-value {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 1.125rem;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #0f172a;
|
||||||
|
direction: ltr;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__asset-hint {
|
||||||
|
margin: 0.35rem 0 0;
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__slider {
|
||||||
|
margin-top: 0.15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__slider-scale {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin-top: -0.15rem;
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__weight-unit {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 800;
|
||||||
|
color: var(--colorPrimary, #2563eb);
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__result {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__result-head {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.1rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.copper-convert__rings {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__ring-card {
|
||||||
|
position: relative;
|
||||||
|
padding: 0.75rem 0.5rem;
|
||||||
|
border-radius: 0.85rem;
|
||||||
|
text-align: center;
|
||||||
|
background: #eff5f3;
|
||||||
|
border: 1px solid #d4e3de;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__ring-badge {
|
||||||
|
display: inline-block;
|
||||||
|
margin-bottom: 0.35rem;
|
||||||
|
padding: 0.15rem 0.45rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 0.625rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--colorPrimary, #2563eb);
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__ring-count {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 800;
|
||||||
|
line-height: 1.2;
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__ring-caption {
|
||||||
|
margin: 0.15rem 0 0;
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__ring-sub {
|
||||||
|
margin: 0.35rem 0 0;
|
||||||
|
font-size: 0.625rem;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__summary {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.45rem;
|
||||||
|
padding-top: 0.65rem;
|
||||||
|
border-top: 1px dashed rgba(15, 39, 68, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__summary-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.5rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__summary-row strong {
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__summary-row strong small {
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copper-convert__warn {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.65rem 0.75rem;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #9a3412;
|
||||||
|
background: #fff7ed;
|
||||||
|
border: 1px solid rgba(234, 88, 12, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 380px) {
|
||||||
|
.copper-convert__price-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
<template>
|
||||||
|
<section
|
||||||
|
:class="side
|
||||||
|
? 'flex min-h-0 min-w-0 flex-1 flex-col'
|
||||||
|
: 'mt-3 flex flex-col gap-2 rounded-xl border border-gray-200 bg-white p-2.5'"
|
||||||
|
aria-label="تاریخچه تبدیل"
|
||||||
|
>
|
||||||
|
<div :class="side ? 'dwallet-side__header' : ''">
|
||||||
|
<div>
|
||||||
|
<h2 :class="side ? 'dwallet-side__title' : 'm-0 text-sm font-bold text-slate-900'">تاریخچه تبدیل</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div :class="side ? 'dwallet-side__scroll' : ''">
|
||||||
|
<a-spin :spinning="historyLoading && !history.length">
|
||||||
|
<div v-if="historyLoading && !history.length" class="min-h-16" />
|
||||||
|
<p
|
||||||
|
v-else-if="!history.length"
|
||||||
|
class="m-0 rounded-lg bg-slate-50 px-3 py-4 text-center text-xs text-slate-500"
|
||||||
|
>
|
||||||
|
درخواست تبدیلی ثبت نشده است.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ul v-else class="m-0 flex list-none flex-col gap-2 p-0">
|
||||||
|
<li
|
||||||
|
v-for="item in history"
|
||||||
|
:key="item.id"
|
||||||
|
class="rounded-lg border p-2.5"
|
||||||
|
:class="editingId === item.id ? 'border-amber-400' : 'border-gray-200'"
|
||||||
|
>
|
||||||
|
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||||
|
<span class="text-xs text-slate-500">{{ item.created_at ? toJalali(item.created_at) : '—' }}</span>
|
||||||
|
<span class="inline-flex items-center gap-1 text-xs text-slate-600">
|
||||||
|
<button
|
||||||
|
v-if="item.status === 'pending'"
|
||||||
|
type="button"
|
||||||
|
class="inline-flex h-7 w-7 items-center justify-center rounded-md border border-gray-200 bg-white"
|
||||||
|
aria-label="ویرایش درخواست"
|
||||||
|
title="ویرایش"
|
||||||
|
@click="beginEdit(item)"
|
||||||
|
>
|
||||||
|
<BasicIcon icon="vuesax-linear:edit" size="15" />
|
||||||
|
</button>
|
||||||
|
وضعیت
|
||||||
|
<a-tag class="!m-0" :color="statusColor(item.status)">{{ statusLabel(item.status) }}</a-tag>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-xs text-slate-600">
|
||||||
|
<span>دارایی: <b class="text-slate-900">{{ sourceLabel(item.source) }}</b></span>
|
||||||
|
<span>
|
||||||
|
مقدار:
|
||||||
|
<b class="text-slate-900">
|
||||||
|
<bdi>{{ item.asset_unit }}</bdi>
|
||||||
|
<bdi> {{ formatAmount(item.consumed_amount) }}</bdi>
|
||||||
|
</b>
|
||||||
|
</span>
|
||||||
|
<span>حلقه ۱.۵: <b class="text-slate-900">{{ item.wire15_rings }}</b></span>
|
||||||
|
<span>حلقه ۲.۵: <b class="text-slate-900">{{ item.wire25_rings }}</b></span>
|
||||||
|
<span v-if="Number(item.leftover_amount) > 0" class="col-span-2">
|
||||||
|
مانده در دارایی:
|
||||||
|
<b class="text-slate-900">
|
||||||
|
<bdi>{{ item.asset_unit }}</bdi>
|
||||||
|
<bdi> {{ formatAmount(item.leftover_amount) }}</bdi>
|
||||||
|
</b>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="item.status === 'pending'" class="mt-2 flex">
|
||||||
|
<a-button
|
||||||
|
size="small"
|
||||||
|
danger
|
||||||
|
:loading="deletingId === item.id"
|
||||||
|
@click="deleteRequest(item.id)"
|
||||||
|
>
|
||||||
|
حذف
|
||||||
|
</a-button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import { toJalali } from '@/utils/useDateTime'
|
||||||
|
import { useCopperConvertPageContext } from '../composables/useCopperConvertPage'
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{ variant?: 'stack' | 'side' }>(), {
|
||||||
|
variant: 'stack',
|
||||||
|
})
|
||||||
|
|
||||||
|
const side = computed(() => props.variant === 'side')
|
||||||
|
|
||||||
|
const { history, historyLoading, editingId, beginEdit, deleteRequest, deletingId } =
|
||||||
|
useCopperConvertPageContext()
|
||||||
|
|
||||||
|
function sourceLabel(source: string) {
|
||||||
|
if (source === 'katod') return 'کاتد'
|
||||||
|
if (source === 'maftoul') return 'مفتول'
|
||||||
|
if (source === 'shamsh') return 'شمش'
|
||||||
|
return source
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusLabel(status: string) {
|
||||||
|
if (status === 'pending') return 'در انتظار تایید'
|
||||||
|
if (status === 'approved') return 'تایید شد'
|
||||||
|
if (status === 'rejected') return 'رد شد'
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusColor(status: string) {
|
||||||
|
if (status === 'approved') return 'green'
|
||||||
|
if (status === 'rejected') return 'red'
|
||||||
|
return 'orange'
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatAmount(value: number) {
|
||||||
|
const amount = Number(value)
|
||||||
|
if (!Number.isFinite(amount)) return '—'
|
||||||
|
return amount.toLocaleString('en-US', { maximumFractionDigits: 3 })
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,502 @@
|
|||||||
|
import {
|
||||||
|
computed,
|
||||||
|
inject,
|
||||||
|
nextTick,
|
||||||
|
onMounted,
|
||||||
|
onUnmounted,
|
||||||
|
provide,
|
||||||
|
ref,
|
||||||
|
watch,
|
||||||
|
type ComputedRef,
|
||||||
|
type InjectionKey,
|
||||||
|
type Ref,
|
||||||
|
} from 'vue'
|
||||||
|
import {
|
||||||
|
createCopperConvertRequest,
|
||||||
|
deleteCopperConvertRequest,
|
||||||
|
getCopperConvertRequests,
|
||||||
|
updateCopperConvertRequest,
|
||||||
|
type CopperConvertHistoryRow,
|
||||||
|
} from '@/api/copperConvert'
|
||||||
|
import { getProducts } from '@/api/products'
|
||||||
|
import { message, Modal } from 'ant-design-vue'
|
||||||
|
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||||
|
import type { Product } from '@/models/products'
|
||||||
|
import type { WalletInventoryCard } from '@/models/walletAssets'
|
||||||
|
import {
|
||||||
|
COPPER_CONVERT_WIRE_FALLBACK,
|
||||||
|
calcCopperWireConvert,
|
||||||
|
type CopperConvertPrices,
|
||||||
|
type CopperConvertResult,
|
||||||
|
type CopperConvertSource,
|
||||||
|
} from '@/utils/copperWireConvert'
|
||||||
|
import { LEGACY_GROUP_KATOD, LEGACY_GROUP_MAFTOL, normalizeProductGroupType } from '@/utils/productCategories'
|
||||||
|
import { getProductWeightUnit } from '@/utils/productDealMethod'
|
||||||
|
import { getProductBuyPrice } from '@/utils/productPrice'
|
||||||
|
import { getLastPrices, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
||||||
|
import { weightToGrams } from '@/utils/weightUnit'
|
||||||
|
|
||||||
|
export const COPPER_CONVERT_PAGE_KEY: InjectionKey<CopperConvertPageContext> =
|
||||||
|
Symbol('copperConvertPageContext')
|
||||||
|
|
||||||
|
export interface CopperConvertPageContext {
|
||||||
|
loading: Ref<boolean>
|
||||||
|
source: Ref<CopperConvertSource>
|
||||||
|
assetAmount: ComputedRef<number>
|
||||||
|
assetUnit: ComputedRef<string>
|
||||||
|
sliderAmount: Ref<number>
|
||||||
|
sliderStep: ComputedRef<number>
|
||||||
|
remainderAmount: ComputedRef<number>
|
||||||
|
maxRings15: ComputedRef<number>
|
||||||
|
maxRings25: ComputedRef<number>
|
||||||
|
wire15Rings: Ref<number>
|
||||||
|
wire25Rings: Ref<number>
|
||||||
|
leftoverAmount: ComputedRef<number>
|
||||||
|
submitting: Ref<boolean>
|
||||||
|
submitRequest: () => Promise<void>
|
||||||
|
editingId: Ref<number | null>
|
||||||
|
beginEdit: (row: CopperConvertHistoryRow) => Promise<void>
|
||||||
|
cancelEdit: () => void
|
||||||
|
deleteRequest: (id: number) => void
|
||||||
|
deletingId: Ref<number>
|
||||||
|
history: Ref<CopperConvertHistoryRow[]>
|
||||||
|
historyLoading: Ref<boolean>
|
||||||
|
prices: ComputedRef<CopperConvertPrices>
|
||||||
|
result: ComputedRef<CopperConvertResult | null>
|
||||||
|
priceRows: ComputedRef<{ label: string; value: string; missing?: boolean }[]>
|
||||||
|
}
|
||||||
|
|
||||||
|
function roundAmount(value: number): number {
|
||||||
|
return Math.round(value * 1000) / 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
function cardMatchesSource(card: WalletInventoryCard, src: CopperConvertSource) {
|
||||||
|
const group = normalizeProductGroupType(card.group_type)
|
||||||
|
const title = card.title ?? ''
|
||||||
|
if (src === 'katod') return group === LEGACY_GROUP_KATOD || title.includes('کاتد')
|
||||||
|
if (src === 'maftoul') return group === LEGACY_GROUP_MAFTOL || title.includes('مفتول')
|
||||||
|
return group.includes('شمش') || title.includes('شمش')
|
||||||
|
}
|
||||||
|
|
||||||
|
function cardQuantity(card: WalletInventoryCard): number {
|
||||||
|
const qty = Number(card.quantity ?? 0)
|
||||||
|
return Number.isFinite(qty) && qty > 0 ? qty : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function quantityToKg(quantity: number, unit: string, product?: Product): number {
|
||||||
|
if (quantity <= 0) return 0
|
||||||
|
if (unit.includes('کیلو')) return quantity
|
||||||
|
if (unit.includes('گرم')) return quantity / 1000
|
||||||
|
const perPiece = Number(product?.amount ?? 0)
|
||||||
|
if (perPiece > 0) return weightToGrams(quantity * perPiece, getProductWeightUnit(product)) / 1000
|
||||||
|
return quantity
|
||||||
|
}
|
||||||
|
|
||||||
|
function kgToNative(kg: number, unit: string, product?: Product): number {
|
||||||
|
if (kg <= 0) return 0
|
||||||
|
if (unit.includes('کیلو')) return kg
|
||||||
|
if (unit.includes('گرم')) return kg * 1000
|
||||||
|
const perPiece = Number(product?.amount ?? 0)
|
||||||
|
if (perPiece > 0) {
|
||||||
|
const gramsPerPiece = weightToGrams(perPiece, getProductWeightUnit(product))
|
||||||
|
if (gramsPerPiece > 0) return (kg * 1000) / gramsPerPiece
|
||||||
|
}
|
||||||
|
return kg
|
||||||
|
}
|
||||||
|
|
||||||
|
function titleIncludes(product: Product, part: string) {
|
||||||
|
return (product.title ?? '').includes(part)
|
||||||
|
}
|
||||||
|
|
||||||
|
function isKatodProduct(product: Product) {
|
||||||
|
const group = normalizeProductGroupType(product.group_type)
|
||||||
|
return group === LEGACY_GROUP_KATOD || titleIncludes(product, 'کاتد')
|
||||||
|
}
|
||||||
|
|
||||||
|
function isMaftolProduct(product: Product) {
|
||||||
|
const group = normalizeProductGroupType(product.group_type)
|
||||||
|
return group === LEGACY_GROUP_MAFTOL || titleIncludes(product, 'مفتول')
|
||||||
|
}
|
||||||
|
|
||||||
|
function isShamshProduct(product: Product) {
|
||||||
|
const group = normalizeProductGroupType(product.group_type)
|
||||||
|
return group.includes('شمش') || titleIncludes(product, 'شمش')
|
||||||
|
}
|
||||||
|
|
||||||
|
function wireCrossSection(product: Product): '1.5' | '2.5' | null {
|
||||||
|
const t = product.title ?? ''
|
||||||
|
if (/1\.5|۱\.۵/.test(t)) return '1.5'
|
||||||
|
if (/2\.5|۲\.۵/.test(t)) return '2.5'
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
function isWireProduct(product: Product) {
|
||||||
|
const t = `${product.group_type ?? ''} ${product.title ?? ''}`
|
||||||
|
return t.includes('سیم') || wireCrossSection(product) != null
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickProduct(
|
||||||
|
products: Product[],
|
||||||
|
matcher: (p: Product) => boolean,
|
||||||
|
): Product | undefined {
|
||||||
|
return products.find((p) => p.active && matcher(p))
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveWireRingPrice(product: Product | undefined, fallback: number): number {
|
||||||
|
if (!product) return fallback
|
||||||
|
const price = getProductBuyPrice(product)
|
||||||
|
return price > 0 ? price : fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCopperConvertPage() {
|
||||||
|
const loading = ref(true)
|
||||||
|
const source = ref<CopperConvertSource>('katod')
|
||||||
|
const sliderAmount = ref(0)
|
||||||
|
const wire15Rings = ref(0)
|
||||||
|
const wire25Rings = ref(0)
|
||||||
|
const submitting = ref(false)
|
||||||
|
const catalog = ref<Product[]>([])
|
||||||
|
const history = ref<CopperConvertHistoryRow[]>([])
|
||||||
|
const historyLoading = ref(true)
|
||||||
|
const editingId = ref<number | null>(null)
|
||||||
|
const deletingId = ref(0)
|
||||||
|
const { assetsSummary, loadWalletAssets } = useWalletAssets()
|
||||||
|
|
||||||
|
const assetCards = computed(() => {
|
||||||
|
const summary = assetsSummary.value
|
||||||
|
if (!summary) return [] as WalletInventoryCard[]
|
||||||
|
const src = source.value
|
||||||
|
const fromInventory = (summary.inventory_cards ?? []).filter((card) =>
|
||||||
|
cardMatchesSource(card, src),
|
||||||
|
)
|
||||||
|
return fromInventory.length
|
||||||
|
? fromInventory
|
||||||
|
: (summary.count_products ?? []).filter((card) => cardMatchesSource(card, src))
|
||||||
|
})
|
||||||
|
|
||||||
|
const assetUnit = computed(() => {
|
||||||
|
const units = [...new Set(assetCards.value.map((card) => (card.unit ?? '').trim()).filter(Boolean))]
|
||||||
|
if (units.length === 1) return units[0]
|
||||||
|
return 'کیلوگرم'
|
||||||
|
})
|
||||||
|
|
||||||
|
const assetAmount = computed(() => {
|
||||||
|
const cards = assetCards.value
|
||||||
|
if (!cards.length) return 0
|
||||||
|
const units = [...new Set(cards.map((card) => (card.unit ?? '').trim()).filter(Boolean))]
|
||||||
|
if (units.length > 1) {
|
||||||
|
return roundAmount(
|
||||||
|
cards.reduce((sum, card) => sum + quantityToKg(cardQuantity(card), card.unit ?? '', undefined), 0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return roundAmount(cards.reduce((sum, card) => sum + cardQuantity(card), 0))
|
||||||
|
})
|
||||||
|
|
||||||
|
const sliderStep = computed(() => (assetUnit.value.includes('عدد') ? 1 : 0.001))
|
||||||
|
|
||||||
|
const remainderAmount = computed(() =>
|
||||||
|
roundAmount(Math.max(0, assetAmount.value - sliderAmount.value)),
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(source, () => {
|
||||||
|
sliderAmount.value = assetAmount.value
|
||||||
|
applyDefaultSplit()
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
assetAmount,
|
||||||
|
(amount, prev) => {
|
||||||
|
const previous = prev ?? 0
|
||||||
|
if (sliderAmount.value === previous || sliderAmount.value > amount) sliderAmount.value = amount
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
const katodProduct = computed(() => pickProduct(catalog.value, isKatodProduct))
|
||||||
|
const maftolProduct = computed(() => pickProduct(catalog.value, isMaftolProduct))
|
||||||
|
const shamshProduct = computed(() => pickProduct(catalog.value, isShamshProduct))
|
||||||
|
const wire15Product = computed(() =>
|
||||||
|
pickProduct(catalog.value, (p) => isWireProduct(p) && wireCrossSection(p) === '1.5'),
|
||||||
|
)
|
||||||
|
const wire25Product = computed(() =>
|
||||||
|
pickProduct(catalog.value, (p) => isWireProduct(p) && wireCrossSection(p) === '2.5'),
|
||||||
|
)
|
||||||
|
|
||||||
|
const prices = computed<CopperConvertPrices>(() => ({
|
||||||
|
katodPerKg: katodProduct.value ? getProductBuyPrice(katodProduct.value) : 0,
|
||||||
|
maftoulPerKg: maftolProduct.value ? getProductBuyPrice(maftolProduct.value) : 0,
|
||||||
|
shamshPerKg: shamshProduct.value ? getProductBuyPrice(shamshProduct.value) : 0,
|
||||||
|
wireRing15: resolveWireRingPrice(wire15Product.value, COPPER_CONVERT_WIRE_FALLBACK.wireRing15),
|
||||||
|
wireRing25: resolveWireRingPrice(wire25Product.value, COPPER_CONVERT_WIRE_FALLBACK.wireRing25),
|
||||||
|
wireWeightGrams15: COPPER_CONVERT_WIRE_FALLBACK.wireWeightGrams15,
|
||||||
|
wireWeightGrams25: COPPER_CONVERT_WIRE_FALLBACK.wireWeightGrams25,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const sourceProduct = computed(() => {
|
||||||
|
if (source.value === 'katod') return katodProduct.value
|
||||||
|
if (source.value === 'maftoul') return maftolProduct.value
|
||||||
|
return shamshProduct.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectedKg = computed(() =>
|
||||||
|
quantityToKg(sliderAmount.value, assetUnit.value, sourceProduct.value),
|
||||||
|
)
|
||||||
|
|
||||||
|
const result = computed(() =>
|
||||||
|
calcCopperWireConvert(selectedKg.value, source.value, prices.value),
|
||||||
|
)
|
||||||
|
|
||||||
|
const sourceUnitPrice = computed(() => {
|
||||||
|
if (source.value === 'katod') return prices.value.katodPerKg
|
||||||
|
if (source.value === 'maftoul') return prices.value.maftoulPerKg
|
||||||
|
return prices.value.shamshPerKg
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectedValue = computed(() => result.value?.totalValueRial ?? 0)
|
||||||
|
|
||||||
|
const maxRings15 = computed(() => {
|
||||||
|
const price = prices.value.wireRing15
|
||||||
|
if (price <= 0 || selectedValue.value <= 0) return 0
|
||||||
|
return Math.floor(selectedValue.value / price)
|
||||||
|
})
|
||||||
|
|
||||||
|
const maxRings25 = computed(() => {
|
||||||
|
const price = prices.value.wireRing25
|
||||||
|
if (price <= 0 || selectedValue.value <= 0) return 0
|
||||||
|
return Math.floor(selectedValue.value / price)
|
||||||
|
})
|
||||||
|
|
||||||
|
function rings25For(rings15: number) {
|
||||||
|
const price = prices.value.wireRing25
|
||||||
|
const left = selectedValue.value - rings15 * prices.value.wireRing15
|
||||||
|
if (price <= 0 || left <= 0) return 0
|
||||||
|
return Math.min(maxRings25.value, Math.floor(left / price))
|
||||||
|
}
|
||||||
|
|
||||||
|
function rings15For(rings25: number) {
|
||||||
|
const price = prices.value.wireRing15
|
||||||
|
const left = selectedValue.value - rings25 * prices.value.wireRing25
|
||||||
|
if (price <= 0 || left <= 0) return 0
|
||||||
|
return Math.min(maxRings15.value, Math.floor(left / price))
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultSplit() {
|
||||||
|
const value = selectedValue.value
|
||||||
|
const price15 = prices.value.wireRing15
|
||||||
|
if (value <= 0 || price15 <= 0) return { rings15: 0, rings25: 0 }
|
||||||
|
const rings15 = Math.min(maxRings15.value, Math.floor(value / 2 / price15))
|
||||||
|
return { rings15, rings25: rings25For(rings15) }
|
||||||
|
}
|
||||||
|
|
||||||
|
let splitLock = false
|
||||||
|
|
||||||
|
function writeRings(rings15: number, rings25: number) {
|
||||||
|
splitLock = true
|
||||||
|
wire15Rings.value = rings15
|
||||||
|
wire25Rings.value = rings25
|
||||||
|
splitLock = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyDefaultSplit() {
|
||||||
|
const split = defaultSplit()
|
||||||
|
writeRings(split.rings15, split.rings25)
|
||||||
|
}
|
||||||
|
|
||||||
|
const leftoverAmount = computed(() => {
|
||||||
|
const spent = wire15Rings.value * prices.value.wireRing15 + wire25Rings.value * prices.value.wireRing25
|
||||||
|
const leftValue = Math.max(0, selectedValue.value - spent)
|
||||||
|
const perUnit = sourceUnitPrice.value
|
||||||
|
if (perUnit <= 0) return 0
|
||||||
|
return roundAmount(kgToNative(leftValue / perUnit, assetUnit.value, sourceProduct.value))
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(sliderAmount, () => applyDefaultSplit(), { flush: 'sync' })
|
||||||
|
|
||||||
|
watch(selectedValue, (value, prev) => {
|
||||||
|
if ((prev ?? 0) <= 0 && value > 0) applyDefaultSplit()
|
||||||
|
}, { flush: 'sync' })
|
||||||
|
|
||||||
|
watch(wire15Rings, (value) => {
|
||||||
|
if (splitLock) return
|
||||||
|
const next15 = Math.max(0, Math.min(maxRings15.value, Math.floor(value)))
|
||||||
|
writeRings(next15, rings25For(next15))
|
||||||
|
}, { flush: 'sync' })
|
||||||
|
|
||||||
|
watch(wire25Rings, (value) => {
|
||||||
|
if (splitLock) return
|
||||||
|
const next25 = Math.max(0, Math.min(maxRings25.value, Math.floor(value)))
|
||||||
|
writeRings(rings15For(next25), next25)
|
||||||
|
}, { flush: 'sync' })
|
||||||
|
|
||||||
|
function hasPendingRequest() {
|
||||||
|
return history.value.some((row) => row.status === 'pending')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function beginEdit(row: CopperConvertHistoryRow) {
|
||||||
|
if (row.status !== 'pending' || submitting.value) return
|
||||||
|
editingId.value = row.id
|
||||||
|
if (row.source === 'katod' || row.source === 'maftoul' || row.source === 'shamsh') {
|
||||||
|
source.value = row.source
|
||||||
|
}
|
||||||
|
await nextTick()
|
||||||
|
const rings15 = Math.max(0, Math.min(maxRings15.value, Math.floor(Number(row.wire15_rings) || 0)))
|
||||||
|
const rings25 = Math.min(Math.floor(Number(row.wire25_rings) || 0), rings25For(rings15))
|
||||||
|
writeRings(rings15, Math.max(0, rings25))
|
||||||
|
const forms = document.querySelectorAll('[data-convert-form]')
|
||||||
|
const visible = [...forms].find((node) => node instanceof HTMLElement && node.getClientRects().length > 0)
|
||||||
|
visible?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelEdit() {
|
||||||
|
if (submitting.value) return
|
||||||
|
editingId.value = null
|
||||||
|
applyDefaultSplit()
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteRequest(id: number) {
|
||||||
|
if (deletingId.value || submitting.value) return
|
||||||
|
const row = history.value.find((item) => item.id === id)
|
||||||
|
if (!row || row.status !== 'pending') return
|
||||||
|
Modal.confirm({
|
||||||
|
title: 'حذف درخواست',
|
||||||
|
content: 'این درخواست در انتظار تایید حذف شود؟',
|
||||||
|
okText: 'حذف',
|
||||||
|
cancelText: 'انصراف',
|
||||||
|
okType: 'danger',
|
||||||
|
async onOk() {
|
||||||
|
deletingId.value = id
|
||||||
|
try {
|
||||||
|
await deleteCopperConvertRequest(id)
|
||||||
|
if (editingId.value === id) editingId.value = null
|
||||||
|
message.success('درخواست تبدیل حذف شد')
|
||||||
|
await loadHistory()
|
||||||
|
} finally {
|
||||||
|
deletingId.value = 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitRequest() {
|
||||||
|
if (submitting.value) return
|
||||||
|
if (wire15Rings.value + wire25Rings.value < 1) return
|
||||||
|
if (!editingId.value && hasPendingRequest()) {
|
||||||
|
message.warning('یک درخواست در انتظار تایید دارید. همان را ویرایش یا حذف کنید.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
submitting.value = true
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
source: source.value,
|
||||||
|
rings15: wire15Rings.value,
|
||||||
|
rings25: wire25Rings.value,
|
||||||
|
}
|
||||||
|
if (editingId.value) {
|
||||||
|
await updateCopperConvertRequest(editingId.value, payload)
|
||||||
|
editingId.value = null
|
||||||
|
message.success('درخواست تبدیل بهروز شد')
|
||||||
|
} else {
|
||||||
|
await createCopperConvertRequest(payload)
|
||||||
|
message.success('درخواست تبدیل برای تأیید ادمین ثبت شد')
|
||||||
|
}
|
||||||
|
wire15Rings.value = 0
|
||||||
|
wire25Rings.value = 0
|
||||||
|
void loadHistory()
|
||||||
|
} finally {
|
||||||
|
submitting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadHistory() {
|
||||||
|
historyLoading.value = true
|
||||||
|
try {
|
||||||
|
const rows = await getCopperConvertRequests()
|
||||||
|
history.value = Array.isArray(rows) ? rows : []
|
||||||
|
} catch {
|
||||||
|
// خطای شبکه را اینترسپتور نشان میدهد؛ لیست قبلی میماند
|
||||||
|
} finally {
|
||||||
|
historyLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const priceRows = computed(() => {
|
||||||
|
const p = prices.value
|
||||||
|
const row = (label: string, amount: number) => ({
|
||||||
|
label,
|
||||||
|
value: amount > 0 ? Math.round(amount).toLocaleString('en-US') : '—',
|
||||||
|
unit: amount > 0 ? 'ریال' : '',
|
||||||
|
missing: amount <= 0,
|
||||||
|
})
|
||||||
|
return [
|
||||||
|
row('قیمت کاتد (هر کیلو)', p.katodPerKg),
|
||||||
|
row('قیمت مفتول (هر کیلو)', p.maftoulPerKg),
|
||||||
|
row('قیمت شمش (هر کیلو)', p.shamshPerKg),
|
||||||
|
row('قیمت حلقه سیم ۱.۵', p.wireRing15),
|
||||||
|
row('قیمت حلقه سیم ۲.۵', p.wireRing25),
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
async function loadCatalog() {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const [, list] = await Promise.all([
|
||||||
|
getLastPrices(),
|
||||||
|
getProducts(),
|
||||||
|
loadWalletAssets(),
|
||||||
|
loadHistory(),
|
||||||
|
])
|
||||||
|
catalog.value = Array.isArray(list) ? list : []
|
||||||
|
} catch {
|
||||||
|
catalog.value = []
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
startLastPricePolling()
|
||||||
|
void loadCatalog()
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
stopLastPricePolling()
|
||||||
|
})
|
||||||
|
|
||||||
|
const ctx: CopperConvertPageContext = {
|
||||||
|
loading,
|
||||||
|
source,
|
||||||
|
assetAmount,
|
||||||
|
assetUnit,
|
||||||
|
sliderAmount,
|
||||||
|
sliderStep,
|
||||||
|
remainderAmount,
|
||||||
|
maxRings15,
|
||||||
|
maxRings25,
|
||||||
|
wire15Rings,
|
||||||
|
wire25Rings,
|
||||||
|
leftoverAmount,
|
||||||
|
submitting,
|
||||||
|
submitRequest,
|
||||||
|
editingId,
|
||||||
|
beginEdit,
|
||||||
|
cancelEdit,
|
||||||
|
deleteRequest,
|
||||||
|
deletingId,
|
||||||
|
history,
|
||||||
|
historyLoading,
|
||||||
|
prices,
|
||||||
|
result,
|
||||||
|
priceRows,
|
||||||
|
}
|
||||||
|
|
||||||
|
provide(COPPER_CONVERT_PAGE_KEY, ctx)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCopperConvertPageContext() {
|
||||||
|
const ctx = inject(COPPER_CONVERT_PAGE_KEY)
|
||||||
|
if (!ctx) {
|
||||||
|
throw new Error('useCopperConvertPageContext requires useCopperConvertPage')
|
||||||
|
}
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dwallet" dir="rtl">
|
||||||
|
<div class="dwallet__container">
|
||||||
|
<DesktopPageTopbar
|
||||||
|
eyebrow="محصول"
|
||||||
|
title="تبدیل محصول"
|
||||||
|
subtitle="تبدیل کاتد، مفتول یا شمش به حلقه سیم"
|
||||||
|
show-back
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="dwallet-grid dconvert-grid">
|
||||||
|
<section class="dwallet-surface dwallet-form">
|
||||||
|
<CopperConvertCalculator />
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="dwallet-surface dwallet-side dconvert-side">
|
||||||
|
<CopperConvertHistory variant="side" />
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
|
||||||
|
import CopperConvertCalculator from '../components/CopperConvertCalculator.vue'
|
||||||
|
import CopperConvertHistory from '../components/CopperConvertHistory.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.dconvert-grid {
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dconvert-side {
|
||||||
|
min-height: 100%;
|
||||||
|
|
||||||
|
:deep(.dwallet-side__scroll) {
|
||||||
|
max-height: none;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<template>
|
||||||
|
<div class="convert-page-root">
|
||||||
|
<DesktopConvertView v-show="isDesktop" />
|
||||||
|
<MobileConvertView v-show="!isDesktop" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
|
import { useCopperConvertPage } from './composables/useCopperConvertPage'
|
||||||
|
import DesktopConvertView from './desktop/DesktopConvertView.vue'
|
||||||
|
import MobileConvertView from './mobile/MobileConvertView.vue'
|
||||||
|
|
||||||
|
const isDesktop = useDesktopBreakpoint()
|
||||||
|
|
||||||
|
useCopperConvertPage()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.convert-page-root {
|
||||||
|
min-height: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<MobilePageHeader title="تبدیل محصول" show-back />
|
||||||
|
<div class="px-5 mpage-content pb-[calc(var(--app-bottom-chrome-height)+1rem)]">
|
||||||
|
<div class="border-gray-200 border-1 rounded-xl p-4 relative bg-white">
|
||||||
|
<CopperConvertCalculator />
|
||||||
|
</div>
|
||||||
|
<CopperConvertHistory />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||||
|
import CopperConvertCalculator from '../components/CopperConvertCalculator.vue'
|
||||||
|
import CopperConvertHistory from '../components/CopperConvertHistory.vue'
|
||||||
|
</script>
|
||||||
@@ -42,14 +42,14 @@
|
|||||||
<bg_main />
|
<bg_main />
|
||||||
<div class="z-100 relative">
|
<div class="z-100 relative">
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
<BasicInput v-model:value="form.goldCash" addon-before="ریال" :addon-bg-color="useConfigStore().config.color"
|
<BasicInput v-model:value="form.goldCash" addon-before="ریال"
|
||||||
addon-text-color="white"
|
addon-text-color="white"
|
||||||
place-holder="ارزش کل"
|
place-holder="ارزش کل"
|
||||||
size="large"
|
size="large"
|
||||||
type="price" @onchange="calculateGold" />
|
type="price" @onchange="calculateGold" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :rules="[justNumber()]">
|
<a-form-item :rules="[justNumber()]">
|
||||||
<BasicInput v-model:value="form.goldValue" addon-before="گرم" :addon-bg-color="useConfigStore().config.color"
|
<BasicInput v-model:value="form.goldValue" addon-before="گرم"
|
||||||
addon-text-color="white"
|
addon-text-color="white"
|
||||||
place-holder="مقدار طلا"
|
place-holder="مقدار طلا"
|
||||||
size="large" type="text" inputmode="decimal" @onchange="calculateCash" />
|
size="large" type="text" inputmode="decimal" @onchange="calculateCash" />
|
||||||
@@ -124,23 +124,9 @@
|
|||||||
<!-- <div>{{form?.goldValue? true: false}}</div>-->
|
<!-- <div>{{form?.goldValue? true: false}}</div>-->
|
||||||
<div v-if="isBuy? ((form?.goldValue || form.goldValue === 0)? form?.goldCash < 500000: false) : false"
|
<div v-if="isBuy? ((form?.goldValue || form.goldValue === 0)? form?.goldCash < 500000: false) : false"
|
||||||
class="text-red-700 text-xs font-bold mt-2">
|
class="text-red-700 text-xs font-bold mt-2">
|
||||||
حداقل مقدار طلا جهت خرید 500,000 ریال می باشد.
|
حداقل مقدار مس جهت خرید 500,000 ریال می باشد.
|
||||||
</div>
|
</div>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<div class=" w-full bottom-18 px-6 rounded-xl py-1 border-1 bg-white">
|
|
||||||
<!-- <BasicInfoItem is-line title="کارمزد" :value="parseFloat(((form.goldValue?? 0)*0.005).toFixed(3))" />-->
|
|
||||||
<!-- <BasicInfoItem is-line title="کارمزد" :value="parseFloat(((form.goldValue?? 0)*0.005).toFixed(3))" />-->
|
|
||||||
<div class="flex justify-between items-center">
|
|
||||||
<div>کارمزد:</div>
|
|
||||||
<div class="flex gap-2 items-center">
|
|
||||||
<div class="">{{ feeInGrams }}</div>
|
|
||||||
<!-- <div class="font-bold text-2xl">{{ 0 }}</div>-->
|
|
||||||
<div>
|
|
||||||
گرم
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a-form>
|
</a-form>
|
||||||
<!-- <div ref="el" :class="loading? 'h-screen': ''"
|
<!-- <div ref="el" :class="loading? 'h-screen': ''"
|
||||||
class="px-3 overflow-y-scroll w-full h-[49vh] pb-25 max-h-[35vh]">
|
class="px-3 overflow-y-scroll w-full h-[49vh] pb-25 max-h-[35vh]">
|
||||||
|
|||||||
@@ -44,8 +44,8 @@
|
|||||||
شیوهٔ خرید از گروسی گالری
|
شیوهٔ خرید از گروسی گالری
|
||||||
</div>
|
</div>
|
||||||
<div :class="variant === 'desktop' ? 'deducate-content__text' : 'mt-5 text-xs leading-5'">
|
<div :class="variant === 'desktop' ? 'deducate-content__text' : 'mt-5 text-xs leading-5'">
|
||||||
• سپس از بخش «خرید و فروش» انتخاب کنید که طلای آبشده میخواهید یا محصولات دیگر (شامل گوی، شمش یا مکعب).<br />
|
• سپس از بخش «خرید و فروش» محصول مورد نظر خود (شامل کاتد مس، مفتول مس یا سیم) را انتخاب کنید.<br />
|
||||||
• توجه داشته باشید کارمزد طلای آبشده حدود ۲٪ است و کارمزد ریالی محصولات دیگر در پایین صفحه قیمت درج شده است.
|
• قیمتهای اعلامشده نهایی بوده و هیچگونه کارمزد جداگانهای از مشتری دریافت نمیشود.
|
||||||
</div>
|
</div>
|
||||||
<img :src="img4" :class="variant === 'desktop' ? 'deducate-content__image' : ''" />
|
<img :src="img4" :class="variant === 'desktop' ? 'deducate-content__image' : ''" />
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
پاداش معرفی
|
پاداش معرفی
|
||||||
</div>
|
</div>
|
||||||
<div :class="variant === 'desktop' ? 'deducate-content__text' : 'mt-5 text-xs leading-5'">
|
<div :class="variant === 'desktop' ? 'deducate-content__text' : 'mt-5 text-xs leading-5'">
|
||||||
• در صفحه اصلی روی "تنظیمات" کلیک کرده و وارد حساب کاربری خود شوید.
|
• در صفحه اصلی روی "امکانات بیشتر" کلیک کرده و وارد حساب کاربری خود شوید.
|
||||||
</div>
|
</div>
|
||||||
<div :class="variant === 'desktop' ? 'deducate-content__text' : 'mt-5 text-xs leading-5'">
|
<div :class="variant === 'desktop' ? 'deducate-content__text' : 'mt-5 text-xs leading-5'">
|
||||||
• سپس گزینه «اشتراکگذاری» یا «کپی لینک» را انتخاب کرده و لینک دعوت را برای دوستانتان ارسال کنید.<br />
|
• سپس گزینه «اشتراکگذاری» یا «کپی لینک» را انتخاب کرده و لینک دعوت را برای دوستانتان ارسال کنید.<br />
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex flex-col gap-3 mt-4" :class="variant === 'desktop' ? 'dgift-lists' : ''">
|
||||||
|
<a-spin :spinning="listLoading">
|
||||||
|
<section class="border border-gray-200 rounded-xl p-3 bg-white">
|
||||||
|
<h3 class="text-sm font-bold m-0 mb-1">کدهای قابل استفاده</h3>
|
||||||
|
<p class="text-xs text-gray-500 m-0 mb-2.5">
|
||||||
|
کارتهای اختصاصی شما و کدهای عمومی فعال. برای ثبت سریع روی کد بزنید.
|
||||||
|
</p>
|
||||||
|
<div v-if="available.length" class="flex flex-col gap-2">
|
||||||
|
<button
|
||||||
|
v-for="item in available"
|
||||||
|
:key="`a-${item.id}`"
|
||||||
|
type="button"
|
||||||
|
class="w-full text-right border border-gray-100 rounded-lg p-2.5 bg-gray-50 hover:bg-gray-100 transition-colors"
|
||||||
|
@click="onAvailableClick(item)"
|
||||||
|
>
|
||||||
|
<div class="flex items-start justify-between gap-2">
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<p class="m-0 text-sm font-bold truncate">{{ item.name || kindLabel(item) }}</p>
|
||||||
|
<p class="m-0 mt-1 text-xs font-mono tracking-wide">{{ item.code }}</p>
|
||||||
|
<p class="m-0 mt-1 text-xs text-gray-500">{{ amountLabel(item) }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col items-end gap-1 shrink-0">
|
||||||
|
<span class="text-xs px-1.5 py-0.5 rounded bg-blue-50 text-blue-700">{{ scopeLabel(item) }}</span>
|
||||||
|
<span class="text-xs px-1.5 py-0.5 rounded bg-emerald-50 text-emerald-700">{{ kindLabel(item) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p v-if="item.expiry_date" class="m-0 mt-1.5 text-xs text-gray-400">
|
||||||
|
انقضا: {{ formatDate(item.expiry_date) }}
|
||||||
|
</p>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p v-else class="text-xs text-gray-400 m-0 py-2">کد قابل استفادهای ندارید.</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="border border-gray-200 rounded-xl p-3 bg-white mt-3">
|
||||||
|
<h3 class="text-sm font-bold m-0 mb-1">تاریخچه</h3>
|
||||||
|
<p class="text-xs text-gray-500 m-0 mb-2.5">
|
||||||
|
کدهایی که قبلاً ثبت یا مصرف کردهاید.
|
||||||
|
</p>
|
||||||
|
<div v-if="history.length" class="flex flex-col gap-2">
|
||||||
|
<div
|
||||||
|
v-for="item in history"
|
||||||
|
:key="`h-${item.id}`"
|
||||||
|
class="w-full border border-gray-100 rounded-lg p-2.5 bg-gray-50"
|
||||||
|
>
|
||||||
|
<div class="flex items-start justify-between gap-2">
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<p class="m-0 text-sm font-bold truncate">{{ item.name || kindLabel(item) }}</p>
|
||||||
|
<p class="m-0 mt-1 text-xs font-mono tracking-wide">{{ item.code }}</p>
|
||||||
|
<p class="m-0 mt-1 text-xs text-gray-500">{{ amountLabel(item) }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col items-end gap-1 shrink-0">
|
||||||
|
<span class="text-xs px-1.5 py-0.5 rounded bg-gray-200 text-gray-700">مصرفشده</span>
|
||||||
|
<span class="text-xs px-1.5 py-0.5 rounded bg-emerald-50 text-emerald-700">{{ kindLabel(item) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p v-if="item.used_at" class="m-0 mt-1.5 text-xs text-gray-400">
|
||||||
|
تاریخ مصرف: {{ formatDate(item.used_at) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p v-else class="text-xs text-gray-400 m-0 py-2">هنوز کدی مصرف نکردهاید.</p>
|
||||||
|
</section>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import type { CustomerGiftCardItem } from '@/api/giftCard'
|
||||||
|
import { useGiftCardPageContext } from '../composables/useGiftCardPage'
|
||||||
|
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
variant?: 'mobile' | 'desktop'
|
||||||
|
}>(),
|
||||||
|
{ variant: 'mobile' },
|
||||||
|
)
|
||||||
|
|
||||||
|
const { available, history, listLoading, fillCode } = useGiftCardPageContext()
|
||||||
|
|
||||||
|
function onAvailableClick(item: CustomerGiftCardItem) {
|
||||||
|
fillCode(item.code)
|
||||||
|
if (item.kind === 'discount') {
|
||||||
|
message.info('کد تخفیف در فیلد پر شد؛ هنگام خرید در سبد استفاده کنید')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function kindLabel(item: CustomerGiftCardItem) {
|
||||||
|
return item.kind === 'discount' ? 'تخفیف' : 'کارت هدیه'
|
||||||
|
}
|
||||||
|
|
||||||
|
function scopeLabel(item: CustomerGiftCardItem) {
|
||||||
|
return item.scope === 'personal' ? 'اختصاصی' : 'عمومی'
|
||||||
|
}
|
||||||
|
|
||||||
|
function amountLabel(item: CustomerGiftCardItem) {
|
||||||
|
const amount = Number(item.amount)
|
||||||
|
if (!Number.isFinite(amount)) return '—'
|
||||||
|
if (item.unit === 3) {
|
||||||
|
const percent = amount <= 1 ? amount * 100 : amount
|
||||||
|
return `${percent.toLocaleString('fa-IR')}٪ تخفیف`
|
||||||
|
}
|
||||||
|
if (item.unit === 2) {
|
||||||
|
return `${amount.toLocaleString('fa-IR')} طلا`
|
||||||
|
}
|
||||||
|
return `${amount.toLocaleString('fa-IR')} ریال`
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(value: string) {
|
||||||
|
try {
|
||||||
|
return new Date(value).toLocaleDateString('fa-IR')
|
||||||
|
} catch {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -1,13 +1,25 @@
|
|||||||
import { computed, inject, provide, ref, type ComputedRef, type InjectionKey, type Ref } from 'vue'
|
import { computed, inject, onMounted, provide, ref, type ComputedRef, type InjectionKey, type Ref } from 'vue'
|
||||||
import { loading } from '@/utils'
|
import { loading } from '@/utils'
|
||||||
import { registerCodeGiftCard } from '@/api/giftCard'
|
import {
|
||||||
|
fetchMyGiftCards,
|
||||||
|
registerCodeGiftCard,
|
||||||
|
type CustomerGiftCardItem,
|
||||||
|
} from '@/api/giftCard'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
|
import { useUserStore } from '@/store/userStore'
|
||||||
|
import { isCustomerIdentityVerified } from '@/utils/customerIdentity'
|
||||||
|
|
||||||
export interface GiftCardPageContext {
|
export interface GiftCardPageContext {
|
||||||
form: Ref<{ code: string }>
|
form: Ref<{ code: string }>
|
||||||
disableButton: ComputedRef<boolean>
|
disableButton: ComputedRef<boolean>
|
||||||
loading: typeof loading
|
loading: typeof loading
|
||||||
registerGiftCard: () => Promise<void>
|
registerGiftCard: () => Promise<void>
|
||||||
|
available: Ref<CustomerGiftCardItem[]>
|
||||||
|
history: Ref<CustomerGiftCardItem[]>
|
||||||
|
listLoading: Ref<boolean>
|
||||||
|
loadMyGiftCards: () => Promise<void>
|
||||||
|
fillCode: (code: string) => void
|
||||||
|
identityRequiredVisible: Ref<boolean>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GIFT_CARD_PAGE_CONTEXT_KEY: InjectionKey<GiftCardPageContext> =
|
export const GIFT_CARD_PAGE_CONTEXT_KEY: InjectionKey<GiftCardPageContext> =
|
||||||
@@ -17,6 +29,11 @@ export function useGiftCardPage() {
|
|||||||
const form = ref<{ code: string }>({
|
const form = ref<{ code: string }>({
|
||||||
code: '',
|
code: '',
|
||||||
})
|
})
|
||||||
|
const available = ref<CustomerGiftCardItem[]>([])
|
||||||
|
const history = ref<CustomerGiftCardItem[]>([])
|
||||||
|
const listLoading = ref(false)
|
||||||
|
const identityRequiredVisible = ref(false)
|
||||||
|
const userStore = useUserStore()
|
||||||
|
|
||||||
const disableButton = computed(() => {
|
const disableButton = computed(() => {
|
||||||
if (!loading.value) {
|
if (!loading.value) {
|
||||||
@@ -25,12 +42,46 @@ export function useGiftCardPage() {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function loadMyGiftCards() {
|
||||||
|
try {
|
||||||
|
listLoading.value = true
|
||||||
|
const res = await fetchMyGiftCards()
|
||||||
|
available.value = res?.available ?? []
|
||||||
|
history.value = res?.history ?? []
|
||||||
|
} catch {
|
||||||
|
available.value = []
|
||||||
|
history.value = []
|
||||||
|
} finally {
|
||||||
|
listLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillCode(code: string) {
|
||||||
|
form.value.code = code
|
||||||
|
}
|
||||||
|
|
||||||
async function registerGiftCard() {
|
async function registerGiftCard() {
|
||||||
|
if (!isCustomerIdentityVerified(userStore.userInfo?.is_legal)) {
|
||||||
|
identityRequiredVisible.value = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const code = form.value.code.trim()
|
||||||
|
if (!code) return
|
||||||
|
|
||||||
|
const matched =
|
||||||
|
available.value.find((item) => item.code === code) ||
|
||||||
|
history.value.find((item) => item.code === code)
|
||||||
|
if (matched?.kind === 'discount') {
|
||||||
|
message.info('کد تخفیف را هنگام ثبت سفارش در سبد خرید وارد کنید')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
await registerCodeGiftCard(form.value.code)
|
await registerCodeGiftCard(code)
|
||||||
message.success('کد کارت هدیه با موفقیت ثبت شد')
|
message.success('کد کارت هدیه با موفقیت ثبت شد')
|
||||||
form.value.code = ''
|
form.value.code = ''
|
||||||
|
await loadMyGiftCards()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
message.error(e?.response?.data?.message || 'خطا در ثبت کد کارت هدیه')
|
message.error(e?.response?.data?.message || 'خطا در ثبت کد کارت هدیه')
|
||||||
} finally {
|
} finally {
|
||||||
@@ -38,11 +89,21 @@ export function useGiftCardPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void loadMyGiftCards()
|
||||||
|
})
|
||||||
|
|
||||||
const context: GiftCardPageContext = {
|
const context: GiftCardPageContext = {
|
||||||
form,
|
form,
|
||||||
disableButton,
|
disableButton,
|
||||||
loading,
|
loading,
|
||||||
registerGiftCard,
|
registerGiftCard,
|
||||||
|
available,
|
||||||
|
history,
|
||||||
|
listLoading,
|
||||||
|
loadMyGiftCards,
|
||||||
|
fillCode,
|
||||||
|
identityRequiredVisible,
|
||||||
}
|
}
|
||||||
|
|
||||||
provide(GIFT_CARD_PAGE_CONTEXT_KEY, context)
|
provide(GIFT_CARD_PAGE_CONTEXT_KEY, context)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<GiftCardForm variant="desktop" />
|
<GiftCardForm variant="desktop" />
|
||||||
|
<GiftCardLists variant="desktop" />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<aside class="dgift-surface dgift-guide">
|
<aside class="dgift-surface dgift-guide">
|
||||||
@@ -47,4 +48,5 @@
|
|||||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import GiftCardForm from '../components/GiftCardForm.vue'
|
import GiftCardForm from '../components/GiftCardForm.vue'
|
||||||
|
import GiftCardLists from '../components/GiftCardLists.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<div class="gift-card-page-root">
|
<div class="gift-card-page-root">
|
||||||
<DesktopGiftCardView v-show="isDesktop" />
|
<DesktopGiftCardView v-show="isDesktop" />
|
||||||
<MobileGiftCardView v-show="!isDesktop" />
|
<MobileGiftCardView v-show="!isDesktop" />
|
||||||
|
<IdentityRequiredDialog v-model:show="identityRequiredVisible" action="ثبت کد هدیه" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -10,10 +11,11 @@ import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
|||||||
import { useGiftCardPage } from './composables/useGiftCardPage'
|
import { useGiftCardPage } from './composables/useGiftCardPage'
|
||||||
import DesktopGiftCardView from './desktop/DesktopGiftCardView.vue'
|
import DesktopGiftCardView from './desktop/DesktopGiftCardView.vue'
|
||||||
import MobileGiftCardView from './mobile/MobileGiftCardView.vue'
|
import MobileGiftCardView from './mobile/MobileGiftCardView.vue'
|
||||||
|
import IdentityRequiredDialog from '@/components/IdentityRequiredDialog.vue'
|
||||||
|
|
||||||
const isDesktop = useDesktopBreakpoint()
|
const isDesktop = useDesktopBreakpoint()
|
||||||
|
|
||||||
useGiftCardPage()
|
const { identityRequiredVisible } = useGiftCardPage()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
<div>
|
<div>
|
||||||
<MobilePageHeader title="کارت هدیه" show-back />
|
<MobilePageHeader title="کارت هدیه" show-back />
|
||||||
<div class="px-5 mpage-content pb-2">
|
<div class="px-5 mpage-content pb-2">
|
||||||
<div class="border-gray-200 border-1 rounded-xl p-5 trans h-40 relative">
|
<div class="border-gray-200 border-1 rounded-xl p-5 trans relative">
|
||||||
<bg_main />
|
<bg_main />
|
||||||
<div class="z-100 relative">
|
<div class="z-100 relative">
|
||||||
<GiftCardForm variant="mobile" />
|
<GiftCardForm variant="mobile" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<GiftCardLists variant="mobile" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -16,4 +17,5 @@
|
|||||||
import Bg_main from '@/components/bg_main.vue'
|
import Bg_main from '@/components/bg_main.vue'
|
||||||
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||||
import GiftCardForm from '../components/GiftCardForm.vue'
|
import GiftCardForm from '../components/GiftCardForm.vue'
|
||||||
|
import GiftCardLists from '../components/GiftCardLists.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|||||||