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
|
2026-06-16 19:47:59 +03:30
|
|
|
v-if="percentChange !== 0"
|
|
|
|
|
class="price-change-badge"
|
|
|
|
|
:class="percentChange > 0 ? 'price-change-badge--up' : 'price-change-badge--down'"
|
2026-05-14 13:44:43 +03:30
|
|
|
>
|
2026-06-16 19:47:59 +03:30
|
|
|
<Icon
|
|
|
|
|
:key="displayGoldVal"
|
|
|
|
|
:size="15"
|
|
|
|
|
:icon="percentChange > 0 ? 'vuesax-linear:send' : 'vuesax-linear:received'"
|
|
|
|
|
:color="percentChange > 0 ? 'green-600' : 'red-600'"
|
|
|
|
|
/>
|
|
|
|
|
<span class="price-change-badge__value">{{ formatSignedPercentChange(percentChange) }}</span>
|
2026-05-14 13:44:43 +03:30
|
|
|
</div>
|
|
|
|
|
<Vue3Odometer
|
2026-06-16 19:47:59 +03:30
|
|
|
:value="displayGoldVal"
|
|
|
|
|
class="o-text !text-xl font-bold"
|
2026-06-17 13:51:29 +03:30
|
|
|
style="direction: ltr"
|
2026-05-14 13:44:43 +03:30
|
|
|
/>
|
|
|
|
|
ریال
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-06-16 19:47:59 +03:30
|
|
|
import { computed } from 'vue'
|
2026-05-14 13:44:43 +03:30
|
|
|
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'
|
2026-06-16 19:47:59 +03:30
|
|
|
import { formatSignedPercentChange } from '@/utils/usePrice'
|
2026-05-14 13:44:43 +03:30
|
|
|
|
|
|
|
|
const config = useConfigStore()
|
|
|
|
|
|
|
|
|
|
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
|
|
|
})
|
2026-06-16 19:47:59 +03:30
|
|
|
</script>
|
2026-05-14 13:44:43 +03:30
|
|
|
|
2026-06-16 19:47:59 +03:30
|
|
|
<style scoped>
|
|
|
|
|
.price-change-badge {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.35rem;
|
|
|
|
|
padding: 0.2rem 0.65rem;
|
|
|
|
|
border-radius: 0.5rem;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.price-change-badge--up {
|
|
|
|
|
background: #dcfce7;
|
|
|
|
|
color: #16a34a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.price-change-badge--down {
|
|
|
|
|
background: #fee2e2;
|
|
|
|
|
color: #dc2626;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.price-change-badge__value {
|
|
|
|
|
direction: ltr;
|
|
|
|
|
unicode-bidi: isolate;
|
|
|
|
|
font-variant-numeric: tabular-nums;
|
|
|
|
|
letter-spacing: 0.01em;
|
|
|
|
|
}
|
|
|
|
|
</style>
|