Compare commits
19
Commits
00c2e38ab9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0cb056e11 | ||
|
|
9f7a98e064 | ||
|
|
db29b7d0d3 | ||
|
|
6e898323d4 | ||
|
|
3e4c0e018e | ||
|
|
9ba2d3ec96 | ||
|
|
1905408993 | ||
|
|
4a9cb2a944 | ||
|
|
54c43fab63 | ||
|
|
60af57e0ed | ||
|
|
8919374055 | ||
|
|
71312d809d | ||
|
|
c6c7635041 | ||
|
|
e630c07d92 | ||
|
|
2ffcee9f3a | ||
|
|
354c5376b8 | ||
|
|
3b08bf6714 | ||
|
|
f18d196e30 | ||
|
|
19a8584fa0 |
@@ -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,4 @@
|
|||||||
|
# یادداشتهای یادگیری — abshode-domain-lookup
|
||||||
|
|
||||||
|
فرمت هر خط:
|
||||||
|
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
|
||||||
@@ -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` اضافه کن.
|
||||||
+3
-3
@@ -17,7 +17,7 @@
|
|||||||
right: 20px;
|
right: 20px;
|
||||||
width: 60px;
|
width: 60px;
|
||||||
height: 60px;
|
height: 60px;
|
||||||
background-color: #25D366;
|
background-color: #ffffff;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -42,8 +42,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
<a href="https://wa.me/989390624220" target="_blank" id="whatsapp-button">
|
<a href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c" target="_blank" id="whatsapp-button">
|
||||||
<img class="p-2" src="/whatsapp.png" alt="" />
|
<img class="p-2" src="/src/assets/img/rubika.webp" alt="" />
|
||||||
</a>
|
</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import useAxios from "@/utils/useAxios";
|
||||||
|
|
||||||
|
|
||||||
|
//customer
|
||||||
|
export const registerCodeGiftCard = async (code: string) => await useAxios.post(`/customer/giftcard/use`, {code:code})
|
||||||
|
export const registerCodeDiscount = async (code: string) => await useAxios.post(`customer/validateDiscount`, {code:code})
|
||||||
@@ -351,4 +351,20 @@ body {
|
|||||||
}
|
}
|
||||||
.ant-radio-group-solid .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover{
|
.ant-radio-group-solid .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover{
|
||||||
color: white !important;
|
color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-dot-item,
|
||||||
|
.ant-spin-dot i {
|
||||||
|
background-color: @primary-color !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* لودینگ محتوای صفحه — وسط ناحیه محتوا (موبایل و دسکتاپ یکسان) */
|
||||||
|
.app-page-content-loading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
min-height: min(52vh, 22rem);
|
||||||
|
padding: 2rem 1rem;
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
+3
-3
@@ -73,8 +73,8 @@ function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||||
if (to.name !== 'home') {
|
if (to.name !== 'buyProduct') {
|
||||||
return next({ name: 'home' }) // Redirect to login
|
return next({ name: 'buyProduct' }) // Redirect to login
|
||||||
} else {
|
} else {
|
||||||
return next() // If already on the login page, don't redirect
|
return next() // If already on the login page, don't redirect
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
if (fingerPosition) {
|
if (fingerPosition) {
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
if (to.name === 'login') {
|
if (to.name === 'login') {
|
||||||
return next({ name: from.name || 'home' }) // Redirect to home if trying to access login after authentication
|
return next({ name: from.name || 'buyProduct' }) // Redirect to home if trying to access login after authentication
|
||||||
}
|
}
|
||||||
return next() // Proceed to the intended route
|
return next() // Proceed to the intended route
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export interface Product {
|
|||||||
description: string
|
description: string
|
||||||
wallet: Wallet
|
wallet: Wallet
|
||||||
similar?:Product[]
|
similar?:Product[]
|
||||||
|
inventory:number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PInventory {
|
export interface PInventory {
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ const router = createRouter({
|
|||||||
name: 'transactions',
|
name: 'transactions',
|
||||||
component: () => import('@/views/base/transactions/index.vue')
|
component: () => import('@/views/base/transactions/index.vue')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'giftCard',
|
||||||
|
name: 'giftCard',
|
||||||
|
component: () => import('@/views/base/giftCard/index.vue')
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'wallet',
|
path: 'wallet',
|
||||||
name: 'wallet',
|
name: 'wallet',
|
||||||
|
|||||||
+45
-3
@@ -138,8 +138,6 @@ let isBuyP = true
|
|||||||
let NumP = 0
|
let NumP = 0
|
||||||
let gatewayP = false
|
let gatewayP = false
|
||||||
const checkNumber = async (_rule: Rule, value: number) => {
|
const checkNumber = async (_rule: Rule, value: number) => {
|
||||||
|
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return Promise.reject('تعداد محصول را مشخص کنید')
|
return Promise.reject('تعداد محصول را مشخص کنید')
|
||||||
}
|
}
|
||||||
@@ -168,8 +166,41 @@ const checkNumber = async (_rule: Rule, value: number) => {
|
|||||||
else
|
else
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
const checkNumber2 = async (_rule: Rule, value: number) => {
|
||||||
|
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
return Promise.reject('تعداد محصول را مشخص کنید')
|
||||||
|
}
|
||||||
|
if (value % 1 !== 0) {
|
||||||
|
return Promise.reject('استفاده از اعداد اعشاری مجاز نمی باشد')
|
||||||
|
}
|
||||||
|
if (isBuyP) {
|
||||||
|
// Skip wallet balance check if gateway is enabled
|
||||||
|
if (!gatewayP && isToken()) {
|
||||||
|
// if (!walletCash?.walletInfo?.cash && methodP == 'cash') {
|
||||||
|
// return Promise.reject('موجودی کیف پول ناکافی است')
|
||||||
|
// }
|
||||||
|
// if (!walletCash?.walletInfo?.gold && methodP == 'gold') {
|
||||||
|
// return Promise.reject('موجودی کیف طلا ناکافی است')
|
||||||
|
// }
|
||||||
|
// if (priceP * value > walletCash?.walletInfo?.cash && methodP == 'cash')
|
||||||
|
// return Promise.reject('موجودی کیف پول ناکافی است')
|
||||||
|
// if (amountP * value > walletCash?.walletInfo?.gold && methodP == 'gold')
|
||||||
|
// return Promise.reject('موجودی کیف طلا ناکافی است')
|
||||||
|
}
|
||||||
|
return Promise.resolve()
|
||||||
|
} else {
|
||||||
|
if (value > NumP)
|
||||||
|
|
||||||
|
return Promise.reject('موجودی محصول ناکافی است')
|
||||||
|
else
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const justNumber2 = (price: number, method?: string, amount?: number, isBuy?: boolean, gateway?: boolean) => {
|
export const justNumber2 = (price: number, method?: string, amount?: number, isBuy?: boolean, gateway?: boolean) => {
|
||||||
priceP = price
|
priceP = price
|
||||||
methodP = method
|
methodP = method
|
||||||
@@ -181,8 +212,8 @@ export const justNumber2 = (price: number, method?: string, amount?: number, isB
|
|||||||
validator: checkNumber,
|
validator: checkNumber,
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const justNumber3 = (price: number, Num?: number, isBuy?: boolean) => {
|
export const justNumber3 = (price: number, Num?: number, isBuy?: boolean) => {
|
||||||
priceP = price
|
priceP = price
|
||||||
NumP = Num
|
NumP = Num
|
||||||
@@ -193,6 +224,17 @@ export const justNumber3 = (price: number, Num?: number, isBuy?: boolean) => {
|
|||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
export const justNumber4 = (price: number, Num?: number, isBuy?: boolean) => {
|
||||||
|
priceP = price
|
||||||
|
NumP = Num
|
||||||
|
isBuyP = isBuy
|
||||||
|
return {
|
||||||
|
required: true,
|
||||||
|
validator: checkNumber2,
|
||||||
|
trigger: 'change'
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ruleNumber = () => {
|
export const ruleNumber = () => {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ export async function setIntervalGetAllPrice() {
|
|||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setIntervalGetLastPrice() {
|
export async function setIntervalGetLastPrice() {
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ _axios.interceptors.response.use(
|
|||||||
return response.data
|
return response.data
|
||||||
},
|
},
|
||||||
async function (error) {
|
async function (error) {
|
||||||
// console.log('this is axios error', error)
|
|
||||||
if (error.response.data && error.response.data.message) {
|
if (error.response.data && error.response.data.message) {
|
||||||
checkStatus(error.response.data.message, error.response.status, error.config)
|
|
||||||
|
checkStatus(error.response.data.message, error.response.status, error.config)
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log('this is error on interceptors.response', error.config.meta)
|
//console.log('this is error on interceptors.response', error.config.meta)
|
||||||
|
|||||||
@@ -66,12 +66,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white">
|
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white items-center">
|
||||||
<a class="w-full" href="tel:09128081392">
|
<a class="w-full" href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
|
||||||
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
|
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://t.me/ghatreh">
|
<a href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
|
||||||
<img src="@/assets/img/telegram.png" alt="" class="h-10 w-10"/>
|
<img src="@/assets/img/rubika.webp" alt="" class=" w-12"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+167
-102
@@ -14,95 +14,121 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<GoldLoading v-model:show="infoVisible" title="" />
|
<GoldLoading v-model:show="infoVisible" title=""/>
|
||||||
<div class="px-5 pt-26 pb-30">
|
<div class="px-5 pt-26 pb-30">
|
||||||
<!-- Empty Cart Message -->
|
<!-- Empty Cart Message -->
|
||||||
<div v-if="cartStore.itemCount === 0" class="flex flex-col items-center justify-center h-[60vh]">
|
<div v-if="cartStore.itemCount === 0" class="flex flex-col items-center justify-center h-[60vh]">
|
||||||
<div class="text-gray-500 text-lg font-semibold mb-4">سبد خرید شما خالی است</div>
|
<div class="text-gray-500 text-lg font-semibold mb-4">سبد خرید شما خالی است</div>
|
||||||
<BasicButton type="primary" @click="$router.push({ name: 'buyProduct' })">
|
<BasicButton type="primary" @click="$router.push({ name: 'buyProduct' })">
|
||||||
مشاهده محصولات
|
مشاهده محصولات
|
||||||
</BasicButton>
|
</BasicButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Cart Items -->
|
<!-- Cart Items -->
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="space-y-4 mb-20">
|
<div class="space-y-4 mb-20">
|
||||||
<div
|
<div
|
||||||
v-for="item in cartStore.cartItems"
|
v-for="item in cartStore.cartItems"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="bg-white rounded-lg border border-gray-200 p-4 shadow-sm"
|
class="bg-white rounded-lg border border-gray-200 p-4 shadow-sm"
|
||||||
>
|
>
|
||||||
<div class="flex gap-4">
|
<div class="flex gap-4">
|
||||||
<!-- Product Image -->
|
<!-- Product Image -->
|
||||||
<div class="bg-gray-100 rounded-lg flex justify-center items-center p-3 min-w-[80px] h-[80px]">
|
<div class="bg-gray-100 rounded-lg flex justify-center items-center p-1 min-w-[80px] h-[80px]">
|
||||||
<img
|
<img
|
||||||
:src="getProductImage(item.product.group_type)"
|
:src="getProductImage(item.product)"
|
||||||
class="max-w-full max-h-full object-contain"
|
class="max-w-full max-h-full object-contain"
|
||||||
alt=""
|
alt=""
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Product Info -->
|
||||||
|
<div class="flex-1 flex flex-col justify-between">
|
||||||
|
<div>
|
||||||
|
<div class="text-base font-semibold mb-1">{{ item.product.title }}</div>
|
||||||
|
<!-- <div class="text-xs text-gray-500 mb-2">-->
|
||||||
|
<!-- {{ getProductAmount(item.product.amount) }}-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<div class="text-xs text-gray-500 mb-2">
|
||||||
|
روش پرداخت: {{ item.method === 'cash' ? 'نقدی' : 'طلایی' }}
|
||||||
|
<span v-if="item.method === 'cash' && item.gateway" class="mr-2">(با درگاه)</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-xs text-gray-500">
|
||||||
|
تعداد: {{ item.quantity }} عدد
|
||||||
|
<span v-if="item.goldVazn" class="mr-2">| وزن: {{ formatWeight(item.goldVazn) }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Product Info -->
|
<div class="flex items-center justify-between mt-2">
|
||||||
<div class="flex-1 flex flex-col justify-between">
|
<div class="text-primary font-bold">
|
||||||
<div>
|
{{ usePrice(item.totalPrice) }}
|
||||||
<div class="text-base font-semibold mb-1">{{ item.product.title }}</div>
|
|
||||||
<!-- <div class="text-xs text-gray-500 mb-2">-->
|
|
||||||
<!-- {{ getProductAmount(item.product.amount) }}-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<div class="text-xs text-gray-500 mb-2">
|
|
||||||
روش پرداخت: {{ item.method === 'cash' ? 'نقدی' : 'طلایی' }}
|
|
||||||
<span v-if="item.method === 'cash' && item.gateway" class="mr-2">(با درگاه)</span>
|
|
||||||
</div>
|
|
||||||
<div class="text-xs text-gray-500">
|
|
||||||
تعداد: {{ item.quantity }} عدد
|
|
||||||
<span v-if="item.goldVazn" class="mr-2">| وزن: {{ formatWeight(item.goldVazn) }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<BasicIcon
|
||||||
<div class="flex items-center justify-between mt-2">
|
|
||||||
<div class="text-primary font-bold">
|
|
||||||
{{ usePrice(item.totalPrice) }}
|
|
||||||
</div>
|
|
||||||
<BasicIcon
|
|
||||||
icon="vuesax-linear:trash"
|
icon="vuesax-linear:trash"
|
||||||
class="text-red-500 cursor-pointer"
|
class="text-red-500 cursor-pointer"
|
||||||
@click.stop="handleRemoveItem(item.id)"
|
@click.stop="handleRemoveItem(item.id)"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Total and Checkout -->
|
<!-- Total and Checkout -->
|
||||||
<div class="fixed bottom-20 left-0 right-0 bg-white border-t border-gray-200 p-4 shadow-lg z-1">
|
<div class="fixed bottom-20 left-0 right-0 bg-white border-t border-gray-200 p-4 shadow-lg z-1">
|
||||||
<div class="flex justify-between items-center mb-4">
|
<div class="flex justify-between items-center mb-4">
|
||||||
<div class="text-lg font-semibold">مجموع:</div>
|
<div class="text-lg font-semibold">مجموع:</div>
|
||||||
|
<div class="flex flex-col gap-2 ">
|
||||||
<div class="text-primary font-bold text-xl">
|
<div class="text-primary font-bold text-xl">
|
||||||
{{ usePrice(totalPrice) }}
|
{{ usePrice(displaytotalPrice) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<BasicButton
|
|
||||||
|
<div class="!text-primary font-bold text-xs line-through cursor-pointer "
|
||||||
|
v-if="discountInfo?.amount>0"
|
||||||
|
@click="showDiscountModal=true">
|
||||||
|
{{ usePrice(totalPrice) }}
|
||||||
|
</div>
|
||||||
|
<div v-else
|
||||||
|
class="!text-primary font-bold text-xs underline-solid underline cursor-pointer"
|
||||||
|
@click="showDiscountModal=true">
|
||||||
|
کد تخفیف دارم
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<BasicButton
|
||||||
class="w-full py-3"
|
class="w-full py-3"
|
||||||
type="primary"
|
type="primary"
|
||||||
size="large"
|
size="large"
|
||||||
@click="handleCheckout"
|
@click="handleCheckout"
|
||||||
>
|
>
|
||||||
تسویه حساب
|
تسویه حساب
|
||||||
</BasicButton>
|
</BasicButton>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<AModal v-model:visible="showDiscountModal" ok-text="اعمال کد تخفیف" cancel-text="انصراف" @ok="submitDiscount"
|
||||||
|
@cancel="showDiscountModal=false">
|
||||||
|
<div class="p-5">
|
||||||
|
<div>کد تخفیف</div>
|
||||||
|
<AInput v-model:value="discountCode"></AInput>
|
||||||
|
<div class="font-bold text-xs mt-3">
|
||||||
|
*حساس به حروف بزرگ و کوچک
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</AModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, onUnmounted, watch, computed } from 'vue'
|
import {ref, onMounted, onUnmounted, watch, computed} from 'vue'
|
||||||
import { useCartStore } from '@/store/cartStore'
|
import {useCartStore} from '@/store/cartStore'
|
||||||
import { usePrice, usePriceWithoutType } from '@/utils/usePrice'
|
import {usePrice, usePriceWithoutType} from '@/utils/usePrice'
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
import { message, Modal } from 'ant-design-vue'
|
import {message, Modal} from 'ant-design-vue'
|
||||||
import img from '@/assets/img/user_ly1.svg'
|
import img from '@/assets/img/user_ly1.svg'
|
||||||
import {
|
import {
|
||||||
getLastPrices,
|
getLastPrices,
|
||||||
@@ -110,12 +136,12 @@ import {
|
|||||||
stopPriceInterval,
|
stopPriceInterval,
|
||||||
setIntervalGetLastPrice
|
setIntervalGetLastPrice
|
||||||
} from '@/utils/price'
|
} from '@/utils/price'
|
||||||
import { checkoutCart } from '@/api/card'
|
import {checkoutCart} from '@/api/card'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { useWalletStore } from '@/store/walletStore'
|
import {useWalletStore} from '@/store/walletStore'
|
||||||
import { useFundUserStore } from '@/store/fundStore'
|
import {useFundUserStore} from '@/store/fundStore'
|
||||||
import type { Price } from '@/models/home'
|
import type {Price} from '@/models/home'
|
||||||
import type { Order } from '@/models/order'
|
import type {Order} from '@/models/order'
|
||||||
|
|
||||||
// Image imports
|
// Image imports
|
||||||
import defaultImg from '@/assets/img/defaultAbshodeh.svg'
|
import defaultImg from '@/assets/img/defaultAbshodeh.svg'
|
||||||
@@ -124,13 +150,19 @@ import mokaabImg from '@/assets/img/mokaabImg.svg'
|
|||||||
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
||||||
import parsianImg from '@/assets/img/parsianImg.svg'
|
import parsianImg from '@/assets/img/parsianImg.svg'
|
||||||
import venusImg from '@/assets/img/venousImg.svg'
|
import venusImg from '@/assets/img/venousImg.svg'
|
||||||
import { loading, getToken } from '@/utils'
|
import {loading, getToken} from '@/utils'
|
||||||
import GoldLoading from '@/components/GoldLoading.vue'
|
import GoldLoading from '@/components/GoldLoading.vue'
|
||||||
|
import {registerCodeDiscount} from "@/api/giftCard";
|
||||||
|
|
||||||
const cartStore = useCartStore()
|
const cartStore = useCartStore()
|
||||||
const walletStore = useWalletStore()
|
const walletStore = useWalletStore()
|
||||||
const fundStore = useFundUserStore()
|
const fundStore = useFundUserStore()
|
||||||
const infoVisible = ref(false)
|
const infoVisible = ref(false)
|
||||||
|
const showDiscountModal = ref(false)
|
||||||
|
const discountCode = ref<string>('')
|
||||||
|
const discountInfo = ref()
|
||||||
|
let totalPriceWithDiscount = 0
|
||||||
|
|
||||||
const price = computed((): Price => <Price>lastPrice.value ?? 0)
|
const price = computed((): Price => <Price>lastPrice.value ?? 0)
|
||||||
|
|
||||||
// Watch for price updates and update cart items
|
// Watch for price updates and update cart items
|
||||||
@@ -139,33 +171,62 @@ watch(lastPrice, () => {
|
|||||||
cartStore.cartItems.forEach((item) => {
|
cartStore.cartItems.forEach((item) => {
|
||||||
const product = item.product
|
const product = item.product
|
||||||
let newPrice = 0
|
let newPrice = 0
|
||||||
|
|
||||||
if (product.group_type == 'آبشده') {
|
if (product.group_type == 'آبشده') {
|
||||||
newPrice = lastPrice.value?.price_last ?? 0
|
newPrice = lastPrice.value?.price_last ?? 0
|
||||||
} else {
|
} else {
|
||||||
newPrice = product.amount * (lastPrice.value?.price_last ?? 0)
|
newPrice = product.amount * (lastPrice.value?.price_last ?? 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update product price
|
// Update product price
|
||||||
product.price = newPrice
|
product.price = newPrice
|
||||||
product.sellPrice = product.amount * (lastPrice.value?.sell ?? 0)
|
product.sellPrice = product.amount * (lastPrice.value?.sell ?? 0)
|
||||||
|
|
||||||
// Update item price and total price
|
// Update item price and total price
|
||||||
item.price = newPrice + (product.cash_fee_buy ?? 0)
|
item.price = newPrice + (product.cash_fee_buy ?? 0)
|
||||||
item.totalPrice = item.price * item.quantity
|
item.totalPrice = parseInt(item.price * item.quantity)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Save updated prices to storage
|
// Save updated prices to storage
|
||||||
cartStore.saveCartToStorage()
|
cartStore.saveCartToStorage()
|
||||||
}
|
}
|
||||||
}, { deep: true, immediate: false })
|
}, {deep: true, immediate: false})
|
||||||
|
|
||||||
// Computed total price that updates with price changes
|
// Computed total price that updates with price changes
|
||||||
const totalPrice = computed(() => {
|
const totalPrice = computed(() => {
|
||||||
return cartStore.cartItems.reduce((sum, item) => sum + item.totalPrice, 0)
|
return parseInt(cartStore.cartItems.reduce((sum, item) => sum + item.totalPrice, 0))
|
||||||
|
})
|
||||||
|
const displaytotalPrice = computed(() => {
|
||||||
|
if (discountInfo.value?.amount > 0) {
|
||||||
|
return (totalPrice.value - (totalPrice.value * discountInfo.value?.amount)).toFixed(0)
|
||||||
|
|
||||||
|
} else
|
||||||
|
return totalPrice.value
|
||||||
})
|
})
|
||||||
|
|
||||||
function getProductImage(type?: string) {
|
async function submitDiscount() {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
const temp = await registerCodeDiscount(discountCode.value)
|
||||||
|
discountInfo.value = temp.giftcard
|
||||||
|
message.success('کد تخفیف با موفقیت اعمال شد')
|
||||||
|
showDiscountModal.value = false
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProductImage(product: any) {
|
||||||
|
// Check if product has file field from server with src property
|
||||||
|
if (product?.file?.src) {
|
||||||
|
return product.file.src
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to local images based on group_type if file is empty or doesn't exist
|
||||||
|
const type = product?.group_type
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'گوی':
|
case 'گوی':
|
||||||
return goyImg
|
return goyImg
|
||||||
@@ -231,62 +292,65 @@ async function handleCheckout() {
|
|||||||
// Check if user is logged in
|
// Check if user is logged in
|
||||||
if (!getToken()) {
|
if (!getToken()) {
|
||||||
message.warning('برای تسویه حساب، لطفا ابتدا وارد حساب کاربری خود شوید')
|
message.warning('برای تسویه حساب، لطفا ابتدا وارد حساب کاربری خود شوید')
|
||||||
await router.push({ name: 'login' })
|
await router.push({name: 'login'})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cartStore.itemCount === 0) {
|
if (cartStore.itemCount === 0) {
|
||||||
message.warning('سبد خرید شما خالی است')
|
message.warning('سبد خرید شما خالی است')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lastPrice.value) {
|
if (!lastPrice.value) {
|
||||||
message.error('لطفا منتظر بمانید تا قیمتها بارگذاری شوند')
|
message.error('لطفا منتظر بمانید تا قیمتها بارگذاری شوند')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check wallet balance for cash method items (without gateway)
|
// Check wallet balance for cash method items (without gateway)
|
||||||
const cashItemsTotal = cartStore.cartItems
|
let cashItemsTotal = cartStore.cartItems
|
||||||
.filter(item => item.method === 'cash' && !item.gateway)
|
.filter(item => item.method === 'cash' && !item.gateway)
|
||||||
.reduce((sum, item) => sum + item.totalPrice, 0)
|
.reduce((sum, item) => parseInt(sum + item.totalPrice), 0)
|
||||||
|
|
||||||
if (cashItemsTotal > 0) {
|
if (cashItemsTotal > 0) {
|
||||||
// Ensure wallet info is loaded
|
// Ensure wallet info is loaded
|
||||||
|
if (discountInfo.value.amount>0){
|
||||||
|
cashItemsTotal=cashItemsTotal-cashItemsTotal*discountInfo.value.amount
|
||||||
|
}
|
||||||
if (!walletStore.walletInfo) {
|
if (!walletStore.walletInfo) {
|
||||||
await walletStore.getMyWallet()
|
await walletStore.getMyWallet()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!walletStore.walletInfo?.cash || cashItemsTotal > walletStore.walletInfo.cash) {
|
if (!walletStore.walletInfo?.cash || cashItemsTotal > walletStore.walletInfo.cash) {
|
||||||
message.error('موجودی کیف پول شما ناکافی است')
|
message.error('موجودی کیف پول شما ناکافی است')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check gold balance for gold method items
|
// Check gold balance for gold method items
|
||||||
const goldItemsTotal = cartStore.cartItems
|
const goldItemsTotal = cartStore.cartItems
|
||||||
.filter(item => item.method === 'gold')
|
.filter(item => item.method === 'gold')
|
||||||
.reduce((sum, item) => {
|
.reduce((sum, item) => {
|
||||||
// Calculate total gold weight needed
|
// Calculate total gold weight needed
|
||||||
const goldWeight = item.goldVazn ? item.goldVazn * item.quantity : 0
|
const goldWeight = item.goldVazn ? item.goldVazn * item.quantity : 0
|
||||||
return sum + goldWeight
|
return sum + goldWeight
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|
||||||
if (goldItemsTotal > 0) {
|
if (goldItemsTotal > 0) {
|
||||||
// Ensure wallet info is loaded
|
// Ensure wallet info is loaded
|
||||||
if (!walletStore.walletInfo) {
|
if (!walletStore.walletInfo) {
|
||||||
await walletStore.getMyWallet()
|
await walletStore.getMyWallet()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!walletStore.walletInfo?.gold || goldItemsTotal > walletStore.walletInfo.gold) {
|
if (!walletStore.walletInfo?.gold || goldItemsTotal > walletStore.walletInfo.gold) {
|
||||||
message.error('موجودی کیف طلا شما ناکافی است')
|
message.error('موجودی کیف طلا شما ناکافی است')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
infoVisible.value = true
|
infoVisible.value = true
|
||||||
|
|
||||||
// Prepare orders array with same structure as createOrder for each product
|
// Prepare orders array with same structure as createOrder for each product
|
||||||
const orders: Order[] = cartStore.cartItems.map(item => {
|
const orders: Order[] = cartStore.cartItems.map(item => {
|
||||||
const product = item.product
|
const product = item.product
|
||||||
@@ -297,21 +361,22 @@ async function handleCheckout() {
|
|||||||
} else {
|
} else {
|
||||||
productPrice = (product.amount ?? 0) * (lastPrice.value?.price_last ?? 0)
|
productPrice = (product.amount ?? 0) * (lastPrice.value?.price_last ?? 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
direction: 1, // 1 for buy (cart items are always buy orders)
|
direction: 1, // 1 for buy (cart items are always buy orders)
|
||||||
price: productPrice,
|
price: productPrice,
|
||||||
amount: item.quantity,
|
amount: product.amount,
|
||||||
gateway: item.gateway,
|
gateway: item.gateway,
|
||||||
product_id: product.id,
|
product_id: product.id,
|
||||||
method: item.method,
|
method: item.method,
|
||||||
number: item.quantity
|
number: item.quantity,
|
||||||
|
discount_code:discountInfo.value.code
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Call checkoutCart API with orders array
|
// Call checkoutCart API with orders array
|
||||||
const data = await checkoutCart(orders)
|
const data = await checkoutCart(orders)
|
||||||
|
|
||||||
// Check for returnUrl (gateway payment)
|
// Check for returnUrl (gateway payment)
|
||||||
let returnUrl = null
|
let returnUrl = null
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
@@ -322,17 +387,17 @@ async function handleCheckout() {
|
|||||||
} else if (data?.returnUrl) {
|
} else if (data?.returnUrl) {
|
||||||
returnUrl = data.returnUrl
|
returnUrl = data.returnUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
// If returnUrl exists, redirect to gateway and stop execution
|
// If returnUrl exists, redirect to gateway and stop execution
|
||||||
if (returnUrl) {
|
if (returnUrl) {
|
||||||
window.location.href = returnUrl
|
window.location.href = returnUrl
|
||||||
return // Stop execution here
|
return // Stop execution here
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no gateway, continue with normal flow
|
// If no gateway, continue with normal flow
|
||||||
await walletStore.getMyWallet()
|
await walletStore.getMyWallet()
|
||||||
cartStore.clearCart()
|
cartStore.clearCart()
|
||||||
await router.push({ name: 'transactions' })
|
await router.push({name: 'transactions'})
|
||||||
message.success('سفارشات شما با موفقیت ثبت شد')
|
message.success('سفارشات شما با موفقیت ثبت شد')
|
||||||
await fundStore.getMyFund()
|
await fundStore.getMyFund()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@@ -348,28 +413,28 @@ async function initPrice() {
|
|||||||
try {
|
try {
|
||||||
await getLastPrices()
|
await getLastPrices()
|
||||||
await setIntervalGetLastPrice()
|
await setIntervalGetLastPrice()
|
||||||
|
|
||||||
// Update prices for all cart items
|
// Update prices for all cart items
|
||||||
if (lastPrice.value && cartStore.cartItems.length > 0) {
|
if (lastPrice.value && cartStore.cartItems.length > 0) {
|
||||||
cartStore.cartItems.forEach((item) => {
|
cartStore.cartItems.forEach((item) => {
|
||||||
const product = item.product
|
const product = item.product
|
||||||
let newPrice = 0
|
let newPrice = 0
|
||||||
|
|
||||||
if (product.group_type == 'آبشده') {
|
if (product.group_type == 'آبشده') {
|
||||||
newPrice = lastPrice.value?.price_last ?? 0
|
newPrice = lastPrice.value?.price_last ?? 0
|
||||||
} else {
|
} else {
|
||||||
newPrice = product.amount * (lastPrice.value?.price_last ?? 0)
|
newPrice = product.amount * (lastPrice.value?.price_last ?? 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update product price
|
// Update product price
|
||||||
product.price = newPrice
|
product.price = newPrice
|
||||||
product.sellPrice = product.amount * (lastPrice.value?.sell ?? 0)
|
product.sellPrice = product.amount * (lastPrice.value?.sell ?? 0)
|
||||||
|
|
||||||
// Update item price and total price
|
// Update item price and total price
|
||||||
item.price = newPrice + (product.cash_fee_buy ?? 0)
|
item.price = newPrice + (product.cash_fee_buy ?? 0)
|
||||||
item.totalPrice = item.price * item.quantity
|
item.totalPrice = parseInt(item.price * item.quantity)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Save updated prices to storage
|
// Save updated prices to storage
|
||||||
cartStore.saveCartToStorage()
|
cartStore.saveCartToStorage()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<div class="ml-1 text-base text-black">{{ info?.wallet[0]?.gold }}</div>
|
<div class="ml-1 text-base text-black">{{ info?.wallet[0]?.gold }}</div>
|
||||||
گرم
|
گرم
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="rialEquivalent !== null" class="mt-1 text-xs text-gray-400">
|
||||||
|
{{ usePriceWithoutType(rialEquivalent) }} ریال
|
||||||
|
</div>
|
||||||
<div class="text-gray-400">موجودی قلک {{ info?.title }}</div>
|
<div class="text-gray-400">موجودی قلک {{ info?.title }}</div>
|
||||||
<div class="w-full p-5">
|
<div class="w-full p-5">
|
||||||
<div class="w-full flex gap-3">
|
<div class="w-full flex gap-3">
|
||||||
@@ -145,6 +148,8 @@ import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
|||||||
import DialogVant from '@/components/DialogVant.vue'
|
import DialogVant from '@/components/DialogVant.vue'
|
||||||
import { useFundUserStore } from '@/store/fundStore'
|
import { useFundUserStore } from '@/store/fundStore'
|
||||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import { getLastPrices, lastPrice } from '@/utils/price'
|
||||||
|
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||||
|
|
||||||
const info = ref<Fund>()
|
const info = ref<Fund>()
|
||||||
const items = ref<Transaction[]>([])
|
const items = ref<Transaction[]>([])
|
||||||
@@ -159,8 +164,16 @@ let fundStore = useFundUserStore()
|
|||||||
let walletStore = useWalletStore()
|
let walletStore = useWalletStore()
|
||||||
|
|
||||||
|
|
||||||
|
const rialEquivalent = computed(() => {
|
||||||
|
const unit = Number(lastPrice.value?.price_last ?? 0)
|
||||||
|
if (!unit) return null
|
||||||
|
const gold = Number(info.value?.wallet?.[0]?.gold ?? 0)
|
||||||
|
return Math.round(gold * unit)
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initInfo()
|
initInfo()
|
||||||
|
if (!lastPrice.value) getLastPrices()
|
||||||
// initTable()
|
// initTable()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="bg-white py-3 px-3 text-black font-bold drop-shadow z-[1999] wrap-fix">کارت هدیه</div>
|
||||||
|
<div class="px-5 pt-26 pb-2">
|
||||||
|
<a-form :model="form" class="!mt-5" name="basic" @finish="registerGiftCard">
|
||||||
|
<div class="border-gray-200 border-1 rounded-xl p-5 trans h-40 relative">
|
||||||
|
<bg_main/>
|
||||||
|
<div class="z-100 relative">
|
||||||
|
<a-form-item :rules="[required()]" label="کد کارت هدیه" name="code">
|
||||||
|
<BasicInput
|
||||||
|
v-model:value="form.code"
|
||||||
|
place-holder="کد کارت هدیه را وارد کنید"
|
||||||
|
size="large"
|
||||||
|
type="text"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<div class="font-bold text-xs mt-1">
|
||||||
|
کد کارت هدیه خود را در فیلد بالا وارد کنید و سپس دکمه ثبت را بزنید.
|
||||||
|
</div>
|
||||||
|
<div class="font-bold text-xs mt-3">
|
||||||
|
*حساس به حروف بزرگ و کوچک
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a-form-item>
|
||||||
|
<BasicButton
|
||||||
|
:disabled="disableButton"
|
||||||
|
class="w-full py-2 mt-5"
|
||||||
|
html-type="submit"
|
||||||
|
type="primary"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<a-spin v-if="loading" size="small"/>
|
||||||
|
<div v-else>ثبت کد</div>
|
||||||
|
</div>
|
||||||
|
</BasicButton>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import {computed, ref} from 'vue'
|
||||||
|
import {loading} from '@/utils'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import Bg_main from '@/components/bg_main.vue'
|
||||||
|
import {registerCodeGiftCard} from '@/api/giftCard'
|
||||||
|
import {message} from 'ant-design-vue'
|
||||||
|
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||||
|
import {required} from '@/utils/inputRules'
|
||||||
|
|
||||||
|
const form = ref<{ code: string }>({
|
||||||
|
code: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const disableButton = computed(() => {
|
||||||
|
if (!loading.value) {
|
||||||
|
return !form.value.code || form.value.code.trim().length === 0
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
async function registerGiftCard() {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
await registerCodeGiftCard(form.value.code)
|
||||||
|
message.success('کد کارت هدیه با موفقیت ثبت شد')
|
||||||
|
form.value.code = ''
|
||||||
|
} catch (e: any) {
|
||||||
|
// message.error(e?.response?.data?.message || 'خطا در ثبت کد کارت هدیه')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -210,7 +210,6 @@ import { useWalletStore } from '@/store/walletStore'
|
|||||||
import { createOrder } from '@/api/order'
|
import { createOrder } from '@/api/order'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import type { Price } from '@/models/home'
|
import type { Price } from '@/models/home'
|
||||||
import { getLastPrice } from '@/api/home'
|
|
||||||
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||||
|
|||||||
+35
-24
@@ -22,27 +22,27 @@
|
|||||||
<div>حساب کاربری</div>
|
<div>حساب کاربری</div>
|
||||||
</div>
|
</div>
|
||||||
</BasicButton>
|
</BasicButton>
|
||||||
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
|
<!-- <BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"-->
|
||||||
@click="$router.push({name: 'notifyTrigger'}); popVisible = false">
|
<!-- @click="$router.push({name: 'notifyTrigger'}); popVisible = false">-->
|
||||||
<div class="flex gap-2 items-center">
|
<!-- <div class="flex gap-2 items-center">-->
|
||||||
<BasicIcon icon="vuesax-linear:bill" size="16" class="absolute right-2" />
|
<!-- <BasicIcon icon="vuesax-linear:bill" size="16" class="absolute right-2" />-->
|
||||||
<div>هشدار قیمت</div>
|
<!-- <div>هشدار قیمت</div>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
</BasicButton>
|
<!-- </BasicButton>-->
|
||||||
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
|
<!-- <BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"-->
|
||||||
@click="$router.push({name: 'transfer'}); popVisible = false">
|
<!-- @click="$router.push({name: 'transfer'}); popVisible = false">-->
|
||||||
<div class="flex gap-2 items-center">
|
<!-- <div class="flex gap-2 items-center">-->
|
||||||
<BasicIcon icon="vuesax-linear:card-send" size="16" class="absolute right-2" />
|
<!-- <BasicIcon icon="vuesax-linear:card-send" size="16" class="absolute right-2" />-->
|
||||||
<div>انتقال قطره</div>
|
<!-- <div>انتقال قطره</div>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
</BasicButton>
|
<!-- </BasicButton>-->
|
||||||
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
|
<!-- <BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"-->
|
||||||
@click="$router.push({name: 'physicalReceive'}); popVisible = false">
|
<!-- @click="$router.push({name: 'physicalReceive'}); popVisible = false">-->
|
||||||
<div class="flex gap-2 items-center">
|
<!-- <div class="flex gap-2 items-center">-->
|
||||||
<BasicIcon icon="vuesax-linear:direct-inbox" size="16" class="absolute right-2" />
|
<!-- <BasicIcon icon="vuesax-linear:direct-inbox" size="16" class="absolute right-2" />-->
|
||||||
<div>دریافت طلای فیزیکی</div>
|
<!-- <div>دریافت طلای فیزیکی</div>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
</BasicButton>
|
<!-- </BasicButton>-->
|
||||||
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
|
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
|
||||||
@click="$router.push({name: 'buyProduct'}); popVisible = false">
|
@click="$router.push({name: 'buyProduct'}); popVisible = false">
|
||||||
<div class="flex gap-2 items-center">
|
<div class="flex gap-2 items-center">
|
||||||
@@ -57,6 +57,13 @@
|
|||||||
<div>لیست دریافتی ها</div>
|
<div>لیست دریافتی ها</div>
|
||||||
</div>
|
</div>
|
||||||
</BasicButton>
|
</BasicButton>
|
||||||
|
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
|
||||||
|
@click="$router.push({name: 'giftCard'}); popVisible = false">
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<BasicIcon icon="vuesax-linear:gift" size="16" class="absolute right-2" />
|
||||||
|
<div>ثبت کارت هدیه</div>
|
||||||
|
</div>
|
||||||
|
</BasicButton>
|
||||||
<BasicButton icon-size="16" class="!font-bold w-15rem"
|
<BasicButton icon-size="16" class="!font-bold w-15rem"
|
||||||
@click="$router.push({name: 'about'}); popVisible = false">
|
@click="$router.push({name: 'about'}); popVisible = false">
|
||||||
<div class="flex gap-2 items-center">
|
<div class="flex gap-2 items-center">
|
||||||
@@ -100,9 +107,13 @@
|
|||||||
<!-- <canvas ref="canvas" id="canvas1" width="400" height="80" class="w-full"></canvas>-->
|
<!-- <canvas ref="canvas" id="canvas1" width="400" height="80" class="w-full"></canvas>-->
|
||||||
<div v-if="isToken()" class="bottom-appbar w-auto mx-auto">
|
<div v-if="isToken()" class="bottom-appbar w-auto mx-auto">
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<div :class="setNavColor('home')" class="tab" @click="setRoute('home')">
|
<!-- <div :class="setNavColor('home')" class="tab" @click="setRoute('home')">-->
|
||||||
<Icon icon="vuesax-linear:home" />
|
<!-- <Icon icon="vuesax-linear:home" />-->
|
||||||
<div class="text-xs mt-1 font-bold">صفحه اصلی</div>
|
<!-- <div class="text-xs mt-1 font-bold">صفحه اصلی</div>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<div :class="setNavColor('buyProduct')" class="tab" @click="setRoute('buyProduct')">
|
||||||
|
<Icon icon="vuesax-linear:coin" />
|
||||||
|
<div class="text-xs mt-1 font-bold">فروشگاه</div>
|
||||||
</div>
|
</div>
|
||||||
<div :class="setNavColor('transactions')" class="tab" @click="setRoute('transactions')">
|
<div :class="setNavColor('transactions')" class="tab" @click="setRoute('transactions')">
|
||||||
<Icon icon="vuesax-linear:receipt-item" />
|
<Icon icon="vuesax-linear:receipt-item" />
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item v-if="isBuy" name="goldValue"
|
<a-form-item v-if="isBuy" name="goldValue"
|
||||||
:rules="[justNumber2(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true, form.gateway)]">
|
:rules="[justNumber4(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true, form.gateway)]">
|
||||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#521620"
|
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#521620"
|
||||||
addon-text-color="white"
|
addon-text-color="white"
|
||||||
place-holder="تعداد"
|
place-holder="تعداد"
|
||||||
@@ -253,7 +253,7 @@ import type { Price } from '@/models/home'
|
|||||||
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||||
import { justNumber, justNumber2, justNumber3, required, ruleNumber } from '@/utils/inputRules'
|
import {justNumber, justNumber2, justNumber3, justNumber4, required, ruleNumber} from '@/utils/inputRules'
|
||||||
import GoldSkeleton from '@/views/base/gold/components/GoldSkeleton.vue'
|
import GoldSkeleton from '@/views/base/gold/components/GoldSkeleton.vue'
|
||||||
import GoldLoading from '@/components/GoldLoading.vue'
|
import GoldLoading from '@/components/GoldLoading.vue'
|
||||||
// import {update} from 'lodash'
|
// import {update} from 'lodash'
|
||||||
@@ -274,10 +274,10 @@ const typeDeal: SelectItem[] = [
|
|||||||
value: 'نقدی',
|
value: 'نقدی',
|
||||||
key: 'cash'
|
key: 'cash'
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
value: ' طلایی',
|
// value: ' طلایی',
|
||||||
key: 'gold'
|
// key: 'gold'
|
||||||
}
|
// }
|
||||||
|
|
||||||
]
|
]
|
||||||
const infoVisible = ref(false)
|
const infoVisible = ref(false)
|
||||||
@@ -558,9 +558,9 @@ const limitedPrice = computed(() => {
|
|||||||
|
|
||||||
function calculateCash(val: number) {
|
function calculateCash(val: number) {
|
||||||
priceErrorVisible.value = false
|
priceErrorVisible.value = false
|
||||||
// console.log(val)
|
console.log("val",val,props?.ProductItem)
|
||||||
if (price.value) {
|
if (price.value) {
|
||||||
form.value.goldVazn = parseFloat((val * (( props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy)))/lastPrice.value?.buy).toFixed(1)
|
form.value.goldVazn = parseFloat((val * props?.ProductItem?.amount).toFixed(3))
|
||||||
console.log(val,props?.ProductItem?.price,props?.ProductItem?.cash_fee_buy,lastPrice.value?.buy)
|
console.log(val,props?.ProductItem?.price,props?.ProductItem?.cash_fee_buy,lastPrice.value?.buy)
|
||||||
if (isBuy.value) {
|
if (isBuy.value) {
|
||||||
if (val){
|
if (val){
|
||||||
@@ -579,7 +579,7 @@ console.log(val,props?.ProductItem?.price,props?.ProductItem?.cash_fee_buy,lastP
|
|||||||
form.value.goldVazn = 0
|
form.value.goldVazn = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(form.value.goldVazn)
|
console.log('goldVazn',form.value.goldVazn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="!props.ProductItem.show"
|
v-if="!props.ProductItem?.inventory || props.ProductItem?.inventory==0"
|
||||||
class="text-xs bg-gray-300 text-gray-600 px-2 py-0.5 rounded-md"
|
class="text-xs bg-gray-300 text-gray-600 px-2 py-0.5 rounded-md"
|
||||||
>
|
>
|
||||||
ناموجود
|
ناموجود
|
||||||
@@ -132,6 +132,12 @@ const amountProduct = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const productImage = computed(() => {
|
const productImage = computed(() => {
|
||||||
|
// Check if product has file field from server with src property
|
||||||
|
if (props.ProductItem?.file?.src) {
|
||||||
|
return props.ProductItem.file.src
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to local images based on group_type if file is empty or doesn't exist
|
||||||
switch (props.ProductItem.group_type) {
|
switch (props.ProductItem.group_type) {
|
||||||
case 'گوی':
|
case 'گوی':
|
||||||
return goyImg
|
return goyImg
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="!props.ProductItem.show"
|
v-if="!props.ProductItem?.inventory || props.ProductItem?.inventory==0"
|
||||||
class="text-xs bg-gray-300 text-gray-600 px-2 py-0.5 rounded-md"
|
class="text-xs bg-gray-300 text-gray-600 px-2 py-0.5 rounded-md"
|
||||||
>
|
>
|
||||||
ناموجود
|
ناموجود
|
||||||
@@ -66,6 +66,12 @@ const amountProduct = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const productImage = computed(() => {
|
const productImage = computed(() => {
|
||||||
|
// Check if product has file field from server with src property
|
||||||
|
if (props.ProductItem?.file?.src) {
|
||||||
|
return props.ProductItem.file.src
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to local images based on group_type if file is empty or doesn't exist
|
||||||
switch (props.ProductItem.group_type) {
|
switch (props.ProductItem.group_type) {
|
||||||
case 'گوی':
|
case 'گوی':
|
||||||
return goyImg
|
return goyImg
|
||||||
|
|||||||
@@ -18,11 +18,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mx-5 pb-30 pt-2 grid grid-cols-2 gap-2" style="color: #1b2b07">
|
<div class="mx-5 pb-30 pt-2 grid grid-cols-2 gap-2" style="color: #1b2b07">
|
||||||
<div class="mt-3 gap-2 " :class="!viewVertical?'col-span-2':''" v-for="item in items">
|
<div class="mt-3 gap-2 " :class="!viewVertical?'col-span-2':''" v-for="item in items?.filter(i => i.show)">
|
||||||
<ProductItemVertical v-if="viewVertical" :ProductItem="item" @click="clickProduct(item)"></ProductItemVertical>
|
<ProductItemVertical v-if="viewVertical" :ProductItem="item" @click="clickProduct(item)"></ProductItemVertical>
|
||||||
<ProductItem v-else class="col-span-2" :ProductItem="item" @click="clickProduct(item)"></ProductItem>
|
<ProductItem v-else class="col-span-2" :ProductItem="item" @click="clickProduct(item)"></ProductItem>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -144,8 +143,8 @@ watch(lastPrice, async () => {
|
|||||||
val.price = lastPrice.value?.price_last
|
val.price = lastPrice.value?.price_last
|
||||||
val.sellPrice = lastPrice.value?.sell
|
val.sellPrice = lastPrice.value?.sell
|
||||||
} else {
|
} else {
|
||||||
val.price = val.amount * lastPrice.value?.price_last
|
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||||
val.sellPrice = val.amount * lastPrice.value?.sell
|
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||||
|
|
||||||
// console.log(lastPrice.value?.price_last + "*" + val.amount + ' ' + val.price)
|
// console.log(lastPrice.value?.price_last + "*" + val.amount + ' ' + val.price)
|
||||||
}
|
}
|
||||||
@@ -154,11 +153,11 @@ watch(lastPrice, async () => {
|
|||||||
if (firstItems.value) {
|
if (firstItems.value) {
|
||||||
firstItems.value.forEach((val) => {
|
firstItems.value.forEach((val) => {
|
||||||
if (val.group_type == 'آبشده') {
|
if (val.group_type == 'آبشده') {
|
||||||
val.price = lastPrice.value?.price_last
|
val.price = parseInt(lastPrice.value?.price_last)
|
||||||
val.sellPrice = lastPrice.value?.sell
|
val.sellPrice = parseInt(lastPrice.value?.sell)
|
||||||
} else {
|
} else {
|
||||||
val.price = val.amount * lastPrice.value?.price_last
|
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||||
val.sellPrice = val.amount * lastPrice.value?.sell
|
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -177,22 +176,22 @@ async function initPrice() {
|
|||||||
if (lastPrice.value && items.value) {
|
if (lastPrice.value && items.value) {
|
||||||
items.value.forEach((val) => {
|
items.value.forEach((val) => {
|
||||||
if (val.group_type == 'آبشده') {
|
if (val.group_type == 'آبشده') {
|
||||||
val.price = lastPrice.value?.price_last
|
val.price = parseInt(lastPrice.value?.price_last)
|
||||||
val.sellPrice = lastPrice.value?.sell
|
val.sellPrice = parseInt(lastPrice.value?.sell)
|
||||||
} else {
|
} else {
|
||||||
val.price = val.amount * lastPrice.value?.price_last
|
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||||
val.sellPrice = val.amount * lastPrice.value?.sell
|
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// Update firstItems as well
|
// Update firstItems as well
|
||||||
if (firstItems.value) {
|
if (firstItems.value) {
|
||||||
firstItems.value.forEach((val) => {
|
firstItems.value.forEach((val) => {
|
||||||
if (val.group_type == 'آبشده') {
|
if (val.group_type == 'آبشده') {
|
||||||
val.price = lastPrice.value?.price_last
|
val.price = parseInt(lastPrice.value?.price_last)
|
||||||
val.sellPrice = lastPrice.value?.sell
|
val.sellPrice =parseInt( lastPrice.value?.sell)
|
||||||
} else {
|
} else {
|
||||||
val.price = val.amount * lastPrice.value?.price_last
|
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||||
val.sellPrice = val.amount * lastPrice.value?.sell
|
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="bottom-0 fixed top-0">
|
<div class="bottom-0 fixed top-0">
|
||||||
<img :src="img" alt="" class="w-inherit" :style="{ backgroundRepeat: 'repeat' }" />
|
<img :src="img" alt="" class="w-inherit" :style="{ backgroundRepeat: 'repeat' }"/>
|
||||||
</div>
|
</div>
|
||||||
<a-spin :spinning="loading">
|
<a-spin :spinning="loading">
|
||||||
<div class="!h-full overflow-y-scroll">
|
<div class="!h-full overflow-y-scroll">
|
||||||
<div class="mx-5 pb-30 pt-5" style="color: #1b2b07">
|
<div class="mx-5 pb-30 pt-5" style="color: #1b2b07">
|
||||||
<!-- Product Image -->
|
<!-- Product Image -->
|
||||||
<div class="bg-gray-100 rounded-lg w-full flex justify-center p-8 mb-4">
|
<div class="bg-gray-100 rounded-lg w-full flex justify-center mb-4">
|
||||||
<img v-if="product?.group_type == 'گوی'" :src="goyImg" class="max-w-full h-auto" />
|
<img :src="getProductImage(product)" class="max-w-full h-auto"/>
|
||||||
<img v-else-if="product?.group_type == 'مکعب'" :src="mokaabImg" class="max-w-full h-auto" />
|
|
||||||
<img v-else-if="product?.group_type == 'سکه'" :src="sekkeImg" class="max-w-full h-auto" />
|
|
||||||
<img v-else-if="product?.group_type == 'شمش ونوس'" :src="venusImg" class="max-w-full h-auto" />
|
|
||||||
<img v-else-if="product?.group_type == 'سکه پارسیان'" :src="parsianImg" class="max-w-full h-auto" />
|
|
||||||
<img v-else :src="defaultImg" class="max-w-full h-auto" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Product Title -->
|
<!-- Product Title -->
|
||||||
@@ -25,7 +20,7 @@
|
|||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<!-- Buy Button -->
|
<!-- Buy Button -->
|
||||||
<BasicButton
|
<BasicButton
|
||||||
v-if="product?.show && product?.open_buy"
|
v-if="product?.show && product?.open_buy &&(product?.inventory || product?.inventory >0)"
|
||||||
class="w-full py-3 "
|
class="w-full py-3 "
|
||||||
type="primary"
|
type="primary"
|
||||||
size="large"
|
size="large"
|
||||||
@@ -39,6 +34,9 @@
|
|||||||
<div v-else-if="!product?.open_buy" class="text-center text-gray-500 py-4">
|
<div v-else-if="!product?.open_buy" class="text-center text-gray-500 py-4">
|
||||||
خرید این محصول در حال حاضر امکان پذیر نیست
|
خرید این محصول در حال حاضر امکان پذیر نیست
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="!product?.inventory || product?.inventory==0" class="text-center text-gray-500 py-4">
|
||||||
|
ناموجود
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -46,33 +44,33 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Product Description -->
|
<!-- Product Description -->
|
||||||
<div v-if="!product?.description" class="mb-6">
|
<div v-if="product?.description" class="mb-6">
|
||||||
<div class="text-lg font-semibold mb-2">توضیحات محصول:</div>
|
<div class="text-lg font-semibold mb-2">توضیحات محصول:</div>
|
||||||
<!-- <div class="text-base text-gray-700 whitespace-pre-line">{{ product.description }}</div>-->
|
<div class="text-base text-gray-700 whitespace-pre-line">{{ product?.description }}</div>
|
||||||
<div class="text-base text-gray-700 whitespace-pre-line">شمش طلای نقش برجسته ونوس ۱ گرمی انتخابی ظریف و ارزشمند برای سرمایهگذاری و هدیه است. این شمش از طلای خالص با عیار بالا ساخته شده و نقش برجستهی الهه ونوس، نمادی از زیبایی و ظرافت، جلوهای هنری و خاص به آن بخشیده است. وزن دقیق ۱ گرم، ابعاد مناسب و بستهبندی شکیل، این محصول را به گزینهای ایدهآل برای نگهداری ارزش، هدیههای خاص و کلکسیونهای طلا تبدیل میکند. </div>
|
<!-- <div class="text-base text-gray-700 whitespace-pre-line">شمش طلای نقش برجسته ونوس ۱ گرمی انتخابی ظریف و ارزشمند برای سرمایهگذاری و هدیه است. این شمش از طلای خالص با عیار بالا ساخته شده و نقش برجستهی الهه ونوس، نمادی از زیبایی و ظرافت، جلوهای هنری و خاص به آن بخشیده است. وزن دقیق ۱ گرم، ابعاد مناسب و بستهبندی شکیل، این محصول را به گزینهای ایدهآل برای نگهداری ارزش، هدیههای خاص و کلکسیونهای طلا تبدیل میکند. </div>-->
|
||||||
</div>
|
</div>
|
||||||
<!-- Similar Products -->
|
<!-- Similar Products -->
|
||||||
<div v-if="product?.similar?.length" class="mt-8">
|
<div v-if="product?.similar?.length" class="mt-8">
|
||||||
<div class="text-lg font-semibold mb-4">محصولات مشابه</div>
|
<div class="text-lg font-semibold mb-4">محصولات مشابه</div>
|
||||||
|
|
||||||
<swiper
|
<swiper
|
||||||
:slides-per-view="2.25"
|
:slides-per-view="2.25"
|
||||||
:space-between="16"
|
:space-between="16"
|
||||||
class="similar-products-swiper"
|
class="similar-products-swiper"
|
||||||
>
|
>
|
||||||
<swiper-slide
|
<swiper-slide
|
||||||
v-for="item in product.similar"
|
v-for="item in product.similar"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="bg-white rounded-lg shadow p-4 cursor-pointer h-full"
|
class="bg-white rounded-lg shadow p-4 cursor-pointer h-full"
|
||||||
@click="goToProduct(item.id)"
|
@click="goToProduct(item.id)"
|
||||||
>
|
>
|
||||||
<!-- Image -->
|
<!-- Image -->
|
||||||
<div class="bg-gray-100 rounded-md flex justify-center p-4 mb-2">
|
<div class="bg-gray-100 rounded-md flex justify-center p-4 mb-2">
|
||||||
<img
|
<img
|
||||||
:src="getProductImage(item.group_type)"
|
:src="getProductImage(item)"
|
||||||
class="h-20 object-contain"
|
class="h-20 object-contain"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -80,11 +78,17 @@
|
|||||||
<div class="text-sm font-semibold mb-1 line-clamp-2">
|
<div class="text-sm font-semibold mb-1 line-clamp-2">
|
||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Price -->
|
<!-- Price -->
|
||||||
<div class="text-sm text-primary font-bold">
|
<div class="text-sm text-primary font-bold mb-3">
|
||||||
{{ usePrice((item.price ?? 0) + (item.cash_fee_buy ?? 0)) }}
|
{{ usePrice((item.price ?? 0) + (item.cash_fee_buy ?? 0)) }}
|
||||||
</div>
|
</div>
|
||||||
|
<span
|
||||||
|
v-if="item.inventory || item.inventory==0"
|
||||||
|
class="text-xs bg-gray-300 text-gray-600 px-1 py-0.5 rounded-md "
|
||||||
|
>
|
||||||
|
ناموجود
|
||||||
|
</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</swiper-slide>
|
</swiper-slide>
|
||||||
</swiper>
|
</swiper>
|
||||||
@@ -106,24 +110,24 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {onMounted, onUnmounted, ref, computed, watch} from 'vue'
|
import {onMounted, onUnmounted, ref, computed, watch} from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
import {getProductById, getProducts} from '@/api/products'
|
import {getProductById, getProducts} from '@/api/products'
|
||||||
import { loading, getToken } from '@/utils'
|
import {loading, getToken} from '@/utils'
|
||||||
import type { Product } from '@/models/products'
|
import type {Product} from '@/models/products'
|
||||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||||
import indexGold from '@/views/base/gold/index.vue'
|
import indexGold from '@/views/base/gold/index.vue'
|
||||||
import DealProduct from '@/views/base/products/components/DealProduct.vue'
|
import DealProduct from '@/views/base/products/components/DealProduct.vue'
|
||||||
import { cloneDeep } from 'lodash'
|
import {cloneDeep} from 'lodash'
|
||||||
import img from '@/assets/img/user_ly1.svg'
|
import img from '@/assets/img/user_ly1.svg'
|
||||||
import { message } from 'ant-design-vue'
|
import {message} from 'ant-design-vue'
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
import { usePrice } from '@/utils/usePrice'
|
import {usePrice} from '@/utils/usePrice'
|
||||||
import {
|
import {
|
||||||
getLastPrices,
|
getLastPrices,
|
||||||
lastPrice,
|
lastPrice,
|
||||||
stopPriceInterval
|
stopPriceInterval
|
||||||
} from '@/utils/price'
|
} from '@/utils/price'
|
||||||
import { Swiper, SwiperSlide } from 'swiper/vue'
|
import {Swiper, SwiperSlide} from 'swiper/vue'
|
||||||
import 'swiper/swiper-bundle.css'
|
import 'swiper/swiper-bundle.css'
|
||||||
|
|
||||||
// Image imports
|
// Image imports
|
||||||
@@ -148,10 +152,11 @@ watch(
|
|||||||
(newId, oldId) => {
|
(newId, oldId) => {
|
||||||
if (newId && newId !== oldId) {
|
if (newId && newId !== oldId) {
|
||||||
loadProduct()
|
loadProduct()
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({top: 0, behavior: 'smooth'})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
async function loadProduct() {
|
async function loadProduct() {
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@@ -160,7 +165,7 @@ async function loadProduct() {
|
|||||||
const foundProduct = products
|
const foundProduct = products
|
||||||
if (!foundProduct) {
|
if (!foundProduct) {
|
||||||
message.error('محصول یافت نشد')
|
message.error('محصول یافت نشد')
|
||||||
router.push({ name: 'buyProduct' })
|
router.push({name: 'buyProduct'})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
product.value = foundProduct
|
product.value = foundProduct
|
||||||
@@ -169,7 +174,7 @@ async function loadProduct() {
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
if (e?.response?.status === 401) {
|
if (e?.response?.status === 401) {
|
||||||
message.warning('برای مشاهده محصولات، لطفا ابتدا وارد حساب کاربری خود شوید')
|
message.warning('برای مشاهده محصولات، لطفا ابتدا وارد حساب کاربری خود شوید')
|
||||||
router.push({ name: 'login' })
|
router.push({name: 'login'})
|
||||||
} else {
|
} else {
|
||||||
message.error('خطا در بارگذاری محصول')
|
message.error('خطا در بارگذاری محصول')
|
||||||
}
|
}
|
||||||
@@ -178,17 +183,36 @@ async function loadProduct() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(lastPrice, async () => {
|
||||||
|
// console.log(items);
|
||||||
|
if (lastPrice.value && product.value.similar) {
|
||||||
|
product.value.similar.forEach((val) => {
|
||||||
|
// console.log(lastPrice.value)
|
||||||
|
if (val.group_type == 'آبشده') {
|
||||||
|
val.price = lastPrice.value?.price_last
|
||||||
|
val.sellPrice = lastPrice.value?.sell
|
||||||
|
} else {
|
||||||
|
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||||
|
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||||
|
|
||||||
|
// console.log(lastPrice.value?.price_last + "*" + val.amount + ' ' + val.price)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}, {deep: true})
|
||||||
|
|
||||||
async function initPrice() {
|
async function initPrice() {
|
||||||
try {
|
try {
|
||||||
await getLastPrices()
|
await getLastPrices()
|
||||||
loading.value = true
|
loading.value = true
|
||||||
if (lastPrice.value && product.value) {
|
if (lastPrice.value && product.value) {
|
||||||
if (product.value.group_type == 'آبشده') {
|
if (product.value.group_type == 'آبشده') {
|
||||||
product.value.price = lastPrice.value?.price_last
|
product.value.price = parseInt(lastPrice.value?.price_last)
|
||||||
product.value.sellPrice = lastPrice.value?.sell
|
product.value.sellPrice = parseInt(lastPrice.value?.sell)
|
||||||
} else {
|
} else {
|
||||||
product.value.price = product.value.amount * lastPrice.value?.price_last
|
product.value.price = parseInt(product.value.amount * lastPrice.value?.price_last)
|
||||||
product.value.sellPrice = product.value.amount * lastPrice.value?.sell
|
product.value.sellPrice = parseInt(product.value.amount * lastPrice.value?.sell)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@@ -202,7 +226,7 @@ function handleBuyClick() {
|
|||||||
if (!product.value?.show) {
|
if (!product.value?.show) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Check if user is logged in
|
// // Check if user is logged in
|
||||||
// if (!getToken()) {
|
// if (!getToken()) {
|
||||||
// message.warning('برای خرید یا فروش محصولات، لطفا ابتدا وارد حساب کاربری خود شوید')
|
// message.warning('برای خرید یا فروش محصولات، لطفا ابتدا وارد حساب کاربری خود شوید')
|
||||||
@@ -221,11 +245,19 @@ onMounted(() => {
|
|||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
stopPriceInterval()
|
stopPriceInterval()
|
||||||
})
|
})
|
||||||
|
|
||||||
function goToProduct(id: number) {
|
function goToProduct(id: number) {
|
||||||
router.push({ name: 'productDetail', params: { id } })
|
router.push({name: 'productDetail', params: {id}})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProductImage(type?: string) {
|
function getProductImage(product: any) {
|
||||||
|
// Check if product has file field from server with src property
|
||||||
|
if (product?.file?.src) {
|
||||||
|
return product.file.src
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to local images based on group_type if file is empty or doesn't exist
|
||||||
|
const type = product?.group_type
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'گوی':
|
case 'گوی':
|
||||||
return goyImg
|
return goyImg
|
||||||
|
|||||||
@@ -154,15 +154,15 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white">
|
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white items-center">
|
||||||
<a class="w-full" href="tel:09128081392">
|
<a class="w-full" href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
|
||||||
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
|
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
|
||||||
</a>
|
</a>
|
||||||
<!-- <BasicButton type="primary" @click="$router.push({name: 'permissions'})">
|
<!-- <BasicButton type="primary" @click="$router.push({name: 'permissions'})">
|
||||||
<div>مجوز ها</div>
|
<div>مجوز ها</div>
|
||||||
</BasicButton>-->
|
</BasicButton>-->
|
||||||
<a href="https://t.me/ghatreh">
|
<a href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
|
||||||
<img src="@/assets/img/telegram.png" alt="" class="h-10 w-10"/>
|
<img src="@/assets/img/rubika.webp" alt="" class="w-12"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -93,16 +93,16 @@
|
|||||||
<div>آدرس ها</div>
|
<div>آدرس ها</div>
|
||||||
</div>
|
</div>
|
||||||
</BasicButton>-->
|
</BasicButton>-->
|
||||||
<BasicButton
|
<!-- <BasicButton-->
|
||||||
class="w-full mt-2"
|
<!-- class="w-full mt-2"-->
|
||||||
size="large"
|
<!-- size="large"-->
|
||||||
@click="$router.push({ name: 'notifyTrigger' })"
|
<!-- @click="$router.push({ name: 'notifyTrigger' })"-->
|
||||||
>
|
<!-- >-->
|
||||||
<div class="flex">
|
<!-- <div class="flex">-->
|
||||||
<BasicIcon icon="vuesax-linear:bill" class="absolute right-8" />
|
<!-- <BasicIcon icon="vuesax-linear:bill" class="absolute right-8" />-->
|
||||||
<div>هشدار قیمت</div>
|
<!-- <div>هشدار قیمت</div>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
</BasicButton>
|
<!-- </BasicButton>-->
|
||||||
<BasicButton
|
<BasicButton
|
||||||
class="mt-2 w-full"
|
class="mt-2 w-full"
|
||||||
icon=""
|
icon=""
|
||||||
@@ -151,22 +151,61 @@
|
|||||||
<div>مجوز ها</div>
|
<div>مجوز ها</div>
|
||||||
</div>
|
</div>
|
||||||
</BasicButton>-->
|
</BasicButton>-->
|
||||||
|
<!-- <BasicButton-->
|
||||||
|
<!-- class="mt-2 w-full"-->
|
||||||
|
<!-- icon=""-->
|
||||||
|
<!-- iconSize="18"-->
|
||||||
|
<!-- size="large"-->
|
||||||
|
<!-- @click="$router.push({ name: 'earnMoney' })"-->
|
||||||
|
<!-- >-->
|
||||||
|
<!-- <div class="flex">-->
|
||||||
|
<!-- <BasicIcon icon="vuesax-linear:dollar-circle" class="absolute right-8" />-->
|
||||||
|
<!-- <div>کسب درآمد</div>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<!-- </BasicButton>-->
|
||||||
<BasicButton
|
<BasicButton
|
||||||
class="mt-2 w-full"
|
class="mt-2 w-full"
|
||||||
icon=""
|
icon=""
|
||||||
iconSize="18"
|
iconSize="18"
|
||||||
size="large"
|
size="large"
|
||||||
@click="$router.push({ name: 'earnMoney' })"
|
@click="showLogoutConfirm=!showLogoutConfirm"
|
||||||
>
|
>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<BasicIcon icon="vuesax-linear:dollar-circle" class="absolute right-8" />
|
<Icon
|
||||||
<div>کسب درآمد</div>
|
:color="y > 50 ? '' : ''"
|
||||||
|
class="color-transition absolute right-8"
|
||||||
|
icon="vuesax-linear:logout"
|
||||||
|
@click="showLogoutConfirm = true"
|
||||||
|
/>
|
||||||
|
<div>خروج از حساب کاربری</div>
|
||||||
</div>
|
</div>
|
||||||
</BasicButton>
|
</BasicButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<DialogVant v-model:show="showLogoutConfirm" :closeOnClickOverlay="false" :timeOut="-1">
|
||||||
|
<!-- <template v-slot:img>
|
||||||
|
<img :src="registerDelayImage" alt="" class="opacity-80">
|
||||||
|
</template>-->
|
||||||
|
|
||||||
|
<template v-slot:title>
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<DotLottieVue
|
||||||
|
class="w-11rem h-11rem"
|
||||||
|
autoplay
|
||||||
|
src="https://lottie.host/129cf3a1-df84-4758-a856-58c133ae6013/R5RqclXA8G.json"
|
||||||
|
/>
|
||||||
|
<div class="p-5 text-sm">آیا از خروج خود اطمینان دارید؟</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:button>
|
||||||
|
<div class="text-center text-red flex items-center justify-center" @click="logout">
|
||||||
|
<a-spin :spinning="logoutLoading" size="small"> خروج</a-spin>
|
||||||
|
</div>
|
||||||
|
<div class="text-center" @click="showLogoutConfirm = false">انصراف</div>
|
||||||
|
</template>
|
||||||
|
</DialogVant>
|
||||||
<BasicActionSheet v-model:show="editPassVisible">
|
<BasicActionSheet v-model:show="editPassVisible">
|
||||||
<div class="flex justify-center justify-between">
|
<div class="flex justify-center justify-between">
|
||||||
<div class="font-bold text-lg">ویرایش اطلاعات</div>
|
<div class="font-bold text-lg">ویرایش اطلاعات</div>
|
||||||
@@ -257,7 +296,7 @@
|
|||||||
import { onMounted, reactive, ref, computed } from 'vue'
|
import { onMounted, reactive, ref, computed } from 'vue'
|
||||||
import img from '@/assets/img/user_ly1.svg'
|
import img from '@/assets/img/user_ly1.svg'
|
||||||
import gr_bottom from './assets/img/gr_bottom_white.svg'
|
import gr_bottom from './assets/img/gr_bottom_white.svg'
|
||||||
import { loading } from '@/utils'
|
import {loading, removeToken} from '@/utils'
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||||
import {
|
import {
|
||||||
@@ -277,6 +316,11 @@ import { message } from 'ant-design-vue'
|
|||||||
import { updateMe, updatePass } from '@/api/me'
|
import { updateMe, updatePass } from '@/api/me'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import BaseDatePicker from '@/components/BasicPacks/BaseDatePicker'
|
import BaseDatePicker from '@/components/BasicPacks/BaseDatePicker'
|
||||||
|
import {DotLottieVue} from "@lottiefiles/dotlottie-vue";
|
||||||
|
import DialogVant from "@/components/DialogVant.vue";
|
||||||
|
import {useWalletStore} from "@/store/walletStore";
|
||||||
|
import Icon from "@/components/BasicPacks/BasicIcon.vue";
|
||||||
|
import {useWindowScroll} from "@vueuse/core/index";
|
||||||
const userFormState = ref<User>({
|
const userFormState = ref<User>({
|
||||||
fname: '',
|
fname: '',
|
||||||
lname: '',
|
lname: '',
|
||||||
@@ -291,11 +335,29 @@ const userPassForm = ref<Password>({
|
|||||||
const formRef = ref<FormInstance>()
|
const formRef = ref<FormInstance>()
|
||||||
const formPassRef = ref<FormInstance>()
|
const formPassRef = ref<FormInstance>()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
const showLogoutConfirm = ref<boolean>()
|
||||||
|
const walletStore=useWalletStore()
|
||||||
|
const logoutLoading = ref<boolean>(false)
|
||||||
|
const { x, y } = useWindowScroll()
|
||||||
|
|
||||||
// const editPassVisible = ref<boolean>(false)
|
// const editPassVisible = ref<boolean>(false)
|
||||||
const editPassVisible = ref<boolean>(false)
|
const editPassVisible = ref<boolean>(false)
|
||||||
const editPasswordVisible = ref<boolean>(false)
|
const editPasswordVisible = ref<boolean>(false)
|
||||||
|
|
||||||
|
async function logout() {
|
||||||
|
logoutLoading.value = true
|
||||||
|
// baseConfirm('آیا از حساب کاربری خارج می شوید؟',async () => {
|
||||||
|
userStore.userInfo = undefined
|
||||||
|
walletStore.walletInfo = undefined
|
||||||
|
/* userStore.$reset()
|
||||||
|
walletStore.$reset()*/
|
||||||
|
removeToken()
|
||||||
|
await router.push({ name: 'login' })
|
||||||
|
logoutLoading.value = true
|
||||||
|
window.location.reload()
|
||||||
|
// console.log('salam')
|
||||||
|
// })
|
||||||
|
}
|
||||||
function setForm() {
|
function setForm() {
|
||||||
userFormState.value = userStore.userInfo
|
userFormState.value = userStore.userInfo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -302,7 +302,7 @@
|
|||||||
<span>جهت شارژ حساب کاربری خود، کلمه "شماره حساب" را برای پشتیبانی ارسال نمایید.</span>
|
<span>جهت شارژ حساب کاربری خود، کلمه "شماره حساب" را برای پشتیبانی ارسال نمایید.</span>
|
||||||
</div>
|
</div>
|
||||||
<BasicButton class="mt-4">
|
<BasicButton class="mt-4">
|
||||||
<a class="w-full" href="https://wa.me/989390624220">
|
<a class="w-full" href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
|
||||||
پیام به پشتیبانی
|
پیام به پشتیبانی
|
||||||
</a>
|
</a>
|
||||||
</BasicButton>
|
</BasicButton>
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ async function enterFingerPrint() {
|
|||||||
const fingerPrint = await authenticateWithFingerprint()
|
const fingerPrint = await authenticateWithFingerprint()
|
||||||
if (fingerPrint) {
|
if (fingerPrint) {
|
||||||
setTruth()
|
setTruth()
|
||||||
await router.push({ name: 'home' })
|
await router.push({ name: 'buyProduct' })
|
||||||
} else {
|
} else {
|
||||||
message.error('خطا در اعتبارسنجی')
|
message.error('خطا در اعتبارسنجی')
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ async function login(accessToken: string | undefined) {
|
|||||||
/* if (userStore.userInfo?.type === (URLUserType() === 'customer' ? 1 : 2)) {*/
|
/* if (userStore.userInfo?.type === (URLUserType() === 'customer' ? 1 : 2)) {*/
|
||||||
await walletStore.getMyWallet()
|
await walletStore.getMyWallet()
|
||||||
setTruth()
|
setTruth()
|
||||||
await router.push({ name: 'home' })
|
await router.push({ name: 'buyProduct' })
|
||||||
/* } else {
|
/* } else {
|
||||||
removeToken()
|
removeToken()
|
||||||
userStore.removeInformation()
|
userStore.removeInformation()
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const userFormState = ref<UserMobile>({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function phoneVerification() {
|
function phoneVerification() {
|
||||||
router.push({name: 'home' })
|
router.push({name: 'buyProduct' })
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<!-- <BasicInput v-model:value="userFormState.password" size="large" place-holder="کلمه عبور"/>-->
|
<!-- <BasicInput v-model:value="userFormState.password" size="large" place-holder="کلمه عبور"/>-->
|
||||||
<AInputPassword v-model:value="userFormState.password" place-holder="کلمه عبور" inputmode="decimal"/>
|
<AInputPassword v-model:value="userFormState.password" place-holder="کلمه عبور" inputmode="decimal"/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" label="کد معرف" name="referral_id">
|
<a-form-item class="home_appear_fade_in_down" label="کد معرف" name="referral_id">
|
||||||
<BasicInput :disabled="disableForm" v-model:value="userFormState.referral_id" place-holder="کد معرف"/>
|
<BasicInput :disabled="disableForm" v-model:value="userFormState.referral_id" place-holder="کد معرف"/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<!-- <a-form-item v-if="URLUserType() === 'customer'" :rules="[required()]" class="home_appear_fade_in_down"
|
<!-- <a-form-item v-if="URLUserType() === 'customer'" :rules="[required()]" class="home_appear_fade_in_down"
|
||||||
|
|||||||
Reference in New Issue
Block a user