2025-10-05 09:44:14 +03:30
< template >
2026-06-29 22:43:28 +03:30
< div class = "home-page-root" >
< GhatrehHomeDesktopView
v-show = "isDesktop"
@logout ="showLogoutConfirm = true"
@ open -balance =" openWholeBalanceVisible ()"
/>
2026-07-01 18:16:12 +03:30
< div v-show = "!isDesktop" class="home-mobile-root pb-[calc(var(--app-bottom-chrome-height)+1rem)]" >
< div class = "app-header-scroll-sentinel" aria -hidden =" true " />
2025-10-05 09:44:14 +03:30
< div
2026-06-29 22:43:28 +03:30
v-if = "!loading"
class = "bg-white w-full md:w-auto h-fit px-5 m-[-1px]"
2025-10-05 09:44:14 +03:30
>
2025-10-21 17:09:16 +03:30
< div
class = "px-5 py-5 shadow-lg rounded-2xl text-white relative overflow-hidden shadow-lg"
2026-05-20 09:41:01 +03:30
style = " background: linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%); "
2025-10-21 17:09:16 +03:30
>
< div
class = "absolute inset-0 opacity-20"
style = " background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.5), transparent 70%); " >
2025-10-20 18:26:45 +03:30
</ div >
2025-10-21 17:09:16 +03:30
< div class = "relative z-10" >
< div class = "flex font-bold text-lg items-center gap-2 mb-3" >
< img src = '@/assets/img/logo.png' alt = '' class = 'h-8 drop-shadow-md' />
2026-05-20 09:41:01 +03:30
< div class = "tracking-wide" > کشکول گلد </ div >
2025-10-21 17:09:16 +03:30
</ div >
< div class = "flex justify-between items-end mb-3" >
2026-06-29 22:43:28 +03:30
< div class = "text-sm" />
2025-10-29 16:34:24 +03:30
< div >
2026-05-19 20:53:52 +03:30
< div class = "text-xs opacity-75" style = "justify-self: end;" > شناسه شما در کشکول گلد </ div >
2025-10-29 16:34:24 +03:30
< div class = "flex" >
< div v-if = "userStore?.userInfo?.virtual_card_number" class="ml-2 " @click.stop="copyCode()" >
< BasicIcon
icon = "vuesax-linear:copy"
/>
</ div >
< div class = "font-semibold text-base" >
{{ userStore ? . userInfo ? . virtual_card_number ?? '---' }}
</ div >
2025-10-21 17:09:16 +03:30
</ div >
</ div >
</ div >
< div class = "flex justify-between items-center font-semibold text-base" >
< div >
< div class = "text-xs opacity-75 mb-1" > موجودی </ div >
2026-06-29 22:43:28 +03:30
< div >{{ balanceLabel }}</ div >
2025-10-21 17:09:16 +03:30
</ 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 >
2026-06-29 22:43:28 +03:30
< div >{{ usePriceWithoutType ( totalRialDisplay ) }} ریال </ div >
2025-10-21 17:09:16 +03:30
</ div >
</ div >
2025-10-20 18:26:45 +03:30
</ div >
</ div >
2025-10-21 17:09:16 +03:30
2025-10-05 09:44:14 +03:30
<!-- < div class = "bg-white" >
< MySlider v-if = "cardItems.length > 0" :items="cardItems" class=" pb-[20vh] "
style = "touch-action: none" />
</ div > -->
<!-- < div class = "bg-gradient-to-l mt-3 p-1 shadow-lg from-primary rounded-lg p-px to-transparent " > -->
2026-05-20 09:41:01 +03:30
< div class = "mt-3 p-1 shadow-lg from-primary rounded-lg p-px to-transparent border-solid border border-primary" >
< div class = " p-1 py-6 rounded-lg bg-white" >
2025-10-05 09:44:14 +03:30
< div class = "flex justify-between " >
<!-- < div
class = "text-center w-full flex-flex-col items-center home_appear_fade_in_up"
style = "text-align: -webkit-center"
@click ="router.push({ name: 'buyProduct', query: { state: 'sell' } })"
>
< div
class = "rounded-full w-[42px] h-[42px] bg-primary flex items-center justify-center"
2026-05-19 20:34:34 +03:30
style = "border: solid 1px #a72b77"
2025-10-05 09:44:14 +03:30
>
< Icon class = "text-tertiary" icon = "vuesax-linear:money-send" />
</ div >
< div class = "text-primary" > فروش </ div >
</ div > -->
< div
class = "text-center w-full flex-flex-col items-center home_appear_fade_in_up"
style = "text-align: -webkit-center"
2025-10-20 18:26:45 +03:30
@click ="router.push({ name: 'gold' })"
2025-10-05 09:44:14 +03:30
>
< div
class = "rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
2026-05-19 20:34:34 +03:30
style = "border: solid 1px #a72b77"
2025-10-05 09:44:14 +03:30
>
2026-05-20 09:41:01 +03:30
< Icon class = "text-white" icon = "vuesax-linear:money-receive" />
2025-10-05 09:44:14 +03:30
</ div >
2025-11-12 20:53:44 +03:30
< div class = "text-primary" > خرید و فروش </ div >
2025-10-05 09:44:14 +03:30
</ div >
< div
class = "text-center w-full flex-flex-col items-center home_appear_fade_in_down"
style = "text-align: -webkit-center"
@click ="router.push({ name: 'wallet', query: { state: 'deposit' } })"
>
< div
class = "rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
2026-05-19 20:34:34 +03:30
style = "border: solid 1px #a72b77"
2025-10-05 09:44:14 +03:30
>
2026-05-20 09:41:01 +03:30
< Icon class = "text-white" icon = "vuesax-linear:card-add" />
2025-10-05 09:44:14 +03:30
</ div >
< div class = "text-primary" > واریز نقدی </ div >
</ div >
< div
class = "text-center w-full flex-flex-col items-center home_appear_fade_in_up"
style = "text-align: -webkit-center"
@click ="openWholeBalanceVisible()"
>
< div
class = "rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center "
2026-05-19 20:34:34 +03:30
style = "border: solid 1px #a72b77"
2025-10-05 09:44:14 +03:30
>
2026-05-20 09:41:01 +03:30
< Icon class = "text-white" icon = "vuesax-linear:receipt-item" />
2025-10-05 09:44:14 +03:30
</ div >
< div class = "text-primary" > موجودی </ div >
</ div >
2025-10-26 16:07:29 +03:30
< div
class = "text-center w-full flex-flex-col items-center home_appear_fade_in_down"
style = "text-align: -webkit-center"
@click ="router.push({ name: 'fund' })"
>
< div
class = "rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
2026-05-19 20:34:34 +03:30
style = " border: solid 1px #a72b77"
2025-10-26 16:07:29 +03:30
>
2026-05-20 09:41:01 +03:30
< Icon class = "text-white font-bold" icon = "vuesax-linear:archive-1" />
2025-10-26 16:07:29 +03:30
</ div >
2026-06-29 22:43:28 +03:30
< div class = "text-primary" > دارایی ها </ div >
2025-10-26 16:07:29 +03:30
</ div >
2025-10-05 09:44:14 +03:30
< div
class = "text-center w-full flex-flex-col items-center home_appear_fade_in_down"
style = "text-align: -webkit-center"
2025-10-20 18:26:45 +03:30
@click ="router.push({ name: 'earnMoney' })"
2025-10-05 09:44:14 +03:30
>
< div
class = "rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
2026-05-19 20:34:34 +03:30
style = " border: solid 1px #a72b77"
2025-10-05 09:44:14 +03:30
>
2026-05-20 09:41:01 +03:30
< Icon class = "text-white font-bold" icon = "vuesax-linear:dollar-circle" />
2025-10-05 09:44:14 +03:30
</ div >
2025-10-20 18:26:45 +03:30
< div class = "text-primary" > کسب درآمد </ div >
2025-10-05 09:44:14 +03:30
</ div >
2025-10-26 16:07:29 +03:30
2025-10-05 09:44:14 +03:30
</ div >
</ div >
<!-- < ADivider ></ ADivider > -->
2025-10-20 18:26:45 +03:30
<!-- < div >
& lt ; !& ndash ; < div @click ="router.push({ name: 'fund' })" > & ndash ;& gt ;
2025-10-05 09:44:14 +03:30
< div class = "bg-primary rounded-lg p-2 py-6 mt-2" >
< div class = "flex justify-center text-tertiary w-full z-20" >
محصولات :
< div class = "text-l mr-2 font-bold" >{{ userStore ? . userInfo ? . wallet ? . count_product ?? 0 }} عدد </ div >
</ div >
< div class = "flex mt-2 justify-center text-tertiary w-full z-20" >
دارایی طلایی :
< div class = "text-l mr-2 font-bold" >{{ ( userStore ? . userInfo ? . wallet ? . count_gold ?? 0 ). toFixed ( 3 )}} گرم </ div >
< BasicIcon @click ="openGoldModal" icon = "vuesax-linear:info-circle" size = "18" color = "orange" />
</ div >
< div class = "flex mt-2 justify-center text-tertiary w-full z-20" >
دارایی ریالی :
< div class = "text-l mr-2 font-bold" >{{ usePriceWithoutType ( userStore ? . userInfo ? . wallet ? . count_cash ?? 0 ) }} ریال </ div >
< BasicIcon @click ="openRialModal" icon = "vuesax-linear:info-circle" size = "18" color = "orange" />
</ div >
</ div >
2025-10-20 18:26:45 +03:30
& lt ; !& ndash ; < div class = "flex justify-center mt-2 w-full z-20" >
2025-10-05 09:44:14 +03:30
دارایی ریالی :
< div class = "text-l mr-4 font-bold" >{{ usePriceWithoutType ( walletStore . walletInfo ? . count_cash ?? 0 ) }} ریال </ div >
2025-10-20 18:26:45 +03:30
</ div > & ndash ; & gt ;
& lt ; !& ndash ; < div class = "flex justify-center mt-2 w-full z-20" >
2025-10-05 09:44:14 +03:30
< BasicInfoItem
title = "دارایی ریالی"
is -line
: info = "`در این قسمت مجموع کیف پول ریالی (${usePrice(walletStore?.walletInfo?.count_cash_wallet ?? 0) }) + معادل ریالی محصولات (${ usePrice(walletStore?.walletInfo?.count_cash_wallets ?? 0)} ) را مشاهده میفرمایید.`"
infoHead = "مجموع کل دارایی ریالی"
: value = "usePriceWithoutType(walletStore.walletInfo?.count_cash ?? 0) + ' ریال'"
/>
2025-10-20 18:26:45 +03:30
</ div > & ndash ; & gt ;
</ div > -->
2025-10-05 09:44:14 +03:30
<!-- < div class = "flex justify-between" >
< div class = "text-center font-bold" > دارایی شما </ div >
< div class = "flex items-center gap-2 mr-4" >
< span class = "text-base font-bold" >{{ usePriceWithoutType ( walletStore . walletInfo ? . cash ?? 0 ) }}</ span >
< span class = "text-xs text-base" > ریال </ span >
</ div >
< div class = "flex items-center gap-2 ml-4" >
2026-06-12 20:29:26 +03:30
< span class = "text-base font-bold" >{{ walletStore . walletInfo ? . gold_sum ? . toFixed ( 3 ) ?? '0.000' }}</ span >
2025-10-05 09:44:14 +03:30
< span class = "text-xs text-base" > گرم </ span >
</ div >
</ div > -->
<!-- < div class = "flex justify-between items-center " >
< div class = "text-sm" >
موجودی کیف پول شما :
</ div >
< div class = "flex items-center gap-2" >
< span class = "text-base font-bold" >{{ usePrice ( walletStore . walletInfo ? . cash ?? 0 ) }}</ span >
</ div >
</ div >
< div class = "flex justify-between items-center " >
< div class = "text-sm" >
موجودی کیف طلای شما :
</ div >
< div class = "flex items-center gap-2" >
< span class = "text-base font-bold" >{{ walletStore . walletInfo ? . gold }}</ span >
< span class = "text-xs text-gray-500" > گرم </ span >
</ div >
</ div > -->
<!-- < div class = "flex justify-between items-center " >
< div class = "text-sm" >
ارزش کل طلا های شما :
</ div >
< div class = "flex items-center gap-2" >
< span class = "text-base font-bold" >{{ walletStore . walletInfo ? . gold_sum }}</ span >
< span class = "text-xs text-gray-500" > گرم </ span >
</ div >
</ div > -->
<!-- < div class = "flex justify-between items-center " >
< div class = "text-sm" >
</ div >
< div class = "flex items-center gap-2" >
< div v-if = "walletStore.walletInfo?.gold_sum*goldVal" >
< Vue3Odometer
:value = "walletStore.walletInfo?.gold_sum*goldVal"
class = "o-text !text-base font-bold"
style = "font-family: iran-sans; direction: ltr"
v-if = "key % 2 === 0"
/>
</ div >
< span class = "text-xs text-gray-500" > ریال </ span >
</ div >
</ div > -->
</ div >
< div
2025-10-21 17:09:16 +03:30
class = "w-full relative mt-5 mb-5 border-gray-200 border-1 rounded-lg h-[88px] flex flex-col justify-center home_appear_fade_in"
2025-10-05 09:44:14 +03:30
>
< div class = "w-full items-center flex flex-col" >
2026-05-19 20:53:52 +03:30
< div class = "text-gray-600" > قیمت خرید از کشکول گلد </ div >
2025-10-05 09:44:14 +03:30
< div v-if = "price" class="flex gap-1 mt-3 text-xs items-center" >
<!-- < div id = "odometer" class = "font-bold text-2xl odometer animated fadeIn" >
& lt ; !& ndash ; {{ usePriceWithoutType ( useCounterAnim ( price . price_last ) ?? 0 ) }} & ndash ; & gt ;
</ div > -->
<!-- < div id = "odometer" class = "odometer animated fadeIn" ></ div > -->
< div v-if = "percentPriceChanged()!=0"
class = "bg-green-100 text-green-600 flex flex-row-reverse rounded-lg justify-between items-center gap-2 px-3"
: class = "percentPriceChanged()>=0?'bg-green-100 text-green-600':'bg-red-100 text-red-600'" >
< div dir = "ltr" >{{ useTowDecimal ( percentPriceChanged ()) }} % </ div >
< div >
< icon v-if = "percentPriceChanged()<0" size="15px" icon="vuesax-linear:received" color="red-600" ></ icon >
< icon v-else size = "15px" icon = "vuesax-linear:send" color = "green-600" ></ icon >
</ div >
</ div >
< Vue3Odometer
:value = "goldVal"
class = "o-text !text-2xl font-bold"
style = "font-family: iran-sans; direction: ltr"
v-if = "key % 2 === 0"
/>
ریال
</ div >
</ div >
</ div >
2025-10-20 18:26:45 +03:30
2026-06-29 22:43:28 +03:30
< 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 >
2025-10-20 18:26:45 +03:30
2026-05-20 09:41:01 +03:30
< div class = "flex mt-5 gap-1 bg-primary text-white font-bold justify-center cursor-pointer rounded-lg py-5"
2025-10-28 09:52:28 +03:30
@click ="router.push({ name: 'gold' })" >
2025-10-05 09:44:14 +03:30
< div > خرید و فروش </ div >
</ div >
<!-- < div class = "mt-10 font-bold home_appear_fade_in" @click ="update" >
نوسانات قیمت هر گرم طلای 18 عیار
</ div > -- >
<!-- < a-spin :spinning = "chartLoading" class = "relative" >
< div ref = "target" class = "absolute" ></ div >
< div v-if = "!chartLoading" id="chart" class="pb-20 mt-7 overflow-x-auto" >
& lt ;!& ndash ; < apexchart v-if = "targetIsVisible" :options="chartOptions" :series="test_series"
: style = "`width: ${chartWidth}`"
height = "350"
type = "candlestick" ></ apexchart > & ndash ; & gt ;
</ div >
</ a-spin > -->
<!-- < a-spin :spinning = "chartLoading" > -->
<!-- < div ref = "target" class = "absolute" ></ div > -->
<!-- < div id = "chart" class = "mt-7" > -->
< div class = "bg-gray-50 w-full flex justify-evenly rounded-lg py-4 mt-4 h-[15rem]" >
< div class = "w-full text-center pt-2" >
< a-radio-group v -model:value = "value" button -style =" solid " >
< a-radio-button value = "a" @click ="updateData('DAILY')" > 24 ساعت اخیر </ a -radio-button >
< a-radio-button value = "b" @click ="updateData('WEEKLY')" > هفته گذشته </ a -radio-button >
< a-radio-button value = "c" @click ="updateData('MONTHLY')" > ماه گذشته </ a -radio-button >
</ a-radio-group >
< div id = "chart-timeline" >
< apexchart
type = "area"
height = "200"
ref = "chart"
:options = "priceChartOptions"
:series = "priceChartSeries"
></ apexchart >
</ div >
</ div >
</ div >
2026-07-01 18:16:12 +03:30
< div class = " w-full flex justify-evenly rounded-lg py-2 home_appear_fade_in mt-6 pb-[calc(var(--app-bottom-chrome-height)+1rem)]" >
2025-10-05 09:44:14 +03:30
< div class = "text-center w-full" >
< div > بالاترین قیمت امروز </ div >
< div v-if = "lastPrice" class="flex flex-col items-center mt-3" >
< div class = "text-green-600 flex gap-1 text-xs items-center" >
< div class = "text-base" >{{ usePriceWithoutType ( price ? . buy ?? 0 ) }}</ div >
ریال
</ div >
</ div >
</ div >
< a-divider class = "bg-gray-200 !h-auto !my-2" type = "vertical" />
< div class = "text-center w-full" >
< div > پایین ترین قیمت امروز </ div >
< div class = "flex w-full mt-3 justify-evenly" >
< div v-if = "lastPrice" class="flex flex-col items-center" >
< div class = "text-red-600 flex gap-1 text-xs items-center" >
< div class = "text-base" >{{ usePriceWithoutType ( price ? . sell ?? 0 ) }}</ div >
ریال
</ div >
</ div >
</ div >
</ div >
</ div >
</ div >
2026-06-29 22:43:28 +03:30
< div v-else class = "bg-white w-full md:w-auto h-[80vh] px-5 m-[-1px] flex justify-center" >
2025-10-05 09:44:14 +03:30
< HomeSkeleton class = "w-full" />
</ div >
2026-07-01 18:16:12 +03:30
< AppHeader @logout ="showLogoutConfirm = true" />
2025-10-05 09:44:14 +03:30
</ div >
< DialogVant v -model:show = "showLogoutConfirm" :closeOnClickOverlay = "false" :timeOut = "-1" >
<!-- < template v -slot : img >
< img :src = "registerDelayImage" alt = "" class = "opacity-80" >
</ template > -->
< template v -slot : title >
< div class = "flex flex-col items-center" >
< DotLottieVue
class = "w-11rem h-11rem"
autoplay
src = "https://lottie.host/129cf3a1-df84-4758-a856-58c133ae6013/R5RqclXA8G.json"
/>
< div class = "p-5 text-sm" > آیا از خروج خود اطمینان دارید ؟ </ div >
</ div >
</ template >
< template v -slot : button >
< div class = "text-center text-red flex items-center justify-center" @click ="logout" >
< a-spin :spinning = "logoutLoading" size = "small" > خروج </ a-spin >
</ div >
< div class = "text-center" @click ="showLogoutConfirm = false" > انصراف </ div >
</ template >
</ DialogVant >
< BasicActionSheet v -model:show = "wholeBalanceVisible" >
< div class = "pb-20" >
< div >
< div class = "w-full text-center font-bold" > موجودی ها </ div >
< div class = "h-30vh overflow-y-auto" >
< div class = "mt-5" >
< BasicInfoItem
class = "flex justify-between"
title = "مجموعه کل دارایی طلایی"
is -line
2026-06-29 22:43:28 +03:30
:value = "balanceLabel"
2025-10-05 09:44:14 +03:30
/>
< a-divider class = "!my-1" />
2026-06-29 22:43:28 +03:30
< BasicInfoItem
v-if = "countBasedInventory > 0"
class = "flex justify-between"
title = "تعداد محصولات"
is -line
: value = "`${countBasedInventory} عدد`"
/>
< a-divider v-if = "countBasedInventory > 0" class="!my-1" />
2025-10-05 09:44:14 +03:30
< BasicInfoItem
class = "flex justify-between"
title = "دارایی کیف پول ریالی"
is -line
2026-06-29 22:43:28 +03:30
: value = "usePrice(assetsSummary?.cash_wallet ?? walletStore.walletInfo?.cash ?? 0)"
2025-10-05 09:44:14 +03:30
/>
< a-divider class = "!my-1" />
< BasicInfoItem
class = "flex justify-between"
title = "دارایی کیف پول طلایی"
is -line
: value = "(walletStore.walletInfo?.count_gold_wallet ?? 0) + ' گرم'"
/>
< a-divider class = "!my-1" />
<!-- < BasicInfoItem class = "flex justify-between" title = "دارایی کیف پول(به گرم)" is -line
: value = "((walletStore.walletInfo?.cash?? 0) / (goldVal?? 0)).toFixed(2)+ ' گرم'" />
< a-divider class = "!my-1" /> -->
< BasicInfoItem
class = "flex justify-between"
title = "ارزش کل دارایی شما"
is -line
2026-06-29 22:43:28 +03:30
:value = "usePrice(totalRialDisplay)"
2025-10-05 09:44:14 +03:30
/>
</ div >
</ div >
</ div >
</ div >
</ BasicActionSheet >
2025-10-20 18:26:45 +03:30
< BasicModal
v -model:visible = "openModal"
custom -footer
2025-11-11 17:33:30 +03:30
:closable = "false"
2025-10-20 18:26:45 +03:30
>
< div class = "text-center" >
< div class = "mt-2" >
2025-11-17 15:03:25 +03:30
< div > 🔥 یه فرصت طلایی واقعی جلوت ِ ! 🔥 </ div >
2026-05-19 20:53:52 +03:30
< div > دوستاتو همین الان به کشکول گلد دعوت کن ! </ div >
2025-11-17 15:03:25 +03:30
< div > اونا اولین خریدشونو کاملا ً بدون کارمزد انجام می دن ، ۱۰ ٪ از کارمزد ۱۰ معامله ی اولشون هم ، مستقیم میاد تو حساب تو ! </ div >
< div > زود باش ، این فرصت همیشه باز نیست ! ⏳✨ </ div >
2025-10-20 18:26:45 +03:30
</ div >
</ div >
< template # footer >
< a-button type = "primary" class = "w-full" @click ="closeModal" >
2025-11-17 15:03:25 +03:30
همین حالا کلیک کنید و پاداش بگیرید !
2025-10-20 18:26:45 +03:30
</ a -button >
</ template >
</ BasicModal >
2026-06-29 22:43:28 +03:30
</ div >
2025-10-05 09:44:14 +03:30
</ template >
< script lang = "tsx" setup >
2025-10-20 18:26:45 +03:30
import { Swiper , SwiperSlide } from 'swiper/vue' ;
import 'swiper/swiper-bundle.css' ;
2025-10-21 17:09:16 +03:30
import img2 from '@/assets/img/banner/2.png'
2025-10-05 09:44:14 +03:30
import Icon from '@/components/BasicPacks/BasicIcon.vue'
2026-07-05 20:49:01 +03:30
import { usePrice , usePriceWithoutType , useTowDecimal , formatGoldAmount } from '../../../utils/usePrice'
2026-06-29 22:43:28 +03:30
import { computed , createVNode , onActivated , onMounted , onUnmounted , ref , watch } from 'vue'
2025-10-05 09:44:14 +03:30
import router from '@/router'
import * as echarts from 'echarts'
2026-07-01 18:16:12 +03:30
import { useIntersectionObserver } from '@vueuse/core'
2025-10-05 09:44:14 +03:30
import { loading , removeToken } from '@/utils'
import { useUserStore } from '@/store/userStore'
import { useWalletStore } from '@/store/walletStore'
import DialogVant from '@/components/DialogVant.vue'
2025-10-20 18:26:45 +03:30
import { getAllPrices , getChart } from '@/api/home'
2025-10-05 09:44:14 +03:30
import Vue3Odometer from 'vue3-odometer'
import 'odometer/themes/odometer-theme-default.css'
import HomeSkeleton from '@/views/base/home/components/HomeSkeleton.vue'
2026-06-29 22:43:28 +03:30
import GhatrehHomeDesktopView from '@/views/base/home/desktop/GhatrehHomeDesktopView.vue'
2025-10-05 09:44:14 +03:30
import {
getLastPrices ,
2026-06-29 22:43:28 +03:30
getTradeBuyPrice ,
2025-10-05 09:44:14 +03:30
getUpPrice ,
lastPrice ,
percentPriceChanged ,
price ,
setIntervalGetAllPrice ,
stopPriceInterval
} from '@/utils/price'
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
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'
2026-06-29 22:43:28 +03:30
import { useWalletAssets } from '@/composables/useWalletAssets'
import { resolveAssetsRialValue } from '@/utils/productAssets'
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
2025-10-29 16:34:24 +03:30
import { message , Modal } from 'ant-design-vue'
2025-10-20 18:26:45 +03:30
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
import BasicModal from '@/components/BasicPacks/BasicModal.vue'
2025-10-29 16:34:24 +03:30
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
2026-07-01 18:16:12 +03:30
import AppHeader from '@/views/base/home/components/AppHeader.vue'
2025-10-05 09:44:14 +03:30
const userStore = useUserStore ()
const walletStore = useWalletStore ()
2026-06-29 22:43:28 +03:30
const isDesktop = useDesktopBreakpoint ()
2025-10-05 09:44:14 +03:30
const chartLoading = ref < boolean >( false )
2025-10-20 18:26:45 +03:30
const openModal = ref < boolean >( false )
2025-10-05 09:44:14 +03:30
const wholeBalanceVisible = ref < boolean >( false )
const series = ref < Chart [] >([{ data : [] }])
const key = ref < number >( 0 )
const main = ref ( null )
const logoutLoading = ref ( false )
const productInventorys = ref < PInventory [] | undefined >()
const value = ref < string >( 'a' )
2026-06-29 22:43:28 +03:30
const { assetsSummary , loadWalletAssets } = useWalletAssets ()
2025-10-05 09:44:14 +03:30
2026-06-29 22:43:28 +03:30
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 } عدد`
2025-10-05 09:44:14 +03:30
}
2026-06-29 22:43:28 +03:30
const metal = primaryMetalTotal . value
if ( metal && Number ( metal . total_weight ) > 0 ) {
2026-07-05 20:49:01 +03:30
return ` ${ formatGoldAmount ( metal . total_weight ) } ${ metal . unit } `
2026-06-29 22:43:28 +03:30
}
const fallback =
walletStore . walletInfo ? . gold_sum ??
userStore . userInfo ? . wallet ? . count_gold ??
0
2026-07-05 20:49:01 +03:30
return ` ${ formatGoldAmount ( fallback ) } گرم`
2026-06-29 22:43:28 +03:30
})
const totalRialDisplay = computed (() =>
resolveAssetsRialValue (
assetsSummary . value ,
getTradeBuyPrice ( price . value ) || Number ( goldVal . value ?? 0 )
)
)
2025-10-05 09:44:14 +03:30
onUnmounted (() => {
stopPriceInterval ()
})
/*
onMounted(() => {
animateNum(2)
})
*/
const goldVal = ref < number | undefined >()
function openWholeBalanceVisible () {
wholeBalanceVisible . value = true
}
function update () {
setInterval (() => {
goldVal . value = lastPrice ? . value . price_last
}, 500 )
}
const target = ref ( null )
const targetIsVisible = ref ( false )
const isHidden = ref < boolean >( false )
const { stop } = useIntersectionObserver ( target , ([{ isIntersecting }], observerElement ) => {
targetIsVisible . value = isIntersecting
console . log ( 'saaaaa' , targetIsVisible . value )
})
watch ( main , ( n ) => {
if ( main . value !== null ) {
// console.log('saaaa')
const echart = echarts . init ( main . value , null , {
renderer : 'candlestick'
})
echart . setOption ({
xAxis : {
data : dates . value . values ,
show : true
},
yAxis : {
show : false ,
scale : true
},
series : [
{
type : 'candlestick' ,
data : series . value
}
]
})
}
})
//whole prices
const priceChartSeries = ref < { data : [ number , number ][] }[] > ([
{
name : 'قیمت' ,
data : []
}
])
const selection = ref ( 'DAILY' )
const chartRef = ref < ApexCharts | null >( null )
const priceChartOptions = ref ({
chart : {
id : 'نوسانات قیمت' ,
type : 'candlestick' ,
height : 200 ,
toolbar : {
show : false // Disable the toolbar to remove download and other options
},
zoom : {
autoScaleYaxis : true
},
events : {
mounted ( chart ) {
chartRef . value = chart
}
}
},
grid : {
padding : {
top : 0 ,
right : 0 ,
bottom : 0 ,
left : 0
},
yaxis : {
lines : {
show : false
}
}
},
stroke : {
width : 2
},
dataLabels : {
enabled : false ,
// formatter: (val) => toPersianNumber(val),
style : {
fontFamily : '\'IranSans\', sans-serif'
}
},
yaxis : {
tickAmount : 8 ,
show : false ,
title : {
style : {
fontSize : '13px' ,
fontFamily : '\'IranSans\', sans-serif' ,
fontWeight : 'bold'
}
},
labels : {
formatter : ( val ) => toPersianNumber ( usePrice ( val )),
style : {
fontSize : '13px' ,
fontFamily : '\'IranSans\', sans-serif'
}
}
},
xaxis : {
show : false ,
type : 'datetime' ,
axisTicks : {
show : false
},
tooltip : {
enabled : false
},
labels : {
show : false ,
rotate : - 45 ,
style : {
fontFamily : '\'IranSans\', sans-serif'
}
// formatter: (val) => toPersianNumber(toJalaliNotime(new Date(val).toString()))
},
axisBorder : {
show : false
}
},
tooltip : {
x : {
// formatter: (val) => toPersianNumber(toJalaliNotime(new Date(val).toString()))
formatter : ( value ) => {
const date = new Date ( value )
return ` ${ date . toLocaleDateString ( 'fa-IR' ) } - ${ date . toLocaleTimeString ( 'fa-IR' , {
hour : '2-digit' ,
minute : '2-digit'
} )}`
}
},
formatter : ( val ) => toPersianNumber ( usePrice ( val )),
style : {
fontFamily : '\'IranSans\', sans-serif'
// fontWeight: 'bold'
},
markers : {
show : false
}
},
2026-05-19 20:34:34 +03:30
colors : [ '#a72b77' ],
2025-10-05 09:44:14 +03:30
fill : {
type : 'gradient' ,
gradient : {
shadeIntensity : 1 ,
opacityFrom : 0.7 ,
opacityTo : 0.9 ,
stops : [ 0 , 100 ]
}
}
})
const toPersianNumber = ( num ) => {
return num . toString (). replace ( /\d/g , ( d ) => '۰۱۲۳۴۵۶۷۸۹' [ d ])
}
const fetchPrices = async () => {
try {
const response = await getAllPrices ()
2026-06-12 20:29:26 +03:30
const data = response ? . data ? . prices ?? {}
const selectedData = data [ selection . value ] ?? []
2025-10-05 09:44:14 +03:30
priceChartSeries . value [ 0 ]. data = selectedData . map (( item ) => [ item . timestamp , item . value - 1 ])
// console.log(priceChartSeries.value[0].data)
chartRef . value ? . updateOptions ({
series : priceChartSeries . value
})
} catch ( error ) {
console . error ( 'خطا در دریافت دادهها' , error )
}
}
const updateData = ( timeline ) => {
selection . value = timeline
fetchPrices ()
}
const test_series = [
{
name : 'candle' ,
data : []
}
]
async function initChart () {
try {
// chartLoading.value = true
const data = await getChart ()
/* data.forEach(item => {
test_series[0].data.push({
x: toJalali(item[0]),
y: item[1]
})
// console.log(x)
})*/
data . forEach (( item ) => {
test_series [ 0 ]. data . push ({
x : item [ 0 ],
y : item [ 1 ]
})
// console.log(x)
})
// console.log(test_series)
} catch ( e ) {
console . log ( e )
} finally {
// chartLoading.value = false
}
}
async function initPrice () {
try {
// loading.value = true
const val = price ? . value ? . price_last
await getLastPrices ()
await getUpPrice ()
await setIntervalGetAllPrice ()
// console.log('runhome')
if ( val !== price ? . value ? . price_last ) {
update ()
/* key.value++
key.value++*/
}
/* price.value = data
lastPrice.value = dataLast*/
goldVal . value = 0
// console.log(price?.value.price_last)
if ( userStore . isFirst ) {
const timer = setInterval ( function () {
update ()
// if (current == end) {
userStore . isFirst = false
clearInterval ( timer )
// }
}, 100 )
} else {
goldVal . value = price . value ? . price_last
}
// console.log(series.value)
} catch ( e ) {
console . log ( e )
} finally {
// loading.value = false
}
}
2025-10-20 18:26:45 +03:30
function closeModal () {
openModal . value = false
localStorage . setItem ( 'hasSeenIntroModal' , 'true' )
router . push ({ name : 'earnMoney' })
}
2026-06-29 22:43:28 +03:30
onActivated (() => {
void loadWalletAssets ( true )
if ( ! userStore . userInfo ) {
void userStore . getMyInfo ()
}
})
2025-10-05 09:44:14 +03:30
onMounted ( async () => {
try {
loading . value = true
2026-06-29 22:43:28 +03:30
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 )
2025-10-05 09:44:14 +03:30
update ()
2025-10-20 18:26:45 +03:30
const hasSeenModal = localStorage . getItem ( 'hasSeenIntroModal' )
if ( ! hasSeenModal ) {
openModal . value = true
}
2025-10-05 09:44:14 +03:30
} catch ( e ) {
console . log ( e )
} finally {
loading . value = false
}
})
onUnmounted (() => {
stopPriceInterval ()
// console.log('okhome')
})
const showLogoutConfirm = ref < boolean >()
async function logout () {
logoutLoading . value = true
// baseConfirm('آیا از حساب کاربری خارج می شوید؟',async () => {
userStore . userInfo = undefined
walletStore . walletInfo = undefined
/* userStore.$reset()
walletStore.$reset()*/
removeToken ()
await router . push ({ name : 'login' })
logoutLoading . value = true
window . location . reload ()
// console.log('salam')
// })
}
async function openGoldModal () {
Modal . confirm ({
title : `در این قسمت مجموع کل وزن طلای آبشده ( ${ ( walletStore . walletInfo ? . gold ?? 0 ) ? . toFixed ( 3 ) } ) + ارزش دارایی ها ( ${ ( walletStore . walletInfo ? . count_gold_wallets ?? 0 ) ? . toFixed ( 3 ) } ) را مشاهده میفرمایید.` ,
okText : 'متوجه شدم' ,
centered : true ,
cancelButtonProps : { style : { display : 'none' } },
})
}
async function openRialModal () {
Modal . confirm ({
title : `در این قسمت مجموع کیف پول ریالی ( ${ usePrice ( walletStore ? . walletInfo ? . count_cash_wallet ?? 0 ) } ) + معادل ریالی محصولات ( ${ usePrice ( walletStore ? . walletInfo ? . count_cash_wallets ?? 0 ) } ) را مشاهده میفرمایید.` ,
okText : 'متوجه شدم' ,
centered : true ,
cancelButtonProps : { style : { display : 'none' } },
})
}
2025-10-29 16:34:24 +03:30
function copyCode () {
const val = userStore ? . userInfo ? . virtual_card_number
navigator . clipboard . writeText ( val )
message . info ( 'کد رونوشت شد' )
}
2025-10-05 09:44:14 +03:30
</ script >
< style lang = "less" >
2026-07-01 18:16:12 +03:30
. home - mobile - root {
position : relative ;
padding - top : var ( -- app - home - header - offset , calc ( 4.25 rem + env ( safe - area - inset - top , 0 px )));
}
. app - header - scroll - sentinel {
height : 1 px ;
width : 100 % ;
pointer - events : none ;
}
. home - page - root . main - with - bottom - chrome - inner {
scroll - padding - top : var ( -- app - home - header - offset , calc ( 4.25 rem + env ( safe - area - inset - top , 0 px )));
}
2025-10-05 09:44:14 +03:30
2026-06-29 22:43:28 +03:30
. 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 ;
}
}
2025-10-05 09:44:14 +03:30
. odometer {
font - size : 60 px ;
text - align : center ;
width : 100 % ;
animation - duration : 3 s ;
}
label : focus - within {
box - shadow : none ! important
}
. chart - container {
width : 100 % ;
height : 100 % ;
padding : 0 ;
margin : 0 ;
display : flex ;
}
apexchart {
width : 100 % ! important ;
height : 100 % ! important ;
padding : 0 ! important ;
margin : 0 ! important ;
}
2026-06-29 22:43:28 +03:30
</ style >