diff --git a/components.d.ts b/components.d.ts index e9be9b0..d3428fd 100644 --- a/components.d.ts +++ b/components.d.ts @@ -8,6 +8,7 @@ export {} declare module 'vue' { export interface GlobalComponents { AButton: typeof import('ant-design-vue/es')['Button'] + AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider'] ADivider: typeof import('ant-design-vue/es')['Divider'] AForm: typeof import('ant-design-vue/es')['Form'] AFormItem: typeof import('ant-design-vue/es')['FormItem'] @@ -23,7 +24,6 @@ declare module 'vue' { 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'] BaseDatePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/BaseDatePicker.vue')['default'] Basic: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/basic.vue')['default'] diff --git a/src/views/base/gold/index.vue b/src/views/base/gold/index.vue index db8ab27..168612c 100644 --- a/src/views/base/gold/index.vue +++ b/src/views/base/gold/index.vue @@ -4,11 +4,11 @@
-
خرید طلا {{ props?.ProductItem?.title }}
-
فروش طلا {{ props?.ProductItem?.title }}
@@ -46,17 +46,17 @@
- + type="price" @onchange="handleGoldCashChange" /> - - + + size="large" type="text" input="decimal" @onchange="handleGoldValueChange" /> @@ -182,6 +182,7 @@
ریال
+ ثبت نهایی @@ -207,35 +208,27 @@ import img1 from '@/assets/img/home_ly2.svg' import { usePrice, usePriceWithoutType } from '@/utils/usePrice' import BasicInput from '@/components/BasicPacks/BasicInput.vue' import type { Gold } from '@/models/gold' -import { isIphone, loading, loadingMore, toFixedDownThreeChar } from '@/utils' +import { loading, loadingMore, toFixedDownThreeChar } from '@/utils' import BasicButton from '@/components/BasicPacks/BasicButton.vue' import router from '@/router' import { useWalletStore } from '@/store/walletStore' import { createOrder } from '@/api/order' import { message } from 'ant-design-vue' import type { Price } from '@/models/home' -import { getLastPrice } from '@/api/home' import Icon from '@/components/BasicPacks/BasicIcon.vue' import { useUserStore } from '@/store/userStore' import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue' import { justNumber } from '@/utils/inputRules' import GoldSkeleton from '@/views/base/gold/components/GoldSkeleton.vue' import GoldLoading from '@/components/GoldLoading.vue' -import { update } from 'lodash' import BasicIcon from '@/components/BasicPacks/BasicIcon.vue' -import TransactionSkeleton from '@/components/TransactionSkeleton.vue' -import ListAnim from '@/components/ListAnim.vue' -import Item from '@/views/base/wallet/components/Item.vue' import type { Transaction } from '@/models/transaction' import type { TableEngineInput, TableOutput } from '@/models/table' -import { useInfiniteScroll } from '@vueuse/core' import { getTransactionTable } from '@/api/transaction' import { getLastPrices, getUpPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price' 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 {debounce} from "lodash"; const infoVisible = ref(false) const walletStore = useWalletStore() const userStore = useUserStore() @@ -254,6 +247,7 @@ interface Prop { } const props = withDefaults(defineProps(), {}) + const isBuy = ref(true) const buyPagination = ref({ @@ -403,24 +397,53 @@ const form = ref({ goldValue: undefined, percentWallet: undefined }) + +const persianToEnglish = (str: string | number | undefined): string => { + if (!str) return ''; + return str.toString() + .replace(/[۰-۹]/g, (d) => '۰۱۲۳۴۵۶۷۸۹'.indexOf(d).toString()) + .replace(/٫/g, '.'); +}; + +function handleGoldCashChange(val: string | number | undefined) { + if (val === undefined || val === null || val === '') { + form.value.goldCash = undefined + return + } + const valStr = val.toString() + const convertedValue = persianToEnglish(valStr) + const numericValue = parseFloat(convertedValue.replace(/,/g, '')) + form.value.goldCash = isNaN(numericValue) ? undefined : numericValue + if (form.value.goldCash !== undefined) { + calculateGold(form.value.goldCash) + } +} + +const handleGoldValueChange = debounce( (val: string | number | undefined) => { + if (val === undefined || val === null || val === '') { + form.value.goldValue = undefined + return + } + const valStr = val.toString() + const convertedValue = persianToEnglish(valStr) + const numericValue = parseFloat(convertedValue) + form.value.goldValue = isNaN(numericValue) ? undefined : numericValue + if (form.value.goldValue !== undefined) { + calculateCash(form.value.goldValue) + } +},1500) + const allowedAsciiCodeFloat = [46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57] const allowedAsciiCodeInt = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57] -watch(form.value, () => { - if (form.value.goldValue) { - const lastCharGoldStr: string = form.value.goldValue.toString() - if (!allowedAsciiCodeFloat.includes(lastCharGoldStr.slice(-1).charCodeAt(0))) { - form.value.goldValue = isNaN(parseFloat(lastCharGoldStr.slice(0, -1))) ? null : parseFloat(lastCharGoldStr.slice(0, -1)) - calculateCash(form.value.goldValue) - } +watch(() => form.value.goldValue, (newVal) => { + if (newVal !== undefined && newVal !== null && newVal !== '') { + calculateCash(newVal) } - if (form.value.goldCash) { - const lastCharCashStr: string = form.value.goldCash.toString() - if (!allowedAsciiCodeInt.includes(lastCharCashStr.slice(-1).charCodeAt(0))) { - form.value.goldCash = isNaN(parseFloat(lastCharCashStr.slice(0, -1))) ? null : parseFloat(lastCharCashStr.slice(0, -1)) - calculateGold(form.value.goldCash) - } +}) +watch(() => form.value.goldCash, (newVal) => { + if (newVal !== undefined && newVal !== null && newVal !== '') { + calculateGold(newVal) } - }) onMounted(() => { @@ -615,7 +638,7 @@ async function ok() { background: blue; }*/ .completeButtonStyle .van-dialog__confirm .van-button__content { - background: @App-primary-color; + background: #000000FF; color: white; } diff --git a/src/views/base/home/index.vue b/src/views/base/home/index.vue index f4d8f9e..3f3c583 100644 --- a/src/views/base/home/index.vue +++ b/src/views/base/home/index.vue @@ -1,19 +1,19 @@