store
This commit is contained in:
@@ -200,7 +200,7 @@
|
||||
<span class="text-xs text-base">ریال</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 ml-4">
|
||||
<span class="text-base font-bold">{{ walletStore.walletInfo?.gold_sum.toFixed(3) }}</span>
|
||||
<span class="text-base font-bold">{{ walletStore.walletInfo?.gold_sum?.toFixed(3) ?? '0.000' }}</span>
|
||||
<span class="text-xs text-base">گرم</span>
|
||||
</div>
|
||||
</div>-->
|
||||
@@ -769,8 +769,8 @@ const toPersianNumber = (num) => {
|
||||
const fetchPrices = async () => {
|
||||
try {
|
||||
const response = await getAllPrices()
|
||||
const data = response.data?.prices
|
||||
const selectedData = data[selection.value] || []
|
||||
const data = response?.data?.prices ?? {}
|
||||
const selectedData = data[selection.value] ?? []
|
||||
priceChartSeries.value[0].data = selectedData.map((item) => [item.timestamp, item.value - 1])
|
||||
// console.log(priceChartSeries.value[0].data)
|
||||
chartRef.value?.updateOptions({
|
||||
|
||||
@@ -638,8 +638,8 @@ const toPersianNumber = (num) => {
|
||||
const fetchPrices = async () => {
|
||||
try {
|
||||
const response = await getAllPrices()
|
||||
const data = response.data.prices
|
||||
const selectedData = data[selection.value] || []
|
||||
const data = response?.data?.prices ?? {}
|
||||
const selectedData = data[selection.value] ?? []
|
||||
priceChartSeries.value[0].data = selectedData.map((item) => [item.timestamp, item.value - 1])
|
||||
// console.log(priceChartSeries.value[0].data)
|
||||
chartRef.value?.updateOptions({
|
||||
|
||||
@@ -182,7 +182,6 @@
|
||||
<div class="text-xs mt-1 font-bold">خرید محصول</div>
|
||||
</div>-->
|
||||
<div :class="setNavColor('cart')" class="tab" @click="setRoute('cart')">
|
||||
dd
|
||||
<a-badge :count="cartStore.itemCount">
|
||||
<Icon icon="vuesax-linear:shopping-cart" />
|
||||
</a-badge>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="bottom-0 fixed top-0">
|
||||
<div class="bottom-0 fixed top-0 -z-10 pointer-events-none">
|
||||
<img :src="img" alt="" class=" w-inherit "
|
||||
:style="{ backgroundRepeat: 'repeat', }"
|
||||
/>
|
||||
</div>
|
||||
<a-spin :spinning="loading">
|
||||
<div class=" !h-full overflow-y-scroll">
|
||||
<div class="relative z-0 !h-full overflow-y-scroll">
|
||||
<div class="w-full flex justify-center top-0 py-5" style="align-self: center">
|
||||
<ARadioGroup @change="changeTab" v-model:value="activekey" button-style="solid">
|
||||
<ARadioButton class="cats" value="همه">همه</ARadioButton>
|
||||
@@ -18,7 +18,7 @@
|
||||
</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?.filter(i => i.show)">
|
||||
<div class="mt-3 gap-2 " :class="!viewVertical?'col-span-2':''" v-for="item in items" :key="item.id">
|
||||
<ProductItemVertical v-if="viewVertical" :ProductItem="item" @click="clickProduct(item)"></ProductItemVertical>
|
||||
<ProductItem v-else class="col-span-2" :ProductItem="item" @click="clickProduct(item)"></ProductItem>
|
||||
</div>
|
||||
@@ -63,7 +63,7 @@ import BasicButton from "@/App.vue";
|
||||
import BasicIcon from "@/components/BasicPacks/BasicIcon.vue";
|
||||
import ProductItemVertical from "@/views/base/products/components/ProductItemVertical.vue";
|
||||
|
||||
const activekey = ref('آبشده')
|
||||
const activekey = ref('همه')
|
||||
const showFilter = ref()
|
||||
const selectedProduct = ref<Product>()
|
||||
const viewVertical=ref<boolean>('true')
|
||||
@@ -92,11 +92,10 @@ onMounted(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
items.value = await getProducts()
|
||||
items.value?.forEach((val, index) => {
|
||||
if (!typeItems.value.includes(val.group_type)){
|
||||
items.value?.forEach((val) => {
|
||||
if (!typeItems.value.includes(val.group_type)) {
|
||||
typeItems.value.push(val.group_type)
|
||||
}
|
||||
// typeItems.value[index] = val.group_type
|
||||
})
|
||||
firstItems.value = items.value
|
||||
await initPrice()
|
||||
@@ -134,34 +133,43 @@ onUnmounted(() => {
|
||||
// console.log('okgold')
|
||||
})
|
||||
|
||||
watch(lastPrice, async () => {
|
||||
// console.log(items);
|
||||
if (lastPrice.value && items.value) {
|
||||
items.value.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)
|
||||
}
|
||||
})
|
||||
// Update firstItems as well
|
||||
if (firstItems.value) {
|
||||
firstItems.value.forEach((val) => {
|
||||
if (val.group_type == 'آبشده') {
|
||||
val.price = parseInt(lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(lastPrice.value?.sell)
|
||||
} else {
|
||||
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||
}
|
||||
})
|
||||
}
|
||||
function applyLivePricesToProducts(products: Product[] | undefined) {
|
||||
if (!lastPrice.value || !products?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
products.forEach((val) => {
|
||||
if (val.group_type == 'آبشده') {
|
||||
val.price = parseInt(String(lastPrice.value?.price_last ?? 0))
|
||||
val.sellPrice = parseInt(String(lastPrice.value?.sell ?? 0))
|
||||
} else {
|
||||
val.price = parseInt(String(val.amount * lastPrice.value?.price_last))
|
||||
val.sellPrice = parseInt(String(val.amount * lastPrice.value?.sell))
|
||||
}
|
||||
|
||||
syncProductShow(val)
|
||||
})
|
||||
}
|
||||
|
||||
/** show از API سرور — بعد از محاسبه قیمت زنده فقط اگر غیرفعال یا قیمت صفر باشد خاموش میشود */
|
||||
function syncProductShow(product: Product) {
|
||||
if (!product.active) {
|
||||
product.show = false
|
||||
return
|
||||
}
|
||||
|
||||
const displayPrice = Number(product.price ?? 0) + Number(product.cash_fee_buy ?? 0)
|
||||
if (displayPrice > 0) {
|
||||
product.show = true
|
||||
return
|
||||
}
|
||||
|
||||
product.show = Number(lastPrice.value?.price_last ?? 0) > 0
|
||||
}
|
||||
|
||||
watch(lastPrice, () => {
|
||||
applyLivePricesToProducts(items.value)
|
||||
applyLivePricesToProducts(firstItems.value)
|
||||
}, { deep: true })
|
||||
|
||||
async function initPrice() {
|
||||
@@ -172,30 +180,8 @@ async function initPrice() {
|
||||
loading.value = true
|
||||
price.value = lastPrice.value
|
||||
|
||||
// Update prices for all items
|
||||
if (lastPrice.value && items.value) {
|
||||
items.value.forEach((val) => {
|
||||
if (val.group_type == 'آبشده') {
|
||||
val.price = parseInt(lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(lastPrice.value?.sell)
|
||||
} else {
|
||||
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 = parseInt(lastPrice.value?.price_last)
|
||||
val.sellPrice =parseInt( lastPrice.value?.sell)
|
||||
} else {
|
||||
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
applyLivePricesToProducts(items.value)
|
||||
applyLivePricesToProducts(firstItems.value)
|
||||
} catch (e: any) {
|
||||
console.log(e)
|
||||
// If 401 error, just skip price initialization
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<div class="text-gray-500">وضعیت :</div>
|
||||
<div class="text-gray-500 flex gap-1 text-xs items-center">
|
||||
<ATag class="!py-1 !px-6 !ml-0" color="blue">
|
||||
{{ (item.order?.sts_str ?? item.withdraw?.sts_str )?? item?.title}}
|
||||
{{ (item.order?.sts_str ?? item.withdraw?.sts_str) ?? item?.title }}
|
||||
</ATag>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user