2026-05-14 13:44:43 +03:30
|
|
|
<template>
|
|
|
|
|
<div class="w-full relative mt-2 border-gray-200 border-1 rounded-lg py-3 flex flex-col justify-center home_appear_fade_in">
|
2026-06-08 12:34:10 +03:30
|
|
|
<div class="text-gray-600 text-[12px] ml-2 w-full text-center">قیمت خرید از {{ config.config.name_fa }}</div>
|
2026-05-14 13:44:43 +03:30
|
|
|
<div class="w-full items-center flex justify-center">
|
|
|
|
|
<div v-if="price" class="flex gap-1 text-xs items-center">
|
|
|
|
|
<div
|
|
|
|
|
v-if="percentPriceChanged() !== 0"
|
|
|
|
|
class="flex flex-row-reverse rounded-lg justify-between items-center gap-2 px-3"
|
|
|
|
|
:class="percentPriceChanged() >= 0 ? 'bg-green-100 text-green-600' : 'bg-red-100 text-red-600'"
|
|
|
|
|
>
|
|
|
|
|
<div dir="ltr">{{ useTowDecimal(percentPriceChanged()) }}%</div>
|
|
|
|
|
<div>
|
|
|
|
|
<Icon
|
|
|
|
|
:size="15"
|
|
|
|
|
:icon="percentPriceChanged() < 0 ? 'vuesax-linear:received' : 'vuesax-linear:send'"
|
|
|
|
|
:color="percentPriceChanged() < 0 ? 'red-600' : 'green-600'"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Vue3Odometer
|
|
|
|
|
:value="displayGoldVal"
|
|
|
|
|
class="o-text !text-xl font-bold"
|
2026-06-16 10:32:10 +03:30
|
|
|
style="font-family: iran-sans; direction: ltr"
|
2026-05-14 13:44:43 +03:30
|
|
|
/>
|
|
|
|
|
ریال
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
|
|
|
|
import { useConfigStore } from '@/store/configStore'
|
2026-06-06 15:48:27 +03:30
|
|
|
import { getTradeBuyPrice, lastPrice, percentPriceChanged, price } from '@/utils/price'
|
2026-05-14 13:44:43 +03:30
|
|
|
import Vue3Odometer from 'vue3-odometer'
|
|
|
|
|
import 'odometer/themes/odometer-theme-default.css'
|
|
|
|
|
import {useTowDecimal} from "../../../../utils/usePrice";
|
|
|
|
|
import {computed} from "vue";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const config = useConfigStore()
|
|
|
|
|
|
|
|
|
|
// محاسبه درصد تغییرات به صورت reactive
|
|
|
|
|
const percentChange = computed(() => {
|
2026-06-06 15:48:27 +03:30
|
|
|
if (!getTradeBuyPrice(lastPrice.value)) return 0
|
2026-05-14 13:44:43 +03:30
|
|
|
return percentPriceChanged()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// بررسی بسته بودن بازار
|
|
|
|
|
const isMarketClosed = computed(() => {
|
2026-06-06 15:48:27 +03:30
|
|
|
return lastPrice?.value?.goldir === 0 && getTradeBuyPrice(lastPrice.value) === 0
|
2026-05-14 13:44:43 +03:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// مقدار نمایشی برای ادومتر (با مدیریت خطا)
|
|
|
|
|
const displayGoldVal = computed(() => {
|
|
|
|
|
if (isMarketClosed.value) return 0
|
2026-06-06 15:48:27 +03:30
|
|
|
return getTradeBuyPrice(lastPrice.value)
|
2026-05-14 13:44:43 +03:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// انیمیشن fade-in
|
|
|
|
|
</script>
|