From 71da064cabdfc9d41b76b8d2fe87e9e12fc2ddce Mon Sep 17 00:00:00 2001 From: adonis Date: Mon, 14 Sep 2026 12:57:53 +0330 Subject: [PATCH] fix some things --- src/api/products.ts | 19 ++++++++++++ src/models/products.ts | 1 + src/utils/productImage.ts | 3 +- src/utils/productPrice.ts | 4 +-- src/views/base/tv/index.vue | 30 +++++++++++++++--- src/views/tv/composables/useTvMonitorPage.ts | 32 +++++++++++++++++--- 6 files changed, 78 insertions(+), 11 deletions(-) diff --git a/src/api/products.ts b/src/api/products.ts index 56db761..77583ea 100644 --- a/src/api/products.ts +++ b/src/api/products.ts @@ -10,6 +10,25 @@ export const getTvProducts = async (): Promise => { const response = await useAxios.get(`/customer/tv/products`, { timeout: 15000 }) return Array.isArray(response) ? (response as Product[]) : [] } + +export type TvServerTime = { + unix: number + iso: string + timezone: string +} + +export const getTvServerTime = async (): Promise => { + try { + const response = await useAxios.get(`/customer/tv/time`, { timeout: 10000 }) + if (response && typeof (response as TvServerTime).unix === 'number') { + return response as TvServerTime + } + } catch { + /* ignore */ + } + return null +} + export const getProductById = async ( id:number|null): Promise => { return await useAxios.get(`/customer/product/list/${id}`, { timeout: 15000 }) } diff --git a/src/models/products.ts b/src/models/products.ts index 1c530fe..4963c1e 100644 --- a/src/models/products.ts +++ b/src/models/products.ts @@ -3,6 +3,7 @@ import type {Wallet} from "@/models/wallet"; export interface Product { id: number img: string | undefined + image?: string | null title: string amount: any metal_id: any diff --git a/src/utils/productImage.ts b/src/utils/productImage.ts index d0a29c4..7e6f50e 100644 --- a/src/utils/productImage.ts +++ b/src/utils/productImage.ts @@ -10,6 +10,7 @@ export type ProductImageSource = { file?: { id?: number | null; src?: string | null; full_src?: string | null; url?: string | null } | null file_id?: number | string | null img?: string | null + image?: string | null group_type?: string | null } | null | undefined @@ -103,7 +104,7 @@ export function getProductFallbackImage(product?: ProductImageSource): string { } export function resolveProductImageSrc(product?: ProductImageSource): string { - const remoteSrc = product?.file?.full_src || product?.file?.url || product?.file?.src + const remoteSrc = product?.file?.full_src || product?.file?.url || product?.file?.src || product?.image || product?.img if (isUsableImageSrc(remoteSrc)) { const url = absolutizeImageUrl(remoteSrc!.trim()) const version = product?.file_id ?? product?.file?.id diff --git a/src/utils/productPrice.ts b/src/utils/productPrice.ts index ce2af22..be8b348 100644 --- a/src/utils/productPrice.ts +++ b/src/utils/productPrice.ts @@ -277,7 +277,7 @@ export function getTvProductBuyPrice(product?: Product | null): number { } const unit = tvBuyUnitPrice(product) if (unit > 0) { - return unit + resolveProductCashFeeBuyRial(product, unit) + return unit } return getProductBuyPrice(product) } @@ -288,7 +288,7 @@ export function getTvProductSellPrice(product?: Product | null): number { } const unit = tvSellUnitPrice(product) if (unit > 0) { - return unit - resolveProductCashFeeSellRial(product, unit) + return unit } return getProductSellPrice(product) } diff --git a/src/views/base/tv/index.vue b/src/views/base/tv/index.vue index 6fa299c..1363309 100644 --- a/src/views/base/tv/index.vue +++ b/src/views/base/tv/index.vue @@ -32,7 +32,7 @@