diff --git a/env.d.ts b/env.d.ts index 11f02fe..f4a38bb 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1 +1,8 @@ /// + +declare module 'vue3-odometer' { + import type { DefineComponent } from 'vue' + + const Vue3Odometer: DefineComponent, Record, unknown> + export default Vue3Odometer +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 0cb2c9f..cf35f95 100644 --- a/src/main.ts +++ b/src/main.ts @@ -78,9 +78,8 @@ function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) { } router.beforeEach(async (to, from, next) => { - authStore.setLoading(true) - console.log(authStore) + // console.log(authStore) if (timeoutId) { clearTimeout(timeoutId) } @@ -107,7 +106,7 @@ router.beforeEach(async (to, from, next) => { if (getToken()) { await userStore.getMyInfo() const finger_print =userStore.userInfo.finger_print - console.log(finger_print) + // console.log(finger_print) // const { finger_print } = await getMe() hasFingerPrint = finger_print // If on an Apple device and fingerprint exists diff --git a/src/store/fundStore.ts b/src/store/fundStore.ts index 388cdb1..db55e5b 100644 --- a/src/store/fundStore.ts +++ b/src/store/fundStore.ts @@ -10,7 +10,7 @@ export const useFundUserStore = defineStore('fund', () => { const myFunds = ref | undefined>(undefined) async function getMyFund() { try { - console.log('fff') + // console.log('fff') myFunds.value = await getFundTable() return myFunds.value } catch (e) { diff --git a/src/views/base/gold/index.vue b/src/views/base/gold/index.vue index 9142c81..668cc7a 100644 --- a/src/views/base/gold/index.vue +++ b/src/views/base/gold/index.vue @@ -25,9 +25,11 @@ {{ !isBuy ? 'قیمت فروش' : 'قیمت خرید' }} - - {{ usePriceWithoutType(isBuy ? ((props?.ProductItem?.price ?? 0) + (props?.ProductItem?.cash_fee_buy ?? 0)) : ((props?.ProductItem?.price ?? 0) - (props?.ProductItem?.cash_fee_sell ?? 0)) ) }} - + ریال @@ -43,7 +45,7 @@ - + { isBuy.value = true break } + await initPrice() /* await initSellTable() await initBuyTable()*/ }) @@ -416,6 +422,10 @@ onMounted(() => { } }) +onUnmounted(() => { + stopPriceInterval() +}) + function percentChange(val: number) { if (val !== 0) if (isBuy.value) { @@ -508,7 +518,6 @@ function useStyle() { else return ' right: 98%; transform: translate(100%, 0);' } - function setIsBuy(val: boolean) { isBuy.value = val form.value.goldValue = undefined @@ -528,21 +537,29 @@ const formatter = (value: number) => { return `${value}%` } - const price = computed((): Price => lastPrice.value ?? 0) +const displayedGoldPrice = ref(0) + +watch([() => lastPrice.value, isBuy], () => { + if (lastPrice.value) { + displayedGoldPrice.value = isBuy.value ? (lastPrice.value.buy ?? 0) : (lastPrice.value.sell ?? 0) + } +}, { immediate: true }) + async function initPrice() { try { - // chartLoading.value = true await getLastPrices() - // await setIntervalGetPrice() + await setIntervalGetAllPrice() loading.value = true price.value = lastPrice.value + if (lastPrice.value) { + displayedGoldPrice.value = isBuy.value ? (lastPrice.value.buy ?? 0) : (lastPrice.value.sell ?? 0) + } } catch (e) { console.log(e) } finally { loading.value = false - // chartLoading.value = false } } @@ -577,8 +594,6 @@ async function ok() { infoVisible.value = false } } - -const livePrice = computed(() => lastPrice.value?.price_last ?? 0)