fix some bug

This commit is contained in:
2026-06-06 15:48:27 +03:30
parent f82a0c3873
commit 4c707849ef
5 changed files with 29 additions and 27 deletions
+8 -3
View File
@@ -227,6 +227,7 @@ import type { Transaction } from '@/models/transaction'
import type { TableEngineInput, TableOutput } from '@/models/table'
import { useInfiniteScroll } from '@vueuse/core'
import { getTransactionTable } from '@/api/transaction'
import { getProductBuyPrice, getProductSellPrice } from '@/utils/productPrice'
import { getLastPrices, getTradeBuyPrice, getTradeSellPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price'
import type { Product } from '@/models/products'
import { useFundUserStore } from '@/store/fundStore'
@@ -277,9 +278,13 @@ const sellPagination = ref<TableEngineInput>({
}], limit: 6, page: 0
})
const unitPrice = computed(() =>
isBuy.value ? getTradeBuyPrice(lastPrice.value) : getTradeSellPrice(lastPrice.value)
)
const unitPrice = computed(() => {
const product = props.ProductItem
if (product?.group_type === 'آبشده') {
return isBuy.value ? getProductBuyPrice(product) : getProductSellPrice(product)
}
return isBuy.value ? getTradeBuyPrice(lastPrice.value) : getTradeSellPrice(lastPrice.value)
})
const feeInGrams = computed(() => calcFeeInGrams(form.value?.goldValue))
const finalPrice = computed(() => (form.value?.goldValue ?? 0) * unitPrice.value)
const feeInRial = computed(() => unitPrice.value * feeInGrams.value)
@@ -31,7 +31,7 @@
<script setup lang="ts">
import Icon from '@/components/BasicPacks/BasicIcon.vue'
import { useConfigStore } from '@/store/configStore'
import {lastPrice, percentPriceChanged, price} from '@/utils/price'
import { getTradeBuyPrice, lastPrice, percentPriceChanged, price } from '@/utils/price'
import Vue3Odometer from 'vue3-odometer'
import 'odometer/themes/odometer-theme-default.css'
import {useTowDecimal} from "../../../../utils/usePrice";
@@ -42,19 +42,19 @@ const config = useConfigStore()
// محاسبه درصد تغییرات به صورت reactive
const percentChange = computed(() => {
if (! lastPrice?.value?.price_last) return 0
if (!getTradeBuyPrice(lastPrice.value)) return 0
return percentPriceChanged()
})
// بررسی بسته بودن بازار
const isMarketClosed = computed(() => {
return lastPrice?.value?.goldir === 0 && lastPrice?.value?.price_last === 0
return lastPrice?.value?.goldir === 0 && getTradeBuyPrice(lastPrice.value) === 0
})
// مقدار نمایشی برای ادومتر (با مدیریت خطا)
const displayGoldVal = computed(() => {
if (isMarketClosed.value) return 0
return lastPrice?.value?.price_last|| 0
return getTradeBuyPrice(lastPrice.value)
})
// انیمیشن fade-in
@@ -32,8 +32,7 @@ import type {Product} from "@/models/products";
import {usePrice} from '@/utils/usePrice';
import {getFileUrl} from '@/utils/file';
import {computed, ref} from "vue";
import { getTradeBuyPrice, lastPrice } from '@/utils/price'
import type { Price } from '@/models/home'
import { getProductBuyPrice } from '@/utils/productPrice'
interface Prop {
ProductItem: Product
@@ -88,9 +87,7 @@ const price = computed(()=>{
}
})
const priceLast = computed((): Price => <Price>lastPrice.value ?? 0)
const goldPriceValue = computed(() => getTradeBuyPrice(priceLast.value))
const goldPriceValue = computed(() => getProductBuyPrice(props.ProductItem))
</script>