change prices &...

This commit is contained in:
2026-06-03 11:57:40 +03:30
parent f4b98576f5
commit b055cd4a5d
16 changed files with 305 additions and 25 deletions
+37 -6
View File
@@ -167,7 +167,7 @@
<div class="flex justify-between mt-3">
<div>کارمزد:</div>
<div class="flex items-center gap-2">
<div class="font-bold text-xl">{{ parseFloat(((form.goldValue ?? 0) * (Number(feeAmount))).toFixed(4)) }}</div>
<div class="font-bold text-xl">{{ feeInGrams }}</div>
<div class="text-xs mr-1">گرم</div>
</div>
</div>
@@ -274,10 +274,18 @@ const sellPagination = ref<TableEngineInput>({
}], limit: 6, page: 0
})
const finalPrice = computed(() => (form.value?.goldValue * (isBuy.value ? price.value?.buy ?? 0 : price.value?.sell ?? 0)))
// const payablePrice = computed(() => finalPrice.value + finalPrice.value * 0.007)
const payablePrice = computed(() => finalPrice.value)
const equivalentPrice = computed(() => usePriceWithoutType(((isBuy ? price.value?.buy ?? 0 : price.value?.sell ?? 0) * (parseFloat(((form.value?.goldValue ?? 0) * 0.01).toFixed(4))) ).toFixed(0)) )
const unitPrice = computed(() =>
isBuy.value ? price.value?.buy ?? 0 : price.value?.sell ?? 0
)
const feeInGrams = computed(() =>
parseFloat(((form.value?.goldValue ?? 0) * Number(feeAmount.value)).toFixed(4))
)
const finalPrice = computed(() => (form.value?.goldValue ?? 0) * unitPrice.value)
const feeInRial = computed(() => unitPrice.value * feeInGrams.value)
const equivalentPrice = computed(() => usePriceWithoutType(feeInRial.value.toFixed(0)))
const payablePrice = computed(() =>
isBuy.value ? finalPrice.value + feeInRial.value : finalPrice.value - feeInRial.value
)
const disableTransaction = computed(() =>
loading.value ||
@@ -472,6 +480,28 @@ const limitedPrice = computed(() => {
return walletStore?.limitedPrice[0]
})
function syncFormWithLatestPrice() {
if (!price.value) return
const goldValue = form.value.goldValue
if (goldValue !== undefined && goldValue !== null && goldValue !== '' && !isNaN(Number(goldValue))) {
calculateCash(Number(goldValue))
return
}
const goldCash = form.value.goldCash
if (goldCash !== undefined && goldCash !== null && goldCash !== '' && !isNaN(Number(goldCash))) {
calculateGold(Number(goldCash))
}
}
watch(
() => [lastPrice.value?.buy, lastPrice.value?.sell, isBuy.value],
() => {
syncFormWithLatestPrice()
}
)
function calculateCash(val: number) {
priceErrorVisible.value = false
// console.log(val)
@@ -556,7 +586,8 @@ const formatter = (value: number) => {
const price = computed((): Price => <Price>lastPrice.value ?? 0)
const goldPriceValue = computed(() => {
if (!price.value) return 0
// if (!price.value) return 0
if (!lastPrice.value?.price) return 0
return isBuy.value
? (price.value.buy ?? 0)
: (price.value.sell ?? 0)