add loadServiceFeeFromSettings
This commit is contained in:
Vendored
-13
@@ -8,24 +8,13 @@ export {}
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
AButton: typeof import('ant-design-vue/es')['Button']
|
||||
ADivider: typeof import('ant-design-vue/es')['Divider']
|
||||
AForm: typeof import('ant-design-vue/es')['Form']
|
||||
AFormItem: typeof import('ant-design-vue/es')['FormItem']
|
||||
AInput: typeof import('ant-design-vue/es')['Input']
|
||||
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
|
||||
AModal: typeof import('ant-design-vue/es')['Modal']
|
||||
ARadio: typeof import('ant-design-vue/es')['Radio']
|
||||
ARadioButton: typeof import('ant-design-vue/es')['RadioButton']
|
||||
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
|
||||
ASelect: typeof import('ant-design-vue/es')['Select']
|
||||
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
|
||||
ASlider: typeof import('ant-design-vue/es')['Slider']
|
||||
ASpin: typeof import('ant-design-vue/es')['Spin']
|
||||
ASwitch: typeof import('ant-design-vue/es')['Switch']
|
||||
ATag: typeof import('ant-design-vue/es')['Tag']
|
||||
ATextarea: typeof import('ant-design-vue/es')['Textarea']
|
||||
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']
|
||||
Basic: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/basic.vue')['default']
|
||||
BasicActionSheet: typeof import('./src/components/BasicPacks/BasicActionSheet.vue')['default']
|
||||
@@ -67,8 +56,6 @@ declare module 'vue' {
|
||||
Text: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/text.vue')['default']
|
||||
Time: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/time.vue')['default']
|
||||
TransactionSkeleton: typeof import('./src/components/TransactionSkeleton.vue')['default']
|
||||
VanActionSheet: typeof import('vant/es')['ActionSheet']
|
||||
VanDialog: typeof import('vant/es')['Dialog']
|
||||
VanField: typeof import('vant/es')['Field']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { ref } from 'vue'
|
||||
import { getSettings } from '@/api/configuration'
|
||||
|
||||
export const serviceFeePercentage = ref<number>(0.01)
|
||||
|
||||
export async function loadServiceFeeFromSettings() {
|
||||
try {
|
||||
const settings = await getSettings()
|
||||
if (settings && Array.isArray(settings)) {
|
||||
const feeSetting = settings.find(
|
||||
(s) => s?.key === 'fee_service_charge_percentage' && s?.is_active === true
|
||||
)
|
||||
if (feeSetting?.value !== undefined && feeSetting?.value !== null) {
|
||||
serviceFeePercentage.value = Number(feeSetting.value)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
export function calcFeeInGrams(goldValue?: number | null) {
|
||||
return parseFloat(((goldValue ?? 0) * Number(serviceFeePercentage.value)).toFixed(4))
|
||||
}
|
||||
@@ -131,7 +131,7 @@
|
||||
<div class="flex justify-between items-center">
|
||||
<div>کارمزد:</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<div class="">{{ parseFloat(((form.goldValue ?? 0) * 0.01).toFixed(4)) }}</div>
|
||||
<div class="">{{ feeInGrams }}</div>
|
||||
<!-- <div class="font-bold text-2xl">{{ 0 }}</div>-->
|
||||
<div>
|
||||
گرم
|
||||
@@ -171,7 +171,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) * 0.01).toFixed(4)) }}</div>
|
||||
<div class="font-bold text-xl">{{ feeInGrams }}</div>
|
||||
<div class="text-xs mr-1">گرم</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -236,7 +236,7 @@ import { getLastPrices, getUpPrice, lastPrice, setIntervalGetAllPrice, stopPrice
|
||||
import type { Product } from '@/models/products'
|
||||
import { useFundUserStore } from '@/store/fundStore'
|
||||
import {useConfigStore} from "@/store/configStore";
|
||||
// import Bg_main from "@/components/bg_main.vue";
|
||||
import { calcFeeInGrams } from '@/utils/serviceFee'
|
||||
|
||||
const infoVisible = ref(false)
|
||||
const walletStore = useWalletStore()
|
||||
@@ -311,9 +311,7 @@ const finalPrice = computed(() => {
|
||||
const payablePrice = computed(() =>
|
||||
isBuy.value ? finalPrice.value + feeInRial.value : finalPrice.value - feeInRial.value
|
||||
)
|
||||
const feeInGrams = computed(() =>
|
||||
parseFloat(((form.value?.goldValue ?? 0) * 0.01).toFixed(4))
|
||||
)
|
||||
const feeInGrams = computed(() => calcFeeInGrams(form.value?.goldValue))
|
||||
const unitPrice = computed(() =>
|
||||
(props?.ProductItem?.price_profit ?? 0) + (props?.ProductItem?.price ?? 0)
|
||||
)
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
<div class="flex justify-between items-center">
|
||||
<div>کارمزد:</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<div class="">{{ parseFloat(((form.goldValue ?? 0) * (Number(feeAmount))).toFixed(4)) }}</div>
|
||||
<div class="">{{ feeInGrams }}</div>
|
||||
<div>
|
||||
گرم
|
||||
</div>
|
||||
@@ -231,8 +231,7 @@ import { getLastPrices, getUpPrice, lastPrice, setIntervalGetAllPrice, stopPrice
|
||||
import type { Product } from '@/models/products'
|
||||
import { useFundUserStore } from '@/store/fundStore'
|
||||
import {useConfigStore} from "@/store/configStore";
|
||||
import { getSettings } from '@/api/configuration'
|
||||
// import Bg_main from "@/components/bg_main.vue";
|
||||
import { calcFeeInGrams, loadServiceFeeFromSettings } from '@/utils/serviceFee'
|
||||
|
||||
const infoVisible = ref(false)
|
||||
const walletStore = useWalletStore()
|
||||
@@ -245,7 +244,6 @@ const sellItems = ref<Transaction[]>([])
|
||||
const priceErrorVisible = ref<boolean>(false)
|
||||
const buyTableOutput = ref<TableOutput<Transaction> | null>(null)
|
||||
const sellTableOutput = ref<TableOutput<Transaction> | null>(null)
|
||||
const feeAmount = ref<number>(0.01)
|
||||
const el = ref()
|
||||
|
||||
interface Prop {
|
||||
@@ -277,9 +275,7 @@ const sellPagination = ref<TableEngineInput>({
|
||||
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 feeInGrams = computed(() => calcFeeInGrams(form.value?.goldValue))
|
||||
const finalPrice = computed(() => (form.value?.goldValue ?? 0) * unitPrice.value)
|
||||
const feeInRial = computed(() => unitPrice.value * feeInGrams.value)
|
||||
const equivalentPrice = computed(() => usePriceWithoutType(feeInRial.value.toFixed(0)))
|
||||
@@ -351,16 +347,6 @@ async function initSellTable() {
|
||||
}
|
||||
}
|
||||
|
||||
async function getFeePercentage() {
|
||||
const settings = await getSettings()
|
||||
if (settings && Array.isArray(settings)) {
|
||||
const feeSetting = settings.find(s => s?.key === 'fee_service_charge_percentage' && s?.is_active === true)
|
||||
if(feeSetting && feeSetting.value !== undefined && feeSetting.value !== null) {
|
||||
feeAmount.value = feeSetting.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (!userStore.isSingle) {
|
||||
/*useInfiniteScroll(
|
||||
el,
|
||||
@@ -407,7 +393,7 @@ onMounted(async () => {
|
||||
break
|
||||
}
|
||||
await initPrice()
|
||||
await getFeePercentage()
|
||||
await loadServiceFeeFromSettings()
|
||||
/* await initSellTable()
|
||||
await initBuyTable()*/
|
||||
})
|
||||
|
||||
@@ -107,6 +107,7 @@ import BasicModal from "@/components/BasicPacks/BasicModal.vue";
|
||||
import { isProductPriceInactive } from '@/utils/productPrice'
|
||||
import { isBoursecuProject } from '@/utils/config'
|
||||
import { isBoursecuDealProductGroup } from '@/utils/productDealMethod'
|
||||
import { loadServiceFeeFromSettings } from '@/utils/serviceFee'
|
||||
|
||||
const activekey = ref('طلا' ||'آبشده')
|
||||
const showFilter = ref(false)
|
||||
@@ -169,7 +170,7 @@ onMounted(async () => {
|
||||
// typeItems.value[index] = val.group_type
|
||||
})
|
||||
firstItems.value = items.value
|
||||
await initPrice()
|
||||
await Promise.all([initPrice(), loadServiceFeeFromSettings()])
|
||||
// await setIntervalGetLastPrice()
|
||||
// console.log('run product')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user