Files
boursecu_user/src/views/base/home/desktop/components/DesktopLivePrice.vue
T
safavimohadeseh78andCursor 0109f3a744 Unify store-closed messaging when the market is closed or has no quote.
Treat missing quotes as closed across home and products, show only the admin closed_message as hint, and block trading with consistent notices.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 12:42:56 +02:00

147 lines
4.0 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div
class="dhome-surface dhome-hero-price"
:class="{
'dhome-hero-price--boursecu-open': displayState === 'open',
'dhome-hero-price--boursecu-closed': displayState !== 'open',
}"
>
<template v-if="displayState !== 'open'">
<div class="dhome-hero-price__closed">
<div class="dhome-hero-price__closed-icon">
<BasicIcon
:icon="displayState === 'closed' ? 'vuesax-linear:lock' : 'vuesax-linear:info-circle'"
size="22"
color="#ffffff"
/>
</div>
<p class="dhome-hero-price__closed-title">{{ statusTitle }}</p>
<p v-if="statusHint" class="dhome-hero-price__closed-hint">{{ statusHint }}</p>
</div>
</template>
<template v-else>
<span class="dhome-label dhome-label--boursecu">
قیمت لحظه‌ای کاتد مس
</span>
<div class="dhome-hero-price__value-row">
<span
v-if="percentChange !== 0"
class="dhome-hero-price__delta"
:class="percentChange > 0 ? 'dhome-hero-price__delta--up' : 'dhome-hero-price__delta--down'"
>
<BasicIcon
:icon="percentChange > 0 ? 'vuesax-linear:arrow-up-2' : 'vuesax-linear:arrow-down-2'"
size="14"
/>
<span class="dhome-hero-price__delta-value">{{ formatSignedPercentChange(percentChange) }}</span>
</span>
<Vue3Odometer
:value="displayGoldVal"
class="dhome-hero-price__odometer o-text dhome-hero-price__odometer--boursecu"
/>
<span class="dhome-hero-price__unit dhome-hero-price__unit--boursecu">ریال</span>
</div>
</template>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import Vue3Odometer from 'vue3-odometer'
import 'odometer/themes/odometer-theme-default.css'
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import { useUserStore } from '@/store/userStore'
import { getTradeBuyPrice, lastPrice, percentPriceChanged } from '@/utils/price'
import {
NO_QUOTE_MESSAGE,
STORE_CLOSED_TITLE,
getPriceDisplayState,
getStoreClosedHint,
} from '@/utils/storeHours'
import { formatSignedPercentChange } from '@/utils/usePrice'
const userStore = useUserStore()
const displayState = computed(() => getPriceDisplayState())
const statusTitle = computed(() =>
displayState.value === 'closed' ? STORE_CLOSED_TITLE : NO_QUOTE_MESSAGE
)
const statusHint = computed(() => {
if (displayState.value === 'closed') {
return getStoreClosedHint(userStore.getValueByKey('closed_message'))
}
return 'در حال حاضر مظنه‌ای برای نمایش وجود ندارد.'
})
const displayGoldVal = computed(() => {
if (displayState.value !== 'open') return 0
return getTradeBuyPrice(lastPrice.value)
})
const percentChange = computed(() => {
if (!getTradeBuyPrice(lastPrice.value)) return 0
return percentPriceChanged()
})
</script>
<style scoped lang="less">
.dhome-hero-price--boursecu-open {
background: linear-gradient(135deg, #c98a4a 0%, #a86528 100%);
border-color: transparent;
box-shadow: 0 4px 14px rgba(168, 101, 40, 0.28);
}
.dhome-hero-price--boursecu-closed {
background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
border-color: transparent;
box-shadow: 0 4px 14px rgba(45, 55, 72, 0.22);
}
.dhome-label--boursecu {
color: rgba(255, 255, 255, 0.92);
}
.dhome-hero-price__odometer--boursecu {
color: #ffffff !important;
}
.dhome-hero-price__unit--boursecu {
color: rgba(255, 255, 255, 0.85);
}
.dhome-hero-price__closed {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 6px;
}
.dhome-hero-price__closed-icon {
display: flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.12);
margin-bottom: 4px;
}
.dhome-hero-price__closed-title {
margin: 0;
font-size: 18px;
font-weight: 700;
color: #ffffff;
}
.dhome-hero-price__closed-hint {
margin: 0;
font-size: 12px;
line-height: 1.7;
color: rgba(255, 255, 255, 0.78);
}
</style>