store
This commit is contained in:
@@ -200,7 +200,7 @@
|
|||||||
<span class="text-xs text-base">ریال</span>
|
<span class="text-xs text-base">ریال</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2 ml-4">
|
<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>
|
<span class="text-xs text-base">گرم</span>
|
||||||
</div>
|
</div>
|
||||||
</div>-->
|
</div>-->
|
||||||
@@ -769,8 +769,8 @@ const toPersianNumber = (num) => {
|
|||||||
const fetchPrices = async () => {
|
const fetchPrices = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await getAllPrices()
|
const response = await getAllPrices()
|
||||||
const data = response.data?.prices
|
const data = response?.data?.prices ?? {}
|
||||||
const selectedData = data[selection.value] || []
|
const selectedData = data[selection.value] ?? []
|
||||||
priceChartSeries.value[0].data = selectedData.map((item) => [item.timestamp, item.value - 1])
|
priceChartSeries.value[0].data = selectedData.map((item) => [item.timestamp, item.value - 1])
|
||||||
// console.log(priceChartSeries.value[0].data)
|
// console.log(priceChartSeries.value[0].data)
|
||||||
chartRef.value?.updateOptions({
|
chartRef.value?.updateOptions({
|
||||||
|
|||||||
@@ -638,8 +638,8 @@ const toPersianNumber = (num) => {
|
|||||||
const fetchPrices = async () => {
|
const fetchPrices = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await getAllPrices()
|
const response = await getAllPrices()
|
||||||
const data = response.data.prices
|
const data = response?.data?.prices ?? {}
|
||||||
const selectedData = data[selection.value] || []
|
const selectedData = data[selection.value] ?? []
|
||||||
priceChartSeries.value[0].data = selectedData.map((item) => [item.timestamp, item.value - 1])
|
priceChartSeries.value[0].data = selectedData.map((item) => [item.timestamp, item.value - 1])
|
||||||
// console.log(priceChartSeries.value[0].data)
|
// console.log(priceChartSeries.value[0].data)
|
||||||
chartRef.value?.updateOptions({
|
chartRef.value?.updateOptions({
|
||||||
|
|||||||
@@ -182,7 +182,6 @@
|
|||||||
<div class="text-xs mt-1 font-bold">خرید محصول</div>
|
<div class="text-xs mt-1 font-bold">خرید محصول</div>
|
||||||
</div>-->
|
</div>-->
|
||||||
<div :class="setNavColor('cart')" class="tab" @click="setRoute('cart')">
|
<div :class="setNavColor('cart')" class="tab" @click="setRoute('cart')">
|
||||||
dd
|
|
||||||
<a-badge :count="cartStore.itemCount">
|
<a-badge :count="cartStore.itemCount">
|
||||||
<Icon icon="vuesax-linear:shopping-cart" />
|
<Icon icon="vuesax-linear:shopping-cart" />
|
||||||
</a-badge>
|
</a-badge>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<template>
|
<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 "
|
<img :src="img" alt="" class=" w-inherit "
|
||||||
:style="{ backgroundRepeat: 'repeat', }"
|
:style="{ backgroundRepeat: 'repeat', }"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<a-spin :spinning="loading">
|
<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">
|
<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">
|
<ARadioGroup @change="changeTab" v-model:value="activekey" button-style="solid">
|
||||||
<ARadioButton class="cats" value="همه">همه</ARadioButton>
|
<ARadioButton class="cats" value="همه">همه</ARadioButton>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
</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?.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>
|
<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>
|
||||||
@@ -63,7 +63,7 @@ import BasicButton from "@/App.vue";
|
|||||||
import BasicIcon from "@/components/BasicPacks/BasicIcon.vue";
|
import BasicIcon from "@/components/BasicPacks/BasicIcon.vue";
|
||||||
import ProductItemVertical from "@/views/base/products/components/ProductItemVertical.vue";
|
import ProductItemVertical from "@/views/base/products/components/ProductItemVertical.vue";
|
||||||
|
|
||||||
const activekey = ref('آبشده')
|
const activekey = ref('همه')
|
||||||
const showFilter = ref()
|
const showFilter = ref()
|
||||||
const selectedProduct = ref<Product>()
|
const selectedProduct = ref<Product>()
|
||||||
const viewVertical=ref<boolean>('true')
|
const viewVertical=ref<boolean>('true')
|
||||||
@@ -92,11 +92,10 @@ onMounted(async () => {
|
|||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
items.value = await getProducts()
|
items.value = await getProducts()
|
||||||
items.value?.forEach((val, index) => {
|
items.value?.forEach((val) => {
|
||||||
if (!typeItems.value.includes(val.group_type)){
|
if (!typeItems.value.includes(val.group_type)) {
|
||||||
typeItems.value.push(val.group_type)
|
typeItems.value.push(val.group_type)
|
||||||
}
|
}
|
||||||
// typeItems.value[index] = val.group_type
|
|
||||||
})
|
})
|
||||||
firstItems.value = items.value
|
firstItems.value = items.value
|
||||||
await initPrice()
|
await initPrice()
|
||||||
@@ -134,34 +133,43 @@ onUnmounted(() => {
|
|||||||
// console.log('okgold')
|
// console.log('okgold')
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(lastPrice, async () => {
|
function applyLivePricesToProducts(products: Product[] | undefined) {
|
||||||
// console.log(items);
|
if (!lastPrice.value || !products?.length) {
|
||||||
if (lastPrice.value && items.value) {
|
return
|
||||||
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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 })
|
}, { deep: true })
|
||||||
|
|
||||||
async function initPrice() {
|
async function initPrice() {
|
||||||
@@ -172,30 +180,8 @@ async function initPrice() {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
price.value = lastPrice.value
|
price.value = lastPrice.value
|
||||||
|
|
||||||
// Update prices for all items
|
applyLivePricesToProducts(items.value)
|
||||||
if (lastPrice.value && items.value) {
|
applyLivePricesToProducts(firstItems.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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
// If 401 error, just skip price initialization
|
// If 401 error, just skip price initialization
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
<div class="text-gray-500">وضعیت :</div>
|
<div class="text-gray-500">وضعیت :</div>
|
||||||
<div class="text-gray-500 flex gap-1 text-xs items-center">
|
<div class="text-gray-500 flex gap-1 text-xs items-center">
|
||||||
<ATag class="!py-1 !px-6 !ml-0" color="blue">
|
<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>
|
</ATag>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user