fix price
This commit is contained in:
Vendored
+2
@@ -25,6 +25,7 @@ declare module 'vue' {
|
|||||||
ATag: typeof import('ant-design-vue/es')['Tag']
|
ATag: typeof import('ant-design-vue/es')['Tag']
|
||||||
ATextarea: typeof import('ant-design-vue/es')['Textarea']
|
ATextarea: typeof import('ant-design-vue/es')['Textarea']
|
||||||
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
|
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
|
||||||
|
AUpload: typeof import('ant-design-vue/es')['Upload']
|
||||||
BaseDatePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/BaseDatePicker.vue')['default']
|
BaseDatePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/BaseDatePicker.vue')['default']
|
||||||
Basic: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/basic.vue')['default']
|
Basic: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/basic.vue')['default']
|
||||||
BasicActionSheet: typeof import('./src/components/BasicPacks/BasicActionSheet.vue')['default']
|
BasicActionSheet: typeof import('./src/components/BasicPacks/BasicActionSheet.vue')['default']
|
||||||
@@ -68,5 +69,6 @@ declare module 'vue' {
|
|||||||
TransactionSkeleton: typeof import('./src/components/TransactionSkeleton.vue')['default']
|
TransactionSkeleton: typeof import('./src/components/TransactionSkeleton.vue')['default']
|
||||||
VanActionSheet: typeof import('vant/es')['ActionSheet']
|
VanActionSheet: typeof import('vant/es')['ActionSheet']
|
||||||
VanDialog: typeof import('vant/es')['Dialog']
|
VanDialog: typeof import('vant/es')['Dialog']
|
||||||
|
VanField: typeof import('vant/es')['Field']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ function applyPriceOffsetPercent(basePrice: number, offsetPercent?: number | nul
|
|||||||
/** قیمت خرید نمایشی محصول (همان مقداری که در لیست و اکشنشیت نشان داده میشود) */
|
/** قیمت خرید نمایشی محصول (همان مقداری که در لیست و اکشنشیت نشان داده میشود) */
|
||||||
export function getProductBuyPrice(product: Product): number {
|
export function getProductBuyPrice(product: Product): number {
|
||||||
if (isMeltedProductUsingAppPrice(product)) {
|
if (isMeltedProductUsingAppPrice(product)) {
|
||||||
const base = applyPriceOffsetPercent(getTradeBuyPrice(lastPrice.value), product.price_offset_percent)
|
const tradeBuy = getTradeBuyPrice(lastPrice.value)
|
||||||
|
const base = tradeBuy > 0
|
||||||
|
? applyPriceOffsetPercent(tradeBuy, product.price_offset_percent)
|
||||||
|
: (product.price ?? 0)
|
||||||
return base + (product.cash_fee_buy ?? 0)
|
return base + (product.cash_fee_buy ?? 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +39,10 @@ export function getProductBuyPrice(product: Product): number {
|
|||||||
/** قیمت فروش نمایشی محصول آبشدهای */
|
/** قیمت فروش نمایشی محصول آبشدهای */
|
||||||
export function getProductSellPrice(product: Product): number {
|
export function getProductSellPrice(product: Product): number {
|
||||||
if (isMeltedProductUsingAppPrice(product)) {
|
if (isMeltedProductUsingAppPrice(product)) {
|
||||||
const base = applyPriceOffsetPercent(getTradeSellPrice(lastPrice.value), product.price_offset_percent)
|
const tradeSell = getTradeSellPrice(lastPrice.value)
|
||||||
|
const base = tradeSell > 0
|
||||||
|
? applyPriceOffsetPercent(tradeSell, product.price_offset_percent)
|
||||||
|
: (product.price ?? 0)
|
||||||
return base - (product.cash_fee_sell ?? 0)
|
return base - (product.cash_fee_sell ?? 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ import { isProductPriceInactive } from '@/utils/productPrice'
|
|||||||
import { isMetalCommodityGroup, isMeltedTradeGroup } from '@/utils/productCategories'
|
import { isMetalCommodityGroup, isMeltedTradeGroup } from '@/utils/productCategories'
|
||||||
import { isBoursecuDealProductGroup } from '@/utils/productDealMethod'
|
import { isBoursecuDealProductGroup } from '@/utils/productDealMethod'
|
||||||
import { loadServiceFeeFromSettings } from '@/utils/serviceFee'
|
import { loadServiceFeeFromSettings } from '@/utils/serviceFee'
|
||||||
|
import { getLastPrices, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
||||||
|
|
||||||
const activekey = ref('طلا' ||'آبشده')
|
const activekey = ref('طلا' ||'آبشده')
|
||||||
const showFilter = ref(false)
|
const showFilter = ref(false)
|
||||||
@@ -210,6 +211,8 @@ async function refreshProducts() {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
await getLastPrices()
|
||||||
|
startLastPricePolling()
|
||||||
items.value = await getProducts()
|
items.value = await getProducts()
|
||||||
|
|
||||||
if (items.value?.length) {
|
if (items.value?.length) {
|
||||||
@@ -225,7 +228,6 @@ onMounted(async () => {
|
|||||||
})
|
})
|
||||||
firstItems.value = items.value
|
firstItems.value = items.value
|
||||||
await loadServiceFeeFromSettings()
|
await loadServiceFeeFromSettings()
|
||||||
// فقط لیست محصولات هر ۱۰ ثانیه — last فقط در صفحه اصلی poll میشود
|
|
||||||
productListInterval = setInterval(refreshProducts, 10000)
|
productListInterval = setInterval(refreshProducts, 10000)
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -247,6 +249,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
stopLastPricePolling()
|
||||||
if (productListInterval) {
|
if (productListInterval) {
|
||||||
clearInterval(productListInterval)
|
clearInterval(productListInterval)
|
||||||
productListInterval = undefined
|
productListInterval = undefined
|
||||||
|
|||||||
Reference in New Issue
Block a user