fixed price

This commit is contained in:
2026-06-28 21:48:48 +03:30
parent 0c36917735
commit 809bd69068
12 changed files with 377 additions and 57 deletions
+46 -1
View File
@@ -1,6 +1,6 @@
import { ref } from 'vue'
import { useSettingsStore } from '@/store/settingsStore'
import { lastPrice } from '@/utils/price'
import { getTradeBuyPrice, getTradeSellPrice, lastPrice } from '@/utils/price'
export interface StoreTradingHours {
start: string
@@ -162,3 +162,48 @@ export function getStoreClosedMessage(): string {
return `فروشگاه در حال حاضر بسته است. ساعت کاری از ${open} تا ${close} می‌باشد.`
}
export type PriceDisplayState = 'open' | 'closed' | 'no_quote'
export const NO_QUOTE_MESSAGE = 'مظنه در دسترس نیست'
/**
* وضعیت نمایش قیمت در صفحه اصلی:
* - closed → فروشگاه بسته است (خارج از ساعت کاری close_price یا بازه محصول)
* - no_quote → مظنه در دسترس نیست (قیمت زنده نداریم و show_last_price خاموش است)
* - open → نمایش عادی قیمت
*
* اولویت با status ارسالی از سرور است؛ اگر نبود به منطق سمت کلاینت برمی‌گردیم.
*/
export function getPriceDisplayState(): PriceDisplayState {
void productTradingHoursVersion.value
const p = lastPrice.value
const status = p?.status
if (status === 'closed') {
return 'closed'
}
if (status === 'no_quote') {
return getTradeBuyPrice(p) > 0 ? 'open' : 'no_quote'
}
if (status === 'open') {
return getTradeBuyPrice(p) > 0 || getTradeSellPrice(p) > 0 ? 'open' : 'no_quote'
}
// سرور status نفرستاده (سازگاری با نسخه قدیمی) → استنتاج سمت کلاینت
if (isStoreClosed()) {
return 'closed'
}
return getTradeBuyPrice(p) > 0 || getTradeSellPrice(p) > 0 ? 'open' : 'no_quote'
}
export function getPriceDisplayMessage(state: PriceDisplayState = getPriceDisplayState()): string {
if (state === 'closed') {
return getStoreClosedMessage()
}
if (state === 'no_quote') {
return NO_QUOTE_MESSAGE
}
return ''
}
+8 -2
View File
@@ -1,5 +1,11 @@
/** بالای ناوبری (5000)، هدر (1999) و فوتر اعتبار (1000000) */
export const APP_Z_MODAL = 1_010_000
/**
* z-index مدال/اکشن‌شیت/دیالوگ.
* بالای ناوبری (5000)، هدر (1999) و دکمه پشتیبانی (5100) می‌نشیند تا این کروم‌ها
* پشت پوشش تیره بمانند، اما زیر لایه دراپ‌داون اینت (99999) است تا تقویم/سلکت
* داخل مدال روی آن باز شود. کروم ثابتی که بالاتر از این مقدار است (مثل نوار
* اعتبار) هنگام باز بودن مدال با CSS مخفی می‌شود.
*/
export const APP_Z_MODAL = 5_500
export function getModalContainer(): HTMLElement {
return document.body