15 Commits
Author SHA1 Message Date
MojtabaSoumi a9922b33ef 1405/03/21-fix bug in ghatreh 2026-06-11 11:02:50 +03:30
MojtabaSoumi 9ba2d3ec96 1405/01/20-fix bugs in gift card 2026-04-11 18:00:05 +03:30
MojtabaSoumi 1905408993 Merge remote-tracking branch 'origin/main' 2026-04-09 14:01:18 +03:30
MojtabaSoumi 4a9cb2a944 1405/01/20-add giftcard & discount 2026-04-09 13:58:37 +03:30
safavimohadeseh78 54c43fab63 . 2026-03-17 20:34:40 +03:30
safavimohadeseh78 60af57e0ed Merge remote-tracking branch 'origin/main'
# Conflicts:
#	src/views/login/components/Register.vue
2026-02-09 13:47:56 +03:30
MojtabaSoumi 8919374055 1404/11/19-add inventory for product 2026-02-09 13:43:02 +03:30
MojtabaSoumi 71312d809d 1404/11/19-change rule in input buy product 2026-02-08 13:37:10 +03:30
MojtabaSoumi c6c7635041 1404/11/18-delete required rule in referral code &
hidden home page
2026-02-07 17:25:59 +03:30
MojtabaSoumi e630c07d92 1404/11/18-delete required rule in referral code &
hidden home page
2026-02-07 14:02:29 +03:30
MojtabaSoumi 2ffcee9f3a 1404/11/18-delete required rule in referral code 2026-02-07 12:13:25 +03:30
MojtabaSoumi 354c5376b8 1404/11/16-change support link 2026-02-05 11:22:48 +03:30
safavimohadeseh78 3b08bf6714 change referral_id 2026-02-05 10:35:01 +03:30
MojtabaSoumi f18d196e30 1404/11/14-round price 2026-02-03 16:58:17 +03:30
MojtabaSoumi 19a8584fa0 1404/11/11-add description in product 2026-01-31 10:19:21 +03:30
28 changed files with 712 additions and 306 deletions
+1 -4
View File
@@ -7,6 +7,7 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
ABadge: typeof import('ant-design-vue/es')['Badge']
AButton: typeof import('ant-design-vue/es')['Button']
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
ADivider: typeof import('ant-design-vue/es')['Divider']
@@ -15,16 +16,13 @@ declare module 'vue' {
AInput: typeof import('ant-design-vue/es')['Input']
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
AModal: typeof import('ant-design-vue/es')['Modal']
ARadio: typeof import('ant-design-vue/es')['Radio']
ARadioButton: typeof import('ant-design-vue/es')['RadioButton']
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
ASelect: typeof import('ant-design-vue/es')['Select']
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
ASlider: typeof import('ant-design-vue/es')['Slider']
ASpin: typeof import('ant-design-vue/es')['Spin']
ASwitch: typeof import('ant-design-vue/es')['Switch']
ATag: typeof import('ant-design-vue/es')['Tag']
ATextarea: typeof import('ant-design-vue/es')['Textarea']
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
BaseDatePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/BaseDatePicker.vue')['default']
Basic: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/basic.vue')['default']
@@ -68,6 +66,5 @@ declare module 'vue' {
TransactionSkeleton: typeof import('./src/components/TransactionSkeleton.vue')['default']
VanActionSheet: typeof import('vant/es')['ActionSheet']
VanDialog: typeof import('vant/es')['Dialog']
VanField: typeof import('vant/es')['Field']
}
}
+3 -3
View File
@@ -17,7 +17,7 @@
right: 20px;
width: 60px;
height: 60px;
background-color: #25D366;
background-color: #ffffff;
border-radius: 50%;
display: flex;
justify-content: center;
@@ -42,8 +42,8 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<a href="https://wa.me/989390624220" target="_blank" id="whatsapp-button">
<img class="p-2" src="/whatsapp.png" alt="" />
<a href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c" target="_blank" id="whatsapp-button">
<img class="p-2" src="/src/assets/img/rubika.webp" alt="" />
</a>
</body>
</html>
+6
View File
@@ -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})
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

