fix kashkool
This commit is contained in:
+126
-123
@@ -1,12 +1,14 @@
|
||||
<template>
|
||||
<div class=" mt-20">
|
||||
<!-- <div class="flex gap-7 overflow-x-scroll px-5">
|
||||
<ProductInventory v-for="item in productInventorys" :ProductItem="item" class="shadow-lg my-5" :key="item.id"></ProductInventory>
|
||||
</div>-->
|
||||
<div>
|
||||
<div class="home-page-root">
|
||||
<GhatrehHomeDesktopView
|
||||
v-show="isDesktop"
|
||||
@logout="showLogoutConfirm = true"
|
||||
@open-balance="openWholeBalanceVisible()"
|
||||
/>
|
||||
<div v-show="!isDesktop" class="mt-20">
|
||||
<div
|
||||
v-if="userStore.userInfo && !loading"
|
||||
class="bg-white w-screen md:w-auto h-fit px-5 m-[-1px]"
|
||||
v-if="!loading"
|
||||
class="bg-white w-full md:w-auto h-fit px-5 m-[-1px]"
|
||||
>
|
||||
<div
|
||||
v-if="limitedPrice !== undefined && userStore?.userInfo.trade_active !== 1"
|
||||
@@ -14,7 +16,7 @@
|
||||
>
|
||||
<Icon icon="vuesax-linear:info-circle" size="16" />
|
||||
حداقل مبلغ اولیه برای ثبت سفارش
|
||||
{{ usePriceWithoutType(limitedPrice.value as number ?? 0) }} ریال می باشد.
|
||||
{{ usePriceWithoutType(parseInt(limitedPrice.value) ?? 0) }} ریال می باشد.
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -34,7 +36,7 @@
|
||||
</div>
|
||||
|
||||
<div class="flex justify-between items-end mb-3">
|
||||
<div class="text-sm "></div>
|
||||
<div class="text-sm" />
|
||||
<div>
|
||||
<div class="text-xs opacity-75" style="justify-self: end;">شناسه شما در کشکول گلد</div>
|
||||
<div class="flex">
|
||||
@@ -53,14 +55,13 @@
|
||||
<div class="flex justify-between items-center font-semibold text-base">
|
||||
<div>
|
||||
<div class="text-xs opacity-75 mb-1">موجودی</div>
|
||||
<div>{{ (userStore?.userInfo?.wallet?.count_gold ?? 0).toFixed(3) }} گرم</div>
|
||||
<div>{{ balanceLabel }}</div>
|
||||
</div>
|
||||
<div class="w-px h-6 bg-white/30 mx-3"></div>
|
||||
<div>
|
||||
<div class="text-xs opacity-75 mb-1" style="justify-self: end;">معادل ریالی</div>
|
||||
<div>{{ usePriceWithoutType( ((userStore?.userInfo?.wallet?.count_gold ?? 0) * (goldVal ?? 0)).toFixed(0) ) }} ریال</div>
|
||||
<div>{{ usePriceWithoutType(totalRialDisplay) }} ریال</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -141,7 +142,7 @@
|
||||
>
|
||||
<Icon class="text-white font-bold" icon="vuesax-linear:archive-1" />
|
||||
</div>
|
||||
<div class="text-primary">قلک</div>
|
||||
<div class="text-primary">دارایی ها</div>
|
||||
</div>
|
||||
<div
|
||||
class="text-center w-full flex-flex-col items-center home_appear_fade_in_down"
|
||||
@@ -278,13 +279,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<swiper
|
||||
:slides-per-view="1"
|
||||
:space-between="5"
|
||||
>
|
||||
<swiper-slide><img class="img rounded-lg" :src="img2" /></swiper-slide>
|
||||
<swiper-slide><img class="img rounded-lg" :src="img2" /></swiper-slide>
|
||||
</swiper>
|
||||
<div class="home-banner w-full mt-5 overflow-hidden rounded-lg">
|
||||
<swiper
|
||||
:slides-per-view="1"
|
||||
:space-between="5"
|
||||
class="home-banner__swiper"
|
||||
>
|
||||
<swiper-slide class="home-banner__slide">
|
||||
<img class="home-banner__img rounded-lg" :src="img2" alt="" />
|
||||
</swiper-slide>
|
||||
<swiper-slide class="home-banner__slide">
|
||||
<img class="home-banner__img rounded-lg" :src="img2" alt="" />
|
||||
</swiper-slide>
|
||||
</swiper>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex mt-5 gap-1 bg-primary text-white font-bold justify-center cursor-pointer rounded-lg py-5"
|
||||
@@ -352,24 +360,12 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div v-else class="bg-white w-screen md:w-auto h-[80vh] px-5 m-[-1px] flex justify-center ">
|
||||
<div v-else class="bg-white w-full md:w-auto h-[80vh] px-5 m-[-1px] flex justify-center">
|
||||
<HomeSkeleton class="w-full" />
|
||||
</div>
|
||||
<!-- <div class="relative pt-15 overflow-hidden ">-->
|
||||
<!-- <div class="absolute left--12 top-0">-->
|
||||
<!-- <img :src="image">-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="bg-primary pb-30"-->
|
||||
<!-- style="background: linear-gradient(to bottom, #fff,#fff, #a72b77, #a72b77);"-->
|
||||
<!-- >-->
|
||||
<!-- <div class=" text-tertiary text-2xl pt-6 pr-5 pl-50" style="font-size: 26px;font-weight: 600; color: #a72b77" >ارسال کالا بعد از ثبت سفارش</div>-->
|
||||
<!-- <div class="pr-5 pl-8 pt-10 text-tertiary ">میتوانید با خرید محصولات بعد از ثبت سفارش درخواست ارسال را-->
|
||||
<!-- ثبت کرده و زیر 24 ساعت خرید خود را دریافت کنید-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
<div
|
||||
v-if="!isDesktop"
|
||||
:class="y > 50 ? 'bg-white shadow opacity-95' : ''"
|
||||
class="px-4 py-2 top-0 z-5 wrap-fix background-color-transition"
|
||||
>
|
||||
@@ -417,7 +413,6 @@
|
||||
<div class="text-center" @click="showLogoutConfirm = false">انصراف</div>
|
||||
</template>
|
||||
</DialogVant>
|
||||
</div>
|
||||
<BasicActionSheet v-model:show="wholeBalanceVisible">
|
||||
<div class="pb-20">
|
||||
<div>
|
||||
@@ -428,30 +423,22 @@
|
||||
class="flex justify-between"
|
||||
title="مجموعه کل دارایی طلایی"
|
||||
is-line
|
||||
:info="`در این قسمت مجموع کل وزن طلای آبشده (${(walletStore.walletInfo?.gold ?? 0)?.toFixed(3)}) + ارزش دارایی ها (${(walletStore.walletInfo?.treasure_sum ?? 0)?.toFixed(3)} ) را مشاهده میفرمایید.`"
|
||||
infoHead="مجموع کل دارایی طلایی"
|
||||
:value="parseFloat((walletStore.walletInfo?.gold_sum ?? 0).toFixed(2)) + ' گرم'"
|
||||
:value="balanceLabel"
|
||||
/>
|
||||
<!-- <a-divider class="!my-1" />
|
||||
<BasicInfoItem
|
||||
class="flex justify-between"
|
||||
title="میزان طلای آبشده"
|
||||
is-line
|
||||
:value="parseFloat((walletStore.walletInfo?.gold ?? 0)?.toFixed(3)) + ' گرم'"
|
||||
/>
|
||||
<a-divider class="!my-1" />
|
||||
<BasicInfoItem
|
||||
class="flex justify-between"
|
||||
title="ارزش گنج ها"
|
||||
is-line
|
||||
:value="parseFloat((walletStore.walletInfo?.treasure_sum ?? 0)?.toFixed(3)) + ' گرم'"
|
||||
/>-->
|
||||
<a-divider class="!my-1" />
|
||||
<BasicInfoItem
|
||||
v-if="countBasedInventory > 0"
|
||||
class="flex justify-between"
|
||||
title="تعداد محصولات"
|
||||
is-line
|
||||
:value="`${countBasedInventory} عدد`"
|
||||
/>
|
||||
<a-divider v-if="countBasedInventory > 0" class="!my-1" />
|
||||
<BasicInfoItem
|
||||
class="flex justify-between"
|
||||
title="دارایی کیف پول ریالی"
|
||||
is-line
|
||||
:value="usePrice(walletStore.walletInfo?.cash ?? 0)"
|
||||
:value="usePrice(assetsSummary?.cash_wallet ?? walletStore.walletInfo?.cash ?? 0)"
|
||||
/>
|
||||
<a-divider class="!my-1" />
|
||||
<BasicInfoItem
|
||||
@@ -468,14 +455,7 @@
|
||||
class="flex justify-between"
|
||||
title="ارزش کل دارایی شما"
|
||||
is-line
|
||||
:value="
|
||||
usePrice(
|
||||
(
|
||||
(walletStore.walletInfo?.gold_sum ?? 0) * (goldVal ?? 0) +
|
||||
(walletStore.walletInfo?.cash ?? 0)
|
||||
).toFixed(0)
|
||||
)
|
||||
"
|
||||
:value="usePrice(totalRialDisplay)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -502,7 +482,7 @@
|
||||
</a-button>
|
||||
</template>
|
||||
</BasicModal>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="tsx" setup>
|
||||
@@ -511,7 +491,7 @@ import 'swiper/swiper-bundle.css';
|
||||
import img2 from '@/assets/img/banner/2.png'
|
||||
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import { usePrice, usePriceWithoutType, useTowDecimal } from '../../../utils/usePrice'
|
||||
import {computed, createVNode, onMounted, onUnmounted, ref, watch} from 'vue'
|
||||
import {computed, createVNode, onActivated, onMounted, onUnmounted, ref, watch} from 'vue'
|
||||
import router from '@/router'
|
||||
import * as echarts from 'echarts'
|
||||
import { useIntersectionObserver, useWindowScroll } from '@vueuse/core'
|
||||
@@ -523,8 +503,10 @@ import { getAllPrices, getChart } from '@/api/home'
|
||||
import Vue3Odometer from 'vue3-odometer'
|
||||
import 'odometer/themes/odometer-theme-default.css'
|
||||
import HomeSkeleton from '@/views/base/home/components/HomeSkeleton.vue'
|
||||
import GhatrehHomeDesktopView from '@/views/base/home/desktop/GhatrehHomeDesktopView.vue'
|
||||
import {
|
||||
getLastPrices,
|
||||
getTradeBuyPrice,
|
||||
getUpPrice,
|
||||
lastPrice,
|
||||
percentPriceChanged,
|
||||
@@ -537,9 +519,9 @@ import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import BasicInfoItem from '@/components/BasicPacks/BasicInfoItem.vue'
|
||||
import ProductInventory from '@/views/base/home/components/ProductInventory.vue'
|
||||
import type { PInventory, Product } from '@/models/products'
|
||||
import type { Fund } from '@/models/fund'
|
||||
import type { TableOutput } from '@/models/table'
|
||||
import { useFundUserStore } from '@/store/fundStore'
|
||||
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||
import { resolveAssetsRialValue } from '@/utils/productAssets'
|
||||
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicModal from '@/components/BasicPacks/BasicModal.vue'
|
||||
@@ -547,6 +529,7 @@ import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const walletStore = useWalletStore()
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
const chartLoading = ref<boolean>(false)
|
||||
const openModal = ref<boolean>(false)
|
||||
const wholeBalanceVisible = ref<boolean>(false)
|
||||
@@ -557,23 +540,41 @@ const main = ref(null)
|
||||
const logoutLoading = ref(false)
|
||||
const productInventorys = ref<PInventory[] | undefined>()
|
||||
const value = ref<string>('a')
|
||||
const items = ref<Fund[]>([])
|
||||
const tableOutput = ref<TableOutput<Fund> | null>(null)
|
||||
const inventory = ref<number>(0)
|
||||
const sumGold = ref<number>(0)
|
||||
const fundStore = useFundUserStore()
|
||||
const { assetsSummary, loadWalletAssets } = useWalletAssets()
|
||||
|
||||
async function initTable() {
|
||||
try {
|
||||
loading.value = true
|
||||
tableOutput.value = fundStore.myFunds ?? await fundStore.getMyFund() ?? null
|
||||
items.value.push(...tableOutput.value?.rows ?? [])
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
const countBasedInventory = computed(() =>
|
||||
(assetsSummary.value?.count_products ?? []).reduce(
|
||||
(sum, item) => sum + Number(item.quantity ?? 0),
|
||||
0
|
||||
)
|
||||
)
|
||||
|
||||
const primaryMetalTotal = computed(() => assetsSummary.value?.metal_totals?.[0])
|
||||
|
||||
const balanceLabel = computed(() => {
|
||||
const meta = assetsSummary.value?.meta
|
||||
if (meta?.has_count_based_products && countBasedInventory.value > 0) {
|
||||
return `${countBasedInventory.value} عدد`
|
||||
}
|
||||
}
|
||||
|
||||
const metal = primaryMetalTotal.value
|
||||
if (metal && Number(metal.total_weight) > 0) {
|
||||
return `${Number(metal.total_weight).toFixed(3)} ${metal.unit}`
|
||||
}
|
||||
|
||||
const fallback =
|
||||
walletStore.walletInfo?.gold_sum ??
|
||||
userStore.userInfo?.wallet?.count_gold ??
|
||||
0
|
||||
return `${Number(fallback).toFixed(3)} گرم`
|
||||
})
|
||||
|
||||
const totalRialDisplay = computed(() =>
|
||||
resolveAssetsRialValue(
|
||||
assetsSummary.value,
|
||||
getTradeBuyPrice(price.value) || Number(goldVal.value ?? 0)
|
||||
)
|
||||
)
|
||||
|
||||
onUnmounted(() => {
|
||||
stopPriceInterval()
|
||||
@@ -588,20 +589,9 @@ onMounted(() => {
|
||||
const goldVal = ref<number | undefined>()
|
||||
|
||||
function openWholeBalanceVisible() {
|
||||
items.value.forEach(x => {
|
||||
if (x.title !== 'آبشده نقدی')
|
||||
inventory.value += x?.wallet?.gold ?? 0
|
||||
})
|
||||
wholeBalanceVisible.value = true
|
||||
}
|
||||
|
||||
function sumOfGold() {
|
||||
items.value.forEach(x => {
|
||||
if (x.title !== 'آبشده نقدی')
|
||||
return sumGold.value += x?.wallet?.gold ?? 0
|
||||
})
|
||||
}
|
||||
|
||||
function update() {
|
||||
setInterval(() => {
|
||||
goldVal.value = lastPrice?.value.price_last
|
||||
@@ -859,42 +849,35 @@ async function initPrice() {
|
||||
}
|
||||
}
|
||||
|
||||
async function initProductInventory() {
|
||||
try {
|
||||
// loading.value = true
|
||||
|
||||
// let { rows } = await getProductInventory()
|
||||
// fundStore.myFunds
|
||||
// productInventorys.value = fundStore.myFunds?.rows
|
||||
productInventorys.value = items.value.sort((a, b) => {
|
||||
if (a.wallet?.gold ?? 0 < b.wallet?.gold ?? 0)
|
||||
return -1
|
||||
if (a.wallet?.gold ?? 0 > b.wallet?.gold ?? 0)
|
||||
return 1
|
||||
return 0
|
||||
})
|
||||
// console.log(productInventorys.value)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
// loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
openModal.value = false
|
||||
localStorage.setItem('hasSeenIntroModal', 'true')
|
||||
router.push({ name: 'earnMoney' })
|
||||
}
|
||||
|
||||
onActivated(() => {
|
||||
void loadWalletAssets(true)
|
||||
if (!userStore.userInfo) {
|
||||
void userStore.getMyInfo()
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
await initTable()
|
||||
await initProductInventory()
|
||||
// await initChart()
|
||||
await initPrice()
|
||||
await fetchPrices()
|
||||
const tasks: Promise<unknown>[] = [
|
||||
initPrice(),
|
||||
fetchPrices(),
|
||||
loadWalletAssets(true),
|
||||
]
|
||||
|
||||
if (!userStore.userInfo) {
|
||||
tasks.push(userStore.getMyInfo())
|
||||
} else if (!walletStore.walletInfo && userStore.userInfo.wallet) {
|
||||
walletStore.walletInfo = userStore.userInfo.wallet
|
||||
}
|
||||
|
||||
await Promise.all(tasks)
|
||||
update()
|
||||
const hasSeenModal = localStorage.getItem('hasSeenIntroModal')
|
||||
if (!hasSeenModal) {
|
||||
@@ -957,6 +940,29 @@ function copyCode() {
|
||||
|
||||
<style lang="less">
|
||||
|
||||
.home-banner {
|
||||
width: 100%;
|
||||
|
||||
&__swiper {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__slide {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
margin: 0 auto;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
.odometer {
|
||||
font-size: 60px;
|
||||
text-align: center;
|
||||
@@ -982,7 +988,4 @@ apexchart {
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
</style>
|
||||
Reference in New Issue
Block a user