fix some bugs
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||||
|
|
||||||
|
/** پیشفرض تاریخی UI وقتی تنظیم خالی است (۱۰۰ هزار تومان = ۱٬۰۰۰٬۰۰۰ ریال) */
|
||||||
|
export const DEFAULT_WALLET_MIN_RIAL = 1_000_000
|
||||||
|
|
||||||
|
export function parseWalletMinRial(
|
||||||
|
raw: string | number | null | undefined,
|
||||||
|
fallback = DEFAULT_WALLET_MIN_RIAL,
|
||||||
|
): number {
|
||||||
|
if (raw == null || String(raw).trim() === '') {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
const n = Number(String(raw).replace(/,/g, '').trim())
|
||||||
|
if (!Number.isFinite(n) || n < 0) {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
return Math.floor(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatWalletMinHint(
|
||||||
|
kind: 'withdraw' | 'deposit',
|
||||||
|
amountRial: number,
|
||||||
|
formatPrice: (value: number) => string = usePriceWithoutType,
|
||||||
|
): string {
|
||||||
|
const label = kind === 'withdraw' ? 'برداشتی' : 'واریزی'
|
||||||
|
return `حداقل مبلغ ${label} ${formatPrice(amountRial)} ریال می باشد.`
|
||||||
|
}
|
||||||
@@ -10,9 +10,11 @@ import { useInfiniteScroll } from '@vueuse/core'
|
|||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import type { Card } from '@/models/wallet'
|
import type { Card } from '@/models/wallet'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
|
import { useSettingsStore } from '@/store/settingsStore'
|
||||||
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
import type { TableEngineInput, TableOutput } from '@/models/table'
|
import type { TableEngineInput, TableOutput } from '@/models/table'
|
||||||
import { getTransactionTable, getTransactionTable2 } from '@/api/transaction'
|
import { getTransactionTable, getTransactionTable2 } from '@/api/transaction'
|
||||||
|
import { formatWalletMinHint, parseWalletMinRial } from '@/utils/walletMinAmount'
|
||||||
|
|
||||||
export interface WalletPageContext {
|
export interface WalletPageContext {
|
||||||
isDeposit: ReturnType<typeof ref<boolean>>
|
isDeposit: ReturnType<typeof ref<boolean>>
|
||||||
@@ -30,6 +32,8 @@ export interface WalletPageContext {
|
|||||||
withdrawItems: ReturnType<typeof ref<Transaction[]>>
|
withdrawItems: ReturnType<typeof ref<Transaction[]>>
|
||||||
mobileDepositScrollEl: ReturnType<typeof ref<HTMLElement | null>>
|
mobileDepositScrollEl: ReturnType<typeof ref<HTMLElement | null>>
|
||||||
desktopDepositScrollEl: ReturnType<typeof ref<HTMLElement | null>>
|
desktopDepositScrollEl: ReturnType<typeof ref<HTMLElement | null>>
|
||||||
|
minWithdrawHint: ReturnType<typeof computed<string>>
|
||||||
|
minDepositHint: ReturnType<typeof computed<string>>
|
||||||
usePriceWithoutType: typeof usePriceWithoutType
|
usePriceWithoutType: typeof usePriceWithoutType
|
||||||
usePrice: typeof usePrice
|
usePrice: typeof usePrice
|
||||||
setIsDeposit: (val: boolean) => void
|
setIsDeposit: (val: boolean) => void
|
||||||
@@ -48,6 +52,7 @@ export function useWalletPage() {
|
|||||||
const isDeposit = ref(true)
|
const isDeposit = ref(true)
|
||||||
const walletStore = useWalletStore()
|
const walletStore = useWalletStore()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
const settingsStore = useSettingsStore()
|
||||||
const isDesktop = useDesktopBreakpoint()
|
const isDesktop = useDesktopBreakpoint()
|
||||||
const showAddCard = ref(false)
|
const showAddCard = ref(false)
|
||||||
const chargeAccountModal = ref(false)
|
const chargeAccountModal = ref(false)
|
||||||
@@ -87,6 +92,19 @@ export function useWalletPage() {
|
|||||||
|
|
||||||
const unitCalculator = computed(() => (walletStore?.walletInfo?.cash ?? 0) / 100)
|
const unitCalculator = computed(() => (walletStore?.walletInfo?.cash ?? 0) / 100)
|
||||||
|
|
||||||
|
const minWithdrawAmount = computed(() =>
|
||||||
|
parseWalletMinRial(settingsStore.getSettingByKey('min_withdraw')),
|
||||||
|
)
|
||||||
|
const minDepositAmount = computed(() =>
|
||||||
|
parseWalletMinRial(settingsStore.getSettingByKey('min_deposit')),
|
||||||
|
)
|
||||||
|
const minWithdrawHint = computed(() =>
|
||||||
|
formatWalletMinHint('withdraw', minWithdrawAmount.value),
|
||||||
|
)
|
||||||
|
const minDepositHint = computed(() =>
|
||||||
|
formatWalletMinHint('deposit', minDepositAmount.value),
|
||||||
|
)
|
||||||
|
|
||||||
const disableButton = computed(() => {
|
const disableButton = computed(() => {
|
||||||
if (loading.value) return true
|
if (loading.value) return true
|
||||||
if (walletStore?.walletInfo?.cash && !isDeposit.value) {
|
if (walletStore?.walletInfo?.cash && !isDeposit.value) {
|
||||||
@@ -95,13 +113,16 @@ export function useWalletPage() {
|
|||||||
walletStore?.walletInfo?.cash <= 0 ||
|
walletStore?.walletInfo?.cash <= 0 ||
|
||||||
walletStore?.walletInfo?.cash < parseInt(String(form.value?.value)) ||
|
walletStore?.walletInfo?.cash < parseInt(String(form.value?.value)) ||
|
||||||
isNaN(parseInt(String(form.value?.value))) ||
|
isNaN(parseInt(String(form.value?.value))) ||
|
||||||
parseInt(String(form.value?.value)) < 1000000
|
parseInt(String(form.value?.value)) < minWithdrawAmount.value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (isDeposit.value) {
|
if (isDeposit.value) {
|
||||||
return isNaN(parseInt(String(form.value?.value))) || parseInt(String(form.value?.value)) < 1000000
|
return (
|
||||||
|
isNaN(parseInt(String(form.value?.value))) ||
|
||||||
|
parseInt(String(form.value?.value)) < minDepositAmount.value
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
@@ -267,6 +288,8 @@ export function useWalletPage() {
|
|||||||
withdrawItems,
|
withdrawItems,
|
||||||
mobileDepositScrollEl,
|
mobileDepositScrollEl,
|
||||||
desktopDepositScrollEl,
|
desktopDepositScrollEl,
|
||||||
|
minWithdrawHint,
|
||||||
|
minDepositHint,
|
||||||
usePriceWithoutType,
|
usePriceWithoutType,
|
||||||
usePrice,
|
usePrice,
|
||||||
setIsDeposit,
|
setIsDeposit,
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
<Transition mode="out-in" name="fade">
|
<Transition mode="out-in" name="fade">
|
||||||
<div v-if="!isDeposit" key="withdraw" class="dwallet-form__extras">
|
<div v-if="!isDeposit" key="withdraw" class="dwallet-form__extras">
|
||||||
<p class="dwallet-form__hint dwallet-form__hint--warn">
|
<p class="dwallet-form__hint dwallet-form__hint--warn">
|
||||||
حداقل مبلغ برداشتی 100 هزار تومان می باشد.
|
{{ minWithdrawHint }}
|
||||||
</p>
|
</p>
|
||||||
<p class="dwallet-form__balance-text">
|
<p class="dwallet-form__balance-text">
|
||||||
موجودی کیف پول:
|
موجودی کیف پول:
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else key="deposit" class="dwallet-form__extras">
|
<div v-else key="deposit" class="dwallet-form__extras">
|
||||||
<p class="dwallet-form__hint dwallet-form__hint--warn">
|
<p class="dwallet-form__hint dwallet-form__hint--warn">
|
||||||
حداقل مبلغ واریزی 100 هزار تومان می باشد.
|
{{ minDepositHint }}
|
||||||
</p>
|
</p>
|
||||||
<div class="dwallet-quick-amounts">
|
<div class="dwallet-quick-amounts">
|
||||||
<button type="button" class="dwallet-quick-amounts__btn" @click="form.value = 10000000">
|
<button type="button" class="dwallet-quick-amounts__btn" @click="form.value = 10000000">
|
||||||
@@ -191,6 +191,8 @@ const {
|
|||||||
percentChange,
|
percentChange,
|
||||||
ok,
|
ok,
|
||||||
getCards,
|
getCards,
|
||||||
|
minWithdrawHint,
|
||||||
|
minDepositHint,
|
||||||
} = useWalletPageContext()
|
} = useWalletPageContext()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user