+3 -3
View File
@@ -73,8 +73,8 @@ function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
}
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
if (to.name !== 'home') {
return next({ name: 'home' }) // Redirect to login
if (to.name !== 'buyProduct') {
return next({ name: 'buyProduct' }) // Redirect to login
} else {
return next() // If already on the login page, don't redirect
}
@@ -151,7 +151,7 @@ router.beforeEach(async (to, from, next) => {
if (fingerPosition) {
if (getToken()) {
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
} else {
+1
View File
@@ -26,6 +26,7 @@ export interface Product {
description: string
wallet: Wallet
similar?:Product[]
inventory:number
}
export interface PInventory {
+15 -10
View File
@@ -20,16 +20,16 @@ const router = createRouter({
redirect: {name: 'buyProduct'},
component: () => import('../views/base/index.vue'),
children: [
{
path: 'home',
name: 'home',
component: () => import('../views/base/home/index.vue')
},
{
path: 'gold',
name: 'gold',
component: () => import('@/views/base/gold/index.vue')
},
// {
// path: 'home',
// name: 'home',
// component: () => import('../views/base/home/index.vue')
// },
// {
// path: 'gold',
// name: 'gold',
// component: () => import('@/views/base/gold/index.vue')
// },
{
path: 'buyProduct',
name: 'buyProduct',
@@ -45,6 +45,11 @@ const router = createRouter({
name: 'transactions',
component: () => import('@/views/base/transactions/index.vue')
},
{
path: 'giftCard',
name: 'giftCard',
component: () => import('@/views/base/giftCard/index.vue')
},
{
path: 'wallet',
name: 'wallet',
+58 -1
View File
@@ -2,6 +2,8 @@ import { computed, ref } from 'vue'
import { defineStore } from 'pinia'
import type { CartItem } from '@/models/cart'
import type { Product } from '@/models/products'
import type { Price } from '@/models/home'
import { getProducts } from '@/api/products'
const CART_STORAGE_KEY = 'ghatre_cart'
@@ -93,6 +95,58 @@ export const useCartStore = defineStore('cart', () => {
return cartItems.value.length
})
function syncProductsFromServer(serverProducts: Product[]): number {
const productMap = new Map(serverProducts.map(p => [p.id, p]))
const beforeCount = cartItems.value.length
cartItems.value = cartItems.value
.filter(item => productMap.has(item.product.id))
.map(item => ({
...item,
product: { ...productMap.get(item.product.id)! }
}))
if (cartItems.value.length > 0 || beforeCount > 0) {
saveCartToStorage()
}
return beforeCount - cartItems.value.length
}
function recalculateCartPrices(lastPrice: Price) {
if (!lastPrice || cartItems.value.length === 0) return
cartItems.value.forEach((item) => {
const product = item.product
let newPrice = 0
if (product.group_type == 'آبشده') {
newPrice = lastPrice.price_last ?? 0
} else {
newPrice = product.amount * (lastPrice.price_last ?? 0)
}
product.price = newPrice
product.sellPrice = product.amount * (lastPrice.sell ?? 0)
item.price = newPrice + (product.cash_fee_buy ?? 0)
item.totalPrice = parseInt(String(item.price * item.quantity))
})
saveCartToStorage()
}
async function refreshCartFromServer(): Promise<number> {
if (cartItems.value.length === 0) return 0
try {
const serverProducts: Product[] = await getProducts()
return syncProductsFromServer(serverProducts)
} catch (e) {
console.error('Error refreshing cart from server:', e)
return 0
}
}
return {
cartItems,
addToCart,
@@ -102,7 +156,10 @@ export const useCartStore = defineStore('cart', () => {
totalPrice,
itemCount,
loadCartFromStorage,
saveCartToStorage
saveCartToStorage,
syncProductsFromServer,
recalculateCartPrices,
refreshCartFromServer
}
})
+45 -3
View File
@@ -138,8 +138,6 @@ let isBuyP = true
let NumP = 0
let gatewayP = false
const checkNumber = async (_rule: Rule, value: number) => {
if (!value) {
return Promise.reject('تعداد محصول را مشخص کنید')
}
@@ -168,8 +166,41 @@ const checkNumber = async (_rule: Rule, value: number) => {
else
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) => {
priceP = price
methodP = method
@@ -181,8 +212,8 @@ export const justNumber2 = (price: number, method?: string, amount?: number, isB
validator: checkNumber,
trigger: 'change'
}
}
export const justNumber3 = (price: number, Num?: number, isBuy?: boolean) => {
priceP = price
NumP = Num
@@ -193,6 +224,17 @@ export const justNumber3 = (price: number, Num?: number, isBuy?: boolean) => {
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 = () => {
-1
View File
@@ -20,7 +20,6 @@ export async function setIntervalGetAllPrice() {
} finally {
loading.value = false
}
}
export async function setIntervalGetLastPrice() {
+2 -2
View File
@@ -50,9 +50,9 @@ _axios.interceptors.response.use(
return response.data
},
async function (error) {
// console.log('this is axios error', error)
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)
+4 -4
View File
@@ -66,12 +66,12 @@
</div>
</div>
</div>
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white">
<a class="w-full" href="tel:09128081392">
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white items-center">
<a class="w-full" href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
</a>
<a href="https://t.me/ghatreh">
<img src="@/assets/img/telegram.png" alt="" class="h-10 w-10"/>
<a href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
<img src="@/assets/img/rubika.webp" alt="" class=" w-12"/>
</a>
</div>
</div>
+188 -137
View File
@@ -14,95 +14,129 @@
</div>
</div>
</div>
<GoldLoading v-model:show="infoVisible" title="" />
<div class="px-5 pt-26 pb-30">
<GoldLoading v-model:show="infoVisible" title=""/>
<div class="px-5 pt-26 pb-30" :class="loading ? 'h-[60vh]' : ''">
<template v-if="loading">
<TransactionSkeleton v-for="i in 3" :key="i" class="mt-4" />
</template>
<template v-else>
<!-- Empty Cart Message -->
<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>
<BasicButton type="primary" @click="$router.push({ name: 'buyProduct' })">
مشاهده محصولات
</BasicButton>
</div>
<div class="text-gray-500 text-lg font-semibold mb-4">سبد خرید شما خالی است</div>
<BasicButton type="primary" @click="$router.push({ name: 'buyProduct' })">
مشاهده محصولات
</BasicButton>
</div>
<!-- Cart Items -->
<div v-else>
<div class="space-y-4 mb-20">
<div
<!-- Cart Items -->
<div v-else>
<div class="space-y-4 mb-20">
<div
v-for="item in cartStore.cartItems"
:key="item.id"
class="bg-white rounded-lg border border-gray-200 p-4 shadow-sm"
>
<div class="flex gap-4">
<!-- Product Image -->
<div class="bg-gray-100 rounded-lg flex justify-center items-center p-3 min-w-[80px] h-[80px]">
<img
:src="getProductImage(item.product.group_type)"
>
<div class="flex gap-4">
<!-- Product Image -->
<div class="bg-gray-100 rounded-lg flex justify-center items-center p-1 min-w-[80px] h-[80px]">
<img
:src="getProductImage(item.product)"
class="max-w-full max-h-full object-contain"
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>
<!-- 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 class="flex items-center justify-between mt-2">
<div class="text-primary font-bold">
{{ usePrice(item.totalPrice) }}
</div>
<div class="flex items-center justify-between mt-2">
<div class="text-primary font-bold">
{{ usePrice(item.totalPrice) }}
</div>
<BasicIcon
<BasicIcon
icon="vuesax-linear:trash"
class="text-red-500 cursor-pointer"
@click.stop="handleRemoveItem(item.id)"
/>
</div>
/>
</div>
</div>
</div>
</div>
</div>
<!-- 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">
<!-- Total and Checkout -->
<div class=" flex justify-center fixed bottom-20 left-0 right-0 z-1">
<div class="md:w-[426px] w-full bg-white border-t border-gray-200 p-4 shadow-lg">
<div class="flex justify-between items-center mb-4">
<div class="text-lg font-semibold">مجموع:</div>
<div class="text-primary font-bold text-xl">
<div class="flex flex-col gap-2 ">
<div class="text-primary font-bold text-xl">
{{ usePrice(displaytotalPrice) }}
</div>
</div>
<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"
type="primary"
size="large"
@click="handleCheckout"
class="w-full py-3"
type="primary"
size="large"
@click="handleCheckout"
>
تسویه حساب
</BasicButton>
</div>
</div>
</div>
</template>
</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>
<script setup lang="ts">
import { ref, onMounted, onUnmounted, watch, computed } from 'vue'
import { useCartStore } from '@/store/cartStore'
import { usePrice, usePriceWithoutType } from '@/utils/usePrice'
import {ref, onMounted, onUnmounted, watch, computed} from 'vue'
import {useCartStore} from '@/store/cartStore'
import {usePrice, usePriceWithoutType} from '@/utils/usePrice'
import BasicButton from '@/components/BasicPacks/BasicButton.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 {
getLastPrices,
@@ -110,12 +144,12 @@ import {
stopPriceInterval,
setIntervalGetLastPrice
} from '@/utils/price'
import { checkoutCart } from '@/api/card'
import {checkoutCart} from '@/api/card'
import router from '@/router'
import { useWalletStore } from '@/store/walletStore'
import { useFundUserStore } from '@/store/fundStore'
import type { Price } from '@/models/home'
import type { Order } from '@/models/order'
import {useWalletStore} from '@/store/walletStore'
import {useFundUserStore} from '@/store/fundStore'
import type {Price} from '@/models/home'
import type {Order} from '@/models/order'
// Image imports
import defaultImg from '@/assets/img/defaultAbshodeh.svg'
@@ -124,48 +158,64 @@ import mokaabImg from '@/assets/img/mokaabImg.svg'
import sekkeImg from '@/assets/img/sekkeImg.svg'
import parsianImg from '@/assets/img/parsianImg.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 TransactionSkeleton from '@/components/TransactionSkeleton.vue'
import {registerCodeDiscount} from "@/api/giftCard";
const cartStore = useCartStore()
const walletStore = useWalletStore()
const fundStore = useFundUserStore()
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)
// Watch for price updates and update cart items
watch(lastPrice, () => {
if (lastPrice.value && cartStore.cartItems.length > 0) {
cartStore.cartItems.forEach((item) => {
const product = item.product
let newPrice = 0
if (product.group_type == 'آبشده') {
newPrice = lastPrice.value?.price_last ?? 0
} else {
newPrice = product.amount * (lastPrice.value?.price_last ?? 0)
}
// Update product price
product.price = newPrice
product.sellPrice = product.amount * (lastPrice.value?.sell ?? 0)
// Update item price and total price
item.price = newPrice + (product.cash_fee_buy ?? 0)
item.totalPrice = item.price * item.quantity
})
// Save updated prices to storage
cartStore.saveCartToStorage()
if (lastPrice.value) {
cartStore.recalculateCartPrices(lastPrice.value)
}
}, { deep: true, immediate: false })
}, {deep: true, immediate: false})
// Computed total price that updates with price changes
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) {
case 'گوی':
return goyImg
@@ -231,62 +281,65 @@ async function handleCheckout() {
// Check if user is logged in
if (!getToken()) {
message.warning('برای تسویه حساب، لطفا ابتدا وارد حساب کاربری خود شوید')
await router.push({ name: 'login' })
await router.push({name: 'login'})
return
}
if (cartStore.itemCount === 0) {
message.warning('سبد خرید شما خالی است')
return
}
if (!lastPrice.value) {
message.error('لطفا منتظر بمانید تا قیمت‌ها بارگذاری شوند')
return
}
// Check wallet balance for cash method items (without gateway)
const cashItemsTotal = cartStore.cartItems
.filter(item => item.method === 'cash' && !item.gateway)
.reduce((sum, item) => sum + item.totalPrice, 0)
let cashItemsTotal = cartStore.cartItems
.filter(item => item.method === 'cash' && !item.gateway)
.reduce((sum, item) => parseInt(sum + item.totalPrice), 0)
if (cashItemsTotal > 0) {
// Ensure wallet info is loaded
if (discountInfo.value?.amount && discountInfo.value?.amount>0){
cashItemsTotal=cashItemsTotal-cashItemsTotal*discountInfo.value?.amount
}
if (!walletStore.walletInfo) {
await walletStore.getMyWallet()
}
if (!walletStore.walletInfo?.cash || cashItemsTotal > walletStore.walletInfo.cash) {
message.error('موجودی کیف پول شما ناکافی است')
return
}
}
// Check gold balance for gold method items
const goldItemsTotal = cartStore.cartItems
.filter(item => item.method === 'gold')
.reduce((sum, item) => {
// Calculate total gold weight needed
const goldWeight = item.goldVazn ? item.goldVazn * item.quantity : 0
return sum + goldWeight
}, 0)
.filter(item => item.method === 'gold')
.reduce((sum, item) => {
// Calculate total gold weight needed
const goldWeight = item.goldVazn ? item.goldVazn * item.quantity : 0
return sum + goldWeight
}, 0)
if (goldItemsTotal > 0) {
// Ensure wallet info is loaded
if (!walletStore.walletInfo) {
await walletStore.getMyWallet()
}
if (!walletStore.walletInfo?.gold || goldItemsTotal > walletStore.walletInfo.gold) {
message.error('موجودی کیف طلا شما ناکافی است')
return
}
}
try {
loading.value = true
infoVisible.value = true
// Prepare orders array with same structure as createOrder for each product
const orders: Order[] = cartStore.cartItems.map(item => {
const product = item.product
@@ -297,21 +350,22 @@ async function handleCheckout() {
} else {
productPrice = (product.amount ?? 0) * (lastPrice.value?.price_last ?? 0)
}
return {
direction: 1, // 1 for buy (cart items are always buy orders)
price: productPrice,
amount: item.quantity,
amount: product.amount,
gateway: item.gateway,
product_id: product.id,
method: item.method,
number: item.quantity
number: item.quantity,
discount_code:discountInfo.value?.code
}
})
// Call checkoutCart API with orders array
const data = await checkoutCart(orders)
// Check for returnUrl (gateway payment)
let returnUrl = null
if (Array.isArray(data)) {
@@ -322,17 +376,17 @@ async function handleCheckout() {
} else if (data?.returnUrl) {
returnUrl = data.returnUrl
}
// If returnUrl exists, redirect to gateway and stop execution
if (returnUrl) {
window.location.href = returnUrl
return // Stop execution here
}
// If no gateway, continue with normal flow
await walletStore.getMyWallet()
cartStore.clearCart()
await router.push({ name: 'transactions' })
await router.push({name: 'transactions'})
message.success('سفارشات شما با موفقیت ثبت شد')
await fundStore.getMyFund()
} catch (e: any) {
@@ -348,40 +402,37 @@ async function initPrice() {
try {
await getLastPrices()
await setIntervalGetLastPrice()
// Update prices for all cart items
if (lastPrice.value && cartStore.cartItems.length > 0) {
cartStore.cartItems.forEach((item) => {
const product = item.product
let newPrice = 0
if (product.group_type == 'آبشده') {
newPrice = lastPrice.value?.price_last ?? 0
} else {
newPrice = product.amount * (lastPrice.value?.price_last ?? 0)
}
// Update product price
product.price = newPrice
product.sellPrice = product.amount * (lastPrice.value?.sell ?? 0)
// Update item price and total price
item.price = newPrice + (product.cash_fee_buy ?? 0)
item.totalPrice = item.price * item.quantity
})
// Save updated prices to storage
cartStore.saveCartToStorage()
if (lastPrice.value) {
cartStore.recalculateCartPrices(lastPrice.value)
}
} catch (e: any) {
console.log(e)
}
}
async function refreshCart() {
const removedCount = await cartStore.refreshCartFromServer()
if (removedCount > 0) {
message.warning(`${removedCount} محصول از سبد خرید حذف شد (دیگر در دسترس نیست)`)
}
if (lastPrice.value) {
cartStore.recalculateCartPrices(lastPrice.value)
}
}
onMounted(async () => {
// Load cart from storage if needed
cartStore.loadCartFromStorage()
await initPrice()
loading.value = true
try {
await initPrice()
await refreshCart()
const refreshCartInfo=setInterval(async () => {
await refreshCart()
// await getUpPrice()
}, 10000)
} finally {
loading.value = false
}
})
onUnmounted(() => {
+81
View File
@@ -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>
-1
View File
@@ -210,7 +210,6 @@ import { useWalletStore } from '@/store/walletStore'
import { createOrder } from '@/api/order'
import { message } from 'ant-design-vue'
import type { Price } from '@/models/home'
import { getLastPrice } from '@/api/home'
import Icon from '@/components/BasicPacks/BasicIcon.vue'
import { useUserStore } from '@/store/userStore'
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
+45 -27
View File
@@ -22,27 +22,27 @@
<div>حساب کاربری</div>
</div>
</BasicButton>
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
@click="$router.push({name: 'notifyTrigger'}); popVisible = false">
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:bill" size="16" class="absolute right-2" />
<div>هشدار قیمت</div>
</div>
</BasicButton>
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
@click="$router.push({name: 'transfer'}); popVisible = false">
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:card-send" size="16" class="absolute right-2" />
<div>انتقال قطره</div>
</div>
</BasicButton>
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
@click="$router.push({name: 'physicalReceive'}); popVisible = false">
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:direct-inbox" size="16" class="absolute right-2" />
<div>دریافت طلای فیزیکی</div>
</div>
</BasicButton>
<!-- <BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"-->
<!-- @click="$router.push({name: 'notifyTrigger'}); popVisible = false">-->
<!-- <div class="flex gap-2 items-center">-->
<!-- <BasicIcon icon="vuesax-linear:bill" size="16" class="absolute right-2" />-->
<!-- <div>هشدار قیمت</div>-->
<!-- </div>-->
<!-- </BasicButton>-->
<!-- <BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"-->
<!-- @click="$router.push({name: 'transfer'}); popVisible = false">-->
<!-- <div class="flex gap-2 items-center">-->
<!-- <BasicIcon icon="vuesax-linear:card-send" size="16" class="absolute right-2" />-->
<!-- <div>انتقال قطره</div>-->
<!-- </div>-->
<!-- </BasicButton>-->
<!-- <BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"-->
<!-- @click="$router.push({name: 'physicalReceive'}); popVisible = false">-->
<!-- <div class="flex gap-2 items-center">-->
<!-- <BasicIcon icon="vuesax-linear:direct-inbox" size="16" class="absolute right-2" />-->
<!-- <div>دریافت طلای فیزیکی</div>-->
<!-- </div>-->
<!-- </BasicButton>-->
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
@click="$router.push({name: 'buyProduct'}); popVisible = false">
<div class="flex gap-2 items-center">
@@ -57,6 +57,13 @@
<div>لیست دریافتی ها</div>
</div>
</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"
@click="$router.push({name: 'about'}); popVisible = false">
<div class="flex gap-2 items-center">
@@ -100,9 +107,13 @@
<!-- <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 class="tabs">
<div :class="setNavColor('home')" class="tab" @click="setRoute('home')">
<Icon icon="vuesax-linear:home" />
<div class="text-xs mt-1 font-bold">صفحه اصلی</div>
<!-- <div :class="setNavColor('home')" class="tab" @click="setRoute('home')">-->
<!-- <Icon icon="vuesax-linear:home" />-->
<!-- <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 :class="setNavColor('transactions')" class="tab" @click="setRoute('transactions')">
<Icon icon="vuesax-linear:receipt-item" />
@@ -133,7 +144,9 @@
<!-- <div class="text-xs mt-1 font-bold">دریافت فیزیکی</div>-->
<!-- </div>-->
<div :class="setNavColor('cart')" class="tab" @click="setRoute('cart')">
<Icon icon="vuesax-linear:shopping-cart" />
<a-badge :count="cartStore.itemCount">
<Icon icon="vuesax-linear:shopping-cart" />
</a-badge>
<div class="text-xs mt-1 font-bold">سبد خرید</div>
</div>
</div>
@@ -169,7 +182,9 @@
<div class="text-xs mt-1 font-bold">خرید محصول</div>
</div>-->
<div :class="setNavColor('cart')" class="tab" @click="setRoute('cart')">
<Icon icon="vuesax-linear:shopping-cart" />
<a-badge :count="cartStore.itemCount">
<Icon icon="vuesax-linear:shopping-cart" />
</a-badge>
<div class="text-xs mt-1 font-bold">سبد خرید</div>
</div>
<div :class="setNavColor('login')" class="tab" @click="setRoute('login')">
@@ -194,11 +209,14 @@ import BasicButton from '@/components/BasicPacks/BasicButton.vue'
import type { Transaction } from '@/models/transaction'
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import {isToken} from "@/utils";
import { useCartStore } from '@/store/cartStore'
const currentRoute = computed(() => router.currentRoute.value.name)
const cartStore = useCartStore()
const popVisible = ref(false)
const currentRoute = computed(() => router.currentRoute.value.name)
function setNavColor(val: string) {
if (currentRoute.value === val) {
return 'text-primary'
@@ -60,7 +60,7 @@
</a-form-item>
<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"
addon-text-color="white"
place-holder="تعداد"
@@ -253,7 +253,7 @@ import type { Price } from '@/models/home'
import Icon from '@/components/BasicPacks/BasicIcon.vue'
import { useUserStore } from '@/store/userStore'
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 GoldLoading from '@/components/GoldLoading.vue'
// import {update} from 'lodash'
@@ -274,10 +274,10 @@ const typeDeal: SelectItem[] = [
value: 'نقدی',
key: 'cash'
},
{
value: ' طلایی',
key: 'gold'
}
// {
// value: ' طلایی',
// key: 'gold'
// }
]
const infoVisible = ref(false)
@@ -558,9 +558,9 @@ const limitedPrice = computed(() => {
function calculateCash(val: number) {
priceErrorVisible.value = false
// console.log(val)
console.log("val",val,props?.ProductItem)
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)
if (isBuy.value) {
if (val){
@@ -579,7 +579,7 @@ console.log(val,props?.ProductItem?.price,props?.ProductItem?.cash_fee_buy,lastP
form.value.goldVazn = 0
}
}
console.log(form.value.goldVazn)
console.log('goldVazn',form.value.goldVazn)
}
}
@@ -95,7 +95,7 @@
</div>
<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"
>
ناموجود
@@ -132,6 +132,12 @@ const amountProduct = 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) {
case 'گوی':
return goyImg
@@ -30,7 +30,7 @@
</div>
<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"
>
ناموجود
@@ -66,6 +66,12 @@ const amountProduct = 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) {
case 'گوی':
return goyImg
+17 -18
View File
@@ -18,11 +18,10 @@
</div>
<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">
<ProductItemVertical v-if="viewVertical" :ProductItem="item" @click="clickProduct(item)"></ProductItemVertical>
<ProductItem v-else class="col-span-2" :ProductItem="item" @click="clickProduct(item)"></ProductItem>
<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>
<ProductItem v-else class="col-span-2" :ProductItem="item" @click="clickProduct(item)"></ProductItem>
</div>
</div>
</div>
@@ -144,8 +143,8 @@ watch(lastPrice, async () => {
val.price = lastPrice.value?.price_last
val.sellPrice = lastPrice.value?.sell
} else {
val.price = val.amount * lastPrice.value?.price_last
val.sellPrice = val.amount * lastPrice.value?.sell
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)
}
@@ -154,11 +153,11 @@ watch(lastPrice, async () => {
if (firstItems.value) {
firstItems.value.forEach((val) => {
if (val.group_type == 'آبشده') {
val.price = lastPrice.value?.price_last
val.sellPrice = lastPrice.value?.sell
val.price = parseInt(lastPrice.value?.price_last)
val.sellPrice = parseInt(lastPrice.value?.sell)
} else {
val.price = val.amount * lastPrice.value?.price_last
val.sellPrice = val.amount * lastPrice.value?.sell
val.price = parseInt(val.amount * lastPrice.value?.price_last)
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
}
})
}
@@ -177,22 +176,22 @@ async function initPrice() {
if (lastPrice.value && items.value) {
items.value.forEach((val) => {
if (val.group_type == 'آبشده') {
val.price = lastPrice.value?.price_last
val.sellPrice = lastPrice.value?.sell
val.price = parseInt(lastPrice.value?.price_last)
val.sellPrice = parseInt(lastPrice.value?.sell)
} else {
val.price = val.amount * lastPrice.value?.price_last
val.sellPrice = val.amount * lastPrice.value?.sell
val.price = parseInt(val.amount * lastPrice.value?.price_last)
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
}
})
// Update firstItems as well
if (firstItems.value) {
firstItems.value.forEach((val) => {
if (val.group_type == 'آبشده') {
val.price = lastPrice.value?.price_last
val.sellPrice = lastPrice.value?.sell
val.price = parseInt(lastPrice.value?.price_last)
val.sellPrice =parseInt( lastPrice.value?.sell)
} else {
val.price = val.amount * lastPrice.value?.price_last
val.sellPrice = val.amount * lastPrice.value?.sell
val.price = parseInt(val.amount * lastPrice.value?.price_last)
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
}
})
}
+72 -40
View File
@@ -1,18 +1,13 @@
<template>
<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>
<a-spin :spinning="loading">
<div class="!h-full overflow-y-scroll">
<div class="mx-5 pb-30 pt-5" style="color: #1b2b07">
<!-- Product Image -->
<div class="bg-gray-100 rounded-lg w-full flex justify-center p-8 mb-4">
<img v-if="product?.group_type == 'گوی'" :src="goyImg" 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 class="bg-gray-100 rounded-lg w-full flex justify-center mb-4">
<img :src="getProductImage(product)" class="max-w-full h-auto"/>
</div>
<!-- Product Title -->
@@ -25,7 +20,7 @@
<div class="flex-1">
<!-- Buy Button -->
<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 "
type="primary"
size="large"
@@ -39,6 +34,9 @@
<div v-else-if="!product?.open_buy" class="text-center text-gray-500 py-4">
خرید این محصول در حال حاضر امکان پذیر نیست
</div>
<div v-else-if="!product?.inventory || product?.inventory==0" class="text-center text-gray-500 py-4">
ناموجود
</div>
</div>
@@ -46,33 +44,33 @@
<!-- 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-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">{{ product?.description }}</div>
<!-- <div class="text-base text-gray-700 whitespace-pre-line">شمش طلای نقش برجسته ونوس ۱ گرمی انتخابی ظریف و ارزشمند برای سرمایه‌گذاری و هدیه است. این شمش از طلای خالص با عیار بالا ساخته شده و نقش برجسته‌ی الهه ونوس، نمادی از زیبایی و ظرافت، جلوه‌ای هنری و خاص به آن بخشیده است. وزن دقیق ۱ گرم، ابعاد مناسب و بسته‌بندی شکیل، این محصول را به گزینه‌ای ایده‌آل برای نگهداری ارزش، هدیه‌های خاص و کلکسیون‌های طلا تبدیل می‌کند. </div>-->
</div>
<!-- Similar Products -->
<div v-if="product?.similar?.length" class="mt-8">
<div class="text-lg font-semibold mb-4">محصولات مشابه</div>
<swiper
:slides-per-view="2.25"
:space-between="16"
class="similar-products-swiper"
:slides-per-view="2.25"
:space-between="16"
class="similar-products-swiper"
>
<swiper-slide
v-for="item in product.similar"
:key="item.id"
v-for="item in product.similar"
:key="item.id"
>
<div
class="bg-white rounded-lg shadow p-4 cursor-pointer h-full"
@click="goToProduct(item.id)"
class="bg-white rounded-lg shadow p-4 cursor-pointer h-full"
@click="goToProduct(item.id)"
>
<!-- Image -->
<div class="bg-gray-100 rounded-md flex justify-center p-4 mb-2">
<img
:src="getProductImage(item.group_type)"
class="h-20 object-contain"
:src="getProductImage(item)"
class="h-20 object-contain"
/>
</div>
@@ -80,11 +78,17 @@
<div class="text-sm font-semibold mb-1 line-clamp-2">
{{ item.title }}
</div>
<!-- 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)) }}
</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>
</swiper-slide>
</swiper>
@@ -106,24 +110,24 @@
<script setup lang="ts">
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 { loading, getToken } from '@/utils'
import type { Product } from '@/models/products'
import {loading, getToken} from '@/utils'
import type {Product} from '@/models/products'
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
import indexGold from '@/views/base/gold/index.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 { message } from 'ant-design-vue'
import {message} from 'ant-design-vue'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
import { usePrice } from '@/utils/usePrice'
import {usePrice} from '@/utils/usePrice'
import {
getLastPrices,
lastPrice,
stopPriceInterval
} from '@/utils/price'
import { Swiper, SwiperSlide } from 'swiper/vue'
import {Swiper, SwiperSlide} from 'swiper/vue'
import 'swiper/swiper-bundle.css'
// Image imports
@@ -148,10 +152,11 @@ watch(
(newId, oldId) => {
if (newId && newId !== oldId) {
loadProduct()
window.scrollTo({ top: 0, behavior: 'smooth' })
window.scrollTo({top: 0, behavior: 'smooth'})
}
}
)
async function loadProduct() {
try {
loading.value = true
@@ -160,7 +165,7 @@ async function loadProduct() {
const foundProduct = products
if (!foundProduct) {
message.error('محصول یافت نشد')
router.push({ name: 'buyProduct' })
router.push({name: 'buyProduct'})
return
}
product.value = foundProduct
@@ -169,7 +174,7 @@ async function loadProduct() {
console.log(e)
if (e?.response?.status === 401) {
message.warning('برای مشاهده محصولات، لطفا ابتدا وارد حساب کاربری خود شوید')
router.push({ name: 'login' })
router.push({name: 'login'})
} else {
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() {
try {
await getLastPrices()
loading.value = true
if (lastPrice.value && product.value) {
if (product.value.group_type == 'آبشده') {
product.value.price = lastPrice.value?.price_last
product.value.sellPrice = lastPrice.value?.sell
product.value.price = parseInt(lastPrice.value?.price_last)
product.value.sellPrice = parseInt(lastPrice.value?.sell)
} else {
product.value.price = product.value.amount * lastPrice.value?.price_last
product.value.sellPrice = product.value.amount * lastPrice.value?.sell
product.value.price = parseInt(product.value.amount * lastPrice.value?.price_last)
product.value.sellPrice = parseInt(product.value.amount * lastPrice.value?.sell)
}
}
} catch (e: any) {
@@ -202,7 +226,7 @@ function handleBuyClick() {
if (!product.value?.show) {
return
}
// // Check if user is logged in
// if (!getToken()) {
// message.warning('برای خرید یا فروش محصولات، لطفا ابتدا وارد حساب کاربری خود شوید')
@@ -221,11 +245,19 @@ onMounted(() => {
onUnmounted(() => {
stopPriceInterval()
})
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) {
case 'گوی':
return goyImg
+4 -4
View File
@@ -154,15 +154,15 @@
</div>
</div>
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white">
<a class="w-full" href="tel:09128081392">
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white items-center">
<a class="w-full" href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
</a>
<!-- <BasicButton type="primary" @click="$router.push({name: 'permissions'})">
<div>مجوز ها</div>
</BasicButton>-->
<a href="https://t.me/ghatreh">
<img src="@/assets/img/telegram.png" alt="" class="h-10 w-10"/>
<a href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
<img src="@/assets/img/rubika.webp" alt="" class="w-12"/>
</a>
</div>
</div>
+59 -14
View File
@@ -16,7 +16,7 @@
class="text-gray-500 text-xs number-ltr">{{ item.gold }}
<div>{{item.unit}}</div>
</div>
<div class="text-gray-500 flex gap-1 text-xs items-center number-ltr">
<div v-if="!isShopProduct" class="text-gray-500 flex gap-1 text-xs items-center number-ltr">
<div :class="item.cash > 0 ? 'text-green-600':'text-red-600'" class="text-base">
{{ usePriceWithoutType(item.cash?? 0) }}
</div>
@@ -25,7 +25,27 @@
</div>
</div>
</div>
<div v-if="isGold" class="flex w-full justify-between mt-2">
<template v-if="isShopProduct">
<div class="flex w-full justify-between mt-2">
<div class="text-gray-500">تعداد:</div>
<div class="text-gray-500 text-xs number-ltr">{{ item?.gold ?? 0 }}</div>
</div>
<div class="flex w-full justify-between mt-2">
<div class="text-gray-500">قیمت کل:</div>
<div class="text-gray-500 flex gap-1 text-xs items-center number-ltr">
<div class="text-base">{{ usePriceWithoutType(item.order?.total_price ?? 0) }}</div>
ریال
</div>
</div>
<div class="flex w-full justify-between mt-2">
<div class="text-gray-500">قیمت واحد:</div>
<div class="text-gray-500 flex gap-1 text-xs items-center number-ltr">
<div class="text-base">{{ usePriceWithoutType(item.order?.price ?? 0) }}</div>
ریال
</div>
</div>
</template>
<div v-else-if="isGold" class="flex w-full justify-between mt-2">
<div class="text-gray-500">قیمت معامله:</div>
<div class="text-gray-500 flex gap-1 text-xs items-center">
<!-- <div class="text-base">{{ typeof parseInt((Math.abs(item.cash) / Math.abs(item.gold)).toFixed(0)) }}</div>-->
@@ -60,20 +80,44 @@
ریال
</div>
</div>
<div v-if="item.order" class="flex justify-between mb-3">
<div class="text-primary">قیمت هر گرم طلا حین معامله:</div>
<div class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.price?? 0) }}</div>
ریال
<template v-if="isShopProduct">
<div class="flex justify-between mb-3">
<div class="text-primary">تعداد:</div>
<div class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ item.order?.number ?? 0 }}</div>
</div>
</div>
</div>
<div class="flex justify-between mb-3">
<div class="text-primary">مقدار {{item.wallet?.product? item.wallet.product.title: 'آبشده' }} مبادله شده:</div>
<div :class="item.gold >= 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ item.gold }}</div>
{{item.unit}}
<div class="flex justify-between mb-3">
<div class="text-primary">قیمت کل:</div>
<div class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.total_price ?? 0) }}</div>
ریال
</div>
</div>
</div>
<div class="flex justify-between mb-3">
<div class="text-primary">قیمت واحد:</div>
<div class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.price ?? 0) }}</div>
ریال
</div>
</div>
</template>
<template v-else>
<div v-if="item.order" class="flex justify-between mb-3">
<div class="text-primary">قیمت هر گرم طلا حین معامله:</div>
<div class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.price?? 0) }}</div>
ریال
</div>
</div>
<div class="flex justify-between mb-3">
<div class="text-primary">مقدار {{item.wallet?.product? item.wallet.product.title: 'آبشده' }} مبادله شده:</div>
<div :class="item.gold >= 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ item.gold }}</div>
{{item.unit}}
</div>
</div>
</template>
<div class="flex justify-between mb-3">
<div class="text-primary">موجودی کیف پول:</div>
<div :class="item.cash > 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center number-ltr">
@@ -156,6 +200,7 @@ interface Prop {
const props = withDefaults(defineProps<Prop>(), {})
const isUp = computed(() => props.item.type === 3 || props.item.type === 1 || props.item.type === 8 || props.item.type === 9)
const isGold = computed(() => props.item.type === 1 || props.item.type === 2 || props.item.type === 10)
const isShopProduct = computed(() => !!props.item?.product_id)
/*const title = computed(() => {
if (isUp.value) {
if (isGold.value) {
+80 -18
View File
@@ -93,16 +93,16 @@
<div>آدرس ها</div>
</div>
</BasicButton>-->
<BasicButton
class="w-full mt-2"
size="large"
@click="$router.push({ name: 'notifyTrigger' })"
>
<div class="flex">
<BasicIcon icon="vuesax-linear:bill" class="absolute right-8" />
<div>هشدار قیمت</div>
</div>
</BasicButton>
<!-- <BasicButton-->
<!-- class="w-full mt-2"-->
<!-- size="large"-->
<!-- @click="$router.push({ name: 'notifyTrigger' })"-->
<!-- >-->
<!-- <div class="flex">-->
<!-- <BasicIcon icon="vuesax-linear:bill" class="absolute right-8" />-->
<!-- <div>هشدار قیمت</div>-->
<!-- </div>-->
<!-- </BasicButton>-->
<BasicButton
class="mt-2 w-full"
icon=""
@@ -151,22 +151,61 @@
<div>مجوز ها</div>
</div>
</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
class="mt-2 w-full"
icon=""
iconSize="18"
size="large"
@click="$router.push({ name: 'earnMoney' })"
class="mt-2 w-full"
icon=""
iconSize="18"
size="large"
@click="showLogoutConfirm=!showLogoutConfirm"
>
<div class="flex">
<BasicIcon icon="vuesax-linear:dollar-circle" class="absolute right-8" />
<div>کسب درآمد</div>
<Icon
:color="y > 50 ? '' : ''"
class="color-transition absolute right-8"
icon="vuesax-linear:logout"
@click="showLogoutConfirm = true"
/>
<div>خروج از حساب کاربری</div>
</div>
</BasicButton>
</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">
<div class="flex justify-center justify-between">
<div class="font-bold text-lg">ویرایش اطلاعات</div>
@@ -257,7 +296,7 @@
import { onMounted, reactive, ref, computed } from 'vue'
import img from '@/assets/img/user_ly1.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 BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
import {
@@ -277,6 +316,11 @@ import { message } from 'ant-design-vue'
import { updateMe, updatePass } from '@/api/me'
import { useUserStore } from '@/store/userStore'
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>({
fname: '',
lname: '',
@@ -291,11 +335,29 @@ const userPassForm = ref<Password>({
const formRef = ref<FormInstance>()
const formPassRef = ref<FormInstance>()
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 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() {
userFormState.value = userStore.userInfo
}
+1 -1
View File
@@ -302,7 +302,7 @@
<span>جهت شارژ حساب کاربری خود، کلمه "شماره حساب" را برای پشتیبانی ارسال نمایید.</span>
</div>
<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>
</BasicButton>
+2 -2
View File
@@ -203,7 +203,7 @@ async function enterFingerPrint() {
const fingerPrint = await authenticateWithFingerprint()
if (fingerPrint) {
setTruth()
await router.push({ name: 'home' })
await router.push({ name: 'buyProduct' })
} else {
message.error('خطا در اعتبارسنجی')
}
@@ -234,7 +234,7 @@ async function login(accessToken: string | undefined) {
/* if (userStore.userInfo?.type === (URLUserType() === 'customer' ? 1 : 2)) {*/
await walletStore.getMyWallet()
setTruth()
await router.push({ name: 'home' })
await router.push({ name: 'buyProduct' })
/* } else {
removeToken()
userStore.removeInformation()
+1 -1
View File
@@ -43,7 +43,7 @@ const userFormState = ref<UserMobile>({
})
function phoneVerification() {
router.push({name: 'home' })
router.push({name: 'buyProduct' })
}
</script>
+1 -1
View File
@@ -18,7 +18,7 @@
<!-- <BasicInput v-model:value="userFormState.password" size="large" place-holder="کلمه عبور"/>-->
<AInputPassword v-model:value="userFormState.password" place-holder="کلمه عبور" inputmode="decimal"/>
</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="کد معرف"/>
</a-form-item>
<!-- <a-form-item v-if="URLUserType() === 'customer'" :rules="[required()]" class="home_appear_fade_in_down"