Compare commits
9
Commits
be17631109
...
mian-test2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12382656e8 | ||
|
|
51e3c3f0cb | ||
|
|
e4d92831c2 | ||
|
|
3561e8ae07 | ||
|
|
ce8029919c | ||
|
|
3a3a55287b | ||
|
|
c3aaeaf91a | ||
|
|
4fa2c0d57d | ||
|
|
8b855e5ee4 |
Binary file not shown.
+16
-38
@@ -123,39 +123,6 @@
|
|||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#whatsapp-button {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 90px;
|
|
||||||
right: 20px;
|
|
||||||
width: 60px;
|
|
||||||
height: 60px;
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
|
|
||||||
cursor: grab;
|
|
||||||
user-select: none;
|
|
||||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
||||||
z-index: 9999;
|
|
||||||
}
|
|
||||||
|
|
||||||
#whatsapp-button:hover:not(.is-dragging) {
|
|
||||||
transform: scale(1.1);
|
|
||||||
box-shadow: 0 6px 14px rgba(0,0,0,0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
#whatsapp-button.is-dragging {
|
|
||||||
cursor: grabbing;
|
|
||||||
transform: none;
|
|
||||||
box-shadow: 0 8px 18px rgba(0,0,0,0.22);
|
|
||||||
}
|
|
||||||
|
|
||||||
#whatsapp-button img {
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -359,7 +326,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getVersionUrls() {
|
function getVersionUrls() {
|
||||||
return ['https://nerkh.gold/get_version', 'https://tablo.talasevin.ir/get_version', 'https://abshode-service.montgit.ir/server/get_version']
|
var protocol = getProtocol()
|
||||||
|
|
||||||
|
return [
|
||||||
|
'https://nerkh.gold/get_version',
|
||||||
|
'https://tablo.talasevin.ir/get_version',
|
||||||
|
'https://abshode-service.montgit.ir/server/get_version',
|
||||||
|
protocol + '//212.23.201.173:8381/get_version',
|
||||||
|
protocol + '//91.212.174.137:4040/server/get_version'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConfigUrls() {
|
function getConfigUrls() {
|
||||||
@@ -486,6 +461,9 @@
|
|||||||
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
|
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
|
||||||
return version
|
return version
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (localStorage.getItem(VERSION_SUCCESS_URL_KEY) === url) {
|
||||||
|
localStorage.removeItem(VERSION_SUCCESS_URL_KEY)
|
||||||
|
}
|
||||||
console.warn('Version failed:', url, error)
|
console.warn('Version failed:', url, error)
|
||||||
return undefined
|
return undefined
|
||||||
} finally {
|
} finally {
|
||||||
@@ -529,6 +507,9 @@
|
|||||||
url: url
|
url: url
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (localStorage.getItem(CONFIG_SUCCESS_URL_KEY) === url) {
|
||||||
|
localStorage.removeItem(CONFIG_SUCCESS_URL_KEY)
|
||||||
|
}
|
||||||
console.warn('Config failed:', url, 'round:', round, error)
|
console.warn('Config failed:', url, 'round:', round, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -659,7 +640,7 @@
|
|||||||
renderRecovering('در حال دریافت تنظیمات جدید برنامه...')
|
renderRecovering('در حال دریافت تنظیمات جدید برنامه...')
|
||||||
|
|
||||||
var version = await loadRemoteVersion(5)
|
var version = await loadRemoteVersion(5)
|
||||||
var freshConfigResult = await fetchFreshConfig(2)
|
var freshConfigResult = await fetchFreshConfig(5)
|
||||||
|
|
||||||
clearReadableCookies()
|
clearReadableCookies()
|
||||||
// clearLocalStorageExceptToken()
|
// clearLocalStorageExceptToken()
|
||||||
@@ -725,8 +706,5 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
<a href="#" target="_blank" id="whatsapp-button">
|
|
||||||
<img class="p-2" src="/src/assets/img/rubika.webp" alt="" />
|
|
||||||
</a>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
+176
-42
@@ -1,75 +1,84 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="desktopConfig w-full right-0 left-0 absolute">
|
<div class="desktopConfig w-full right-0 left-0">
|
||||||
<div v-if="popVisible" class="top-0 bottom-0 wrap-fix bg-primary z-100 opacity-60">
|
|
||||||
<div class="absolute right-0 left-0 bottom-10vh flex flex-col items-center">
|
|
||||||
<div><BasicButton>درباره ما</BasicButton></div>
|
|
||||||
<div></div>
|
|
||||||
<div></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<transition mode="out-in" name="fade">
|
<transition mode="out-in" name="fade">
|
||||||
<AConfigProvider
|
<AConfigProvider
|
||||||
v-if="!showSplash"
|
v-if="!showSplash"
|
||||||
:theme="{
|
:theme="antDesignTheme"
|
||||||
token: {
|
|
||||||
colorPrimary: colors.primary,
|
|
||||||
colorLink: colors.primary,
|
|
||||||
colorLinkActive: colors.primary,
|
|
||||||
colorLinkHover: colors['primary-rgba']
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
direction="rtl"
|
direction="rtl"
|
||||||
>
|
>
|
||||||
<router-view v-slot="{ Component, route }">
|
<router-view v-slot="{ Component, route }">
|
||||||
<!-- Use any custom transition and to `fade` -->
|
|
||||||
<transition :name="route.meta.transition || 'fade'">
|
<transition :name="route.meta.transition || 'fade'">
|
||||||
<div>
|
<component :is="Component" :key="route.fullPath" class="app-main" />
|
||||||
<component :is="Component" />
|
|
||||||
</div>
|
|
||||||
</transition>
|
</transition>
|
||||||
</router-view>
|
</router-view>
|
||||||
</AConfigProvider>
|
</AConfigProvider>
|
||||||
|
|
||||||
<div v-else class="flex bottom-0 wrap-fix top-0 bg-white z-1000000000000 justify-center">
|
<div v-else class="app-splash-screen flex items-center justify-center bg-white">
|
||||||
<div class="top-0 wrap-fix h-1/3 w-screen flex">
|
<div class="app-splash-screen__gradient app-splash-screen__gradient--top h-1/3 flex">
|
||||||
<img :src="img_topGradiant" alt="" class="absolute z-10 w-screen h-full object-cover" />
|
<img :src="img_topGradiant" alt="" class="absolute z-10 w-full h-full object-cover" />
|
||||||
<img :src="img_pattern" alt="" class="absolute w-screen h-full object-none" />
|
<img :src="img_pattern" alt="" class="absolute w-full h-full object-none" />
|
||||||
</div>
|
</div>
|
||||||
<div class="wrap-fix bottom-0 h-1/3 w-screen">
|
<div class="app-splash-screen__gradient app-splash-screen__gradient--bottom h-1/3">
|
||||||
<img
|
<img
|
||||||
:src="img_bottomGradiant"
|
:src="img_bottomGradiant"
|
||||||
alt=""
|
alt=""
|
||||||
class="absolute z-10 w-screen h-full object-cover"
|
class="absolute z-10 w-full h-full object-cover"
|
||||||
/>
|
/>
|
||||||
<img :src="img_pattern" alt="" class="absolute w-screen h-full object-none" />
|
<img :src="img_pattern" alt="" class="absolute w-full h-full object-none" />
|
||||||
</div>
|
</div>
|
||||||
<div class="self-center splash_appear_fade_in">
|
<div class="splash_appear_fade_in relative z-10">
|
||||||
<img :src="logoFull" class="h-[20vh]">
|
<img :src="logoFull" class="h-[20vh] max-h-[180px] w-auto object-contain" alt="" />
|
||||||
<!-- <img :src="logo" alt="" class="z-100 bg-primary rounded-full w-full aspect-square self-center h-40" />-->
|
|
||||||
</div>
|
</div>
|
||||||
<div class="fixed w-full bottom-5 home_appear_fade_in_up">
|
<div class="app-splash-screen__version home_appear_fade_in_up">
|
||||||
<div class="text-center text-xs">نسخه: {{ pkg.version }}</div>
|
<div class="text-center text-xs">نسخه: {{ displayVersion }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="absolute bottom-10">
|
<div class="app-splash-screen__spinner">
|
||||||
<a-spin :indicator="indicator" size="small" />
|
<a-spin :indicator="indicator" size="small" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="showSupportButton && !showSplash"
|
||||||
|
id="support-button"
|
||||||
|
class="draggable-support-button"
|
||||||
|
:class="{ 'is-dragging': supportDragging }"
|
||||||
|
:style="supportButtonStyle"
|
||||||
|
title="پشتیبانی"
|
||||||
|
@pointerdown="onSupportPointerDown"
|
||||||
|
@pointermove="onSupportPointerMove"
|
||||||
|
@pointerup="handleSupportPointerUp"
|
||||||
|
@pointercancel="onSupportPointerCancel"
|
||||||
|
>
|
||||||
|
<div class="support-button-inner" :style="{ '--support-accent': supportAccentColor }">
|
||||||
|
<BasicIcon :icon="supportIcon" size="18" class="support-button-icon" />
|
||||||
|
<span class="support-button-label">پشتیبانی</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<VersionUpdateModal />
|
<VersionUpdateModal />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { colors } from './themeConfig'
|
import { getDisplayAppVersion } from '@/config/config-cache'
|
||||||
|
import { computed, defineAsyncComponent, h, onMounted, ref } from 'vue'
|
||||||
import pkg from '../package.json'
|
import pkg from '../package.json'
|
||||||
import { defineAsyncComponent, h, onMounted, ref } from 'vue'
|
|
||||||
import img_topGradiant from '@/views/login/assets/img/gr_top_white.svg'
|
import img_topGradiant from '@/views/login/assets/img/gr_top_white.svg'
|
||||||
import img_pattern from '@/views/login/assets/img/pattern.svg'
|
import img_pattern from '@/views/login/assets/img/pattern.svg'
|
||||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import {
|
||||||
|
buildSupportMessengerUrl,
|
||||||
|
loadSupportMessengerFromSettings,
|
||||||
|
supportMessengerSettings,
|
||||||
|
} from '@/utils/supportMessenger'
|
||||||
|
import { useDraggableFloatingButton } from '@/utils/useDraggableFloatingButton'
|
||||||
|
import { useApplyDesktopLayoutClass } from '@/layouts/composables/useAppLayout'
|
||||||
|
import { getProjectBranding } from '@/utils/project'
|
||||||
|
|
||||||
import img_bottomGradiant from '@/views/login/assets/img/gr_bottom_white.svg'
|
import img_bottomGradiant from '@/views/login/assets/img/gr_bottom_white.svg'
|
||||||
import logoFull from '@/assets/img/logo_full_.png'
|
import logoFull from '@/assets/img/logo_full_.png'
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
|
||||||
|
|
||||||
const VersionUpdateModal = defineAsyncComponent(
|
const VersionUpdateModal = defineAsyncComponent(
|
||||||
() => import('@/modules/version/VersionUpdateModal.vue')
|
() => import('@/modules/version/VersionUpdateModal.vue')
|
||||||
@@ -81,9 +90,94 @@ const indicator = h(LoadingOutlined, {
|
|||||||
},
|
},
|
||||||
spin: true
|
spin: true
|
||||||
})
|
})
|
||||||
|
const displayVersion = getDisplayAppVersion(pkg.version)
|
||||||
const showSplash = ref(true)
|
const showSplash = ref(true)
|
||||||
|
|
||||||
onMounted(() => {
|
const antDesignTheme = computed(() => {
|
||||||
|
const primary = getProjectBranding().accentColor
|
||||||
|
|
||||||
|
return {
|
||||||
|
token: {
|
||||||
|
colorPrimary: primary,
|
||||||
|
colorLink: primary,
|
||||||
|
colorLinkActive: primary,
|
||||||
|
colorLinkHover: primary,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
useApplyDesktopLayoutClass()
|
||||||
|
|
||||||
|
const supportLink = computed(() =>
|
||||||
|
buildSupportMessengerUrl(
|
||||||
|
supportMessengerSettings.value.messenger,
|
||||||
|
supportMessengerSettings.value.messengerId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
const showSupportButton = computed(() => !!supportLink.value)
|
||||||
|
|
||||||
|
const supportIcon = computed(() => {
|
||||||
|
const messenger = (supportMessengerSettings.value.messenger ?? '').toLowerCase()
|
||||||
|
switch (messenger) {
|
||||||
|
case 'whatsapp':
|
||||||
|
return 'vuesax-linear:whatsapp'
|
||||||
|
case 'telegram':
|
||||||
|
return 'vuesax-linear:send-2'
|
||||||
|
case 'bale':
|
||||||
|
return 'vuesax-linear:messages-2'
|
||||||
|
default:
|
||||||
|
return 'vuesax-linear:messages-2'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const supportAccentColor = computed(() => {
|
||||||
|
const messenger = (supportMessengerSettings.value.messenger ?? '').toLowerCase()
|
||||||
|
switch (messenger) {
|
||||||
|
case 'whatsapp':
|
||||||
|
return '#22c55e'
|
||||||
|
case 'telegram':
|
||||||
|
return '#0ea5e9'
|
||||||
|
case 'bale':
|
||||||
|
return '#16a34a'
|
||||||
|
case 'rubika':
|
||||||
|
return '#7c3aed'
|
||||||
|
case 'eitaa':
|
||||||
|
return '#f59e0b'
|
||||||
|
case 'soroush':
|
||||||
|
return '#2563eb'
|
||||||
|
default:
|
||||||
|
return getProjectBranding().accentColor
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const {
|
||||||
|
dragging: supportDragging,
|
||||||
|
fabStyle: supportButtonStyle,
|
||||||
|
handlePointerDown: onSupportPointerDown,
|
||||||
|
handlePointerMove: onSupportPointerMove,
|
||||||
|
handlePointerUp: supportPointerUp,
|
||||||
|
handlePointerCancel: onSupportPointerCancel,
|
||||||
|
} = useDraggableFloatingButton('ghatreh_support_button_position_v1', {
|
||||||
|
width: 118,
|
||||||
|
height: 42,
|
||||||
|
defaultBottomGap: 12,
|
||||||
|
defaultRightOffset: 16,
|
||||||
|
})
|
||||||
|
|
||||||
|
function openSupportLink() {
|
||||||
|
if (!supportLink.value) return
|
||||||
|
window.open(supportLink.value, '_blank', 'noopener,noreferrer')
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSupportPointerUp(event: PointerEvent) {
|
||||||
|
if (supportPointerUp(event)) {
|
||||||
|
openSupportLink()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadSupportMessengerFromSettings()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
showSplash.value = false
|
showSplash.value = false
|
||||||
}, 2000)
|
}, 2000)
|
||||||
@@ -93,15 +187,55 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
.updateButton .van-dialog__confirm .van-button__text {
|
.updateButton .van-dialog__confirm .van-button__text {
|
||||||
color: @primary-color !important;
|
color: @theme-primary !important;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 426px) {
|
#support-button {
|
||||||
.desktopConfig {
|
position: fixed;
|
||||||
width: 426px;
|
z-index: 5100;
|
||||||
position: relative !important;
|
cursor: grab;
|
||||||
|
user-select: none;
|
||||||
|
border-radius: 9999px;
|
||||||
|
|
||||||
|
&.is-dragging {
|
||||||
|
cursor: grabbing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.support-button-inner {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 9px 14px 9px 12px;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.08);
|
||||||
|
border-radius: 9999px;
|
||||||
|
box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
|
||||||
|
color: #1e293b;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1;
|
||||||
|
direction: rtl;
|
||||||
|
transition: box-shadow 0.2s ease, transform 0.2s ease;
|
||||||
|
|
||||||
|
.support-button-icon {
|
||||||
|
color: var(--support-accent, #334155);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-button-label {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#support-button:not(.is-dragging):hover .support-button-inner {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
#support-button.is-dragging .support-button-inner {
|
||||||
|
box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+2
-2
@@ -4,10 +4,10 @@ import type { PWallet, Wallet } from '@/models/wallet'
|
|||||||
|
|
||||||
|
|
||||||
export const getProducts = async (): Promise<any> => {
|
export const getProducts = async (): Promise<any> => {
|
||||||
return await useAxios.get<Product[]>(`/customer/product/list`)
|
return await useAxios.get<Product[]>(`/customer/product/list`, { timeout: 15000 })
|
||||||
}
|
}
|
||||||
export const getProductById = async ( id:number|null): Promise<any> => {
|
export const getProductById = async ( id:number|null): Promise<any> => {
|
||||||
return await useAxios.get<Product[]>(`/customer/product/list/${id}`)
|
return await useAxios.get<Product[]>(`/customer/product/list/${id}`, { timeout: 15000 })
|
||||||
}
|
}
|
||||||
export const getProductInventory = async (): Promise<any> => {
|
export const getProductInventory = async (): Promise<any> => {
|
||||||
return await useAxios.post<PInventory[]>(`/customer/wallet/product/table`)
|
return await useAxios.post<PInventory[]>(`/customer/wallet/product/table`)
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import useAxios from '@/utils/useAxios'
|
import useAxios from '@/utils/useAxios'
|
||||||
import type { Card, Wallet } from '@/models/wallet'
|
import type { Card, Wallet } from '@/models/wallet'
|
||||||
|
import type { WalletAssetsSummary } from '@/models/walletAssets'
|
||||||
import type {Transaction} from '@/models/transaction'
|
import type {Transaction} from '@/models/transaction'
|
||||||
|
|
||||||
export const getWallet = async () => await useAxios.get<Wallet>(`/customer/wallet/me`)
|
export const getWallet = async () => await useAxios.get<Wallet>(`/customer/wallet/me`)
|
||||||
|
|
||||||
|
export const getWalletAssets = async () =>
|
||||||
|
await useAxios.get<WalletAssetsSummary>(`/customer/wallet/assets`)
|
||||||
|
|
||||||
export const withdraw = async (obj: Transaction): Promise<any> => {
|
export const withdraw = async (obj: Transaction): Promise<any> => {
|
||||||
return await useAxios.post<Transaction>(`/customer/wallet/withdraw`, obj)
|
return await useAxios.post<Transaction>(`/customer/wallet/withdraw`, obj)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { createVueApp } from '@/app/createApp'
|
|||||||
import { setupRouterGuards } from '@/app/setupRouter'
|
import { setupRouterGuards } from '@/app/setupRouter'
|
||||||
import { useSettingsStore } from '@/store/settingsStore'
|
import { useSettingsStore } from '@/store/settingsStore'
|
||||||
import { initPriceRealtimeChannel } from '@/utils/priceSocket'
|
import { initPriceRealtimeChannel } from '@/utils/priceSocket'
|
||||||
|
import { initMobileScrollRestoration } from '@/layouts/composables/useMobileScrollReset'
|
||||||
|
|
||||||
type BootWindow = Window & {
|
type BootWindow = Window & {
|
||||||
__BOOT_TIMEOUT__?: number
|
__BOOT_TIMEOUT__?: number
|
||||||
@@ -74,6 +75,7 @@ export async function bootstrapApp() {
|
|||||||
await withTimeout(settingsStore.fetchSettings(), 45000, 'Settings loading timeout')
|
await withTimeout(settingsStore.fetchSettings(), 45000, 'Settings loading timeout')
|
||||||
initPriceRealtimeChannel((key) => settingsStore.getSettingByKey(key))
|
initPriceRealtimeChannel((key) => settingsStore.getSettingByKey(key))
|
||||||
|
|
||||||
|
initMobileScrollRestoration()
|
||||||
setupRouterGuards()
|
setupRouterGuards()
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
+22
-11
@@ -2,8 +2,6 @@ import { computed, watch } from 'vue'
|
|||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { authenticateWithFingerprint, getToken, isIphone, removeToken } from '@/utils'
|
import { authenticateWithFingerprint, getToken, isIphone, removeToken } from '@/utils'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import { useWalletStore } from '@/store/walletStore'
|
|
||||||
import { useFundUserStore } from '@/store/fundStore'
|
|
||||||
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
|
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
|
||||||
import { useAuthStore } from '@/store/useAuthStore'
|
import { useAuthStore } from '@/store/useAuthStore'
|
||||||
import {
|
import {
|
||||||
@@ -14,11 +12,11 @@ import {
|
|||||||
setFingerTimeOut,
|
setFingerTimeOut,
|
||||||
setHasFingerPrint
|
setHasFingerPrint
|
||||||
} from '@/app/authBoot'
|
} from '@/app/authBoot'
|
||||||
|
import { recoverMobileViewportAfterAuth } from '@/layouts/composables/useMobileScrollReset'
|
||||||
|
import { getProjectDefaultRoute, isGhatreProject } from '@/utils/project'
|
||||||
|
|
||||||
export function setupRouterGuards() {
|
export function setupRouterGuards() {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const walletStore = useWalletStore()
|
|
||||||
const fundStore = useFundUserStore()
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
const isApple: boolean = isIphone()
|
const isApple: boolean = isIphone()
|
||||||
@@ -27,10 +25,12 @@ export function setupRouterGuards() {
|
|||||||
const currentRoute = computed(() => router.currentRoute.value.fullPath)
|
const currentRoute = computed(() => router.currentRoute.value.fullPath)
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
if (getToken()) {
|
if (!getToken()) {
|
||||||
await walletStore.getLimitedPrice()
|
return
|
||||||
await walletStore.getLimitedBuyGold()
|
}
|
||||||
await fundStore.getMyFund()
|
|
||||||
|
if (!userStore.userInfo) {
|
||||||
|
await userStore.getMyInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,13 +45,17 @@ export function setupRouterGuards() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||||
if (to.name !== 'buyProduct') {
|
const defaultRoute = getProjectDefaultRoute()
|
||||||
return next({ name: 'buyProduct' })
|
if (to.name !== defaultRoute) {
|
||||||
|
return next({ name: defaultRoute })
|
||||||
}
|
}
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
|
if (to.name === 'home' && isGhatreProject()) {
|
||||||
|
return next({ name: 'buyProduct' })
|
||||||
|
}
|
||||||
authStore.setLoading(true)
|
authStore.setLoading(true)
|
||||||
clearFingerTimeout()
|
clearFingerTimeout()
|
||||||
setFingerTimeOut(to)
|
setFingerTimeOut(to)
|
||||||
@@ -89,7 +93,7 @@ export function setupRouterGuards() {
|
|||||||
if (getFingerPosition()) {
|
if (getFingerPosition()) {
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
if (to.name === 'login') {
|
if (to.name === 'login') {
|
||||||
return next({ name: from.name || 'buyProduct' })
|
return next({ name: from.name || getProjectDefaultRoute() })
|
||||||
}
|
}
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
@@ -108,5 +112,12 @@ export function setupRouterGuards() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.afterEach((to, from) => {
|
||||||
|
if (document.documentElement.classList.contains('app-layout--desktop')) return
|
||||||
|
if (from.name === 'login') {
|
||||||
|
recoverMobileViewportAfterAuth()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
watch(currentRoute, async () => (userStore.userInfo ? '' : await start()))
|
watch(currentRoute, async () => (userStore.userInfo ? '' : await start()))
|
||||||
}
|
}
|
||||||
|
|||||||
+53
-10
@@ -1,5 +1,16 @@
|
|||||||
@import (less) './var.less';
|
@import (less) './var.less';
|
||||||
@import (less) './fonts.less';
|
@import (less) './fonts.less';
|
||||||
|
@import (less) '../../layouts/styles/desktop-shell.less';
|
||||||
|
@import (less) '../../layouts/styles/mobile-frame.less';
|
||||||
|
@import (less) '../../layouts/styles/mobile-page-common.less';
|
||||||
|
@import (less) '../../layouts/desktop/styles/desktop-page-common.less';
|
||||||
|
@import (less) '../../views/base/fund/desktop/styles/desktop-fund.less';
|
||||||
|
@import (less) '../../views/base/transactions/desktop/styles/desktop-transactions.less';
|
||||||
|
@import (less) '../../views/base/wallet/desktop/styles/desktop-wallet.less';
|
||||||
|
@import (less) '../../views/base/user/desktop/styles/desktop-user.less';
|
||||||
|
@import (less) '../../views/base/priceTrigger/desktop/styles/desktop-price-trigger.less';
|
||||||
|
@import (less) '../../views/base/home/desktop/styles/desktop-home.less';
|
||||||
|
@import (less) '../../layouts/desktop/styles/desktop-inner-pages.less';
|
||||||
|
|
||||||
html {
|
html {
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
@@ -50,6 +61,33 @@ body {
|
|||||||
|
|
||||||
:root {
|
:root {
|
||||||
color-scheme: only light;
|
color-scheme: only light;
|
||||||
|
--app-primary-color: #a72b77;
|
||||||
|
--project-hero-gradient: linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%);
|
||||||
|
--app-safe-top: env(safe-area-inset-top, 0px);
|
||||||
|
--app-safe-bottom: env(safe-area-inset-bottom, 0px);
|
||||||
|
--app-credit-bar-inner: 0px;
|
||||||
|
--app-home-header-offset: calc(4.25rem + var(--app-safe-top));
|
||||||
|
--app-credit-footer-offset: var(--app-safe-bottom);
|
||||||
|
--app-nav-height: 80px;
|
||||||
|
--app-bottom-chrome-height: calc(var(--app-nav-height) + var(--app-safe-bottom));
|
||||||
|
--app-add-card-height: 88px;
|
||||||
|
--wallet-card-dock-overlap: 52px;
|
||||||
|
--app-z-nav: 5000;
|
||||||
|
--app-z-wallet-dock: 4490;
|
||||||
|
--app-z-wallet-add-bar: 4510;
|
||||||
|
--app-z-action-sheet: 5200;
|
||||||
|
--app-z-dialog: 5300;
|
||||||
|
--app-z-modal: 5500;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-project='ghatre'] {
|
||||||
|
--app-primary-color: #521620;
|
||||||
|
--project-hero-gradient: linear-gradient(145deg, #521620 0%, #7a2a1e 40%, #521620 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-project='kashkool'] {
|
||||||
|
--app-primary-color: #a72b77;
|
||||||
|
--project-hero-gradient: linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-form-item {
|
.ant-form-item {
|
||||||
@@ -74,18 +112,23 @@ body {
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*.van-action-sheet{
|
.van-action-sheet{
|
||||||
z-index: 2001 !important;
|
z-index: 5001 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-overlay{
|
//.van-overlay{
|
||||||
z-index: 2000 !important;
|
// z-index: 2000 !important;
|
||||||
}*/
|
//}
|
||||||
|
|
||||||
.color-transition {
|
.color-transition {
|
||||||
transition: color 0.3s ease;
|
transition: color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-main {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
.background-color-transition {
|
.background-color-transition {
|
||||||
transition: background-color 0.3s ease;
|
transition: background-color 0.3s ease;
|
||||||
}
|
}
|
||||||
@@ -133,7 +176,7 @@ body {
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
//display: none;
|
//display: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
border: 1px solid #a72b77 !important;
|
border: 1px solid var(--app-primary-color, #a72b77) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,18 +374,18 @@ body {
|
|||||||
}
|
}
|
||||||
.ant-radio-group-solid
|
.ant-radio-group-solid
|
||||||
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover{
|
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover{
|
||||||
color: #a72b77 !important;
|
color: var(--app-primary-color, #a72b77) !important;
|
||||||
}
|
}
|
||||||
.ant-input-group-addon{
|
.ant-input-group-addon{
|
||||||
background-color: #a72b77 !important;
|
background-color: var(--app-primary-color, #a72b77) !important;
|
||||||
color: #e0be7f !important;
|
color: #e0be7f !important;
|
||||||
}
|
}
|
||||||
.ant-slider-track{
|
.ant-slider-track{
|
||||||
background-color: #a72b77 !important;
|
background-color: var(--app-primary-color, #a72b77) !important;
|
||||||
|
|
||||||
}
|
}
|
||||||
.ant-slider-handle {
|
.ant-slider-handle {
|
||||||
background-color: #a72b77 !important;
|
background-color: var(--app-primary-color, #a72b77) !important;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
@primary-color: #a72b77;
|
@primary-color: #a72b77;
|
||||||
@secondary-color: #a72b77;
|
@secondary-color: #a72b77;
|
||||||
|
@App-primary-color: #a72b77;
|
||||||
|
@theme-primary: var(--app-primary-color, #a72b77);
|
||||||
@prefixCls-font-family: 'iran-sans';
|
@prefixCls-font-family: 'iran-sans';
|
||||||
@prefixCls-background-color: #fff;
|
@prefixCls-background-color: #fff;
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
import {usePrefix} from "@/utils/usePrefix";
|
import {usePrefix} from "@/utils/usePrefix";
|
||||||
import {computed} from "vue";
|
import {computed} from "vue";
|
||||||
import {usePrice} from "@/components/BasicPacks/BasicPriceInput/src/utils/usePrice";
|
import {usePrice} from "@/components/BasicPacks/BasicPriceInput/src/utils/usePrice";
|
||||||
|
import {persianToEnglishDigits, shouldNormalizeInputDigits} from '@/utils/persianDigits';
|
||||||
|
|
||||||
//Props
|
//Props
|
||||||
interface Prop {
|
interface Prop {
|
||||||
@@ -56,29 +57,42 @@ interface Prop {
|
|||||||
|
|
||||||
const addonBgColor = computed(() => props.addonBgColor)
|
const addonBgColor = computed(() => props.addonBgColor)
|
||||||
const addonTextColor = computed(() => props.addonTextColor)
|
const addonTextColor = computed(() => props.addonTextColor)
|
||||||
//emits
|
|
||||||
const localValue = computed({
|
|
||||||
set(value) {
|
|
||||||
// console.log(value?.toString().replaceAll(',', ''))
|
|
||||||
props.type === 'price' ? emits('update:value', value?.toString().replaceAll(',', '')) : emits('update:value', value)
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
let a = props.type === 'price' ? props.value ? usePrice(props.value as number, true, '').trim() : '' : props.value
|
|
||||||
// console.log(props.value)
|
|
||||||
return a
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Prop>(), {
|
const props = withDefaults(defineProps<Prop>(), {
|
||||||
isPassword: false
|
isPassword: false
|
||||||
})
|
})
|
||||||
const emits = defineEmits(['update:value', 'onchange'])
|
const emits = defineEmits(['update:value', 'onchange'])
|
||||||
|
|
||||||
|
const localValue = computed({
|
||||||
|
set(value) {
|
||||||
|
emits('update:value', normalizeValue(value))
|
||||||
|
},
|
||||||
|
get() {
|
||||||
|
return props.type === 'price'
|
||||||
|
? props.value ? usePrice(props.value as number, true, '').trim() : ''
|
||||||
|
: props.value
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
function normalizeValue(value: unknown) {
|
||||||
|
if (value == null || value === '') {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
let normalized = String(value)
|
||||||
|
if (shouldNormalizeInputDigits(props)) {
|
||||||
|
normalized = persianToEnglishDigits(normalized)
|
||||||
|
}
|
||||||
|
if (props.type === 'price') {
|
||||||
|
normalized = normalized.replaceAll(',', '')
|
||||||
|
}
|
||||||
|
return normalized
|
||||||
|
}
|
||||||
|
|
||||||
const handlerChange = (e: any) => {
|
const handlerChange = (e: any) => {
|
||||||
// emits('onchange', e.target.value)
|
const normalized = normalizeValue(e.target.value)
|
||||||
props.type === 'price' ? emits('update:value', e.target.value?.toString().replaceAll(',', '')) : emits('update:value', e.target.value)
|
emits('update:value', normalized)
|
||||||
props.type === 'price' ? emits('onchange', e.target.value?.toString().replaceAll(',', '')) : emits('onchange', e.target.value)
|
emits('onchange', normalized)
|
||||||
// console.log('sas')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//css style
|
//css style
|
||||||
@@ -89,11 +103,6 @@ const {prefixCls} = usePrefix('input')
|
|||||||
@prefix: ~'@{prefixCls}-input';
|
@prefix: ~'@{prefixCls}-input';
|
||||||
|
|
||||||
.@{prefix} {
|
.@{prefix} {
|
||||||
/* .ant-input-group-addon:first-child {
|
|
||||||
!* border: #d9d9d9 1px solid;
|
|
||||||
border-radius: 0 6px 6px 0;*!
|
|
||||||
}*/
|
|
||||||
|
|
||||||
.ant-input-group {
|
.ant-input-group {
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasicInput v-model:value="_val">
|
<BasicInput v-model:value="_val" type="price">
|
||||||
<template v-for="(_, slotKey) in $slots" #[slotKey]="data">
|
<template v-for="(_, slotKey) in $slots" #[slotKey]="data">
|
||||||
<slot :name="slotKey" v-bind="data || {}"></slot>
|
<slot :name="slotKey" v-bind="data || {}"></slot>
|
||||||
</template>
|
</template>
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
import {usePrice} from './utils/usePrice'
|
import {usePrice} from './utils/usePrice'
|
||||||
import {computed} from "vue";
|
import {computed} from "vue";
|
||||||
import BasicInput from "../../BasicInput.vue";
|
import BasicInput from "../../BasicInput.vue";
|
||||||
|
import {persianToEnglishDigits} from '@/utils/persianDigits'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value?: string | number
|
value?: string | number
|
||||||
@@ -23,9 +24,7 @@ const props = withDefaults(defineProps<Props>(), {})
|
|||||||
|
|
||||||
const _val = computed({
|
const _val = computed({
|
||||||
set(val: string) {
|
set(val: string) {
|
||||||
// const temp = val.toString().replaceAll(',', '')
|
emit('update:value', persianToEnglishDigits(val).replaceAll(',', ''))
|
||||||
const temp = val.toString().replaceAll(',', '')
|
|
||||||
emit('update:value', temp)
|
|
||||||
},
|
},
|
||||||
get() {
|
get() {
|
||||||
return props.value ? usePrice(props.value as number, true, '').trim() : ''
|
return props.value ? usePrice(props.value as number, true, '').trim() : ''
|
||||||
|
|||||||
@@ -1,17 +1 @@
|
|||||||
export function usePrice(price: number, digit = true, unit = 'ریال') {
|
export { usePrice, usePriceWithoutType, useTowDecimal, useFormat } from '@/utils/usePrice'
|
||||||
let _price = price.toString()
|
|
||||||
if (digit) {
|
|
||||||
_price = _price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
||||||
}
|
|
||||||
return `${_price} ${unit}`
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useTowDecimal(num: string | number): string | number {
|
|
||||||
const temp = num.toString().match(/^-?\d+(?:\.\d{0,2})?/)
|
|
||||||
if (temp && temp.length > 0) return temp[0]
|
|
||||||
return Math.round(+num * 100) / 100
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useFormat(num: string | number, unit = '') {
|
|
||||||
return usePrice(Math.abs(+useTowDecimal(num)), true, unit)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { getProducts } from '@/api/products'
|
||||||
|
import type { Product } from '@/models/products'
|
||||||
|
import { getLastStreamProductsList } from '@/utils/productStreamBridge'
|
||||||
|
|
||||||
|
/** کش مشترک لیست محصولات — dedupe درخواستهای polling */
|
||||||
|
const catalogProducts = ref<Product[]>([])
|
||||||
|
let catalogPromise: Promise<Product[]> | null = null
|
||||||
|
|
||||||
|
export function getProductsCatalogRef() {
|
||||||
|
return catalogProducts
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findProductInCatalog(id: number): Product | undefined {
|
||||||
|
const cached = catalogProducts.value.find((p) => p.id === id)
|
||||||
|
if (cached) {
|
||||||
|
return cached
|
||||||
|
}
|
||||||
|
|
||||||
|
return getLastStreamProductsList()?.find((p) => p.id === id)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getProductsCatalog(force = false): Promise<Product[]> {
|
||||||
|
if (!force) {
|
||||||
|
const streamed = getLastStreamProductsList()
|
||||||
|
if (streamed?.length) {
|
||||||
|
catalogProducts.value = streamed
|
||||||
|
return Promise.resolve(streamed)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (catalogProducts.value.length > 0) {
|
||||||
|
return Promise.resolve(catalogProducts.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!force && catalogPromise) {
|
||||||
|
return catalogPromise
|
||||||
|
}
|
||||||
|
|
||||||
|
catalogPromise = getProducts()
|
||||||
|
.then((products) => {
|
||||||
|
catalogProducts.value = products ?? []
|
||||||
|
return catalogProducts.value
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
catalogPromise = null
|
||||||
|
})
|
||||||
|
|
||||||
|
return catalogPromise
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clearProductsCatalog() {
|
||||||
|
catalogProducts.value = []
|
||||||
|
catalogPromise = null
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { computed } from 'vue'
|
||||||
|
import {
|
||||||
|
getProjectBranding,
|
||||||
|
getProjectId,
|
||||||
|
isBoursecuProject,
|
||||||
|
isGhatreProject,
|
||||||
|
isKashkoolProject,
|
||||||
|
type ProjectBranding,
|
||||||
|
type ProjectId,
|
||||||
|
} from '@/utils/project'
|
||||||
|
|
||||||
|
export function useProject() {
|
||||||
|
const projectId = computed<ProjectId>(() => getProjectId())
|
||||||
|
const branding = computed<ProjectBranding>(() => getProjectBranding())
|
||||||
|
|
||||||
|
const isGhatre = computed(() => isGhatreProject())
|
||||||
|
const isKashkool = computed(() => isKashkoolProject())
|
||||||
|
const isBoursecu = computed(() => isBoursecuProject())
|
||||||
|
|
||||||
|
const projectNameFa = computed(() => branding.value.nameFa)
|
||||||
|
const heroGradient = computed(() => branding.value.heroGradient)
|
||||||
|
const accentColor = computed(() => branding.value.accentColor)
|
||||||
|
const fundLabel = computed(() => branding.value.fundLabel)
|
||||||
|
const showHomeRoute = computed(() => branding.value.showHomeRoute)
|
||||||
|
const defaultRoute = computed(() => branding.value.defaultRoute)
|
||||||
|
|
||||||
|
return {
|
||||||
|
projectId,
|
||||||
|
branding,
|
||||||
|
isGhatre,
|
||||||
|
isKashkool,
|
||||||
|
isBoursecu,
|
||||||
|
projectNameFa,
|
||||||
|
heroGradient,
|
||||||
|
accentColor,
|
||||||
|
fundLabel,
|
||||||
|
showHomeRoute,
|
||||||
|
defaultRoute,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { getWalletAssets } from '@/api/wallet'
|
||||||
|
import { getProductsCatalog, getProductsCatalogRef } from '@/composables/useProductsCatalog'
|
||||||
|
import { useWalletStore } from '@/store/walletStore'
|
||||||
|
import type { WalletAssetsSummary } from '@/models/walletAssets'
|
||||||
|
import { enrichInventoryCardsWithCatalog } from '@/utils/productAssets'
|
||||||
|
|
||||||
|
const assetsSummary = ref<WalletAssetsSummary | null>(null)
|
||||||
|
let assetsPromise: Promise<WalletAssetsSummary> | null = null
|
||||||
|
|
||||||
|
function enrichAssetsSummary(data: WalletAssetsSummary): WalletAssetsSummary {
|
||||||
|
const catalog = getProductsCatalogRef().value
|
||||||
|
|
||||||
|
return {
|
||||||
|
...data,
|
||||||
|
inventory_cards: enrichInventoryCardsWithCatalog(data.inventory_cards ?? [], catalog ?? []),
|
||||||
|
count_products: enrichInventoryCardsWithCatalog(data.count_products ?? [], catalog ?? []),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncWalletStoreFromAssets(data: WalletAssetsSummary) {
|
||||||
|
const walletStore = useWalletStore()
|
||||||
|
if (!walletStore.walletInfo) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const goldMetal = data.metal_totals?.find((metal) => metal.metal_id === 1) ?? data.metal_totals?.[0]
|
||||||
|
|
||||||
|
walletStore.walletInfo.cash = data.cash_wallet ?? walletStore.walletInfo.cash
|
||||||
|
|
||||||
|
if (goldMetal) {
|
||||||
|
walletStore.walletInfo.gold = goldMetal.melted_weight ?? walletStore.walletInfo.gold
|
||||||
|
walletStore.walletInfo.gold_sum = goldMetal.total_weight ?? walletStore.walletInfo.gold_sum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useWalletAssets() {
|
||||||
|
async function loadWalletAssets(force = false) {
|
||||||
|
if (!force && assetsSummary.value) {
|
||||||
|
return assetsSummary.value
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!force && assetsPromise) {
|
||||||
|
return assetsPromise
|
||||||
|
}
|
||||||
|
|
||||||
|
assetsPromise = Promise.all([getWalletAssets(), getProductsCatalog(force)])
|
||||||
|
.then(([data]) => {
|
||||||
|
assetsSummary.value = enrichAssetsSummary(data)
|
||||||
|
syncWalletStoreFromAssets(assetsSummary.value)
|
||||||
|
return assetsSummary.value
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
assetsPromise = null
|
||||||
|
})
|
||||||
|
|
||||||
|
return assetsPromise
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearWalletAssets() {
|
||||||
|
assetsSummary.value = null
|
||||||
|
assetsPromise = null
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
assetsSummary,
|
||||||
|
loadWalletAssets,
|
||||||
|
clearWalletAssets,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,14 +15,33 @@ export function getRawAppConfig() {
|
|||||||
return appConfig ?? window.__APP_CONFIG__ ?? null
|
return appConfig ?? window.__APP_CONFIG__ ?? null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isPlainObject(value: unknown): value is Record<string, any> {
|
||||||
|
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||||
|
}
|
||||||
|
|
||||||
export function getTenantConfig() {
|
export function getTenantConfig() {
|
||||||
const rawConfig = getRawAppConfig()
|
const rawConfig = getRawAppConfig()
|
||||||
|
if (!rawConfig) return {}
|
||||||
|
|
||||||
if (rawConfig?.user && typeof rawConfig.user === 'object') {
|
const user = rawConfig.user
|
||||||
return rawConfig.user
|
|
||||||
|
if (isPlainObject(user)) {
|
||||||
|
return {
|
||||||
|
...user,
|
||||||
|
name: rawConfig.name ?? user.name,
|
||||||
|
name_fa: rawConfig.name_fa ?? user.name_fa,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawConfig && Object.keys(rawConfig).length > 0) {
|
if (Array.isArray(user) && isPlainObject(user[0])) {
|
||||||
|
return {
|
||||||
|
...user[0],
|
||||||
|
name: rawConfig.name ?? user[0].name,
|
||||||
|
name_fa: rawConfig.name_fa ?? user[0].name_fa,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(rawConfig).length > 0) {
|
||||||
return rawConfig
|
return rawConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,37 @@
|
|||||||
import { getConfig } from '@/config/app-config'
|
import { getConfig } from '@/config/app-config'
|
||||||
import { isPwaManifestReady } from '@/modules/pwa/manifest'
|
import { isPwaManifestReady } from '@/modules/pwa/manifest'
|
||||||
|
import { getProjectBranding } from '@/utils/project'
|
||||||
|
|
||||||
export function applyAppConfig() {
|
export function applyAppConfig() {
|
||||||
if (isPwaManifestReady()) return
|
applyProjectTheme()
|
||||||
|
|
||||||
|
if (isPwaManifestReady()) {
|
||||||
|
setTitle()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
setTitle()
|
setTitle()
|
||||||
setFavicon()
|
setFavicon()
|
||||||
setAppleTouchIconFallback()
|
setAppleTouchIconFallback()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyProjectTheme() {
|
||||||
|
const branding = getProjectBranding()
|
||||||
|
const root = document.documentElement
|
||||||
|
const primary = branding.accentColor
|
||||||
|
|
||||||
|
root.style.setProperty('--project-accent', primary)
|
||||||
|
root.style.setProperty('--project-hero-gradient', branding.heroGradient)
|
||||||
|
root.style.setProperty('--app-primary-color', primary)
|
||||||
|
root.style.setProperty('--primary-color', primary)
|
||||||
|
root.dataset.project = branding.id
|
||||||
|
|
||||||
|
const secondaryColor = getConfig<string>('secondary_color')
|
||||||
|
if (secondaryColor) {
|
||||||
|
root.style.setProperty('--secondary-color', secondaryColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setTitle() {
|
function setTitle() {
|
||||||
document.title = getConfig('name_fa', 'در حال بارگذاری...')
|
document.title = getConfig('name_fa', 'در حال بارگذاری...')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,10 @@ export function getStoredAppVersion() {
|
|||||||
return localStorage.getItem(VERSION_STORAGE_KEY)
|
return localStorage.getItem(VERSION_STORAGE_KEY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDisplayAppVersion(fallbackVersion: string) {
|
||||||
|
return getStoredAppVersion() || fallbackVersion
|
||||||
|
}
|
||||||
|
|
||||||
export function writeStoredAppVersion(version: string) {
|
export function writeStoredAppVersion(version: string) {
|
||||||
localStorage.setItem(VERSION_STORAGE_KEY, String(version).trim())
|
localStorage.setItem(VERSION_STORAGE_KEY, String(version).trim())
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-16
@@ -2,6 +2,7 @@ import type { AppConfig } from '@/config/types'
|
|||||||
import { readCachedAppConfig, writeCachedAppConfig } from '@/config/config-cache'
|
import { readCachedAppConfig, writeCachedAppConfig } from '@/config/config-cache'
|
||||||
|
|
||||||
const CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
|
const CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
|
||||||
|
export const CONFIG_RETRY_ROUNDS = 5
|
||||||
|
|
||||||
function getProtocol() {
|
function getProtocol() {
|
||||||
return window.location.protocol === 'https:' ? 'https:' : 'http:'
|
return window.location.protocol === 'https:' ? 'https:' : 'http:'
|
||||||
@@ -29,6 +30,12 @@ export function sortConfigUrls(urls: string[]) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearStaleConfigSuccessUrl(url: string) {
|
||||||
|
if (localStorage.getItem(CONFIG_SUCCESS_URL_KEY) === url) {
|
||||||
|
localStorage.removeItem(CONFIG_SUCCESS_URL_KEY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchConfig(url: string, timeout = 3000): Promise<AppConfig> {
|
async function fetchConfig(url: string, timeout = 3000): Promise<AppConfig> {
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
const timeoutId = window.setTimeout(() => controller.abort(), timeout)
|
const timeoutId = window.setTimeout(() => controller.abort(), timeout)
|
||||||
@@ -59,22 +66,25 @@ async function fetchConfig(url: string, timeout = 3000): Promise<AppConfig> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchFreshAppConfig(): Promise<AppConfig> {
|
export async function fetchFreshAppConfig(rounds = CONFIG_RETRY_ROUNDS): Promise<AppConfig> {
|
||||||
const urls = sortConfigUrls(getConfigUrls())
|
const urls = sortConfigUrls(getConfigUrls())
|
||||||
|
|
||||||
for (let index = 0; index < urls.length; index++) {
|
for (let round = 1; round <= rounds; round++) {
|
||||||
const url = urls[index]
|
for (let index = 0; index < urls.length; index++) {
|
||||||
|
const url = urls[index]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const timeout = index === urls.length - 1 ? 5000 : 2500
|
const timeout = index === urls.length - 1 ? 7000 : 4000
|
||||||
const config = await fetchConfig(url, timeout)
|
const config = await fetchConfig(url, timeout)
|
||||||
|
|
||||||
localStorage.setItem(CONFIG_SUCCESS_URL_KEY, url)
|
localStorage.setItem(CONFIG_SUCCESS_URL_KEY, url)
|
||||||
writeCachedAppConfig(config)
|
writeCachedAppConfig(config)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(`Config failed from ${url}`, error)
|
clearStaleConfigSuccessUrl(url)
|
||||||
|
console.warn(`Config failed from ${url}. Round: ${round}`, error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,11 +92,16 @@ export async function fetchFreshAppConfig(): Promise<AppConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadAppConfig(): Promise<AppConfig> {
|
export async function loadAppConfig(): Promise<AppConfig> {
|
||||||
const cachedConfig = readCachedAppConfig()
|
try {
|
||||||
|
return await fetchFreshAppConfig()
|
||||||
|
} catch (error) {
|
||||||
|
const cachedConfig = readCachedAppConfig()
|
||||||
|
|
||||||
if (cachedConfig) {
|
if (cachedConfig) {
|
||||||
return cachedConfig
|
console.warn('Using cached app config because fresh fetch failed', error)
|
||||||
|
return cachedConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
return await fetchFreshAppConfig()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,24 @@ type VersionResponse =
|
|||||||
}
|
}
|
||||||
|
|
||||||
const VERSION_SUCCESS_URL_KEY = 'VERSION_Success_URL'
|
const VERSION_SUCCESS_URL_KEY = 'VERSION_Success_URL'
|
||||||
const VERSION_RETRY_ROUNDS = 5
|
export const VERSION_RETRY_ROUNDS = 5
|
||||||
|
|
||||||
let versionFetchPromise: Promise<string | null> | null = null
|
let versionFetchPromise: Promise<string | null> | null = null
|
||||||
let cachedVersionResult: string | null | undefined
|
let cachedVersionResult: string | null | undefined
|
||||||
|
|
||||||
|
function getProtocol() {
|
||||||
|
return window.location.protocol === 'https:' ? 'https:' : 'http:'
|
||||||
|
}
|
||||||
|
|
||||||
function getVersionUrls() {
|
function getVersionUrls() {
|
||||||
|
const protocol = getProtocol()
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'https://nerkh.gold/get_version',
|
'https://nerkh.gold/get_version',
|
||||||
'https://tablo.talasevin.ir/get_version',
|
'https://tablo.talasevin.ir/get_version',
|
||||||
'https://abshode-service.montgit.ir/server/get_version'
|
'https://abshode-service.montgit.ir/server/get_version',
|
||||||
|
`${protocol}//212.23.201.173:8381/get_version`,
|
||||||
|
`${protocol}//91.212.174.137:4040/server/get_version`
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +41,12 @@ function sortVersionUrls(urls: string[]) {
|
|||||||
return [lastSuccessUrl, ...others]
|
return [lastSuccessUrl, ...others]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearStaleVersionSuccessUrl(url: string) {
|
||||||
|
if (localStorage.getItem(VERSION_SUCCESS_URL_KEY) === url) {
|
||||||
|
localStorage.removeItem(VERSION_SUCCESS_URL_KEY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function readUserVersion(user: unknown) {
|
function readUserVersion(user: unknown) {
|
||||||
if (!user || typeof user !== 'object' || Array.isArray(user)) {
|
if (!user || typeof user !== 'object' || Array.isArray(user)) {
|
||||||
return ''
|
return ''
|
||||||
@@ -82,7 +96,6 @@ async function fetchVersion(url: string, timeout = 3500): Promise<string | null>
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
// Non-2xx/timeout should be treated as "request failed" and we may try the next URL.
|
|
||||||
throw new Error(`Version request failed with status ${response.status}`)
|
throw new Error(`Version request failed with status ${response.status}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,10 +107,8 @@ async function fetchVersion(url: string, timeout = 3500): Promise<string | null>
|
|||||||
|
|
||||||
const version = normalizeVersionResponse(data)
|
const version = normalizeVersionResponse(data)
|
||||||
|
|
||||||
// IMPORTANT: if the request returned 200/ok, we stop here even if we couldn't extract a version.
|
|
||||||
// This prevents unnecessary looping when the endpoint is "reachable" but returns an empty payload.
|
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return null
|
throw new Error('Version response is empty')
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
|
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
|
||||||
@@ -118,10 +129,11 @@ async function fetchVersionWithRetry(rounds = VERSION_RETRY_ROUNDS): Promise<str
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const version = await fetchVersion(url, timeout)
|
const version = await fetchVersion(url, timeout)
|
||||||
// fetchVersion only throws on real request failures (non-ok / timeout).
|
if (version) {
|
||||||
// If it returns null, we got HTTP 200 but empty version => stop immediately.
|
return version
|
||||||
return version
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
clearStaleVersionSuccessUrl(url)
|
||||||
console.warn(`Version failed from ${url}. Round: ${round}`, error)
|
console.warn(`Version failed from ${url}. Round: ${round}`, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<template>
|
||||||
|
<DesktopAppLayout v-if="isDesktopLayout" />
|
||||||
|
<MobileAppLayout v-else />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useDesktopBreakpoint } from './composables/useAppLayout'
|
||||||
|
import DesktopAppLayout from './desktop/DesktopAppLayout.vue'
|
||||||
|
import MobileAppLayout from './mobile/MobileAppLayout.vue'
|
||||||
|
|
||||||
|
const isDesktopLayout = useDesktopBreakpoint()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dpage">
|
||||||
|
<header v-if="title" class="dpage-topbar">
|
||||||
|
<div>
|
||||||
|
<h1 class="dpage-topbar__title">{{ title }}</h1>
|
||||||
|
<p v-if="subtitle" class="dpage-topbar__subtitle">{{ subtitle }}</p>
|
||||||
|
</div>
|
||||||
|
<slot name="actions" />
|
||||||
|
</header>
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
defineProps<{
|
||||||
|
title?: string
|
||||||
|
subtitle?: string
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.dpage-topbar__subtitle {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #6b7280;
|
||||||
|
margin: 6px 0 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<template>
|
||||||
|
<header class="dpage-topbar" :class="{ 'dpage-topbar--sticky': sticky }">
|
||||||
|
<button
|
||||||
|
v-if="showBack"
|
||||||
|
type="button"
|
||||||
|
class="dpage-topbar__back"
|
||||||
|
@click="handleBack"
|
||||||
|
>
|
||||||
|
<BasicIcon icon="vuesax-linear:arrow-right-1" size="16" />
|
||||||
|
<span>بازگشت</span>
|
||||||
|
</button>
|
||||||
|
<div class="dpage-topbar__meta">
|
||||||
|
<p v-if="eyebrow" class="dpage-topbar__eyebrow">{{ eyebrow }}</p>
|
||||||
|
<h1 class="dpage-topbar__title">{{ title }}</h1>
|
||||||
|
<p v-if="subtitle" class="dpage-topbar__subtitle">{{ subtitle }}</p>
|
||||||
|
</div>
|
||||||
|
<div v-if="$slots.trailing">
|
||||||
|
<slot name="trailing" />
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
title: string
|
||||||
|
eyebrow?: string
|
||||||
|
subtitle?: string
|
||||||
|
showBack?: boolean
|
||||||
|
sticky?: boolean
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
showBack: false,
|
||||||
|
sticky: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
function handleBack() {
|
||||||
|
router.back()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mpage-header wrap-fix">
|
||||||
|
<button
|
||||||
|
v-if="showBack"
|
||||||
|
type="button"
|
||||||
|
class="mpage-header__back"
|
||||||
|
@click="handleBack"
|
||||||
|
>
|
||||||
|
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||||
|
</button>
|
||||||
|
<div class="mpage-header__title">{{ title }}</div>
|
||||||
|
<div v-if="$slots.trailing" class="mpage-header__trailing">
|
||||||
|
<slot name="trailing" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
title: string
|
||||||
|
showBack?: boolean
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
showBack: false,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
function handleBack() {
|
||||||
|
router.back()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<template>
|
||||||
|
<div class="responsive-view-pair">
|
||||||
|
<div v-show="!isDesktop" class="responsive-view-pair__pane">
|
||||||
|
<slot name="mobile" />
|
||||||
|
</div>
|
||||||
|
<div v-show="isDesktop" class="responsive-view-pair__pane">
|
||||||
|
<slot name="desktop" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useDesktopBreakpoint } from '../composables/useResponsiveLayout'
|
||||||
|
|
||||||
|
const isDesktop = useDesktopBreakpoint()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.responsive-view-pair {
|
||||||
|
min-height: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.responsive-view-pair__pane {
|
||||||
|
min-height: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { useMediaQuery } from '@vueuse/core'
|
||||||
|
import { onUnmounted, watch } from 'vue'
|
||||||
|
import { DESKTOP_LAYOUT_MIN_WIDTH } from '../constants'
|
||||||
|
|
||||||
|
const DESKTOP_LAYOUT_CLASS = 'app-layout--desktop'
|
||||||
|
|
||||||
|
export function useDesktopBreakpoint() {
|
||||||
|
return useMediaQuery(`(min-width: ${DESKTOP_LAYOUT_MIN_WIDTH}px)`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useApplyDesktopLayoutClass() {
|
||||||
|
const isDesktopLayout = useDesktopBreakpoint()
|
||||||
|
|
||||||
|
const stop = watch(
|
||||||
|
isDesktopLayout,
|
||||||
|
(desktop) => {
|
||||||
|
document.documentElement.classList.toggle(DESKTOP_LAYOUT_CLASS, desktop)
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
stop()
|
||||||
|
document.documentElement.classList.remove(DESKTOP_LAYOUT_CLASS)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
export function useAppNavigation() {
|
||||||
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const popVisible = ref(false)
|
||||||
|
const currentRoute = computed(() => route.name)
|
||||||
|
const hideMenu = computed(() => !!route.meta.hideMenu)
|
||||||
|
|
||||||
|
function isNavActive(routeName: string) {
|
||||||
|
return currentRoute.value === routeName
|
||||||
|
}
|
||||||
|
|
||||||
|
function navItemClass(routeName: string) {
|
||||||
|
return isNavActive(routeName) ? 'text-primary' : 'text-gray-400'
|
||||||
|
}
|
||||||
|
|
||||||
|
function navigateTo(routeName: string) {
|
||||||
|
popVisible.value = false
|
||||||
|
router.push({ name: routeName })
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleOverflowMenu() {
|
||||||
|
popVisible.value = !popVisible.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeOverflowMenu() {
|
||||||
|
popVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
popVisible,
|
||||||
|
currentRoute,
|
||||||
|
hideMenu,
|
||||||
|
isNavActive,
|
||||||
|
navItemClass,
|
||||||
|
navigateTo,
|
||||||
|
toggleOverflowMenu,
|
||||||
|
closeOverflowMenu,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
import { nextTick } from 'vue'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
let recoveryTimers: ReturnType<typeof setTimeout>[] = []
|
||||||
|
|
||||||
|
function clearRecoveryTimers() {
|
||||||
|
recoveryTimers.forEach(clearTimeout)
|
||||||
|
recoveryTimers = []
|
||||||
|
}
|
||||||
|
|
||||||
|
function blurFocusedField() {
|
||||||
|
const active = document.activeElement
|
||||||
|
if (active instanceof HTMLElement && active !== document.body) {
|
||||||
|
active.blur()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearBodyScrollLock() {
|
||||||
|
document.body.classList.remove('van-overflow-hidden')
|
||||||
|
document.body.style.removeProperty('position')
|
||||||
|
document.body.style.removeProperty('top')
|
||||||
|
document.body.style.removeProperty('left')
|
||||||
|
document.body.style.removeProperty('right')
|
||||||
|
document.body.style.removeProperty('width')
|
||||||
|
document.body.style.removeProperty('height')
|
||||||
|
document.body.style.removeProperty('min-height')
|
||||||
|
document.body.style.removeProperty('overflow')
|
||||||
|
document.body.style.removeProperty('transform')
|
||||||
|
document.documentElement.style.removeProperty('overflow')
|
||||||
|
document.documentElement.style.removeProperty('height')
|
||||||
|
document.documentElement.style.removeProperty('transform')
|
||||||
|
|
||||||
|
const appRoot = document.getElementById('app')
|
||||||
|
if (appRoot) {
|
||||||
|
appRoot.style.removeProperty('position')
|
||||||
|
appRoot.style.removeProperty('top')
|
||||||
|
appRoot.style.removeProperty('height')
|
||||||
|
appRoot.style.removeProperty('min-height')
|
||||||
|
appRoot.style.removeProperty('overflow')
|
||||||
|
appRoot.style.removeProperty('transform')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetAllScrollPositions() {
|
||||||
|
window.scrollTo(0, 0)
|
||||||
|
document.documentElement.scrollTop = 0
|
||||||
|
document.body.scrollTop = 0
|
||||||
|
|
||||||
|
document
|
||||||
|
.querySelectorAll('.main-with-bottom-chrome-inner, .login-page, .login-page-root')
|
||||||
|
.forEach((node) => {
|
||||||
|
if (node instanceof HTMLElement) {
|
||||||
|
node.scrollTop = 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function kickViewportReflow() {
|
||||||
|
window.dispatchEvent(new Event('resize'))
|
||||||
|
|
||||||
|
if (window.visualViewport) {
|
||||||
|
window.scrollTo(0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function runViewportRecovery() {
|
||||||
|
clearBodyScrollLock()
|
||||||
|
resetAllScrollPositions()
|
||||||
|
kickViewportReflow()
|
||||||
|
}
|
||||||
|
|
||||||
|
function scheduleViewportRecovery() {
|
||||||
|
clearRecoveryTimers()
|
||||||
|
runViewportRecovery()
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
runViewportRecovery()
|
||||||
|
|
||||||
|
for (const delay of [50, 150, 300, 500]) {
|
||||||
|
recoveryTimers.push(window.setTimeout(runViewportRecovery, delay))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reset scroll offsets after navigation — fixes iOS safe-area drift. */
|
||||||
|
export function resetMobileAppScroll() {
|
||||||
|
runViewportRecovery()
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
requestAnimationFrame(runViewportRecovery)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function dismissMobileKeyboard() {
|
||||||
|
blurFocusedField()
|
||||||
|
await new Promise((resolve) => window.setTimeout(resolve, 120))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function prepareMobileViewportForAppShell() {
|
||||||
|
blurFocusedField()
|
||||||
|
resetAllScrollPositions()
|
||||||
|
await dismissMobileKeyboard()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Full recovery after auth — runs after home shell is mounted. */
|
||||||
|
export function recoverMobileViewportAfterAuth() {
|
||||||
|
scheduleViewportRecovery()
|
||||||
|
}
|
||||||
|
|
||||||
|
export const resetMobileAppScrollAfterLogin = recoverMobileViewportAfterAuth
|
||||||
|
|
||||||
|
export async function completeLoginNavigation() {
|
||||||
|
await prepareMobileViewportForAppShell()
|
||||||
|
await router.push({ name: 'buyProduct' })
|
||||||
|
await router.isReady()
|
||||||
|
recoverMobileViewportAfterAuth()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initMobileScrollRestoration() {
|
||||||
|
if (typeof history !== 'undefined' && 'scrollRestoration' in history) {
|
||||||
|
history.scrollRestoration = 'manual'
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { useDesktopBreakpoint, useApplyDesktopLayoutClass } from './useAppLayout'
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import type { AppNavItem } from '../types'
|
||||||
|
import { getProjectBranding, isGhatreProject } from '@/utils/project'
|
||||||
|
|
||||||
|
/** تبهای پایین موبایل — کاربر لاگینشده (کشکول) */
|
||||||
|
export const AUTH_PRIMARY_NAV: AppNavItem[] = [
|
||||||
|
{ id: 'home', routeName: 'home', label: 'صفحه اصلی', icon: 'vuesax-linear:home' },
|
||||||
|
{ id: 'transactions', routeName: 'transactions', label: 'گزارش', icon: 'vuesax-linear:receipt-item' },
|
||||||
|
{ id: 'wallet', routeName: 'wallet', label: 'کیف پول', icon: 'vuesax-linear:wallet-1' },
|
||||||
|
{ id: 'cart', routeName: 'cart', label: 'سبد خرید', icon: 'vuesax-linear:shopping-cart' },
|
||||||
|
]
|
||||||
|
|
||||||
|
/** تبهای پایین موبایل — کاربر لاگینشده (قطره) */
|
||||||
|
export const GHATRE_AUTH_PRIMARY_NAV: AppNavItem[] = [
|
||||||
|
{ id: 'buyProduct', routeName: 'buyProduct', label: 'فروشگاه', icon: 'vuesax-linear:coin' },
|
||||||
|
{ id: 'transactions', routeName: 'transactions', label: 'گزارش', icon: 'vuesax-linear:receipt-item' },
|
||||||
|
{ id: 'wallet', routeName: 'wallet', label: 'کیف پول', icon: 'vuesax-linear:wallet-1' },
|
||||||
|
{ id: 'cart', routeName: 'cart', label: 'سبد خرید', icon: 'vuesax-linear:shopping-cart' },
|
||||||
|
]
|
||||||
|
|
||||||
|
/** تبهای پایین موبایل — مهمان */
|
||||||
|
export const GUEST_PRIMARY_NAV: AppNavItem[] = [
|
||||||
|
{ id: 'buyProduct', routeName: 'buyProduct', label: 'فروشگاه', icon: 'vuesax-linear:coin' },
|
||||||
|
{ id: 'about', routeName: 'about', label: 'درباره ما', icon: 'vuesax-linear:info-circle' },
|
||||||
|
{ id: 'cart', routeName: 'cart', label: 'سبد خرید', icon: 'vuesax-linear:shopping-cart' },
|
||||||
|
{ id: 'login', routeName: 'login', label: 'ورود', icon: 'vuesax-linear:login' },
|
||||||
|
]
|
||||||
|
|
||||||
|
/** منوی FAB موبایل + بخش فرعی سایدبار دسکتاپ — کاربر لاگینشده */
|
||||||
|
export const AUTH_SECONDARY_NAV: AppNavItem[] = [
|
||||||
|
{ id: 'notifyTrigger', routeName: 'notifyTrigger', label: 'هشدار قیمت', icon: 'vuesax-linear:bill' },
|
||||||
|
{ id: 'buyProduct', routeName: 'buyProduct', label: 'فروشگاه', icon: 'vuesax-linear:coin' },
|
||||||
|
{ id: 'fund', routeName: 'fund', label: 'دارایی ها', icon: 'vuesax-linear:archive-1' },
|
||||||
|
{ id: 'user', routeName: 'user', label: 'حساب کاربری', icon: 'vuesax-linear:user' },
|
||||||
|
{ id: 'physicalReceive', routeName: 'physicalReceive', label: 'دریافت طلای فیزیکی', icon: 'vuesax-linear:direct-inbox' },
|
||||||
|
{ id: 'list', routeName: 'list', label: 'لیست دریافتیها', icon: 'vuesax-linear:receipt-item' },
|
||||||
|
{ id: 'giftCard', routeName: 'giftCard', label: 'ثبت کارت هدیه', icon: 'vuesax-linear:gift' },
|
||||||
|
{ id: 'earnMoney', routeName: 'earnMoney', label: 'کسب درآمد', icon: 'vuesax-linear:dollar-circle' },
|
||||||
|
{ id: 'about', routeName: 'about', label: 'درباره ما', icon: 'vuesax-linear:info-circle' },
|
||||||
|
{ id: 'rules', routeName: 'rules', label: 'قوانین و مقررات', icon: 'vuesax-linear:task' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export function getPrimaryNavItems(isAuthenticated: boolean): AppNavItem[] {
|
||||||
|
if (!isAuthenticated) return GUEST_PRIMARY_NAV
|
||||||
|
return isGhatreProject() ? GHATRE_AUTH_PRIMARY_NAV : AUTH_PRIMARY_NAV
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSecondaryNavItems(isAuthenticated: boolean): AppNavItem[] {
|
||||||
|
if (!isAuthenticated) return []
|
||||||
|
|
||||||
|
const fundLabel = getProjectBranding().fundLabel
|
||||||
|
|
||||||
|
return AUTH_SECONDARY_NAV.map((item) =>
|
||||||
|
item.id === 'fund' ? { ...item, label: fundLabel } : item
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/** Minimum viewport width for desktop app shell (sidebar layout). */
|
||||||
|
export const DESKTOP_LAYOUT_MIN_WIDTH = 768
|
||||||
|
|
||||||
|
export const DESKTOP_SIDEBAR_WIDTH = 260
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<template>
|
||||||
|
<div class="desktop-app-layout">
|
||||||
|
<DesktopSidebar v-if="!hideMenu" />
|
||||||
|
<main
|
||||||
|
class="desktop-app-layout__main"
|
||||||
|
:class="{ 'desktop-app-layout__main--full': hideMenu }"
|
||||||
|
>
|
||||||
|
<router-view v-slot="{ Component, route }">
|
||||||
|
<div :key="route.fullPath" class="desktop-app-layout__content">
|
||||||
|
<component :is="Component" />
|
||||||
|
</div>
|
||||||
|
</router-view>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { onUnmounted, watch } from 'vue'
|
||||||
|
import { useAppNavigation } from '../composables/useAppNavigation'
|
||||||
|
import DesktopSidebar from './DesktopSidebar.vue'
|
||||||
|
|
||||||
|
const NO_SIDEBAR_CLASS = 'app-layout--desktop-no-sidebar'
|
||||||
|
const { hideMenu } = useAppNavigation()
|
||||||
|
|
||||||
|
watch(
|
||||||
|
hideMenu,
|
||||||
|
(hidden) => {
|
||||||
|
document.documentElement.classList.toggle(NO_SIDEBAR_CLASS, hidden)
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
document.documentElement.classList.remove(NO_SIDEBAR_CLASS)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" src="./desktop-layout.less"></style>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<template>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="desktop-nav-item"
|
||||||
|
:class="{ 'desktop-nav-item--active': active }"
|
||||||
|
@click="$emit('click')"
|
||||||
|
>
|
||||||
|
<span class="desktop-nav-item__icon-wrap">
|
||||||
|
<img
|
||||||
|
v-if="iconSrc"
|
||||||
|
:src="iconSrc"
|
||||||
|
alt=""
|
||||||
|
class="desktop-nav-item__icon desktop-nav-item__icon--image"
|
||||||
|
/>
|
||||||
|
<BasicIcon v-else :icon="icon" size="20" class="desktop-nav-item__icon" />
|
||||||
|
<span v-if="badgeCount && badgeCount > 0" class="desktop-nav-item__badge">{{ badgeCount }}</span>
|
||||||
|
</span>
|
||||||
|
<span class="desktop-nav-item__label">{{ label }}</span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
icon: string
|
||||||
|
iconSrc?: string
|
||||||
|
label: string
|
||||||
|
active: boolean
|
||||||
|
badgeCount?: number
|
||||||
|
}>()
|
||||||
|
|
||||||
|
defineEmits<{
|
||||||
|
click: []
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.desktop-nav-item__icon-wrap {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-nav-item__badge {
|
||||||
|
position: absolute;
|
||||||
|
top: -4px;
|
||||||
|
left: -4px;
|
||||||
|
min-width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
padding: 0 4px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--app-primary-color, #a72b77);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-nav-item__icon--image {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
object-fit: contain;
|
||||||
|
transform: scale(1.75);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<template>
|
||||||
|
<aside class="desktop-sidebar">
|
||||||
|
<div class="desktop-sidebar__brand">
|
||||||
|
<img :src="navLogo" :alt="projectNameFa" class="desktop-sidebar__logo" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav class="desktop-sidebar__section" aria-label="منوی اصلی">
|
||||||
|
<DesktopNavItem
|
||||||
|
v-for="item in primaryItems"
|
||||||
|
:key="item.id"
|
||||||
|
:icon="item.icon"
|
||||||
|
:icon-src="item.iconSrc"
|
||||||
|
:label="item.label"
|
||||||
|
:active="isNavActive(item.routeName)"
|
||||||
|
:badge-count="item.routeName === 'cart' && cartCount ? cartCount : undefined"
|
||||||
|
@click="navigateTo(item.routeName)"
|
||||||
|
/>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div v-if="secondaryItems.length" class="desktop-sidebar__divider" />
|
||||||
|
|
||||||
|
<nav
|
||||||
|
v-if="secondaryItems.length"
|
||||||
|
class="desktop-sidebar__section desktop-sidebar__section--secondary"
|
||||||
|
aria-label="منوی فرعی"
|
||||||
|
>
|
||||||
|
<DesktopNavItem
|
||||||
|
v-for="item in secondaryItems"
|
||||||
|
:key="item.id"
|
||||||
|
:icon="item.icon"
|
||||||
|
:icon-src="item.iconSrc"
|
||||||
|
:label="item.label"
|
||||||
|
:active="isNavActive(item.routeName)"
|
||||||
|
@click="navigateTo(item.routeName)"
|
||||||
|
/>
|
||||||
|
</nav>
|
||||||
|
</aside>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import logoFull from '@/assets/img/logo_full_.png'
|
||||||
|
import { isToken } from '@/utils'
|
||||||
|
import { useCartStore } from '@/store/cartStore'
|
||||||
|
import { getPrimaryNavItems, getSecondaryNavItems } from '../config/navigation'
|
||||||
|
import { useAppNavigation } from '../composables/useAppNavigation'
|
||||||
|
import DesktopNavItem from './DesktopNavItem.vue'
|
||||||
|
import { useProject } from '@/composables/useProject'
|
||||||
|
|
||||||
|
const { projectNameFa } = useProject()
|
||||||
|
const cartStore = useCartStore()
|
||||||
|
const authenticated = computed(() => isToken())
|
||||||
|
const navLogo = logoFull
|
||||||
|
const primaryItems = computed(() => getPrimaryNavItems(authenticated.value))
|
||||||
|
const secondaryItems = computed(() => getSecondaryNavItems(authenticated.value))
|
||||||
|
const cartCount = computed(() => cartStore.itemCount || 0)
|
||||||
|
|
||||||
|
const { isNavActive, navigateTo } = useAppNavigation()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
.desktop-app-layout {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
height: 100vh;
|
||||||
|
max-height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100vw;
|
||||||
|
background: @prefixCls-background-color;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-app-layout__main {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-right: var(--app-desktop-sidebar-width, 260px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-app-layout__main--full {
|
||||||
|
width: 100%;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-app-layout__content {
|
||||||
|
flex: 1 1 0;
|
||||||
|
min-height: 0;
|
||||||
|
width: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
background: @prefixCls-background-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: var(--app-desktop-sidebar-width, 260px);
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: #fff;
|
||||||
|
z-index: 100;
|
||||||
|
padding: 20px 12px 16px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-left: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
|
overflow: hidden;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__brand {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 8px 12px 20px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__logo {
|
||||||
|
max-width: 140px;
|
||||||
|
max-height: 56px;
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__section--secondary {
|
||||||
|
margin-top: auto;
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__divider {
|
||||||
|
height: 1px;
|
||||||
|
background: rgba(0, 0, 0, 0.08);
|
||||||
|
margin: 12px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-nav-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: right;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #6b7280;
|
||||||
|
transition: background 0.15s ease, color 0.15s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(167, 43, 119, 0.06);
|
||||||
|
color: @theme-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--active {
|
||||||
|
background: rgba(167, 43, 119, 0.1);
|
||||||
|
color: @theme-primary;
|
||||||
|
|
||||||
|
.desktop-nav-item__icon {
|
||||||
|
color: @theme-primary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-nav-item__icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-nav-item__icon-wrap {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: transparent;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-nav-item__label {
|
||||||
|
flex: 1;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__section--secondary .desktop-nav-item {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 8px 12px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,255 @@
|
|||||||
|
/* Shared desktop layouts for inner pages */
|
||||||
|
|
||||||
|
.dinner {
|
||||||
|
min-height: 100%;
|
||||||
|
background: #f6f7f9;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dinner__container {
|
||||||
|
max-width: 1180px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 28px 36px 40px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dinner-surface {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cart */
|
||||||
|
.dcart-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
|
||||||
|
gap: 20px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dcart-items {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dcart-item {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 14px;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
|
||||||
|
&__image {
|
||||||
|
width: 88px;
|
||||||
|
height: 88px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: #f9fafb;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__main {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111827;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__meta {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__price {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: @theme-primary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dcart-summary {
|
||||||
|
position: sticky;
|
||||||
|
top: 88px;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__total {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: @theme-primary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Product detail */
|
||||||
|
.dproduct-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
|
||||||
|
gap: 24px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dproduct-gallery {
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 280px;
|
||||||
|
background: #f9fafb;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dproduct-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dproduct-info__price-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dproduct-info__price {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: @theme-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dproduct-info__desc {
|
||||||
|
padding: 20px;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.8;
|
||||||
|
color: #4b5563;
|
||||||
|
white-space: pre-line;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Simple form pages (gift card, etc.) */
|
||||||
|
.dform-page {
|
||||||
|
max-width: 560px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dform-card {
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Earn money */
|
||||||
|
.dearn-stats {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 12px;
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dearn-stat {
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 12px;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
&--blue {
|
||||||
|
background: #dbeafe;
|
||||||
|
color: #2563eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--yellow {
|
||||||
|
background: #fef9c3;
|
||||||
|
color: #ca8a04;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__value {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__label {
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dearn-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dearn-list-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 14px 16px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Physical receive */
|
||||||
|
.dphysical-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dphysical-add {
|
||||||
|
margin-top: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 14px;
|
||||||
|
border: 1px dashed rgba(15, 23, 42, 0.15);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: #fff;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #374151;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #f9fafb;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
html.app-layout--desktop {
|
||||||
|
.dpage {
|
||||||
|
max-width: 1180px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 28px 36px 48px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dpage-topbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
|
||||||
|
&--sticky {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 30;
|
||||||
|
margin: -4px 0 20px;
|
||||||
|
padding: 12px 0 20px;
|
||||||
|
background: #f6f7f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__back {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__meta {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__eyebrow {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #9ca3af;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
color: #111827;
|
||||||
|
line-height: 1.2;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__subtitle {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #6b7280;
|
||||||
|
margin: 6px 0 0;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide mobile fixed headers on desktop inner pages */
|
||||||
|
.fund-info-page-root,
|
||||||
|
.cart-page-root,
|
||||||
|
.gift-card-page-root,
|
||||||
|
.earn-money-page-root,
|
||||||
|
.physical-receive-page-root,
|
||||||
|
.product-detail-page-root,
|
||||||
|
.dinner-page,
|
||||||
|
.cart-page,
|
||||||
|
.gift-card-page,
|
||||||
|
.earn-money-page,
|
||||||
|
.physical-receive-page,
|
||||||
|
.product-detail-page,
|
||||||
|
.about-page-root,
|
||||||
|
.rules-page-root {
|
||||||
|
> .wrap-fix,
|
||||||
|
> div > .wrap-fix,
|
||||||
|
.transaction-list {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.products-page .grid-cols-2 {
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 1100px) {
|
||||||
|
.products-page .grid-cols-2 {
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dpage-surface {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dhome-topbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 24px;
|
||||||
|
margin-bottom: 28px;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
|
||||||
|
&__eyebrow {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #9ca3af;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
color: #111827;
|
||||||
|
line-height: 1.2;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dhome-btn-ghost {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #6b7280;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 0.15s ease, background 0.15s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #111827;
|
||||||
|
background: rgba(15, 23, 42, 0.04);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mobile-app-layout">
|
||||||
|
<MobileOverflowMenu
|
||||||
|
:show="popVisible"
|
||||||
|
@close="closeOverflowMenu"
|
||||||
|
@navigate="navigateTo"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div :class="['main-with-bottom-chrome', { 'main-with-bottom-chrome--no-nav': hideMenu }]">
|
||||||
|
<router-view v-slot="{ Component, route: activeRoute }">
|
||||||
|
<transition :name="activeRoute.meta.transition || 'fade'">
|
||||||
|
<component :is="Component" :key="activeRoute.fullPath" class="main-with-bottom-chrome-inner" />
|
||||||
|
</transition>
|
||||||
|
</router-view>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Teleport to="body">
|
||||||
|
<MobileBottomNav
|
||||||
|
v-if="!hideMenu"
|
||||||
|
:nav-item-class="navItemClass"
|
||||||
|
@navigate="navigateTo"
|
||||||
|
@toggle-overflow="toggleOverflowMenu"
|
||||||
|
/>
|
||||||
|
</Teleport>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { onMounted, watch } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { useAppNavigation } from '../composables/useAppNavigation'
|
||||||
|
import { recoverMobileViewportAfterAuth, resetMobileAppScroll } from '../composables/useMobileScrollReset'
|
||||||
|
import MobileBottomNav from './MobileBottomNav.vue'
|
||||||
|
import MobileOverflowMenu from './MobileOverflowMenu.vue'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const {
|
||||||
|
popVisible,
|
||||||
|
hideMenu,
|
||||||
|
navItemClass,
|
||||||
|
navigateTo,
|
||||||
|
toggleOverflowMenu,
|
||||||
|
closeOverflowMenu,
|
||||||
|
} = useAppNavigation()
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.fullPath,
|
||||||
|
() => {
|
||||||
|
resetMobileAppScroll()
|
||||||
|
},
|
||||||
|
{ flush: 'post' },
|
||||||
|
)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
resetMobileAppScroll()
|
||||||
|
recoverMobileViewportAfterAuth()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" src="./mobile-layout.less"></style>
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<template>
|
||||||
|
<div class="bottom-appbar w-auto mx-auto bg-white">
|
||||||
|
<div class="tabs bottom-0">
|
||||||
|
<template v-for="item in leftTabs" :key="item.id">
|
||||||
|
<div :class="navItemClass(item.routeName)" class="tab" @click="$emit('navigate', item.routeName)">
|
||||||
|
<div class="tab__icon">
|
||||||
|
<a-badge v-if="item.routeName === 'cart'" :count="cartCount">
|
||||||
|
<Icon :icon="item.icon" size="24" />
|
||||||
|
</a-badge>
|
||||||
|
<Icon v-else :icon="item.icon" size="24" />
|
||||||
|
</div>
|
||||||
|
<div class="text-xs mt-1 font-bold">{{ item.label }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="main_in">
|
||||||
|
<div class="text-white circle_in">
|
||||||
|
<div class="circle_into" @click="$emit('toggle-overflow')">
|
||||||
|
<img class="p-2" :src="navLogo" alt="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-for="item in rightTabs" :key="item.id">
|
||||||
|
<div :class="navItemClass(item.routeName)" class="tab" @click="$emit('navigate', item.routeName)">
|
||||||
|
<div class="tab__icon">
|
||||||
|
<a-badge v-if="item.routeName === 'cart'" :count="cartCount">
|
||||||
|
<Icon :icon="item.icon" size="24" />
|
||||||
|
</a-badge>
|
||||||
|
<Icon v-else :icon="item.icon" size="24" />
|
||||||
|
</div>
|
||||||
|
<div class="text-xs mt-1 font-bold">{{ item.label }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main">
|
||||||
|
<div class="circle" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import { isToken } from '@/utils'
|
||||||
|
import { useCartStore } from '@/store/cartStore'
|
||||||
|
import { getPrimaryNavItems } from '../config/navigation'
|
||||||
|
import logo from '@/assets/img/logo.png'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
navItemClass: (routeName: string) => string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
defineEmits<{
|
||||||
|
navigate: [routeName: string]
|
||||||
|
'toggle-overflow': []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const cartStore = useCartStore()
|
||||||
|
const navLogo = logo
|
||||||
|
const cartCount = computed(() => cartStore.itemCount || 0)
|
||||||
|
|
||||||
|
const primaryItems = computed(() => getPrimaryNavItems(isToken()))
|
||||||
|
const leftTabs = computed(() => primaryItems.value.slice(0, 2))
|
||||||
|
const rightTabs = computed(() => primaryItems.value.slice(2))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.tab__icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab__icon :deep(.ant-badge) {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
<template>
|
||||||
|
<Transition>
|
||||||
|
<div
|
||||||
|
v-if="show"
|
||||||
|
class="top-0 bottom-0 bg-black wrap-fix z-5000 opacity-60"
|
||||||
|
@click="$emit('close')"
|
||||||
|
/>
|
||||||
|
</Transition>
|
||||||
|
<Transition name="slide-fade">
|
||||||
|
<div v-if="show" class="wrap-fix bottom-11vh z-5000 flex justify-center items-end">
|
||||||
|
<div class="relative flex flex-col items-center">
|
||||||
|
<div
|
||||||
|
class="flex items-center justify-center bg-white rounded-full w-[30px] h-[30px] mb-2"
|
||||||
|
@click="$emit('close')"
|
||||||
|
>
|
||||||
|
<BasicIcon icon="vuesax-linear:close-circle" />
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col items-center gap-2">
|
||||||
|
<BasicButton
|
||||||
|
icon-size="16"
|
||||||
|
class="!font-bold w-15rem"
|
||||||
|
@click="go('user')"
|
||||||
|
>
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<BasicIcon icon="vuesax-linear:user" size="16" class="absolute right-2" />
|
||||||
|
<div>حساب کاربری</div>
|
||||||
|
</div>
|
||||||
|
</BasicButton>
|
||||||
|
<BasicButton
|
||||||
|
v-if="authenticated"
|
||||||
|
icon-size="16"
|
||||||
|
class="!font-bold w-15rem"
|
||||||
|
@click="go('physicalReceive')"
|
||||||
|
>
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<BasicIcon icon="vuesax-linear:direct-inbox" size="16" class="absolute right-2" />
|
||||||
|
<div>دریافت طلای فیزیکی</div>
|
||||||
|
</div>
|
||||||
|
</BasicButton>
|
||||||
|
<BasicButton
|
||||||
|
v-if="authenticated"
|
||||||
|
icon-size="16"
|
||||||
|
class="!font-bold w-15rem"
|
||||||
|
@click="go('notifyTrigger')"
|
||||||
|
>
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<BasicIcon icon="vuesax-linear:bill" size="16" class="absolute right-2" />
|
||||||
|
<div>هشدار قیمت</div>
|
||||||
|
</div>
|
||||||
|
</BasicButton>
|
||||||
|
<BasicButton
|
||||||
|
v-if="authenticated"
|
||||||
|
icon-size="16"
|
||||||
|
class="!font-bold w-15rem"
|
||||||
|
@click="go('buyProduct')"
|
||||||
|
>
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<BasicIcon icon="vuesax-linear:coin" size="16" class="absolute right-2" />
|
||||||
|
<div>خرید محصول</div>
|
||||||
|
</div>
|
||||||
|
</BasicButton>
|
||||||
|
<!-- <BasicButton-->
|
||||||
|
<!-- v-if="authenticated"-->
|
||||||
|
<!-- icon-size="16"-->
|
||||||
|
<!-- class="!font-bold w-15rem"-->
|
||||||
|
<!-- @click="go('list')"-->
|
||||||
|
<!-- >-->
|
||||||
|
<!-- <div class="flex gap-2 items-center">-->
|
||||||
|
<!-- <BasicIcon icon="vuesax-linear:receipt-item" size="16" class="absolute right-2" />-->
|
||||||
|
<!-- <div>لیست دریافتی ها</div>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<!-- </BasicButton>-->
|
||||||
|
<BasicButton
|
||||||
|
v-if="authenticated"
|
||||||
|
icon-size="16"
|
||||||
|
class="!font-bold w-15rem"
|
||||||
|
@click="go('giftCard')"
|
||||||
|
>
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<BasicIcon icon="vuesax-linear:gift" size="16" class="absolute right-2" />
|
||||||
|
<div>ثبت کارت هدیه</div>
|
||||||
|
</div>
|
||||||
|
</BasicButton>
|
||||||
|
<BasicButton icon-size="16" class="!font-bold w-15rem" @click="go('about')">
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<BasicIcon icon="vuesax-linear:info-circle" size="16" class="absolute right-2" />
|
||||||
|
<div>درباره ما</div>
|
||||||
|
</div>
|
||||||
|
</BasicButton>
|
||||||
|
<BasicButton
|
||||||
|
v-if="authenticated"
|
||||||
|
icon-size="16"
|
||||||
|
class="!font-bold w-15rem"
|
||||||
|
@click="go('rules')"
|
||||||
|
>
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<BasicIcon icon="vuesax-linear:task" size="16" class="absolute right-2" />
|
||||||
|
<div>قوانین و مقررات</div>
|
||||||
|
</div>
|
||||||
|
</BasicButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import { isToken } from '@/utils'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
show: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
close: []
|
||||||
|
navigate: [routeName: string]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const authenticated = computed(() => isToken())
|
||||||
|
|
||||||
|
function go(routeName: string) {
|
||||||
|
emit('navigate', routeName)
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
.bottom-appbar {
|
||||||
|
z-index: var(--app-z-nav, 5000);
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100vw;
|
||||||
|
height: calc(var(--app-nav-height, 80px) + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
|
||||||
|
padding-bottom: var(--app-safe-bottom, env(safe-area-inset-bottom, 0px));
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
background: #fff;
|
||||||
|
|
||||||
|
@media screen and (min-width: 426px) {
|
||||||
|
width: 426px;
|
||||||
|
max-width: 426px;
|
||||||
|
left: 50%;
|
||||||
|
right: auto;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs {
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
background: #fff;
|
||||||
|
justify-content: space-between;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 400;
|
||||||
|
box-shadow: 0 -2px 4px -2px #0000001a;
|
||||||
|
|
||||||
|
.tab {
|
||||||
|
width: 80px;
|
||||||
|
text-align: center;
|
||||||
|
flex-flow: column;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
align-content: center;
|
||||||
|
|
||||||
|
&.text-primary .tab__icon,
|
||||||
|
&.text-primary .tab__icon .ant-badge {
|
||||||
|
color: @theme-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.text-gray-400 .tab__icon,
|
||||||
|
&.text-gray-400 .tab__icon .ant-badge {
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main_in {
|
||||||
|
width: 70px;
|
||||||
|
height: 70px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-self: center;
|
||||||
|
|
||||||
|
.circle_in {
|
||||||
|
margin-top: -10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 70px;
|
||||||
|
height: 70px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
z-index: 20;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
background-color: @theme-primary;
|
||||||
|
|
||||||
|
.circle_into {
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: @theme-primary;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
border: white 1px solid;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
height: 70px;
|
||||||
|
width: 70px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.circle {
|
||||||
|
border-radius: 50%;
|
||||||
|
height: 70px;
|
||||||
|
width: 70px;
|
||||||
|
z-index: 20;
|
||||||
|
box-shadow: 0 -5px 4px -2px #0000001a;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-enter-active,
|
||||||
|
.v-leave-active {
|
||||||
|
transition: opacity 0.5s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-enter-from,
|
||||||
|
.v-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-fade-enter-active {
|
||||||
|
transition: all 0.3s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-fade-leave-active {
|
||||||
|
transition: all 0.4s cubic-bezier(1, 0.5, 0.8, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-fade-enter-from,
|
||||||
|
.slide-fade-leave-to {
|
||||||
|
transform: translateX(20px);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-app-layout {
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-with-bottom-chrome {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-with-bottom-chrome-inner {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
width: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
overscroll-behavior-y: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-with-bottom-chrome-inner--contained {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-with-bottom-chrome--no-nav,
|
||||||
|
.main-with-bottom-chrome--no-nav .main-with-bottom-chrome-inner {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
@desktop-layout-min: 768px;
|
||||||
|
|
||||||
|
@media screen and (min-width: @desktop-layout-min) {
|
||||||
|
html {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
width: 100%;
|
||||||
|
max-width: none;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktopConfig {
|
||||||
|
position: static !important;
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: none !important;
|
||||||
|
min-height: 100vh;
|
||||||
|
left: auto !important;
|
||||||
|
right: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrap-fix {
|
||||||
|
width: auto !important;
|
||||||
|
max-width: none !important;
|
||||||
|
left: 0 !important;
|
||||||
|
right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom-appbar {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html.app-layout--desktop {
|
||||||
|
@media screen and (min-width: @desktop-layout-min) {
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
body,
|
||||||
|
#app,
|
||||||
|
.desktopConfig {
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-config-provider {
|
||||||
|
display: block;
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-main {
|
||||||
|
height: 100vh;
|
||||||
|
max-height: 100vh;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
--app-desktop-sidebar-width: 260px;
|
||||||
|
|
||||||
|
.wrap-fix {
|
||||||
|
right: var(--app-desktop-sidebar-width, 260px) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#goftino_w {
|
||||||
|
right: 24px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.app-layout--desktop-no-sidebar .wrap-fix {
|
||||||
|
right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-app-layout__content {
|
||||||
|
.w-screen,
|
||||||
|
.md\:w-auto,
|
||||||
|
.md\:w-\[426px\] {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mt-20 {
|
||||||
|
margin-top: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dpage {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed.bottom-20,
|
||||||
|
.fixed.bottom-23 {
|
||||||
|
left: var(--app-desktop-sidebar-width, 260px) !important;
|
||||||
|
right: 0 !important;
|
||||||
|
width: auto !important;
|
||||||
|
max-width: none !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
transform: none !important;
|
||||||
|
|
||||||
|
> div {
|
||||||
|
max-width: 640px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.transaction-list {
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: none !important;
|
||||||
|
left: 0 !important;
|
||||||
|
right: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Splash — full viewport, centered; never sidebar-offset */
|
||||||
|
.app-splash-screen {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
width: 100vw;
|
||||||
|
min-height: 100vh;
|
||||||
|
max-width: none;
|
||||||
|
left: 0 !important;
|
||||||
|
right: 0 !important;
|
||||||
|
z-index: 1000000000000;
|
||||||
|
|
||||||
|
&__gradient {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 100%;
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
|
&--top {
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--bottom {
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__version {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__spinner {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 40px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html.app-layout--desktop .app-splash-screen {
|
||||||
|
right: 0 !important;
|
||||||
|
left: 0 !important;
|
||||||
|
width: 100vw !important;
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/**
|
||||||
|
* Mobile shell width rules.
|
||||||
|
* Below 426px: full viewport (phones).
|
||||||
|
* 426px–767px: centered 426px frame (tablet-ish mobile).
|
||||||
|
*/
|
||||||
|
|
||||||
|
html:not(.app-layout--desktop) {
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#app {
|
||||||
|
min-height: 0;
|
||||||
|
height: 100dvh;
|
||||||
|
max-height: 100dvh;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
overscroll-behavior: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktopConfig,
|
||||||
|
.app-main {
|
||||||
|
min-height: 0;
|
||||||
|
height: 100dvh;
|
||||||
|
max-height: 100dvh;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-main > * {
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-dock-add-bar,
|
||||||
|
.wallet-card-slider {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 425.98px) {
|
||||||
|
body {
|
||||||
|
display: block !important;
|
||||||
|
width: 100% !important;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#app,
|
||||||
|
.desktopConfig,
|
||||||
|
.app-main,
|
||||||
|
.main-with-bottom-chrome,
|
||||||
|
.main-with-bottom-chrome-inner {
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: 100vw !important;
|
||||||
|
min-width: 0 !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrap-fix,
|
||||||
|
.bottom-appbar {
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: 100vw !important;
|
||||||
|
left: 0 !important;
|
||||||
|
right: 0 !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
transform: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-dock-add-bar,
|
||||||
|
.wallet-card-slider {
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: 100vw !important;
|
||||||
|
left: 0 !important;
|
||||||
|
right: 0 !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
transform: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 426px) and (max-width: 767.98px) {
|
||||||
|
body {
|
||||||
|
display: flex !important;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktopConfig {
|
||||||
|
width: 426px !important;
|
||||||
|
max-width: 426px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrap-fix,
|
||||||
|
.bottom-appbar {
|
||||||
|
width: 426px !important;
|
||||||
|
max-width: 426px !important;
|
||||||
|
left: 50% !important;
|
||||||
|
right: auto !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
transform: translateX(-50%) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-dock-add-bar,
|
||||||
|
.wallet-card-slider {
|
||||||
|
width: 426px !important;
|
||||||
|
max-width: 426px !important;
|
||||||
|
left: 50% !important;
|
||||||
|
right: auto !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
transform: translateX(-50%) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
/* Shared mobile page chrome (inner pages — not home .app-header) */
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--mpage-header-bar: 2.75rem;
|
||||||
|
--mpage-header-offset: calc(4rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
--mpage-subheader-offset: calc(var(--mpage-header-bar) + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
--mpage-content-with-subheader: calc(6.5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
--mpage-scroll-max-height: calc(100dvh - 50px - var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
--mobile-info-support-block: calc(5rem + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fixed top bar: background fills under status bar; content sits below safe area */
|
||||||
|
.mobile-top-chrome {
|
||||||
|
top: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding-top: calc(0.75rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-top-chrome.h-12,
|
||||||
|
.mobile-top-chrome.min-h-12 {
|
||||||
|
height: auto;
|
||||||
|
min-height: calc(3rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
}
|
||||||
|
|
||||||
|
.mpage-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
top: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0.75rem;
|
||||||
|
padding-top: calc(0.75rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
background: #fff;
|
||||||
|
color: @theme-primary;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.5;
|
||||||
|
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
|
||||||
|
z-index: 1999;
|
||||||
|
|
||||||
|
&__back {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
padding: 0;
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__trailing {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.mpage-subheader {
|
||||||
|
top: var(--mpage-subheader-offset);
|
||||||
|
z-index: 1999;
|
||||||
|
padding: 0.75rem;
|
||||||
|
background: #fff;
|
||||||
|
color: @theme-primary;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mpage-content {
|
||||||
|
padding-top: var(--mpage-header-offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mpage-content--with-subheader {
|
||||||
|
padding-top: var(--mpage-content-with-subheader);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mpage-scroll {
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: var(--mpage-scroll-max-height);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-page-body--pt10 {
|
||||||
|
padding-top: calc(2.5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-page-body--pt15 {
|
||||||
|
padding-top: calc(3.75rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-page-body--pt20 {
|
||||||
|
padding-top: calc(5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Info pages (about, educate): fixed shell, scroll inside content box only */
|
||||||
|
.mobile-info-page {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-info-page__header {
|
||||||
|
z-index: 1999;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Decorative page background — fixed to viewport, never scrolls on iOS */
|
||||||
|
.mobile-page-bg,
|
||||||
|
.mobile-info-page__bg {
|
||||||
|
pointer-events: none;
|
||||||
|
position: fixed;
|
||||||
|
z-index: 0;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: var(--app-bottom-chrome-height, 80px);
|
||||||
|
overflow: hidden;
|
||||||
|
max-width: 100vw;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
img {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-page-bg--no-nav,
|
||||||
|
.mobile-info-page__bg {
|
||||||
|
bottom: var(--app-credit-footer-offset, 0px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-page-bg--cover {
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
html:not(.app-layout--desktop) {
|
||||||
|
@media screen and (min-width: 426px) and (max-width: 767.98px) {
|
||||||
|
.mobile-page-bg,
|
||||||
|
.mobile-info-page__bg {
|
||||||
|
width: 426px;
|
||||||
|
max-width: 426px;
|
||||||
|
left: 50%;
|
||||||
|
right: auto;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-info-page__main {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
flex: 1 1 0;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-top: calc(var(--mpage-header-offset) + 1rem);
|
||||||
|
padding-right: 2.5rem;
|
||||||
|
padding-left: 2.5rem;
|
||||||
|
padding-bottom: calc(
|
||||||
|
var(--mobile-info-support-block, 5rem) + var(--app-credit-footer-offset, 0px) + 1.25rem
|
||||||
|
);
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
|
> * {
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-info-page__support {
|
||||||
|
bottom: var(--app-credit-footer-offset, 0px);
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 1rem 2.5rem;
|
||||||
|
padding-bottom: calc(1rem + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.06);
|
||||||
|
z-index: 1998;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-content-box {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1 1 0;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-content-box__scroll {
|
||||||
|
flex: 1 1 0;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
overscroll-behavior-y: contain;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export interface AppNavItem {
|
||||||
|
id: string
|
||||||
|
routeName: string
|
||||||
|
label: string
|
||||||
|
icon: string
|
||||||
|
iconSrc?: string
|
||||||
|
authOnly?: boolean
|
||||||
|
guestOnly?: boolean
|
||||||
|
}
|
||||||
+1
-4
@@ -4,7 +4,6 @@ import 'virtual:uno.css'
|
|||||||
|
|
||||||
import { initPwaInstallCapture } from '@/modules/pwa/manifest'
|
import { initPwaInstallCapture } from '@/modules/pwa/manifest'
|
||||||
import { bootstrapApp } from '@/app/bootstrap'
|
import { bootstrapApp } from '@/app/bootstrap'
|
||||||
import { initWhatsappButtonDrag } from '@/utils/initWhatsappButtonDrag'
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
setTruth,
|
setTruth,
|
||||||
@@ -16,6 +15,4 @@ export {
|
|||||||
import '@unocss/reset/tailwind-compat.css'
|
import '@unocss/reset/tailwind-compat.css'
|
||||||
|
|
||||||
initPwaInstallCapture()
|
initPwaInstallCapture()
|
||||||
bootstrapApp().then(() => {
|
bootstrapApp()
|
||||||
initWhatsappButtonDrag()
|
|
||||||
})
|
|
||||||
|
|||||||
+18
-3
@@ -12,8 +12,23 @@ export interface Series {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export interface PriceUp {
|
||||||
|
buy: number
|
||||||
|
sell: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PriceStatus = 'open' | 'closed' | 'no_quote'
|
||||||
|
|
||||||
export interface Price {
|
export interface Price {
|
||||||
sell: number
|
sell: number
|
||||||
buy: number
|
buy: number
|
||||||
price_last: number
|
price: number
|
||||||
|
price_last: number
|
||||||
|
goldir?: number
|
||||||
|
up?: PriceUp
|
||||||
|
closed?: boolean
|
||||||
|
status?: PriceStatus
|
||||||
|
time?: string
|
||||||
|
main_product?: number
|
||||||
|
montzar?: number
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ export interface Order {
|
|||||||
sts_str?: string
|
sts_str?: string
|
||||||
payment_sts?: number
|
payment_sts?: number
|
||||||
payment_amount?: number
|
payment_amount?: number
|
||||||
|
target_cash?: number
|
||||||
service_charge_price?: number
|
service_charge_price?: number
|
||||||
total_fee?: number
|
total_fee?: number
|
||||||
total_price?: number
|
total_price?: number
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
export interface WalletAssetsMeta {
|
||||||
|
metal_ids: number[]
|
||||||
|
metal_count: number
|
||||||
|
has_count_based_products: boolean
|
||||||
|
has_weight_based_products: boolean
|
||||||
|
weight_unit: string
|
||||||
|
single_metal: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WalletInventoryCard {
|
||||||
|
product_id: number
|
||||||
|
title: string
|
||||||
|
group_type: string
|
||||||
|
metal_id: number
|
||||||
|
quantity: number
|
||||||
|
unit: string
|
||||||
|
display_type: 'count' | 'weight'
|
||||||
|
unit_weight?: string | null
|
||||||
|
show_in_assets: boolean
|
||||||
|
is_melted?: boolean
|
||||||
|
is_main_wallet?: boolean
|
||||||
|
file?: { src?: string | null } | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WalletMetalTotal {
|
||||||
|
metal_id: number
|
||||||
|
metal_label: string
|
||||||
|
label: string
|
||||||
|
product_weight: number
|
||||||
|
melted_weight: number
|
||||||
|
total_weight: number
|
||||||
|
unit: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WalletAssetsSummary {
|
||||||
|
meta: WalletAssetsMeta
|
||||||
|
cash_wallet: number
|
||||||
|
inventory_cards: WalletInventoryCard[]
|
||||||
|
count_products: WalletInventoryCard[]
|
||||||
|
metal_totals: WalletMetalTotal[]
|
||||||
|
assets_rial_value: number
|
||||||
|
total_rial_value: number
|
||||||
|
profit_loss?: number
|
||||||
|
}
|
||||||
+5
-20
@@ -1,4 +1,5 @@
|
|||||||
import {createRouter, createWebHistory} from 'vue-router'
|
import {createRouter, createWebHistory} from 'vue-router'
|
||||||
|
import { getProjectDefaultRoute } from '@/utils/project'
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
@@ -8,16 +9,10 @@ const router = createRouter({
|
|||||||
name: 'login',
|
name: 'login',
|
||||||
component: () => import('../views/login/index.vue')
|
component: () => import('../views/login/index.vue')
|
||||||
},
|
},
|
||||||
/* {
|
|
||||||
path: '/',
|
|
||||||
name: 'null',
|
|
||||||
redirect: {name: 'home'},
|
|
||||||
// component: () => import('../views/login/index.vue')
|
|
||||||
},*/
|
|
||||||
{
|
{
|
||||||
path: `/`,
|
path: `/`,
|
||||||
name: 'main',
|
name: 'main',
|
||||||
redirect: {name: 'buyProduct'},
|
redirect: () => ({ name: getProjectDefaultRoute() }),
|
||||||
component: () => import('../views/base/index.vue'),
|
component: () => import('../views/base/index.vue'),
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@@ -85,22 +80,12 @@ const router = createRouter({
|
|||||||
name: 'address',
|
name: 'address',
|
||||||
component: () => import('@/views/base/address/index.vue')
|
component: () => import('@/views/base/address/index.vue')
|
||||||
},
|
},
|
||||||
/* {
|
|
||||||
path: 'physicalReceive',
|
|
||||||
name: 'physicalReceive',
|
|
||||||
component: () => import('@/views/base/physicalReceive/index.vue'),
|
|
||||||
},*/
|
|
||||||
// {
|
|
||||||
// path: 'list',
|
|
||||||
// name: 'list',
|
|
||||||
// component: () => import('@/views/base/physicalReceive/components/RequestList.vue'),
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
path: 'physicalReceive',
|
path: 'physicalReceive',
|
||||||
name: 'physicalReceive',
|
name: 'physicalReceive',
|
||||||
redirect:{name: 'list'},
|
redirect: { name: 'list' },
|
||||||
// component: () => import('@/views/base/physicalReceive/index.vue'),
|
component: () => import('@/views/base/physicalReceive/index.vue'),
|
||||||
children:[
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
name: 'list',
|
name: 'list',
|
||||||
|
|||||||
+12
-20
@@ -2,8 +2,8 @@ import { computed, ref } from 'vue'
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import type { CartItem } from '@/models/cart'
|
import type { CartItem } from '@/models/cart'
|
||||||
import type { Product } from '@/models/products'
|
import type { Product } from '@/models/products'
|
||||||
import type { Price } from '@/models/home'
|
import { getProductsCatalog } from '@/composables/useProductsCatalog'
|
||||||
import { getProducts } from '@/api/products'
|
import { getProductBuyPrice } from '@/utils/productPrice'
|
||||||
|
|
||||||
const CART_STORAGE_KEY = 'ghatre_cart'
|
const CART_STORAGE_KEY = 'ghatre_cart'
|
||||||
|
|
||||||
@@ -113,23 +113,13 @@ export const useCartStore = defineStore('cart', () => {
|
|||||||
return beforeCount - cartItems.value.length
|
return beforeCount - cartItems.value.length
|
||||||
}
|
}
|
||||||
|
|
||||||
function recalculateCartPrices(lastPrice: Price) {
|
function updateCartItemPrices() {
|
||||||
if (!lastPrice || cartItems.value.length === 0) return
|
if (cartItems.value.length === 0) return
|
||||||
|
|
||||||
cartItems.value.forEach((item) => {
|
cartItems.value.forEach((item) => {
|
||||||
const product = item.product
|
const buyPrice = getProductBuyPrice(item.product)
|
||||||
let newPrice = 0
|
item.price = buyPrice
|
||||||
|
item.totalPrice = parseInt(String(buyPrice * item.quantity))
|
||||||
if (product.group_type == 'آبشده') {
|
|
||||||
newPrice = lastPrice.price_last ?? 0
|
|
||||||
} else {
|
|
||||||
newPrice = product.amount * (lastPrice.price_last ?? 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
product.price = newPrice
|
|
||||||
product.sellPrice = product.amount * (lastPrice.sell ?? 0)
|
|
||||||
item.price = newPrice + (product.cash_fee_buy ?? 0)
|
|
||||||
item.totalPrice = parseInt(String(item.price * item.quantity))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
saveCartToStorage()
|
saveCartToStorage()
|
||||||
@@ -139,8 +129,10 @@ export const useCartStore = defineStore('cart', () => {
|
|||||||
if (cartItems.value.length === 0) return 0
|
if (cartItems.value.length === 0) return 0
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const serverProducts: Product[] = await getProducts()
|
const serverProducts: Product[] = await getProductsCatalog()
|
||||||
return syncProductsFromServer(serverProducts)
|
const removed = syncProductsFromServer(serverProducts)
|
||||||
|
updateCartItemPrices()
|
||||||
|
return removed
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error refreshing cart from server:', e)
|
console.error('Error refreshing cart from server:', e)
|
||||||
return 0
|
return 0
|
||||||
@@ -158,7 +150,7 @@ export const useCartStore = defineStore('cart', () => {
|
|||||||
loadCartFromStorage,
|
loadCartFromStorage,
|
||||||
saveCartToStorage,
|
saveCartToStorage,
|
||||||
syncProductsFromServer,
|
syncProductsFromServer,
|
||||||
recalculateCartPrices,
|
updateCartItemPrices,
|
||||||
refreshCartFromServer
|
refreshCartFromServer
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
import { type ComputedRef, ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import {defineStore} from "pinia";
|
import {defineStore} from "pinia";
|
||||||
import {getMe} from "@/api/me";
|
|
||||||
import type {User} from "@/models/login";
|
|
||||||
import type {Wallet} from "@/models/wallet";
|
import type {Wallet} from "@/models/wallet";
|
||||||
import {getWallet} from "@/api/wallet";
|
import {getWallet} from "@/api/wallet";
|
||||||
import type {Const} from "@/models/const";
|
|
||||||
import {getConstByKey} from "@/api/const";
|
|
||||||
export const useWalletStore = defineStore('wallet', () => {
|
export const useWalletStore = defineStore('wallet', () => {
|
||||||
const walletInfo = ref<Wallet | undefined>(undefined)
|
const walletInfo = ref<Wallet | undefined>(undefined)
|
||||||
const limitedPrice = ref<Const[]>()
|
|
||||||
const limitedBuyGold = ref<Const[]>()
|
|
||||||
|
|
||||||
async function getMyWallet() {
|
async function getMyWallet() {
|
||||||
try {
|
try {
|
||||||
@@ -19,40 +13,6 @@ export const useWalletStore = defineStore('wallet', () => {
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function getLimitedPrice(){
|
|
||||||
try {
|
|
||||||
limitedPrice.value = await getConstByKey('limited_price')
|
|
||||||
return limitedPrice.value
|
|
||||||
}catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getLimitedBuyGold(){
|
return { walletInfo, getMyWallet }
|
||||||
try {
|
|
||||||
limitedBuyGold.value = await getConstByKey('first_customer_wallet_value')
|
|
||||||
return limitedBuyGold.value
|
|
||||||
}catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* const permissions: ComputedRef<string[]> = computed(() => {
|
|
||||||
const permissions: string[] = get(userInfo.value, 'permission', [])
|
|
||||||
const excludes: string[] = get(userInfo.value, 'exclude', [])
|
|
||||||
return permissions.filter((item) => !excludes.includes(item))
|
|
||||||
})*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
function canAccess(permissionKey: string) {
|
|
||||||
if (isAdmin.value) return true
|
|
||||||
return permissions.value.includes(permissionKey)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
const isAdmin = computed(() => {
|
|
||||||
return userInfo.value?.is_admin
|
|
||||||
})*/
|
|
||||||
|
|
||||||
return { walletInfo, getMyWallet, getLimitedPrice, getLimitedBuyGold, limitedPrice, limitedBuyGold/* permissions, canAccess, isAdmin*/ }
|
|
||||||
})
|
})
|
||||||
|
|||||||
+17
-6
@@ -1,8 +1,19 @@
|
|||||||
export function getConfigApp(key: string) {
|
import { getTenantConfig } from '@/config/app-config'
|
||||||
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user : {}
|
|
||||||
|
|
||||||
if (config) {
|
export function getConfigApp(key: string) {
|
||||||
return config[key]
|
const config = getTenantConfig()
|
||||||
}
|
const value = config?.[key]
|
||||||
return null
|
|
||||||
|
return value ?? null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
getProjectId,
|
||||||
|
getProjectBranding,
|
||||||
|
getProjectDefaultRoute,
|
||||||
|
isGhatreProject,
|
||||||
|
isKashkoolProject,
|
||||||
|
isBoursecuProject,
|
||||||
|
} from '@/utils/project'
|
||||||
|
|
||||||
|
export type { ProjectId, ProjectBranding } from '@/utils/project'
|
||||||
|
|||||||
@@ -1,158 +0,0 @@
|
|||||||
import {
|
|
||||||
buildSupportMessengerUrl,
|
|
||||||
loadSupportMessengerFromSettings,
|
|
||||||
supportMessengerSettings,
|
|
||||||
} from '@/utils/supportMessenger'
|
|
||||||
|
|
||||||
const STORAGE_KEY = 'ghatreh_whatsapp_button_position'
|
|
||||||
const DRAG_THRESHOLD = 6
|
|
||||||
const WIDTH = 60
|
|
||||||
const HEIGHT = 60
|
|
||||||
const DEFAULT_BOTTOM_OFFSET = 90
|
|
||||||
const DEFAULT_RIGHT_OFFSET = 20
|
|
||||||
|
|
||||||
type FabPosition = { x: number; y: number }
|
|
||||||
|
|
||||||
function getViewportWidth() {
|
|
||||||
return Math.min(window.innerWidth, 426)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getHorizontalOffset() {
|
|
||||||
const vw = window.innerWidth
|
|
||||||
const contentWidth = getViewportWidth()
|
|
||||||
return Math.max(0, (vw - contentWidth) / 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDefaultPosition(): FabPosition {
|
|
||||||
const vh = window.innerHeight
|
|
||||||
const offsetX = getHorizontalOffset()
|
|
||||||
const contentWidth = getViewportWidth()
|
|
||||||
|
|
||||||
return {
|
|
||||||
x: offsetX + contentWidth - WIDTH - DEFAULT_RIGHT_OFFSET,
|
|
||||||
y: vh - DEFAULT_BOTTOM_OFFSET - HEIGHT,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadPosition(): FabPosition | null {
|
|
||||||
try {
|
|
||||||
const raw = localStorage.getItem(STORAGE_KEY)
|
|
||||||
if (!raw) return null
|
|
||||||
const parsed = JSON.parse(raw) as FabPosition
|
|
||||||
if (typeof parsed?.x === 'number' && typeof parsed?.y === 'number') {
|
|
||||||
return parsed
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
function savePosition(pos: FabPosition) {
|
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(pos))
|
|
||||||
}
|
|
||||||
|
|
||||||
function clampPosition(pos: FabPosition): FabPosition {
|
|
||||||
const vw = window.innerWidth
|
|
||||||
const vh = window.innerHeight
|
|
||||||
|
|
||||||
return {
|
|
||||||
x: Math.max(0, Math.min(vw - WIDTH, pos.x)),
|
|
||||||
y: Math.max(0, Math.min(vh - HEIGHT, pos.y)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function applyPosition(button: HTMLElement, pos: FabPosition) {
|
|
||||||
button.style.position = 'fixed'
|
|
||||||
button.style.bottom = 'auto'
|
|
||||||
button.style.right = 'auto'
|
|
||||||
button.style.left = `${pos.x}px`
|
|
||||||
button.style.top = `${pos.y}px`
|
|
||||||
button.style.touchAction = 'none'
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateWhatsappHref(button: HTMLAnchorElement) {
|
|
||||||
const link = buildSupportMessengerUrl(
|
|
||||||
supportMessengerSettings.value.messenger,
|
|
||||||
supportMessengerSettings.value.messengerId
|
|
||||||
)
|
|
||||||
|
|
||||||
button.href = link || '#'
|
|
||||||
button.style.display = 'flex'
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initWhatsappButtonDrag() {
|
|
||||||
const button = document.getElementById('whatsapp-button') as HTMLAnchorElement | null
|
|
||||||
if (!button) return
|
|
||||||
|
|
||||||
let pos = clampPosition(loadPosition() ?? getDefaultPosition())
|
|
||||||
applyPosition(button, pos)
|
|
||||||
|
|
||||||
let pointerId: number | null = null
|
|
||||||
let startX = 0
|
|
||||||
let startY = 0
|
|
||||||
let originX = 0
|
|
||||||
let originY = 0
|
|
||||||
let hasMoved = false
|
|
||||||
let dragging = false
|
|
||||||
|
|
||||||
function onResize() {
|
|
||||||
pos = clampPosition(pos)
|
|
||||||
applyPosition(button!, pos)
|
|
||||||
savePosition(pos)
|
|
||||||
}
|
|
||||||
|
|
||||||
function onPointerDown(event: PointerEvent) {
|
|
||||||
dragging = true
|
|
||||||
hasMoved = false
|
|
||||||
pointerId = event.pointerId
|
|
||||||
startX = event.clientX
|
|
||||||
startY = event.clientY
|
|
||||||
originX = pos.x
|
|
||||||
originY = pos.y
|
|
||||||
button!.classList.add('is-dragging')
|
|
||||||
button!.setPointerCapture(event.pointerId)
|
|
||||||
event.preventDefault()
|
|
||||||
}
|
|
||||||
|
|
||||||
function onPointerMove(event: PointerEvent) {
|
|
||||||
if (!dragging || pointerId !== event.pointerId) return
|
|
||||||
|
|
||||||
const dx = event.clientX - startX
|
|
||||||
const dy = event.clientY - startY
|
|
||||||
|
|
||||||
if (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD) {
|
|
||||||
hasMoved = true
|
|
||||||
}
|
|
||||||
|
|
||||||
pos = clampPosition({ x: originX + dx, y: originY + dy })
|
|
||||||
applyPosition(button!, pos)
|
|
||||||
}
|
|
||||||
|
|
||||||
function finishPointer(event: PointerEvent) {
|
|
||||||
if (!dragging || pointerId !== event.pointerId) return
|
|
||||||
|
|
||||||
dragging = false
|
|
||||||
pointerId = null
|
|
||||||
button!.classList.remove('is-dragging')
|
|
||||||
savePosition(pos)
|
|
||||||
|
|
||||||
const clicked = !hasMoved
|
|
||||||
hasMoved = false
|
|
||||||
|
|
||||||
if (clicked && button!.href && button!.href !== '#') {
|
|
||||||
window.open(button!.href, '_blank', 'noopener,noreferrer')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
button.addEventListener('pointerdown', onPointerDown)
|
|
||||||
button.addEventListener('pointermove', onPointerMove)
|
|
||||||
button.addEventListener('pointerup', finishPointer)
|
|
||||||
button.addEventListener('pointercancel', finishPointer)
|
|
||||||
button.addEventListener('click', (event) => event.preventDefault())
|
|
||||||
window.addEventListener('resize', onResize)
|
|
||||||
|
|
||||||
void loadSupportMessengerFromSettings().then(() => {
|
|
||||||
updateWhatsappHref(button)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
+16
-2
@@ -32,9 +32,23 @@ import { computed, ref } from 'vue'
|
|||||||
import type { Rule } from 'ant-design-vue/es/form'
|
import type { Rule } from 'ant-design-vue/es/form'
|
||||||
import { useWalletStore } from '@/store/walletStore'
|
import { useWalletStore } from '@/store/walletStore'
|
||||||
import {isToken} from "@/utils/index";
|
import {isToken} from "@/utils/index";
|
||||||
|
import { persianToEnglishDigits } from '@/utils/persianDigits'
|
||||||
|
|
||||||
export const mobileValidation = (title?: string) => {
|
export const mobileValidation = (title?: string): Rule => {
|
||||||
return { len: 11, message: `شماره همراه باید 11 رقم باشد` }
|
const label = title ?? 'شماره تلفن'
|
||||||
|
return {
|
||||||
|
validator: (_rule, value) => {
|
||||||
|
const normalized = persianToEnglishDigits(String(value ?? '').trim())
|
||||||
|
if (!normalized) {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
if (!/^09\d{9}$/.test(normalized)) {
|
||||||
|
return Promise.reject(`${label} باید با 09 شروع شود و 11 رقم باشد`)
|
||||||
|
}
|
||||||
|
return Promise.resolve()
|
||||||
|
},
|
||||||
|
trigger: ['change', 'blur'],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const required = (title?: string) => {
|
export const required = (title?: string) => {
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
const PERSIAN_DIGITS = '۰۱۲۳۴۵۶۷۸۹'
|
||||||
|
const ARABIC_DIGITS = '٠١٢٣٤٥٦٧٨٩'
|
||||||
|
|
||||||
|
/** تبدیل ارقام فارسی/عربی و جداکننده اعشار به فرمت انگلیسی */
|
||||||
|
export function persianToEnglishDigits(value: string | number | null | undefined): string {
|
||||||
|
if (value == null) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
return String(value)
|
||||||
|
.replace(/[۰-۹]/g, (d) => String(PERSIAN_DIGITS.indexOf(d)))
|
||||||
|
.replace(/[٠-٩]/g, (d) => String(ARABIC_DIGITS.indexOf(d)))
|
||||||
|
.replace(/٫/g, '.')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function shouldNormalizeInputDigits(options: {
|
||||||
|
isPassword?: boolean
|
||||||
|
type?: string
|
||||||
|
inputmode?: string
|
||||||
|
}): boolean {
|
||||||
|
if (options.isPassword) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (options.type === 'price' || options.type === 'number') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
const mode = String(options.inputmode ?? '').trim().toLowerCase()
|
||||||
|
return mode === 'numeric' || mode === 'decimal' || mode === 'number'
|
||||||
|
}
|
||||||
+25
-6
@@ -20,14 +20,28 @@ export const olderPrice = ref<number | undefined>(0)
|
|||||||
let lastPriceSourceAt = 0
|
let lastPriceSourceAt = 0
|
||||||
let consecutivePriceFetchFailures = 0
|
let consecutivePriceFetchFailures = 0
|
||||||
|
|
||||||
|
/** buy/sell نمایش و معامله — همان buy/sell/price_last از /api/price/last */
|
||||||
|
export function getTradeBuyPrice(p?: Price | null) {
|
||||||
|
return p?.buy ?? p?.price_last ?? p?.up?.buy ?? 0
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getTradeSellPrice(p?: Price | null) {
|
||||||
|
return p?.sell ?? p?.up?.sell ?? 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/** up جدا نگه داشته میشود؛ buy/sell/price_last از lastPrice سرور دستنخورده میماند */
|
||||||
|
export function normalizePriceResponse(data: Price): Price {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
function hasValidPricePayload(data?: Price | null): boolean {
|
function hasValidPricePayload(data?: Price | null): boolean {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
Number(data.buy ?? data.up?.buy ?? 0) > 0
|
getTradeBuyPrice(data) > 0
|
||||||
|| Number(data.sell ?? data.up?.sell ?? 0) > 0
|
|| getTradeSellPrice(data) > 0
|
||||||
|| Number(data.price_last ?? data.price ?? 0) > 0
|
|| Number(data.price_last ?? data.price ?? 0) > 0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -147,13 +161,18 @@ export async function getLastPrices(): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function applyLastPricePayload(dataLast: Price) {
|
export function applyLastPricePayload(dataLast: Price) {
|
||||||
if (lastPrice.value?.price_last != dataLast.price_last) {
|
const normalized = normalizePriceResponse(dataLast)
|
||||||
|
if (lastPrice.value?.price_last != normalized.price_last) {
|
||||||
olderPrice.value = lastPrice.value?.price_last
|
olderPrice.value = lastPrice.value?.price_last
|
||||||
}
|
}
|
||||||
lastPrice.value = dataLast
|
lastPrice.value = normalized
|
||||||
price.value = dataLast
|
price.value = {
|
||||||
|
...normalized,
|
||||||
|
buy: getTradeBuyPrice(normalized),
|
||||||
|
sell: getTradeSellPrice(normalized),
|
||||||
|
}
|
||||||
|
|
||||||
if (hasValidPricePayload(dataLast)) {
|
if (hasValidPricePayload(normalized)) {
|
||||||
markPriceSourceReceived()
|
markPriceSourceReceived()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,16 +189,14 @@ async function runFallbackPoll() {
|
|||||||
const { getLastPrices, hasRecentPriceFromSource, markPriceSourceFetchFailed } = await import(
|
const { getLastPrices, hasRecentPriceFromSource, markPriceSourceFetchFailed } = await import(
|
||||||
'@/utils/price'
|
'@/utils/price'
|
||||||
)
|
)
|
||||||
const { getProducts } = await import('@/api/products')
|
const { refreshProductsPageData } = await import(
|
||||||
const { applyProductsListFromStream: applyList } = await import('@/utils/productStreamBridge')
|
'@/views/base/products/composables/useProductsPageData'
|
||||||
const [lastResult, products] = await Promise.allSettled([
|
)
|
||||||
getLastPrices(),
|
|
||||||
getProducts(),
|
|
||||||
])
|
|
||||||
|
|
||||||
if (products.status === 'fulfilled' && Array.isArray(products.value) && products.value.length) {
|
const [lastResult] = await Promise.allSettled([
|
||||||
applyList(products.value)
|
getLastPrices(),
|
||||||
}
|
refreshProductsPageData(),
|
||||||
|
])
|
||||||
|
|
||||||
const priceOk =
|
const priceOk =
|
||||||
lastResult.status === 'fulfilled'
|
lastResult.status === 'fulfilled'
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import type { Product } from '@/models/products'
|
||||||
|
import type { WalletInventoryCard, WalletMetalTotal } from '@/models/walletAssets'
|
||||||
|
import { resolveProductImageSrc } from '@/utils/productImage'
|
||||||
|
|
||||||
|
export function fundPageInventoryCards<T extends { quantity?: number }>(cards: T[]): T[] {
|
||||||
|
return cards.filter((card) => Number(card.quantity ?? 0) > 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveSummaryMetalWeight(
|
||||||
|
metal: { total_weight: number },
|
||||||
|
_cards?: Array<{ metal_id?: number; quantity?: number }>
|
||||||
|
): number {
|
||||||
|
return Number(metal.total_weight ?? 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function enrichInventoryCardsWithCatalog<T extends WalletInventoryCard>(
|
||||||
|
cards: T[],
|
||||||
|
catalog: Product[]
|
||||||
|
): T[] {
|
||||||
|
return cards.map((card) => {
|
||||||
|
const fromCatalog = catalog.find((product) => product.id === card.product_id)
|
||||||
|
if (!fromCatalog) {
|
||||||
|
return card
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...card,
|
||||||
|
file: card.file ?? fromCatalog.file ?? null,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getProductDisplayImage(product?: {
|
||||||
|
group_type?: string | null
|
||||||
|
title?: string | null
|
||||||
|
file?: { src?: string | null } | null
|
||||||
|
img?: string | null
|
||||||
|
} | null): string {
|
||||||
|
return resolveProductImageSrc(product)
|
||||||
|
}
|
||||||
|
|
||||||
|
import { formatGoldAmount } from '@/utils/usePrice'
|
||||||
|
|
||||||
|
export function formatMetalTotal(
|
||||||
|
metal: WalletMetalTotal,
|
||||||
|
inventoryCards: WalletInventoryCard[]
|
||||||
|
): string {
|
||||||
|
return `${formatGoldAmount(resolveSummaryMetalWeight(metal, inventoryCards))}${metal.unit}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveAssetsRialValue(
|
||||||
|
summary: {
|
||||||
|
total_rial_value?: number
|
||||||
|
assets_rial_value?: number
|
||||||
|
cash_wallet?: number
|
||||||
|
} | null | undefined,
|
||||||
|
liveGoldPrice = 0
|
||||||
|
): number {
|
||||||
|
const total = Number(summary?.total_rial_value ?? 0)
|
||||||
|
if (total > 0) {
|
||||||
|
return total
|
||||||
|
}
|
||||||
|
|
||||||
|
const cash = Number(summary?.cash_wallet ?? 0)
|
||||||
|
const assetsRial = Number(summary?.assets_rial_value ?? 0)
|
||||||
|
if (assetsRial > 0) {
|
||||||
|
return cash + assetsRial
|
||||||
|
}
|
||||||
|
|
||||||
|
const metalWeight = (summary as { metal_totals?: Array<{ total_weight?: number }> } | null)
|
||||||
|
?.metal_totals?.[0]?.total_weight
|
||||||
|
return cash + Number(metalWeight ?? 0) * liveGoldPrice
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
function normalizeGroupType(value: unknown): string {
|
||||||
|
return String(value ?? '').trim().toLowerCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isKatodMesGroup(groupType: unknown): boolean {
|
||||||
|
const type = normalizeGroupType(groupType)
|
||||||
|
return type.includes('کاتد') || type.includes('katod')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isMaftolMesGroup(groupType: unknown): boolean {
|
||||||
|
const type = normalizeGroupType(groupType)
|
||||||
|
return type.includes('مفتول') || type.includes('maftol')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isShamshMesGroup(groupType: unknown, title?: unknown): boolean {
|
||||||
|
const type = normalizeGroupType(groupType)
|
||||||
|
const name = normalizeGroupType(title)
|
||||||
|
|
||||||
|
return (
|
||||||
|
type.includes('شمش') ||
|
||||||
|
type.includes('shamsh') ||
|
||||||
|
name.includes('شمش') ||
|
||||||
|
name.includes('shamsh')
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
import type { Product } from '@/models/products'
|
||||||
|
import { getTradeBuyPrice, getTradeSellPrice, lastPrice } from '@/utils/price'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* قیمتگیری ماژولار محصول در حالت فروشگاهی (is_store=true).
|
||||||
|
*
|
||||||
|
* منبع حقیقت قیمت و وضعیت نمایش، سرور است: `/customer/product/list` و رویداد SSE
|
||||||
|
* `list` هر دو قیمت هر محصول (`price`/`price_profit`) و `show` را محاسبهشده میفرستند.
|
||||||
|
* این ماژول فقط همان قیمت سرور را میخواند و فقط برای آبشده وقتی قیمت سرور صفر است
|
||||||
|
* به قیمت زندهٔ مرجع (`lastPrice`) fallback میکند — هیچجا قیمت سرور بازنویسی نمیشود.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const MELTED_GROUP = 'آبشده'
|
||||||
|
|
||||||
|
export function isMeltedProduct(product?: Product | null): boolean {
|
||||||
|
return product?.group_type === MELTED_GROUP
|
||||||
|
}
|
||||||
|
|
||||||
|
/** قیمت پایهٔ خرید (بدون کارمزد) — قیمت سرور، با fallback زندهٔ آبشده وقتی سرور صفر است */
|
||||||
|
export function getProductBaseBuyPrice(product?: Product | null): number {
|
||||||
|
if (!product) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const serverPrice = Number(product.price ?? 0)
|
||||||
|
if (serverPrice > 0) {
|
||||||
|
return serverPrice
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMeltedProduct(product)) {
|
||||||
|
const liveBuy = getTradeBuyPrice(lastPrice.value)
|
||||||
|
if (liveBuy > 0) {
|
||||||
|
const amount = Number(product.amount ?? 0)
|
||||||
|
return amount > 0 ? liveBuy * amount : liveBuy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/** قیمت خرید نمایشی محصول (همان مقداری که در لیست و صفحهٔ محصول نشان داده میشود) */
|
||||||
|
export function getProductBuyPrice(product?: Product | null): number {
|
||||||
|
const base = getProductBaseBuyPrice(product)
|
||||||
|
if (base <= 0) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return base + Number(product?.cash_fee_buy ?? 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** قیمت پایهٔ فروش (بدون کارمزد) — قیمت فروش سرور، با fallback زندهٔ آبشده */
|
||||||
|
export function getProductBaseSellPrice(product?: Product | null): number {
|
||||||
|
if (!product) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const serverSell = Number(product.sellPrice ?? 0)
|
||||||
|
if (serverSell > 0) {
|
||||||
|
return serverSell
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMeltedProduct(product)) {
|
||||||
|
const liveSell = getTradeSellPrice(lastPrice.value)
|
||||||
|
if (liveSell > 0) {
|
||||||
|
const amount = Number(product.amount ?? 0)
|
||||||
|
return amount > 0 ? liveSell * amount : liveSell
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getProductBaseBuyPrice(product)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** قیمت فروش نمایشی محصول */
|
||||||
|
export function getProductSellPrice(product?: Product | null): number {
|
||||||
|
const base = getProductBaseSellPrice(product)
|
||||||
|
if (base <= 0) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return base - Number(product?.cash_fee_sell ?? 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** محصول وقتی قیمت پایهٔ معتبری ندارد، غیرفعال (غیرقابل معامله) است */
|
||||||
|
export function isProductPriceInactive(product?: Product | null): boolean {
|
||||||
|
return getProductBaseBuyPrice(product) <= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* نمایش محصول در فروشگاه — اولویت با `show` سرور.
|
||||||
|
* فقط برای آبشدهای که قیمت سرورش هنوز نرسیده، با قیمت زنده تکمیل میکنیم.
|
||||||
|
*/
|
||||||
|
export function isProductVisible(product?: Product | null): boolean {
|
||||||
|
if (!product || product.active === false) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (product.show) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// سازگاری: آبشدهای که سرور هنوز قیمت نداده ولی قیمت زنده موجود است
|
||||||
|
return isMeltedProduct(product) && getProductBaseBuyPrice(product) > 0
|
||||||
|
}
|
||||||
@@ -3,10 +3,15 @@ import type { Product } from '@/models/products'
|
|||||||
type ProductListHandler = (products: Product[]) => void
|
type ProductListHandler = (products: Product[]) => void
|
||||||
|
|
||||||
const handlers = new Set<ProductListHandler>()
|
const handlers = new Set<ProductListHandler>()
|
||||||
|
let lastProductsList: Product[] | null = null
|
||||||
|
|
||||||
export function subscribeProductListStream(handler: ProductListHandler) {
|
export function subscribeProductListStream(handler: ProductListHandler) {
|
||||||
handlers.add(handler)
|
handlers.add(handler)
|
||||||
|
|
||||||
|
if (lastProductsList?.length) {
|
||||||
|
handler(lastProductsList)
|
||||||
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
handlers.delete(handler)
|
handlers.delete(handler)
|
||||||
}
|
}
|
||||||
@@ -17,5 +22,10 @@ export function applyProductsListFromStream(products: Product[]) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastProductsList = products
|
||||||
handlers.forEach((handler) => handler(products))
|
handlers.forEach((handler) => handler(products))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getLastStreamProductsList(): Product[] | null {
|
||||||
|
return lastProductsList
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,155 @@
|
|||||||
|
import { getRawAppConfig } from '@/config/app-config'
|
||||||
|
import type { AppConfig } from '@/config/types'
|
||||||
|
|
||||||
|
export type ProjectId = 'ghatre' | 'kashkool' | 'boursecu'
|
||||||
|
|
||||||
|
export interface ProjectBranding {
|
||||||
|
id: ProjectId
|
||||||
|
nameFa: string
|
||||||
|
heroGradient: string
|
||||||
|
accentColor: string
|
||||||
|
borderAccent: string
|
||||||
|
fundLabel: string
|
||||||
|
fundHeroBg: string
|
||||||
|
idCardLabel: string
|
||||||
|
buyPriceLabel: string
|
||||||
|
defaultRoute: string
|
||||||
|
showHomeRoute: boolean
|
||||||
|
referralDomain: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const PROJECT_BRANDING: Record<ProjectId, ProjectBranding> = {
|
||||||
|
ghatre: {
|
||||||
|
id: 'ghatre',
|
||||||
|
nameFa: 'قطره',
|
||||||
|
heroGradient: 'linear-gradient(145deg, #521620 0%, #7a2a1e 40%, #521620 100%)',
|
||||||
|
accentColor: '#521620',
|
||||||
|
borderAccent: '#521620',
|
||||||
|
fundLabel: 'قلک',
|
||||||
|
fundHeroBg: '#EFCED9',
|
||||||
|
idCardLabel: 'شناسه شما در قطره',
|
||||||
|
buyPriceLabel: 'قیمت خرید از قطره',
|
||||||
|
defaultRoute: 'buyProduct',
|
||||||
|
showHomeRoute: false,
|
||||||
|
referralDomain: 'ghatre.gold',
|
||||||
|
},
|
||||||
|
kashkool: {
|
||||||
|
id: 'kashkool',
|
||||||
|
nameFa: 'کشکول',
|
||||||
|
heroGradient: 'linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%)',
|
||||||
|
accentColor: '#a72b77',
|
||||||
|
borderAccent: '#a72b77',
|
||||||
|
fundLabel: 'دارایی ها',
|
||||||
|
fundHeroBg: '',
|
||||||
|
idCardLabel: 'شناسه شما در کشکول',
|
||||||
|
buyPriceLabel: 'قیمت خرید از کشکول',
|
||||||
|
defaultRoute: 'home',
|
||||||
|
showHomeRoute: true,
|
||||||
|
referralDomain: 'kh.kashkolgold.ir',
|
||||||
|
},
|
||||||
|
boursecu: {
|
||||||
|
id: 'boursecu',
|
||||||
|
nameFa: 'بورسکو',
|
||||||
|
heroGradient: 'linear-gradient(145deg, #1e2229 0%, #374151 40%, #1e2229 100%)',
|
||||||
|
accentColor: '#1e2229',
|
||||||
|
borderAccent: '#1e2229',
|
||||||
|
fundLabel: 'دارایی ها',
|
||||||
|
fundHeroBg: '',
|
||||||
|
idCardLabel: 'شناسه شما',
|
||||||
|
buyPriceLabel: 'قیمت خرید',
|
||||||
|
defaultRoute: 'home',
|
||||||
|
showHomeRoute: true,
|
||||||
|
referralDomain: '',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeProjectName(value: unknown): string {
|
||||||
|
return String(value ?? '')
|
||||||
|
.trim()
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/\s+/g, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveProjectNameFromConfig(raw: AppConfig | null | undefined): string {
|
||||||
|
if (!raw) return ''
|
||||||
|
|
||||||
|
const candidates: unknown[] = [
|
||||||
|
raw.name,
|
||||||
|
typeof raw.user === 'object' && raw.user !== null && !Array.isArray(raw.user)
|
||||||
|
? (raw.user as Record<string, unknown>).name
|
||||||
|
: undefined,
|
||||||
|
Array.isArray(raw.user) && raw.user[0] && typeof raw.user[0] === 'object'
|
||||||
|
? (raw.user[0] as Record<string, unknown>).name
|
||||||
|
: undefined,
|
||||||
|
]
|
||||||
|
|
||||||
|
for (const value of candidates) {
|
||||||
|
const normalized = normalizeProjectName(value)
|
||||||
|
if (normalized) return normalized
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProjectNameRaw(): string {
|
||||||
|
return resolveProjectNameFromConfig(getRawAppConfig())
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchesProjectName(name: string, aliases: string[]): boolean {
|
||||||
|
return aliases.some((alias) => name.includes(normalizeProjectName(alias)))
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getProjectId(): ProjectId {
|
||||||
|
const name = getProjectNameRaw()
|
||||||
|
|
||||||
|
if (name === 'ghatreh') {
|
||||||
|
return 'ghatre'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name === 'kashkolgold') {
|
||||||
|
return 'kashkool'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matchesProjectName(name, ['boursecu', 'bourse', 'بورسکو', 'بورس'])) {
|
||||||
|
return 'boursecu'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matchesProjectName(name, ['ghatre', 'qatre', 'قطره'])) {
|
||||||
|
return 'ghatre'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matchesProjectName(name, ['kashkool', 'kashkol', 'کشکول'])) {
|
||||||
|
return 'kashkool'
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'kashkool'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isGhatreProject(): boolean {
|
||||||
|
return getProjectId() === 'ghatre'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isKashkoolProject(): boolean {
|
||||||
|
return getProjectId() === 'kashkool'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isBoursecuProject(): boolean {
|
||||||
|
return getProjectId() === 'boursecu'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getProjectBranding(): ProjectBranding {
|
||||||
|
const id = getProjectId()
|
||||||
|
const defaults = PROJECT_BRANDING[id]
|
||||||
|
|
||||||
|
return {
|
||||||
|
...defaults,
|
||||||
|
nameFa: defaults.nameFa,
|
||||||
|
accentColor: defaults.accentColor,
|
||||||
|
borderAccent: defaults.borderAccent,
|
||||||
|
heroGradient: defaults.heroGradient,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getProjectDefaultRoute(): string {
|
||||||
|
return getProjectBranding().defaultRoute
|
||||||
|
}
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { getSettings } from '@/api/configuration'
|
||||||
|
|
||||||
|
export const serviceFeePercentage = ref<number>(0.01)
|
||||||
|
|
||||||
|
/** true = مبالغ رند: فروش → ریال دقیق (کارمزد از طلا)؛ خرید → وزن دقیق (کارمزد از ریال) */
|
||||||
|
export const feeDeductFromGold = ref(false)
|
||||||
|
|
||||||
|
/** آخرین فیلدی که کاربر مستقیم ویرایش کرده — مبنای بهروزرسانی هنگام تغییر قیمت */
|
||||||
|
export type TradeInputLock = 'gram' | 'rial' | null
|
||||||
|
|
||||||
|
/** حداکثر اعشار ذخیره/ارسال به سرور (مطابق orders.amount) */
|
||||||
|
export const TRADE_GRAM_STORAGE_DECIMALS = 10
|
||||||
|
|
||||||
|
/** حداکثر اعشار نمایش به کاربر در اپ */
|
||||||
|
export const TRADE_GRAM_DISPLAY_DECIMALS = 8
|
||||||
|
|
||||||
|
export function normalizeOrderGoldAmount(grams?: number | null): number {
|
||||||
|
const value = Number(grams ?? 0)
|
||||||
|
if (!Number.isFinite(value) || value === 0) return 0
|
||||||
|
return parseFloat(value.toFixed(TRADE_GRAM_STORAGE_DECIMALS))
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatTradeGramDisplay(grams?: number | null): number {
|
||||||
|
const value = Number(grams ?? 0)
|
||||||
|
if (!Number.isFinite(value)) return 0
|
||||||
|
return parseFloat(value.toFixed(TRADE_GRAM_DISPLAY_DECIMALS))
|
||||||
|
}
|
||||||
|
|
||||||
|
function feeRate() {
|
||||||
|
return Number(serviceFeePercentage.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function loadServiceFeeFromSettings() {
|
||||||
|
try {
|
||||||
|
const settings = await getSettings()
|
||||||
|
if (settings && Array.isArray(settings)) {
|
||||||
|
const feeSetting = settings.find(
|
||||||
|
(s) => s?.key === 'fee_service_charge_percentage' && s?.is_active === true
|
||||||
|
)
|
||||||
|
if (feeSetting?.value !== undefined && feeSetting?.value !== null) {
|
||||||
|
serviceFeePercentage.value = Number(feeSetting.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const feeModeSetting = settings.find(
|
||||||
|
(s) => s?.key === 'fee_deduct_from_gold' && s?.is_active === true
|
||||||
|
)
|
||||||
|
if (feeModeSetting?.value !== undefined && feeModeSetting?.value !== null) {
|
||||||
|
const raw = String(feeModeSetting.value).trim().toLowerCase()
|
||||||
|
feeDeductFromGold.value = raw === 'true' || raw === '1'
|
||||||
|
} else {
|
||||||
|
feeDeductFromGold.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function calcFeeInGrams(goldValue?: number | null) {
|
||||||
|
return parseFloat(((goldValue ?? 0) * Number(serviceFeePercentage.value)).toFixed(4))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** گرم معادل برای دریافت دقیق مبلغ ریالی در فروش */
|
||||||
|
export function calcGoldAmountFromTargetRial(rialAmount: number, unitPriceRial: number) {
|
||||||
|
if (!rialAmount || !unitPriceRial) return 0
|
||||||
|
return normalizeOrderGoldAmount(rialAmount / unitPriceRial)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** وقتی کاربر گرم را قفل کرده — ریال نمایشی/قابل پرداخت از همان گرم */
|
||||||
|
export function calcRialFromLockedGram(displayGram: number, unitPriceRial: number, isBuy: boolean) {
|
||||||
|
const grams = Number(displayGram)
|
||||||
|
const unit = Number(unitPriceRial)
|
||||||
|
if (!grams || !unit) return 0
|
||||||
|
const fee = feeRate()
|
||||||
|
|
||||||
|
if (isBuy) {
|
||||||
|
if (feeDeductFromGold.value) {
|
||||||
|
return Math.round(grams * unit * (1 + fee))
|
||||||
|
}
|
||||||
|
return Math.round(grams * unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (feeDeductFromGold.value) {
|
||||||
|
return Math.round(grams * unit)
|
||||||
|
}
|
||||||
|
return Math.round(grams * unit * (1 - fee))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** وقتی کاربر ریال را قفل کرده — گرم نمایشی از همان مبلغ */
|
||||||
|
export function calcGramFromLockedRial(rialAmount: number, unitPriceRial: number, isBuy: boolean) {
|
||||||
|
const rial = Number(rialAmount)
|
||||||
|
const unit = Number(unitPriceRial)
|
||||||
|
if (!rial || !unit) return 0
|
||||||
|
const fee = feeRate()
|
||||||
|
|
||||||
|
if (isBuy) {
|
||||||
|
if (feeDeductFromGold.value) {
|
||||||
|
return rial / (unit * (1 + fee))
|
||||||
|
}
|
||||||
|
return (rial / unit) * (1 - fee)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (feeDeductFromGold.value) {
|
||||||
|
return rial / unit
|
||||||
|
}
|
||||||
|
return rial / (unit * (1 - fee))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** مبلغ ریالی قفلشده توسط کاربر — برای ارسال به سرور */
|
||||||
|
export function calcTradeTargetCash(
|
||||||
|
goldCash?: number | null,
|
||||||
|
inputLock?: TradeInputLock,
|
||||||
|
): number | undefined {
|
||||||
|
if (inputLock !== 'rial') return undefined
|
||||||
|
const cash = Number(goldCash ?? 0)
|
||||||
|
if (cash <= 0) return undefined
|
||||||
|
return Math.round(cash)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** مبلغ نهایی قابل پرداخت (خرید) یا دریافت (فروش) به ریال */
|
||||||
|
export function calcPayablePriceRial(
|
||||||
|
finalPriceRial: number,
|
||||||
|
feeInRial: number,
|
||||||
|
isBuy: boolean,
|
||||||
|
targetRialCash?: number | null
|
||||||
|
) {
|
||||||
|
if (targetRialCash != null && Number(targetRialCash) > 0) {
|
||||||
|
return Number(targetRialCash)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (feeDeductFromGold.value) {
|
||||||
|
if (isBuy) return finalPriceRial + feeInRial
|
||||||
|
return finalPriceRial
|
||||||
|
}
|
||||||
|
return isBuy ? finalPriceRial : Math.max(0, finalPriceRial - feeInRial)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** وزن ارسالی به سرور */
|
||||||
|
export function calcOrderGoldAmount(
|
||||||
|
goldValue?: number | null,
|
||||||
|
goldCash?: number | null,
|
||||||
|
unitPriceRial?: number,
|
||||||
|
isBuy?: boolean,
|
||||||
|
inputLock?: TradeInputLock
|
||||||
|
) {
|
||||||
|
const gold = Number(goldValue ?? 0)
|
||||||
|
const cash = Number(goldCash ?? 0)
|
||||||
|
const unit = Number(unitPriceRial ?? 0)
|
||||||
|
|
||||||
|
if (isBuy && inputLock === 'rial' && cash > 0 && unit > 0) {
|
||||||
|
if (feeDeductFromGold.value) {
|
||||||
|
const fee = feeRate()
|
||||||
|
return normalizeOrderGoldAmount(cash / (unit * (1 + fee)))
|
||||||
|
}
|
||||||
|
return normalizeOrderGoldAmount(cash / unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isBuy && feeDeductFromGold.value) {
|
||||||
|
if (inputLock === 'rial' && cash > 0 && unit > 0) {
|
||||||
|
return calcGoldAmountFromTargetRial(cash, unit)
|
||||||
|
}
|
||||||
|
if (inputLock !== 'rial') {
|
||||||
|
return normalizeOrderGoldAmount(gold)
|
||||||
|
}
|
||||||
|
const targetCash = calcSellTargetCash(goldCash, goldValue, unitPriceRial, inputLock)
|
||||||
|
if (targetCash != null && unit > 0) {
|
||||||
|
return calcGoldAmountFromTargetRial(targetCash, unit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalizeOrderGoldAmount(gold)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** مبلغ ریالی دقیق دریافتی در فروش (فقط وقتی کاربر با ریال وارد کرده) */
|
||||||
|
export function calcSellTargetCash(
|
||||||
|
goldCash?: number | null,
|
||||||
|
goldValue?: number | null,
|
||||||
|
unitPriceRial?: number,
|
||||||
|
inputLock?: TradeInputLock
|
||||||
|
) {
|
||||||
|
if (!feeDeductFromGold.value) return undefined
|
||||||
|
if (inputLock === 'gram') return undefined
|
||||||
|
|
||||||
|
const cash = Number(goldCash ?? 0)
|
||||||
|
if (cash <= 0) return undefined
|
||||||
|
if (inputLock === 'rial') return Math.round(cash)
|
||||||
|
|
||||||
|
const gold = Number(goldValue ?? 0)
|
||||||
|
const unit = Number(unitPriceRial ?? 0)
|
||||||
|
if (gold > 0 && unit > 0) {
|
||||||
|
const derived = Math.round(gold * unit)
|
||||||
|
if (Math.abs(derived - Math.round(cash)) <= 1) return undefined
|
||||||
|
}
|
||||||
|
return Math.round(cash)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** کل طلای کسرشونده از کیف در فروش (شامل کارمزد وقتی fee_deduct_from_gold روشن است) */
|
||||||
|
export function calcSellGoldDebit(goldValue?: number | null, feeInGrams?: number | null) {
|
||||||
|
const gold = Number(goldValue ?? 0)
|
||||||
|
const fee = Number(feeInGrams ?? 0)
|
||||||
|
if (feeDeductFromGold.value) {
|
||||||
|
return parseFloat((gold + fee).toFixed(4))
|
||||||
|
}
|
||||||
|
return gold
|
||||||
|
}
|
||||||
+46
-1
@@ -1,6 +1,6 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useSettingsStore } from '@/store/settingsStore'
|
import { useSettingsStore } from '@/store/settingsStore'
|
||||||
import { lastPrice } from '@/utils/price'
|
import { getTradeBuyPrice, getTradeSellPrice, lastPrice } from '@/utils/price'
|
||||||
|
|
||||||
export interface StoreTradingHours {
|
export interface StoreTradingHours {
|
||||||
start: string
|
start: string
|
||||||
@@ -162,3 +162,48 @@ export function getStoreClosedMessage(): string {
|
|||||||
|
|
||||||
return `فروشگاه در حال حاضر بسته است. ساعت کاری از ${open} تا ${close} میباشد.`
|
return `فروشگاه در حال حاضر بسته است. ساعت کاری از ${open} تا ${close} میباشد.`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PriceDisplayState = 'open' | 'closed' | 'no_quote'
|
||||||
|
|
||||||
|
export const NO_QUOTE_MESSAGE = 'مظنه در دسترس نیست'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* وضعیت نمایش قیمت در صفحه اصلی:
|
||||||
|
* - closed → فروشگاه بسته است (خارج از ساعت کاری close_price یا بازه محصول)
|
||||||
|
* - no_quote → مظنه در دسترس نیست (قیمت زنده نداریم و show_last_price خاموش است)
|
||||||
|
* - open → نمایش عادی قیمت
|
||||||
|
*
|
||||||
|
* اولویت با status ارسالی از سرور است؛ اگر نبود به منطق سمت کلاینت برمیگردیم.
|
||||||
|
*/
|
||||||
|
export function getPriceDisplayState(): PriceDisplayState {
|
||||||
|
void productTradingHoursVersion.value
|
||||||
|
const p = lastPrice.value
|
||||||
|
const status = p?.status
|
||||||
|
|
||||||
|
if (status === 'closed') {
|
||||||
|
return 'closed'
|
||||||
|
}
|
||||||
|
if (status === 'no_quote') {
|
||||||
|
return getTradeBuyPrice(p) > 0 ? 'open' : 'no_quote'
|
||||||
|
}
|
||||||
|
if (status === 'open') {
|
||||||
|
return getTradeBuyPrice(p) > 0 || getTradeSellPrice(p) > 0 ? 'open' : 'no_quote'
|
||||||
|
}
|
||||||
|
|
||||||
|
// سرور status نفرستاده (سازگاری با نسخه قدیمی) → استنتاج سمت کلاینت
|
||||||
|
if (isStoreClosed()) {
|
||||||
|
return 'closed'
|
||||||
|
}
|
||||||
|
|
||||||
|
return getTradeBuyPrice(p) > 0 || getTradeSellPrice(p) > 0 ? 'open' : 'no_quote'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPriceDisplayMessage(state: PriceDisplayState = getPriceDisplayState()): string {
|
||||||
|
if (state === 'closed') {
|
||||||
|
return getStoreClosedMessage()
|
||||||
|
}
|
||||||
|
if (state === 'no_quote') {
|
||||||
|
return NO_QUOTE_MESSAGE
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|||||||
+75
-43
@@ -55,61 +55,93 @@ _axios.interceptors.response.use(
|
|||||||
return response.data
|
return response.data
|
||||||
},
|
},
|
||||||
async function (error) {
|
async function (error) {
|
||||||
if (error.response.data && error.response.data.message) {
|
const response = error.response
|
||||||
|
const config = error.config as MyAxiosRequestConfig | undefined
|
||||||
|
|
||||||
checkStatus(error.response.data.message, error.response.status, error.config)
|
if (response?.status === 401) {
|
||||||
}
|
|
||||||
|
|
||||||
//console.log('this is error on interceptors.response', error.config.meta)
|
|
||||||
/* if (error.response && (error.response.status == 401 || error.response.status == 400)) {
|
|
||||||
//debugger
|
|
||||||
removeToken()
|
|
||||||
router.push({ name: 'login' })
|
|
||||||
}*/
|
|
||||||
if (error.response && error.response.status == 401) {
|
|
||||||
///removeToken()
|
|
||||||
console.log('error')
|
|
||||||
removeToken()
|
removeToken()
|
||||||
// Don't redirect to login if user is on buyProduct page
|
|
||||||
if (router.currentRoute.value.name !== 'buyProduct') {
|
if (router.currentRoute.value.name !== 'buyProduct') {
|
||||||
await router.push({name: 'login'})
|
await router.push({name: 'login'})
|
||||||
}
|
}
|
||||||
} else if (error.response && error.response.status == 403) {
|
return Promise.reject(error)
|
||||||
message.error('شما دسترسی لازم برای انجام این عملیات را ندارید')
|
|
||||||
} else if (error.response && error.response.status == 422) {
|
|
||||||
// message.error(error.response.data?.message)
|
|
||||||
} else if (error.response) {
|
|
||||||
message.error('خطا در بارگذاری اطلاعات')
|
|
||||||
}
|
}
|
||||||
// Any status codes that falls outside the range of 2xx cause this function to trigger
|
|
||||||
// Do something with response error
|
|
||||||
|
|
||||||
//const { response, code, message, config } = error || {}
|
if (!shouldShowApiError(config)) {
|
||||||
//const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none'
|
return Promise.reject(error)
|
||||||
//const msg: string = response?.data?.error?.message ?? ''
|
}
|
||||||
//checkStatus(error?.response?.status, msg)
|
|
||||||
|
const apiMessage = extractApiErrorMessage(response?.data)
|
||||||
|
|
||||||
|
if (response?.status === 403) {
|
||||||
|
showApiError(apiMessage || 'شما دسترسی لازم برای انجام این عملیات را ندارید', config)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response?.status === 422) {
|
||||||
|
if (apiMessage) {
|
||||||
|
showApiError(apiMessage, config)
|
||||||
|
}
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response) {
|
||||||
|
showApiError(apiMessage || DEFAULT_LOAD_ERROR, config)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
showApiError(DEFAULT_LOAD_ERROR, config)
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
function checkStatus(msg: string, code: number, config: any) {
|
const DEFAULT_LOAD_ERROR = 'خطا در بارگذاری اطلاعات'
|
||||||
//const { code, data, message } = data
|
|
||||||
const errorMessage = get(config, 'meta.errorMessage', 'message')
|
function extractApiErrorMessage(data: unknown): string {
|
||||||
/*if (config.meta) {
|
if (!data || typeof data !== 'object') {
|
||||||
if (config.meta.message) {
|
return ''
|
||||||
errorMessage = config.meta.message
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
// console.log('this is config', config)
|
|
||||||
if (errorMessage == 'none') return
|
|
||||||
switch (errorMessage) {
|
|
||||||
case 'message':
|
|
||||||
message.error(msg)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
message.error(msg)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const record = data as Record<string, unknown>
|
||||||
|
const rawMessage = record.message
|
||||||
|
|
||||||
|
if (typeof rawMessage === 'string' && rawMessage.trim()) {
|
||||||
|
return rawMessage.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof rawMessage === 'number') {
|
||||||
|
return String(rawMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
const rawError = record.error
|
||||||
|
if (typeof rawError === 'string' && rawError.trim()) {
|
||||||
|
return rawError.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
const errors = record.errors
|
||||||
|
if (errors && typeof errors === 'object') {
|
||||||
|
for (const value of Object.values(errors as Record<string, unknown>)) {
|
||||||
|
if (Array.isArray(value) && typeof value[0] === 'string' && value[0].trim()) {
|
||||||
|
return value[0].trim()
|
||||||
|
}
|
||||||
|
if (typeof value === 'string' && value.trim()) {
|
||||||
|
return value.trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldShowApiError(config: MyAxiosRequestConfig | undefined): boolean {
|
||||||
|
return get(config, 'meta.errorMessage', 'message') !== 'none'
|
||||||
|
}
|
||||||
|
|
||||||
|
function showApiError(msg: string, config: MyAxiosRequestConfig | undefined) {
|
||||||
|
if (!shouldShowApiError(config)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
message.error(msg)
|
||||||
|
}
|
||||||
|
|
||||||
const myAxios = {
|
const myAxios = {
|
||||||
//AxiosResponse<T>
|
//AxiosResponse<T>
|
||||||
|
|||||||
@@ -1,24 +1,53 @@
|
|||||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
|
||||||
const DRAG_THRESHOLD = 6
|
const DRAG_THRESHOLD = 6
|
||||||
|
const POSITION_VERSION = 1
|
||||||
|
|
||||||
type FabPosition = { x: number; y: number }
|
type FabPosition = { x: number; y: number }
|
||||||
|
|
||||||
|
type SavedFabOffset = {
|
||||||
|
version: number
|
||||||
|
dx: number
|
||||||
|
dy: number
|
||||||
|
}
|
||||||
|
|
||||||
type DraggableFloatingOptions = {
|
type DraggableFloatingOptions = {
|
||||||
width?: number
|
width?: number
|
||||||
height?: number
|
height?: number
|
||||||
defaultBottomOffset?: number
|
defaultBottomGap?: number
|
||||||
defaultRightOffset?: number
|
defaultRightOffset?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readBottomChromeHeight(): number {
|
||||||
|
const styles = getComputedStyle(document.documentElement)
|
||||||
|
const direct = parseFloat(styles.getPropertyValue('--app-bottom-chrome-height'))
|
||||||
|
if (!Number.isNaN(direct) && direct > 0) {
|
||||||
|
return direct
|
||||||
|
}
|
||||||
|
|
||||||
|
const nav = parseFloat(styles.getPropertyValue('--app-nav-height')) || 80
|
||||||
|
const creditOffset = parseFloat(styles.getPropertyValue('--app-credit-footer-offset'))
|
||||||
|
if (!Number.isNaN(creditOffset) && creditOffset > 0) {
|
||||||
|
return nav + creditOffset
|
||||||
|
}
|
||||||
|
|
||||||
|
const probe = document.createElement('div')
|
||||||
|
probe.style.cssText = 'position:fixed;visibility:hidden;pointer-events:none;height:var(--app-bottom-chrome-height)'
|
||||||
|
document.body.appendChild(probe)
|
||||||
|
const measured = probe.getBoundingClientRect().height
|
||||||
|
document.body.removeChild(probe)
|
||||||
|
|
||||||
|
return measured > 0 ? measured : nav
|
||||||
|
}
|
||||||
|
|
||||||
export function useDraggableFloatingButton(
|
export function useDraggableFloatingButton(
|
||||||
storageKey: string,
|
storageKey: string,
|
||||||
options: DraggableFloatingOptions = {}
|
options: DraggableFloatingOptions = {}
|
||||||
) {
|
) {
|
||||||
const width = options.width ?? 96
|
const width = options.width ?? 96
|
||||||
const height = options.height ?? 44
|
const height = options.height ?? 44
|
||||||
const defaultBottomOffset = options.defaultBottomOffset ?? 92
|
const defaultBottomGap = options.defaultBottomGap ?? 12
|
||||||
const defaultRightOffset = options.defaultRightOffset ?? 20
|
const defaultRightOffset = options.defaultRightOffset ?? 16
|
||||||
|
|
||||||
const pos = ref<FabPosition>({ x: 0, y: 0 })
|
const pos = ref<FabPosition>({ x: 0, y: 0 })
|
||||||
const dragging = ref(false)
|
const dragging = ref(false)
|
||||||
@@ -44,26 +73,40 @@ export function useDraggableFloatingButton(
|
|||||||
function getHorizontalOffset() {
|
function getHorizontalOffset() {
|
||||||
const vw = window.innerWidth
|
const vw = window.innerWidth
|
||||||
const contentWidth = getViewportWidth()
|
const contentWidth = getViewportWidth()
|
||||||
|
|
||||||
return Math.max(0, (vw - contentWidth) / 2)
|
return Math.max(0, (vw - contentWidth) / 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetToDefault() {
|
function getDefaultPosition(): FabPosition {
|
||||||
const vh = window.innerHeight
|
const vh = window.innerHeight
|
||||||
const offsetX = getHorizontalOffset()
|
const offsetX = getHorizontalOffset()
|
||||||
const contentWidth = getViewportWidth()
|
const contentWidth = getViewportWidth()
|
||||||
|
const bottomChrome = readBottomChromeHeight()
|
||||||
|
|
||||||
pos.value = {
|
return {
|
||||||
x: offsetX + contentWidth - width - defaultRightOffset,
|
x: offsetX + contentWidth - width - defaultRightOffset,
|
||||||
y: vh - defaultBottomOffset - height
|
y: vh - bottomChrome - defaultBottomGap - height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applySavedOffset(dx: number, dy: number) {
|
||||||
|
const base = getDefaultPosition()
|
||||||
|
pos.value = {
|
||||||
|
x: base.x + dx,
|
||||||
|
y: base.y + dy
|
||||||
|
}
|
||||||
|
clampToViewport()
|
||||||
|
}
|
||||||
|
|
||||||
function clampToViewport() {
|
function clampToViewport() {
|
||||||
const vw = window.innerWidth
|
|
||||||
const vh = window.innerHeight
|
const vh = window.innerHeight
|
||||||
|
const offsetX = getHorizontalOffset()
|
||||||
|
const contentWidth = getViewportWidth()
|
||||||
|
const minX = offsetX
|
||||||
|
const maxX = offsetX + contentWidth - width
|
||||||
|
|
||||||
pos.value = {
|
pos.value = {
|
||||||
x: Math.max(0, Math.min(vw - width, pos.value.x)),
|
x: Math.max(minX, Math.min(maxX, pos.value.x)),
|
||||||
y: Math.max(0, Math.min(vh - height, pos.value.y))
|
y: Math.max(0, Math.min(vh - height, pos.value.y))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,25 +115,56 @@ export function useDraggableFloatingButton(
|
|||||||
try {
|
try {
|
||||||
const raw = localStorage.getItem(storageKey)
|
const raw = localStorage.getItem(storageKey)
|
||||||
if (!raw) return false
|
if (!raw) return false
|
||||||
const parsed = JSON.parse(raw) as FabPosition
|
|
||||||
if (typeof parsed?.x === 'number' && typeof parsed?.y === 'number') {
|
const parsed = JSON.parse(raw) as SavedFabOffset
|
||||||
pos.value = parsed
|
if (
|
||||||
clampToViewport()
|
parsed?.version === POSITION_VERSION
|
||||||
|
&& typeof parsed.dx === 'number'
|
||||||
|
&& typeof parsed.dy === 'number'
|
||||||
|
) {
|
||||||
|
applySavedOffset(parsed.dx, parsed.dy)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function savePosition() {
|
function savePosition() {
|
||||||
localStorage.setItem(storageKey, JSON.stringify(pos.value))
|
const base = getDefaultPosition()
|
||||||
|
const payload: SavedFabOffset = {
|
||||||
|
version: POSITION_VERSION,
|
||||||
|
dx: pos.value.x - base.x,
|
||||||
|
dy: pos.value.y - base.y
|
||||||
|
}
|
||||||
|
localStorage.setItem(storageKey, JSON.stringify(payload))
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetToDefault() {
|
||||||
|
pos.value = getDefaultPosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleResize() {
|
function handleResize() {
|
||||||
clampToViewport()
|
try {
|
||||||
savePosition()
|
const raw = localStorage.getItem(storageKey)
|
||||||
|
if (raw) {
|
||||||
|
const parsed = JSON.parse(raw) as SavedFabOffset
|
||||||
|
if (
|
||||||
|
parsed?.version === POSITION_VERSION
|
||||||
|
&& typeof parsed.dx === 'number'
|
||||||
|
&& typeof parsed.dy === 'number'
|
||||||
|
) {
|
||||||
|
applySavedOffset(parsed.dx, parsed.dy)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
resetToDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePointerDown(event: PointerEvent) {
|
function handlePointerDown(event: PointerEvent) {
|
||||||
|
|||||||
+88
-14
@@ -1,24 +1,46 @@
|
|||||||
export function usePrice(price: number, digit = true, unit = 'ریال') {
|
function formatGroupedPrice(price: string | number | null | undefined, digit: boolean) {
|
||||||
price= price??0
|
let value = price === null || price === undefined ? '' : String(price)
|
||||||
let _price = price.toString()
|
|
||||||
if (digit) {
|
if (digit) {
|
||||||
_price = _price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||||
}
|
}
|
||||||
return `${_price} ${unit}`
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePriceWithoutType(price?: number, digit = true, unit = 'ریال') {
|
/** مبلغ ریالی — بدون اعشار، گرد به بالا */
|
||||||
let _price = price?.toString()
|
export function ceilRial(price?: number | string | null): number {
|
||||||
if (digit) {
|
const num = Number(price ?? 0)
|
||||||
_price = _price?.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
if (!Number.isFinite(num)) {
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
return `${_price}`
|
|
||||||
|
return Math.ceil(num)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatNumber(value: string | number | null | undefined, grouped = false): string {
|
||||||
|
return formatGroupedPrice(value, grouped)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function usePrice(price: number, digit = true, unit = 'ریال') {
|
||||||
|
const formatted = formatGroupedPrice(ceilRial(price), digit)
|
||||||
|
return `${formatted} ${unit}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function usePriceWithoutType(price?: number, digit = true) {
|
||||||
|
return formatGroupedPrice(ceilRial(price), digit)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useTowDecimal(num: string | number): string | number {
|
export function useTowDecimal(num: string | number): string | number {
|
||||||
const temp = num.toString().match(/^-?\d+(?:\.\d{0,2})?/)
|
const temp = num.toString().match(/^-?\d+(?:\.\d{0,2})?/)
|
||||||
if (temp && temp.length > 0) return temp[0]
|
if (temp && temp.length > 0) return formatGroupedPrice(temp[0], false)
|
||||||
return Math.round(+num * 100) / 100
|
return formatGroupedPrice(Math.round(+num * 100) / 100, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatSignedPercentChange(value: number): string {
|
||||||
|
if (!value) return '0%'
|
||||||
|
|
||||||
|
const formatted = useTowDecimal(Math.abs(value))
|
||||||
|
const prefix = value > 0 ? '+' : '-'
|
||||||
|
return `${prefix}${formatted}%`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useFormat(num: string | number, unit = '') {
|
export function useFormat(num: string | number, unit = '') {
|
||||||
@@ -28,11 +50,26 @@ export function useFormat(num: string | number, unit = '') {
|
|||||||
type TransactionPriceSource = {
|
type TransactionPriceSource = {
|
||||||
cash?: number | null
|
cash?: number | null
|
||||||
gold?: number | null
|
gold?: number | null
|
||||||
|
type?: number | null
|
||||||
order?: {
|
order?: {
|
||||||
price?: number | null
|
price?: number | null
|
||||||
total_price?: number | null
|
total_price?: number | null
|
||||||
amount?: number | null
|
amount?: number | null
|
||||||
|
sts?: number | null
|
||||||
|
sts_str?: string | number | null
|
||||||
|
payment_sts?: number | null
|
||||||
} | null
|
} | null
|
||||||
|
withdraw?: {
|
||||||
|
sts?: number | null
|
||||||
|
sts_str?: string | number | null
|
||||||
|
} | null
|
||||||
|
order_id?: number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
const ORDER_STATUS_LABELS: Record<number, string> = {
|
||||||
|
1: 'باز',
|
||||||
|
2: 'موفق',
|
||||||
|
3: 'ناموفق',
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTransactionTradePrice(item: TransactionPriceSource): number {
|
export function getTransactionTradePrice(item: TransactionPriceSource): number {
|
||||||
@@ -57,6 +94,38 @@ export function getTransactionTradePrice(item: TransactionPriceSource): number {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resolveTransactionStatusLabel(item?: TransactionPriceSource | null): string {
|
||||||
|
if (!item) return ''
|
||||||
|
|
||||||
|
const raw = item.order?.sts_str ?? item.withdraw?.sts_str
|
||||||
|
if (typeof raw === 'string') {
|
||||||
|
const trimmed = raw.trim()
|
||||||
|
if (trimmed && trimmed !== 'بدون مقدار') {
|
||||||
|
return trimmed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof raw === 'number' || (typeof raw === 'string' && /^\d+$/.test(String(raw).trim()))) {
|
||||||
|
const mapped = ORDER_STATUS_LABELS[Number(raw)]
|
||||||
|
if (mapped) return mapped
|
||||||
|
}
|
||||||
|
|
||||||
|
const sts = item.order?.sts ?? item.withdraw?.sts
|
||||||
|
if (sts != null && ORDER_STATUS_LABELS[Number(sts)]) {
|
||||||
|
return ORDER_STATUS_LABELS[Number(sts)]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.order_id && Number(item.order?.payment_sts) === 4) {
|
||||||
|
return 'موفق'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.order_id && (item.type === 1 || item.type === 2 || item.type === 10)) {
|
||||||
|
return 'موفق'
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
export function getTransactionGoldAmount(item: TransactionPriceSource): number {
|
export function getTransactionGoldAmount(item: TransactionPriceSource): number {
|
||||||
const gold = Number(item.gold) || 0
|
const gold = Number(item.gold) || 0
|
||||||
if (Math.abs(gold) > 0) {
|
if (Math.abs(gold) > 0) {
|
||||||
@@ -74,8 +143,13 @@ export function getTransactionGoldAmount(item: TransactionPriceSource): number {
|
|||||||
return gold
|
return gold
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatGoldAmount(amount?: number | null): string {
|
export function formatGoldAmount(amount?: number | null, decimals = 8): string {
|
||||||
const num = Number(amount)
|
const num = Number(amount)
|
||||||
if (!Number.isFinite(num)) return '0'
|
if (!Number.isFinite(num)) return '0'
|
||||||
return String(Number(num.toFixed(3)))
|
return formatGroupedPrice(Number(num.toFixed(decimals)), false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** وزن فلز (گرم) — بدون گرد کردن به بالا */
|
||||||
|
export function formatWeightAmount(amount?: number | null): string {
|
||||||
|
return formatGoldAmount(amount)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
export interface AboutSection {
|
||||||
|
title?: string
|
||||||
|
paragraphs?: string[]
|
||||||
|
items?: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAboutSections(projectName: string): AboutSection[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
paragraphs: [`${projectName} وبسایت رسمی است.`],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="dabout-content dabout-content--default"
|
||||||
|
:class="variant === 'desktop' ? 'dabout-content--default' : 'bg-primary text-white rounded-[12px] p-4 text-xs leading-5'"
|
||||||
|
>
|
||||||
|
<template v-for="(section, sectionIndex) in aboutSections" :key="sectionIndex">
|
||||||
|
<div
|
||||||
|
v-if="sectionIndex > 0"
|
||||||
|
:class="variant === 'desktop' ? 'dabout-content__divider' : 'w-full h-1px my-3 bg-tertiary'"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-for="(paragraph, paragraphIndex) in section.paragraphs ?? []"
|
||||||
|
:key="`p-${sectionIndex}-${paragraphIndex}`"
|
||||||
|
:class="[variant === 'desktop' ? 'dabout-content__paragraph' : '', paragraphIndex > 0 ? 'mt-3' : '']"
|
||||||
|
>
|
||||||
|
{{ paragraph }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useAboutPageContext } from '../composables/useAboutPage'
|
||||||
|
|
||||||
|
withDefaults(defineProps<{ variant?: 'mobile' | 'desktop' }>(), { variant: 'mobile' })
|
||||||
|
|
||||||
|
const { aboutSections } = useAboutPageContext()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<template>
|
||||||
|
<div :class="variant === 'desktop' ? 'dabout-support' : 'wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white items-center'">
|
||||||
|
<a class="w-full" :href="supportHref" target="_blank" rel="noopener noreferrer">
|
||||||
|
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
|
||||||
|
</a>
|
||||||
|
<a :href="supportHref" target="_blank" rel="noopener noreferrer">
|
||||||
|
<img
|
||||||
|
src="@/assets/img/rubika.webp"
|
||||||
|
alt=""
|
||||||
|
:class="variant === 'desktop' ? 'dabout-support__bale' : 'w-12'"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import { useAboutPageContext } from '../composables/useAboutPage'
|
||||||
|
|
||||||
|
withDefaults(defineProps<{ variant?: 'mobile' | 'desktop' }>(), { variant: 'mobile' })
|
||||||
|
|
||||||
|
const { supportHref } = useAboutPageContext()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { computed, inject, provide, type InjectionKey, type ComputedRef } from 'vue'
|
||||||
|
import { getConfig } from '@/config/app-config'
|
||||||
|
import { getAboutSections, type AboutSection } from '../aboutContent'
|
||||||
|
|
||||||
|
export interface AboutPageContext {
|
||||||
|
projectName: ComputedRef<string>
|
||||||
|
aboutSections: ComputedRef<AboutSection[]>
|
||||||
|
supportHref: ComputedRef<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ABOUT_PAGE_CONTEXT_KEY: InjectionKey<AboutPageContext> = Symbol('aboutPageContext')
|
||||||
|
|
||||||
|
const SUPPORT_LINK = 'https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c'
|
||||||
|
|
||||||
|
export function useAboutPage() {
|
||||||
|
const projectName = computed(() => getConfig('name_fa', 'کشکول گلد'))
|
||||||
|
const aboutSections = computed(() => getAboutSections(projectName.value))
|
||||||
|
const supportHref = computed(() => SUPPORT_LINK)
|
||||||
|
|
||||||
|
const context: AboutPageContext = { projectName, aboutSections, supportHref }
|
||||||
|
provide(ABOUT_PAGE_CONTEXT_KEY, context)
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAboutPageContext() {
|
||||||
|
const context = inject(ABOUT_PAGE_CONTEXT_KEY)
|
||||||
|
if (!context) throw new Error('useAboutPageContext must be used within useAboutPage')
|
||||||
|
return context
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dabout">
|
||||||
|
<div class="dabout__container">
|
||||||
|
<DesktopPageTopbar eyebrow="اطلاعات" title="درباره ما" show-back />
|
||||||
|
|
||||||
|
<div class="dabout-layout">
|
||||||
|
<section class="dabout-surface dabout-main">
|
||||||
|
<div class="dabout-main__intro">
|
||||||
|
<div class="dabout-main__logo">
|
||||||
|
<BasicIcon icon="vuesax-linear:info-circle" size="28" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2 class="dabout-main__project">{{ projectName }}</h2>
|
||||||
|
<p class="dabout-main__tagline">آشنایی با خدمات و چشمانداز ما</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<AboutSectionsContent variant="desktop" />
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<aside class="dabout-surface dabout-side">
|
||||||
|
<h3 class="dabout-side__title">پشتیبانی و ارتباط</h3>
|
||||||
|
<p class="dabout-side__text">
|
||||||
|
در صورت نیاز به راهنمایی یا پاسخ به سوالات، از راههای زیر با ما در ارتباط باشید.
|
||||||
|
</p>
|
||||||
|
<AboutSupportActions variant="desktop" />
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
|
||||||
|
import AboutSectionsContent from '../components/AboutSectionsContent.vue'
|
||||||
|
import AboutSupportActions from '../components/AboutSupportActions.vue'
|
||||||
|
import { useAboutPageContext } from '../composables/useAboutPage'
|
||||||
|
|
||||||
|
const { projectName } = useAboutPageContext()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" src="./styles/desktop-about.less"></style>
|
||||||
@@ -0,0 +1,234 @@
|
|||||||
|
/* Premium desktop about page */
|
||||||
|
|
||||||
|
.dabout {
|
||||||
|
min-height: 100%;
|
||||||
|
background: #f6f7f9;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dabout__container {
|
||||||
|
max-width: 1080px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 28px 36px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dabout-topbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 28px;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
|
||||||
|
&__back {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__meta {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__eyebrow {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #9ca3af;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
color: #111827;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dabout-layout {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
|
||||||
|
gap: 20px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dabout-surface {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dabout-main {
|
||||||
|
padding: 28px;
|
||||||
|
|
||||||
|
&__intro {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
border-bottom: 1px solid #eef0f3;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__logo {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
border-radius: 14px;
|
||||||
|
background: rgba(9, 61, 81, 0.08);
|
||||||
|
color: @theme-primary;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__project {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #111827;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__tagline {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dabout-content {
|
||||||
|
&--default {
|
||||||
|
padding: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--boursecu {
|
||||||
|
padding: 20px;
|
||||||
|
border: 1px solid rgba(9, 61, 81, 0.15);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: rgba(9, 61, 81, 0.03);
|
||||||
|
color: @theme-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__divider {
|
||||||
|
width: 100%;
|
||||||
|
height: 1px;
|
||||||
|
background: #eef0f3;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: inherit;
|
||||||
|
margin: 0 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__paragraph {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.9;
|
||||||
|
color: inherit;
|
||||||
|
text-align: justify;
|
||||||
|
margin: 0 0 12px;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__list {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__list-item {
|
||||||
|
position: relative;
|
||||||
|
padding-right: 16px;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: inherit;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 10px;
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: currentColor;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dabout-side {
|
||||||
|
padding: 24px;
|
||||||
|
position: sticky;
|
||||||
|
top: 24px;
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111827;
|
||||||
|
margin: 0 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__text {
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: #6b7280;
|
||||||
|
margin: 0 0 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dabout-support {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
> a:first-child {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__bale {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
object-fit: contain;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1023.98px) {
|
||||||
|
.dabout-layout {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dabout-side {
|
||||||
|
position: static;
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
-184
@@ -1,195 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="about-page-root">
|
||||||
<div class="bg-white wrap-fix z-200001 py-3 px-3 text-primary font-bold drop-shadow flex">
|
<DesktopAboutView v-show="isDesktop" />
|
||||||
<div @click="router.back()" class="cursor-pointer">
|
<MobileAboutView v-show="!isDesktop" />
|
||||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
|
||||||
</div>
|
|
||||||
<div class="mr-2">درباره ما</div>
|
|
||||||
</div>
|
|
||||||
<div class="pt-20">
|
|
||||||
<div>
|
|
||||||
<img :src="img" alt="" class="mt-2 w-full absolute bottom-0" />
|
|
||||||
</div>
|
|
||||||
<div class="text-justify text-base z-200000 relative">
|
|
||||||
<div class="px-10">
|
|
||||||
<!-- <img :src="logoFull" class="mb-20 mt-5" />-->
|
|
||||||
<div class="overflow-y-auto h-65vh">
|
|
||||||
<div class="bg-primary text-white rounded-[12px] p-4 text-xs leading-5">
|
|
||||||
<div class="w-full h-1px my-3 bg-tertiary"></div>
|
|
||||||
<div>
|
|
||||||
کشکول گلد وبسایت رسمی تست.
|
|
||||||
</div>
|
|
||||||
<!-- <div class="mt-3">-->
|
|
||||||
<!-- این وبسایت با پشتوانه سه مجموعه معتبر نور هشتم فعالیت میکند و امکان خرید شمش طلا را از وزنهای خرد تا معاملات عمده، با قیمت شفاف و امنیت کامل فراهم میسازد.-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="mt-3">-->
|
|
||||||
<!-- تمامی فرآیندهای خرید در کشکول گلد بر اساس استانداردهای حرفهای بازار طلا و با اتکا به اعتبار مجموعههای نور هشتم مشهد، نورهشتم فردوس و نورهشتم (داماس) بجستان انجام میشود تا کاربران با آرامش و اطمینان کامل اقدام به خرید کنند.-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="mt-3">-->
|
|
||||||
<!-- کشکول گلدکشکول گلد، بانکی از طلا بساز...-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="mt-3">-->
|
|
||||||
<!-- برای ارتباط حضوری، دریافت مشاوره و اطمینان بیشتر، کاربران میتوانند از طریق آدرسهای سه شعبه رسمی نور هشتم با مجموعه در ارتباط باشند و از پشتیبانی مستقیم مجموعه بهرهمند شوند.-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="w-full h-1px my-3 bg-tertiary"></div>-->
|
|
||||||
<!-- <div class="mt-3 text-xl font-bold">چرا کشکول گلد؟</div>
|
|
||||||
<div class="mt-3">
|
|
||||||
۱. خرید بدون اجرت و مالیات
|
|
||||||
طلایی که از اپلیکیشن کشکول گلد خریداری میکنید، بدون اجرت ساخت و مالیات محاسبه میشود و تنها ۰.۵٪ کارمزد از شما دریافت خواهد شد.
|
|
||||||
</div>
|
|
||||||
<div class="mt-3">
|
|
||||||
۲. خرید بدون محدودیت
|
|
||||||
در کشکول گلد میتوانید از ۵۰ سوت تا چند کیلوگرم طلا را بهصورت آنلاین و بدون هیچگونه محدودیت مکانی خریداری کنید
|
|
||||||
</div>
|
|
||||||
<div class="mt-3">
|
|
||||||
۳. فعالیت در ساعات رسمی معاملات طلا
|
|
||||||
برای رعایت قوانین صنف طلا و جلوگیری از خالیفروشی، فعالیت اپلیکیشن کشکول گلد منطبق با ساعات رسمی معاملات اتحادیه طلافروشان کشور است.
|
|
||||||
</div>
|
|
||||||
<div class="mt-3">
|
|
||||||
۴. امکان تحویل فیزیکی طلا
|
|
||||||
کشکول گلد دارای شعب حضوری معتبر با مجوز خردهفروشی طلاست تا کاربران بتوانند در صورت تمایل، طلای خریداریشده خود را بهصورت فیزیکی تحویل بگیرند و از نزدیک از اصالت آن اطمینان حاصل کنند.
|
|
||||||
</div>
|
|
||||||
<div class="w-full h-1px my-3 bg-tertiary"></div>-->
|
|
||||||
<!-- <div class="mt-3">-->
|
|
||||||
<!-- آدرس شعب ما:-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="mt-3">-->
|
|
||||||
<!-- مشهد : خیابان امام خمینی / برج طلا و جواهر مرمر / طبقه همکف / واحد 16 / طلا و سکه نورهشتم-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="mt-3">-->
|
|
||||||
<!-- فردوس : خیابان امام خمینی / بعد از امام خمینی 11 / طلا و سکه نورهشتم-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="mt-3">-->
|
|
||||||
<!-- بجستان : خیابان امام خمینی / چهارراه وحدت / طلا و جواهر داماس [طلا و سکه نورهشتم]-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="w-full h-1px my-3 bg-tertiary"></div>-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white items-center">
|
|
||||||
<a class="w-full" href="https://web.rubika.ir/#">
|
|
||||||
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
|
|
||||||
</a>
|
|
||||||
<a href="https://web.rubika.ir/#">
|
|
||||||
<img src="@/assets/img/rubika.webp" alt="" class=" w-12"/>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- <ActionSheet v-model:show="editPassVisible">salam</ActionSheet>-->
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
import img from '@/assets/img/user_ly1.svg'
|
import { useAboutPage } from './composables/useAboutPage'
|
||||||
import gr_bottom from './assets/img/gr_bottom_white.svg'
|
import DesktopAboutView from './desktop/DesktopAboutView.vue'
|
||||||
import { loading } from '@/utils'
|
import MobileAboutView from './mobile/MobileAboutView.vue'
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
|
||||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
|
||||||
import { lengthValidation, required } from '@/utils/inputRules'
|
|
||||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
|
||||||
import type { User } from '@/models/login'
|
|
||||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
|
||||||
import router from '@/router'
|
|
||||||
import type { FormInstance } from 'ant-design-vue'
|
|
||||||
import { message } from 'ant-design-vue'
|
|
||||||
import { updateMe } from '@/api/me'
|
|
||||||
import { useUserStore } from '@/store/userStore'
|
|
||||||
import BaseDatePicker from '@/components/BasicPacks/BaseDatePicker'
|
|
||||||
import img_pattern from "@/views/login/assets/img/pattern.svg";
|
|
||||||
|
|
||||||
const userFormState = ref<User>({
|
const isDesktop = useDesktopBreakpoint()
|
||||||
fname: '',
|
useAboutPage()
|
||||||
lname: '',
|
|
||||||
mobile: undefined,
|
|
||||||
birth_date: '',
|
|
||||||
phone_number: '',
|
|
||||||
province: '',
|
|
||||||
city: '',
|
|
||||||
n_code: undefined
|
|
||||||
})
|
|
||||||
const formRef = ref<FormInstance>()
|
|
||||||
const userStore = useUserStore()
|
|
||||||
|
|
||||||
// const editPassVisible = ref<boolean>(false)
|
|
||||||
const editPassVisible = ref<boolean>(false)
|
|
||||||
|
|
||||||
function setForm() {
|
|
||||||
userFormState.value = userStore.userInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyCode() {
|
|
||||||
// nextTick(() => {
|
|
||||||
const val = userStore.userInfo?.referral_id
|
|
||||||
navigator.clipboard.writeText(val)
|
|
||||||
message.info('کد رونوشت شد')
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
function shareCode() {
|
|
||||||
// nextTick(() => {
|
|
||||||
const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر!
|
|
||||||
با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر!
|
|
||||||
|
|
||||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای کشکول گلد جا نمونید.
|
|
||||||
روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید.
|
|
||||||
|
|
||||||
kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}`
|
|
||||||
navigator.share({
|
|
||||||
title: 'کشکول گلد',
|
|
||||||
text: val
|
|
||||||
})
|
|
||||||
// message.info('کد رونوشت شد')
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
const resetData = () => {
|
|
||||||
formRef.value?.resetFields()
|
|
||||||
userFormState.value = {
|
|
||||||
fname: '',
|
|
||||||
lname: '',
|
|
||||||
mobile: undefined,
|
|
||||||
birth_date: '',
|
|
||||||
phone_number: '',
|
|
||||||
province: '',
|
|
||||||
city: '',
|
|
||||||
n_code: undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
setForm()
|
|
||||||
})
|
|
||||||
|
|
||||||
function ok() {
|
|
||||||
formRef.value?.validateFields().then(async () => {
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
await updateMe(userFormState.value)
|
|
||||||
await userStore.getMyInfo()
|
|
||||||
editPassVisible.value = false
|
|
||||||
message.success('اطلاعات شما با موفقیت به روز رسانی شد')
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/*.fade-enter-active,
|
.about-page-root {
|
||||||
.fade-leave-active {
|
min-height: 100%;
|
||||||
transition: opacity 0.2s ease;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fade-enter-from,
|
|
||||||
.fade-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
}*/
|
|
||||||
/*.trans{
|
|
||||||
transition: height 1s;
|
|
||||||
}*/
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<MobilePageHeader title="درباره ما" show-back />
|
||||||
|
<div class="mpage-content pb-[calc(var(--app-bottom-chrome-height)+1rem)]">
|
||||||
|
<div class="px-5">
|
||||||
|
<AboutSectionsContent variant="mobile" />
|
||||||
|
</div>
|
||||||
|
<AboutSupportActions variant="mobile" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||||
|
import AboutSectionsContent from '../components/AboutSectionsContent.vue'
|
||||||
|
import AboutSupportActions from '../components/AboutSupportActions.vue'
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,309 @@
|
|||||||
|
import { computed, inject, onMounted, onUnmounted, provide, ref, watch, type InjectionKey } from 'vue'
|
||||||
|
import { message, Modal } from 'ant-design-vue'
|
||||||
|
import { useCartStore } from '@/store/cartStore'
|
||||||
|
import { useWalletStore } from '@/store/walletStore'
|
||||||
|
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||||
|
import { checkoutCart } from '@/api/card'
|
||||||
|
import { registerCodeDiscount } from '@/api/giftCard'
|
||||||
|
import { getProductBaseBuyPrice } from '@/utils/productPrice'
|
||||||
|
import { subscribeProductListStream } from '@/utils/productStreamBridge'
|
||||||
|
import {
|
||||||
|
getLastPrices,
|
||||||
|
lastPrice,
|
||||||
|
startLastPricePolling,
|
||||||
|
stopPriceInterval,
|
||||||
|
} from '@/utils/price'
|
||||||
|
import {
|
||||||
|
priceSocketConnected,
|
||||||
|
priceStreamLifecycle,
|
||||||
|
priceWssEnabled,
|
||||||
|
shouldUsePricePolling,
|
||||||
|
} from '@/utils/priceSocketState'
|
||||||
|
import { getToken, loading } from '@/utils'
|
||||||
|
import router from '@/router'
|
||||||
|
import type { Price } from '@/models/home'
|
||||||
|
import type { Order } from '@/models/order'
|
||||||
|
import type { Product } from '@/models/products'
|
||||||
|
|
||||||
|
export interface CartPageContext {
|
||||||
|
cartStore: ReturnType<typeof useCartStore>
|
||||||
|
loading: typeof loading
|
||||||
|
infoVisible: ReturnType<typeof ref<boolean>>
|
||||||
|
showDiscountModal: ReturnType<typeof ref<boolean>>
|
||||||
|
discountCode: ReturnType<typeof ref<string>>
|
||||||
|
discountInfo: ReturnType<typeof ref<any>>
|
||||||
|
price: ReturnType<typeof computed<Price>>
|
||||||
|
totalPrice: ReturnType<typeof computed<number>>
|
||||||
|
displaytotalPrice: ReturnType<typeof computed<number | string>>
|
||||||
|
discountPercentLabel: ReturnType<typeof computed<string>>
|
||||||
|
formatWeight: (weight?: number) => string
|
||||||
|
handleRemoveItem: (itemId: string) => void
|
||||||
|
handleCheckout: () => Promise<void>
|
||||||
|
submitDiscount: () => Promise<void>
|
||||||
|
removeDiscount: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CART_PAGE_CONTEXT_KEY: InjectionKey<CartPageContext> = Symbol('cartPageContext')
|
||||||
|
|
||||||
|
export function useCartPage() {
|
||||||
|
const cartStore = useCartStore()
|
||||||
|
const walletStore = useWalletStore()
|
||||||
|
const { loadWalletAssets } = useWalletAssets()
|
||||||
|
const infoVisible = ref(false)
|
||||||
|
const showDiscountModal = ref(false)
|
||||||
|
const discountCode = ref('')
|
||||||
|
const discountInfo = ref<any>()
|
||||||
|
|
||||||
|
let cartRefreshInterval: ReturnType<typeof setInterval> | undefined
|
||||||
|
let unsubscribeProductStream: (() => void) | undefined
|
||||||
|
|
||||||
|
const price = computed((): Price => <Price>lastPrice.value ?? 0)
|
||||||
|
|
||||||
|
function syncCartFromProducts(products: Product[]) {
|
||||||
|
if (cartStore.itemCount === 0) return
|
||||||
|
const removedCount = cartStore.syncProductsFromServer(products)
|
||||||
|
cartStore.updateCartItemPrices()
|
||||||
|
if (removedCount > 0) {
|
||||||
|
message.warning(`${removedCount} محصول از سبد خرید حذف شد (دیگر در دسترس نیست)`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(lastPrice, () => {
|
||||||
|
if (lastPrice.value && cartStore.itemCount > 0) {
|
||||||
|
cartStore.updateCartItemPrices()
|
||||||
|
}
|
||||||
|
}, { deep: true, immediate: false })
|
||||||
|
|
||||||
|
const totalPrice = computed(() =>
|
||||||
|
parseInt(String(cartStore.cartItems.reduce((sum, item) => sum + item.totalPrice, 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
const displaytotalPrice = computed(() => {
|
||||||
|
if (discountInfo.value?.amount > 0) {
|
||||||
|
return (totalPrice.value - totalPrice.value * discountInfo.value.amount).toFixed(0)
|
||||||
|
}
|
||||||
|
return totalPrice.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const discountPercentLabel = computed(() => {
|
||||||
|
const amount = Number(discountInfo.value?.amount ?? 0)
|
||||||
|
if (amount <= 0) return ''
|
||||||
|
return `${Math.round(amount * 100)}٪`
|
||||||
|
})
|
||||||
|
|
||||||
|
function removeDiscount() {
|
||||||
|
discountInfo.value = undefined
|
||||||
|
discountCode.value = ''
|
||||||
|
message.success('کد تخفیف حذف شد')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitDiscount() {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
const temp = await registerCodeDiscount(discountCode.value)
|
||||||
|
discountInfo.value = temp.giftcard
|
||||||
|
message.success('کد تخفیف با موفقیت اعمال شد')
|
||||||
|
showDiscountModal.value = false
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatWeight(weight?: number) {
|
||||||
|
if (!weight) return ''
|
||||||
|
if (weight < 1) {
|
||||||
|
const sot = weight * 1000
|
||||||
|
return sot < 1 ? '1 سوت' : `${Math.round(sot)} سوت`
|
||||||
|
}
|
||||||
|
return `${weight} گرم`
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRemoveItem(itemId: string) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: 'حذف از سبد خرید',
|
||||||
|
content: 'آیا از حذف این آیتم از سبد خرید اطمینان دارید؟',
|
||||||
|
okText: 'تایید',
|
||||||
|
okType: 'danger',
|
||||||
|
centered: true,
|
||||||
|
cancelText: 'انصراف',
|
||||||
|
onOk() {
|
||||||
|
cartStore.removeFromCart(itemId)
|
||||||
|
message.success('آیتم از سبد خرید حذف شد')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleCheckout() {
|
||||||
|
if (!getToken()) {
|
||||||
|
message.warning('برای تسویه حساب، لطفا ابتدا وارد حساب کاربری خود شوید')
|
||||||
|
await router.push({ name: 'login' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (cartStore.itemCount === 0) {
|
||||||
|
message.warning('سبد خرید شما خالی است')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!lastPrice.value) {
|
||||||
|
message.error('لطفا منتظر بمانید تا قیمتها بارگذاری شوند')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let cashItemsTotal = cartStore.cartItems
|
||||||
|
.filter((item) => item.method === 'cash' && !item.gateway)
|
||||||
|
.reduce((sum, item) => parseInt(String(sum + item.totalPrice)), 0)
|
||||||
|
|
||||||
|
if (cashItemsTotal > 0) {
|
||||||
|
if (discountInfo.value?.amount > 0) {
|
||||||
|
cashItemsTotal -= cashItemsTotal * discountInfo.value.amount
|
||||||
|
}
|
||||||
|
if (!walletStore.walletInfo) await walletStore.getMyWallet()
|
||||||
|
if (!walletStore.walletInfo?.cash || cashItemsTotal > walletStore.walletInfo.cash) {
|
||||||
|
message.error('موجودی کیف پول شما ناکافی است')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const goldItemsTotal = cartStore.cartItems
|
||||||
|
.filter((item) => item.method === 'gold')
|
||||||
|
.reduce((sum, item) => sum + (item.goldVazn ? item.goldVazn * item.quantity : 0), 0)
|
||||||
|
|
||||||
|
if (goldItemsTotal > 0) {
|
||||||
|
if (!walletStore.walletInfo) await walletStore.getMyWallet()
|
||||||
|
if (!walletStore.walletInfo?.gold || goldItemsTotal > walletStore.walletInfo.gold) {
|
||||||
|
message.error('موجودی کیف طلا شما ناکافی است')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
infoVisible.value = true
|
||||||
|
const orders: Order[] = cartStore.cartItems.map((item) => ({
|
||||||
|
direction: 1,
|
||||||
|
price: getProductBaseBuyPrice(item.product),
|
||||||
|
amount: item.product.amount,
|
||||||
|
gateway: item.gateway,
|
||||||
|
product_id: item.product.id,
|
||||||
|
method: item.method,
|
||||||
|
number: item.quantity,
|
||||||
|
discount_code: discountInfo.value?.code,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const data = await checkoutCart(orders)
|
||||||
|
let returnUrl: string | null = null
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
const itemWithReturnUrl = data.find((item) => item?.returnUrl)
|
||||||
|
if (itemWithReturnUrl?.returnUrl) returnUrl = itemWithReturnUrl.returnUrl
|
||||||
|
} else if (data?.returnUrl) {
|
||||||
|
returnUrl = data.returnUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnUrl) {
|
||||||
|
window.location.href = returnUrl
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await walletStore.getMyWallet()
|
||||||
|
cartStore.clearCart()
|
||||||
|
await router.push({ name: 'transactions' })
|
||||||
|
message.success('سفارشات شما با موفقیت ثبت شد')
|
||||||
|
await loadWalletAssets(true)
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error in checkout:', e)
|
||||||
|
message.error('خطا در ثبت سفارش. لطفا دوباره تلاش کنید.')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
infoVisible.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initPrice() {
|
||||||
|
try {
|
||||||
|
if (shouldUsePricePolling()) await getLastPrices()
|
||||||
|
startLastPricePolling()
|
||||||
|
cartStore.updateCartItemPrices()
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshCart() {
|
||||||
|
const removedCount = await cartStore.refreshCartFromServer()
|
||||||
|
if (removedCount > 0) {
|
||||||
|
message.warning(`${removedCount} محصول از سبد خرید حذف شد (دیگر در دسترس نیست)`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startCartRefreshPolling() {
|
||||||
|
if (cartRefreshInterval || !shouldUsePricePolling()) return
|
||||||
|
cartRefreshInterval = setInterval(() => {
|
||||||
|
if (shouldUsePricePolling()) void refreshCart()
|
||||||
|
}, 10000)
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopCartRefreshPolling() {
|
||||||
|
if (cartRefreshInterval) {
|
||||||
|
clearInterval(cartRefreshInterval)
|
||||||
|
cartRefreshInterval = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncCartRefreshPolling() {
|
||||||
|
if (shouldUsePricePolling()) startCartRefreshPolling()
|
||||||
|
else stopCartRefreshPolling()
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [priceWssEnabled.value, priceSocketConnected.value, priceStreamLifecycle.value] as const,
|
||||||
|
() => {
|
||||||
|
syncCartRefreshPolling()
|
||||||
|
if (shouldUsePricePolling() && cartStore.itemCount > 0) void refreshCart()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
cartStore.loadCartFromStorage()
|
||||||
|
unsubscribeProductStream = subscribeProductListStream(syncCartFromProducts)
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
await initPrice()
|
||||||
|
if (shouldUsePricePolling()) await refreshCart()
|
||||||
|
syncCartRefreshPolling()
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
unsubscribeProductStream?.()
|
||||||
|
unsubscribeProductStream = undefined
|
||||||
|
stopCartRefreshPolling()
|
||||||
|
stopPriceInterval()
|
||||||
|
})
|
||||||
|
|
||||||
|
const context: CartPageContext = {
|
||||||
|
cartStore,
|
||||||
|
loading,
|
||||||
|
infoVisible,
|
||||||
|
showDiscountModal,
|
||||||
|
discountCode,
|
||||||
|
discountInfo,
|
||||||
|
price,
|
||||||
|
totalPrice,
|
||||||
|
displaytotalPrice,
|
||||||
|
discountPercentLabel,
|
||||||
|
formatWeight,
|
||||||
|
handleRemoveItem,
|
||||||
|
handleCheckout,
|
||||||
|
submitDiscount,
|
||||||
|
removeDiscount,
|
||||||
|
}
|
||||||
|
|
||||||
|
provide(CART_PAGE_CONTEXT_KEY, context)
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCartPageContext() {
|
||||||
|
const context = inject(CART_PAGE_CONTEXT_KEY)
|
||||||
|
if (!context) throw new Error('useCartPageContext must be used within useCartPage')
|
||||||
|
return context
|
||||||
|
}
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dinner cart-page">
|
||||||
|
<div class="dinner__container">
|
||||||
|
<DesktopPageTopbar title="سبد خرید" show-back>
|
||||||
|
<template #trailing>
|
||||||
|
<div v-if="price" class="dcart-header-price number-ltr">
|
||||||
|
<span class="dcart-header-price__label">قیمت خرید از کشکول گلد:</span>
|
||||||
|
<strong>{{ usePriceWithoutType(price?.price_last ?? 0) }}</strong>
|
||||||
|
<span>ریال</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</DesktopPageTopbar>
|
||||||
|
|
||||||
|
<GoldLoading v-model:show="infoVisible" title="" />
|
||||||
|
|
||||||
|
<template v-if="loading">
|
||||||
|
<TransactionSkeleton v-for="i in 3" :key="i" class="mt-4" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div v-else-if="cartStore.itemCount === 0" class="dinner-surface dcart-empty">
|
||||||
|
<p>سبد خرید شما خالی است</p>
|
||||||
|
<BasicButton type="primary" @click="router.push({ name: 'buyProduct' })">مشاهده محصولات</BasicButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="dcart-grid">
|
||||||
|
<div class="dcart-items">
|
||||||
|
<article v-for="item in cartStore.cartItems" :key="item.id" class="dcart-item">
|
||||||
|
<div class="dcart-item__image">
|
||||||
|
<ProductImage :product="item.product" img-class="max-w-full max-h-full object-contain" />
|
||||||
|
</div>
|
||||||
|
<div class="dcart-item__main">
|
||||||
|
<h3 class="dcart-item__title">{{ item.product.title }}</h3>
|
||||||
|
<p class="dcart-item__meta">
|
||||||
|
روش پرداخت: {{ item.method === 'cash' ? 'نقدی' : 'طلایی' }}
|
||||||
|
<span v-if="item.method === 'cash' && item.gateway"> (با درگاه)</span>
|
||||||
|
</p>
|
||||||
|
<p class="dcart-item__meta">
|
||||||
|
تعداد: {{ item.quantity }} عدد
|
||||||
|
<span v-if="item.goldVazn"> | وزن: {{ formatWeight(item.goldVazn) }}</span>
|
||||||
|
</p>
|
||||||
|
<div class="dcart-item__footer">
|
||||||
|
<span class="dcart-item__price">{{ usePrice(item.totalPrice) }}</span>
|
||||||
|
<BasicIcon
|
||||||
|
icon="vuesax-linear:trash"
|
||||||
|
class="text-red-500 cursor-pointer"
|
||||||
|
@click.stop="handleRemoveItem(item.id)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<aside class="dinner-surface dcart-summary">
|
||||||
|
<h2 class="dcart-summary__title">خلاصه سفارش</h2>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="discountInfo?.amount > 0"
|
||||||
|
class="dcart-summary__discount"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<span>کد تخفیف: </span>
|
||||||
|
<strong>{{ discountInfo.code }}</strong>
|
||||||
|
<div class="text-xs text-green-600">{{ discountPercentLabel }} تخفیف اعمال شد</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="dcart-summary__remove-discount" @click="removeDiscount">
|
||||||
|
<BasicIcon icon="vuesax-linear:close-circle" size="18" />
|
||||||
|
حذف
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dcart-summary__row">
|
||||||
|
<span>مجموع:</span>
|
||||||
|
<div class="text-left">
|
||||||
|
<div class="dcart-summary__total">{{ usePrice(displaytotalPrice) }}</div>
|
||||||
|
<div v-if="discountInfo?.amount > 0" class="text-xs text-gray-400 line-through">
|
||||||
|
{{ usePrice(totalPrice) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
v-if="!discountInfo?.amount"
|
||||||
|
type="button"
|
||||||
|
class="dcart-summary__discount-link"
|
||||||
|
@click="showDiscountModal = true"
|
||||||
|
>
|
||||||
|
کد تخفیف دارم
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<BasicButton class="w-full" type="primary" size="large" @click="handleCheckout">
|
||||||
|
تسویه حساب
|
||||||
|
</BasicButton>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import router from '@/router'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import GoldLoading from '@/components/GoldLoading.vue'
|
||||||
|
import ProductImage from '@/components/ProductImage.vue'
|
||||||
|
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||||
|
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
|
||||||
|
import { usePrice, usePriceWithoutType } from '@/utils/usePrice'
|
||||||
|
import { useCartPageContext } from '../composables/useCartPage'
|
||||||
|
|
||||||
|
const {
|
||||||
|
cartStore,
|
||||||
|
loading,
|
||||||
|
infoVisible,
|
||||||
|
showDiscountModal,
|
||||||
|
discountInfo,
|
||||||
|
price,
|
||||||
|
totalPrice,
|
||||||
|
displaytotalPrice,
|
||||||
|
discountPercentLabel,
|
||||||
|
formatWeight,
|
||||||
|
handleRemoveItem,
|
||||||
|
handleCheckout,
|
||||||
|
removeDiscount,
|
||||||
|
} = useCartPageContext()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.dcart-header-price {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dcart-empty {
|
||||||
|
padding: 48px 24px;
|
||||||
|
text-align: center;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dcart-summary__discount {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(167, 43, 119, 0.06);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dcart-summary__remove-discount {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: #ef4444;
|
||||||
|
font-size: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dcart-summary__discount-link {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: @App-primary-color;
|
||||||
|
font-size: 13px;
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: inherit;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+26
-453
@@ -1,464 +1,37 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="cart-page-root">
|
||||||
<div class="absolute inset-0 bg-cover bg-center opacity-60 z--1" :style="{ backgroundImage: `url(${img})` }"></div>
|
<DesktopCartView v-show="isDesktop" />
|
||||||
<div class="bg-white drop-shadow z-[1999] wrap-fix">
|
<MobileCartView v-show="!isDesktop" />
|
||||||
<div class="py-3 px-3 font-bold flex items-center justify-between">
|
|
||||||
<div>سبد خرید</div>
|
<AModal
|
||||||
<!-- Price Display in Header -->
|
v-model:visible="showDiscountModal"
|
||||||
<div v-if="price" class="flex gap-1 items-center text-xs flex-1 justify-end">
|
ok-text="اعمال کد تخفیف"
|
||||||
<span class="text-gray-600 text-xs">قیمت خرید از کشکول گلد:</span>
|
cancel-text="انصراف"
|
||||||
<div class="font-bold text-base" style="font-family: iran-sans; direction: ltr">
|
@ok="submitDiscount"
|
||||||
{{ usePriceWithoutType(price?.price_last ?? 0) }}
|
@cancel="showDiscountModal = false"
|
||||||
</div>
|
>
|
||||||
<span class="text-xs">ریال</span>
|
<div class="p-5">
|
||||||
</div>
|
<div>کد تخفیف</div>
|
||||||
|
<AInput v-model:value="discountCode" />
|
||||||
|
<div class="font-bold text-xs mt-3">*حساس به حروف بزرگ و کوچک</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</AModal>
|
||||||
<GoldLoading v-model:show="infoVisible" title=""/>
|
|
||||||
<div class="px-5 pt-26 pb-30" :class="loading ? 'h-[60vh]' : ''">
|
|
||||||
<template v-if="loading">
|
|
||||||
<TransactionSkeleton v-for="i in 3" :key="i" class="mt-4" />
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<!-- Empty Cart Message -->
|
|
||||||
<div v-if="cartStore.itemCount === 0" class="flex flex-col items-center justify-center h-[60vh]">
|
|
||||||
<div class="text-gray-500 text-lg font-semibold mb-4">سبد خرید شما خالی است</div>
|
|
||||||
<BasicButton type="primary" @click="$router.push({ name: 'buyProduct' })">
|
|
||||||
مشاهده محصولات
|
|
||||||
</BasicButton>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Cart Items -->
|
|
||||||
<div v-else>
|
|
||||||
<div class="space-y-4 mb-20">
|
|
||||||
<div
|
|
||||||
v-for="item in cartStore.cartItems"
|
|
||||||
:key="item.id"
|
|
||||||
class="bg-white rounded-lg border border-gray-200 p-4 shadow-sm"
|
|
||||||
>
|
|
||||||
<div class="flex gap-4">
|
|
||||||
<!-- Product Image -->
|
|
||||||
<div class="bg-gray-100 rounded-lg flex justify-center items-center p-1 min-w-[80px] h-[80px]">
|
|
||||||
<ProductImage
|
|
||||||
:product="item.product"
|
|
||||||
img-class="max-w-full max-h-full object-contain"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Product Info -->
|
|
||||||
<div class="flex-1 flex flex-col justify-between">
|
|
||||||
<div>
|
|
||||||
<div class="text-base font-semibold mb-1">{{ item.product.title }}</div>
|
|
||||||
<!-- <div class="text-xs text-gray-500 mb-2">-->
|
|
||||||
<!-- {{ getProductAmount(item.product.amount) }}-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<div class="text-xs text-gray-500 mb-2">
|
|
||||||
روش پرداخت: {{ item.method === 'cash' ? 'نقدی' : 'طلایی' }}
|
|
||||||
<span v-if="item.method === 'cash' && item.gateway" class="mr-2">(با درگاه)</span>
|
|
||||||
</div>
|
|
||||||
<div class="text-xs text-gray-500">
|
|
||||||
تعداد: {{ item.quantity }} عدد
|
|
||||||
<span v-if="item.goldVazn" class="mr-2">| وزن: {{ formatWeight(item.goldVazn) }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center justify-between mt-2">
|
|
||||||
<div class="text-primary font-bold">
|
|
||||||
{{ usePrice(item.totalPrice) }}
|
|
||||||
</div>
|
|
||||||
<BasicIcon
|
|
||||||
icon="vuesax-linear:trash"
|
|
||||||
class="text-red-500 cursor-pointer"
|
|
||||||
@click.stop="handleRemoveItem(item.id)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Total and Checkout -->
|
|
||||||
<div class=" flex justify-center fixed bottom-20 left-0 right-0 z-1">
|
|
||||||
<div class="md:w-[426px] w-full bg-white border-t border-gray-200 p-4 shadow-lg">
|
|
||||||
<div
|
|
||||||
v-if="discountInfo?.amount > 0"
|
|
||||||
class="mb-3 flex items-center justify-between rounded-lg bg-purple-50 px-3 py-2"
|
|
||||||
>
|
|
||||||
<div class="flex flex-col gap-0.5 text-sm">
|
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<span class="text-gray-600">کد تخفیف:</span>
|
|
||||||
<span class="font-semibold">{{ discountInfo.code }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="text-xs text-green-600">
|
|
||||||
{{ discountPercentLabel }} تخفیف اعمال شد
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="flex items-center gap-1 text-xs text-red-500"
|
|
||||||
@click="removeDiscount"
|
|
||||||
>
|
|
||||||
<BasicIcon icon="vuesax-linear:close-circle" size="18" />
|
|
||||||
<span>حذف</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex justify-between items-center mb-4">
|
|
||||||
<div class="text-lg font-semibold">مجموع:</div>
|
|
||||||
<div class="flex flex-col items-end gap-1">
|
|
||||||
<div class="text-primary font-bold text-xl">
|
|
||||||
{{ usePrice(displaytotalPrice) }}
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="discountInfo?.amount > 0"
|
|
||||||
class="text-xs text-gray-400 line-through"
|
|
||||||
>
|
|
||||||
{{ usePrice(totalPrice) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="!discountInfo?.amount"
|
|
||||||
class="mb-3 text-center"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="text-xs text-primary underline cursor-pointer"
|
|
||||||
@click="showDiscountModal = true"
|
|
||||||
>
|
|
||||||
کد تخفیف دارم
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<BasicButton
|
|
||||||
class="w-full py-3"
|
|
||||||
type="primary"
|
|
||||||
size="large"
|
|
||||||
@click="handleCheckout"
|
|
||||||
>
|
|
||||||
تسویه حساب
|
|
||||||
</BasicButton>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<AModal v-model:visible="showDiscountModal" ok-text="اعمال کد تخفیف" cancel-text="انصراف" @ok="submitDiscount"
|
|
||||||
@cancel="showDiscountModal=false">
|
|
||||||
<div class="p-5">
|
|
||||||
<div>کد تخفیف</div>
|
|
||||||
<AInput v-model:value="discountCode"></AInput>
|
|
||||||
<div class="font-bold text-xs mt-3">
|
|
||||||
*حساس به حروف بزرگ و کوچک
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</AModal>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script lang="ts" setup>
|
||||||
import {ref, onMounted, onUnmounted, watch, computed} from 'vue'
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
import {useCartStore} from '@/store/cartStore'
|
import { useCartPage } from './composables/useCartPage'
|
||||||
import {usePrice, usePriceWithoutType} from '@/utils/usePrice'
|
import DesktopCartView from './desktop/DesktopCartView.vue'
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
import MobileCartView from './mobile/MobileCartView.vue'
|
||||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
|
||||||
import {message, Modal} from 'ant-design-vue'
|
|
||||||
import img from '@/assets/img/user_ly1.svg'
|
|
||||||
import {
|
|
||||||
getLastPrices,
|
|
||||||
lastPrice,
|
|
||||||
stopPriceInterval,
|
|
||||||
setIntervalGetLastPrice
|
|
||||||
} from '@/utils/price'
|
|
||||||
import {checkoutCart} from '@/api/card'
|
|
||||||
import router from '@/router'
|
|
||||||
import {useWalletStore} from '@/store/walletStore'
|
|
||||||
import {useFundUserStore} from '@/store/fundStore'
|
|
||||||
import type {Price} from '@/models/home'
|
|
||||||
import type {Order} from '@/models/order'
|
|
||||||
|
|
||||||
import {loading, getToken} from '@/utils'
|
const isDesktop = useDesktopBreakpoint()
|
||||||
import GoldLoading from '@/components/GoldLoading.vue'
|
const { showDiscountModal, discountCode, submitDiscount } = useCartPage()
|
||||||
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
|
||||||
import ProductImage from '@/components/ProductImage.vue'
|
|
||||||
import {registerCodeDiscount} from "@/api/giftCard";
|
|
||||||
|
|
||||||
const cartStore = useCartStore()
|
|
||||||
const walletStore = useWalletStore()
|
|
||||||
const fundStore = useFundUserStore()
|
|
||||||
const infoVisible = ref(false)
|
|
||||||
const showDiscountModal = ref(false)
|
|
||||||
const discountCode = ref<string>('')
|
|
||||||
const discountInfo = ref()
|
|
||||||
let totalPriceWithDiscount = 0
|
|
||||||
|
|
||||||
const price = computed((): Price => <Price>lastPrice.value ?? 0)
|
|
||||||
|
|
||||||
// Watch for price updates and update cart items
|
|
||||||
watch(lastPrice, () => {
|
|
||||||
if (lastPrice.value) {
|
|
||||||
cartStore.recalculateCartPrices(lastPrice.value)
|
|
||||||
}
|
|
||||||
}, {deep: true, immediate: false})
|
|
||||||
|
|
||||||
// Computed total price that updates with price changes
|
|
||||||
const totalPrice = computed(() => {
|
|
||||||
return parseInt(cartStore.cartItems.reduce((sum, item) => sum + item.totalPrice, 0))
|
|
||||||
})
|
|
||||||
const displaytotalPrice = computed(() => {
|
|
||||||
if (discountInfo.value?.amount > 0) {
|
|
||||||
return (totalPrice.value - (totalPrice.value * discountInfo.value?.amount)).toFixed(0)
|
|
||||||
|
|
||||||
} else
|
|
||||||
return totalPrice.value
|
|
||||||
})
|
|
||||||
|
|
||||||
const discountPercentLabel = computed(() => {
|
|
||||||
const amount = Number(discountInfo.value?.amount ?? 0)
|
|
||||||
if (amount <= 0) return ''
|
|
||||||
return `${Math.round(amount * 100)}٪`
|
|
||||||
})
|
|
||||||
|
|
||||||
function removeDiscount() {
|
|
||||||
discountInfo.value = undefined
|
|
||||||
discountCode.value = ''
|
|
||||||
message.success('کد تخفیف حذف شد')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitDiscount() {
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
const temp = await registerCodeDiscount(discountCode.value)
|
|
||||||
discountInfo.value = temp.giftcard
|
|
||||||
message.success('کد تخفیف با موفقیت اعمال شد')
|
|
||||||
showDiscountModal.value = false
|
|
||||||
} catch (e) {
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getProductAmount(amount?: number) {
|
|
||||||
if (!amount) return ''
|
|
||||||
if (amount < 1) {
|
|
||||||
// کمتر از 1 گرم را به سوت تبدیل کن (مشابه ProductItem)
|
|
||||||
const sot = amount * 1000
|
|
||||||
// اگر نتیجه کمتر از 1 شد، حداقل 1 نمایش بده
|
|
||||||
if (sot < 1) {
|
|
||||||
return `1 سوت`
|
|
||||||
}
|
|
||||||
// در غیر این صورت، عدد را به عدد صحیح گرد کن
|
|
||||||
return `${Math.round(sot)} سوت`
|
|
||||||
}
|
|
||||||
return `${amount} گرم`
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatWeight(weight?: number) {
|
|
||||||
if (!weight) return ''
|
|
||||||
if (weight < 1) {
|
|
||||||
// کمتر از 1 گرم را به سوت تبدیل کن
|
|
||||||
const sot = weight * 1000
|
|
||||||
// اگر نتیجه کمتر از 1 شد، حداقل 1 نمایش بده
|
|
||||||
if (sot < 1) {
|
|
||||||
return `1 سوت`
|
|
||||||
}
|
|
||||||
// در غیر این صورت، عدد را به عدد صحیح گرد کن
|
|
||||||
return `${Math.round(sot)} سوت`
|
|
||||||
}
|
|
||||||
return `${weight} گرم`
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRemoveItem(itemId: string) {
|
|
||||||
Modal.confirm({
|
|
||||||
title: 'حذف از سبد خرید',
|
|
||||||
content: 'آیا از حذف این آیتم از سبد خرید اطمینان دارید؟',
|
|
||||||
okText: 'تایید',
|
|
||||||
okType: 'danger',
|
|
||||||
centered: true,
|
|
||||||
cancelText: 'انصراف',
|
|
||||||
onOk() {
|
|
||||||
cartStore.removeFromCart(itemId)
|
|
||||||
message.success('آیتم از سبد خرید حذف شد')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleCheckout() {
|
|
||||||
// Check if user is logged in
|
|
||||||
if (!getToken()) {
|
|
||||||
message.warning('برای تسویه حساب، لطفا ابتدا وارد حساب کاربری خود شوید')
|
|
||||||
await router.push({name: 'login'})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cartStore.itemCount === 0) {
|
|
||||||
message.warning('سبد خرید شما خالی است')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lastPrice.value) {
|
|
||||||
message.error('لطفا منتظر بمانید تا قیمتها بارگذاری شوند')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check wallet balance for cash method items (without gateway)
|
|
||||||
let cashItemsTotal = cartStore.cartItems
|
|
||||||
.filter(item => item.method === 'cash' && !item.gateway)
|
|
||||||
.reduce((sum, item) => parseInt(sum + item.totalPrice), 0)
|
|
||||||
|
|
||||||
if (cashItemsTotal > 0) {
|
|
||||||
// Ensure wallet info is loaded
|
|
||||||
if (discountInfo.value?.amount && discountInfo.value?.amount>0){
|
|
||||||
cashItemsTotal=cashItemsTotal-cashItemsTotal*discountInfo.value?.amount
|
|
||||||
}
|
|
||||||
if (!walletStore.walletInfo) {
|
|
||||||
await walletStore.getMyWallet()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!walletStore.walletInfo?.cash || cashItemsTotal > walletStore.walletInfo.cash) {
|
|
||||||
message.error('موجودی کیف پول شما ناکافی است')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check gold balance for gold method items
|
|
||||||
const goldItemsTotal = cartStore.cartItems
|
|
||||||
.filter(item => item.method === 'gold')
|
|
||||||
.reduce((sum, item) => {
|
|
||||||
// Calculate total gold weight needed
|
|
||||||
const goldWeight = item.goldVazn ? item.goldVazn * item.quantity : 0
|
|
||||||
return sum + goldWeight
|
|
||||||
}, 0)
|
|
||||||
|
|
||||||
if (goldItemsTotal > 0) {
|
|
||||||
// Ensure wallet info is loaded
|
|
||||||
if (!walletStore.walletInfo) {
|
|
||||||
await walletStore.getMyWallet()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!walletStore.walletInfo?.gold || goldItemsTotal > walletStore.walletInfo.gold) {
|
|
||||||
message.error('موجودی کیف طلا شما ناکافی است')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
infoVisible.value = true
|
|
||||||
|
|
||||||
// Prepare orders array with same structure as createOrder for each product
|
|
||||||
const orders: Order[] = cartStore.cartItems.map(item => {
|
|
||||||
console.log(item)
|
|
||||||
const product = item.product
|
|
||||||
// Calculate price similar to createOrder (buy price)
|
|
||||||
let productPrice = 0
|
|
||||||
if (product.group_type == 'آبشده') {
|
|
||||||
productPrice = lastPrice.value?.price_last ?? 0
|
|
||||||
} else {
|
|
||||||
productPrice = (product.amount ?? 0) * (lastPrice.value?.price_last ?? 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
direction: 1, // 1 for buy (cart items are always buy orders)
|
|
||||||
price: productPrice,
|
|
||||||
amount: product.amount,
|
|
||||||
gateway: item.gateway,
|
|
||||||
product_id: product.id,
|
|
||||||
method: item.method,
|
|
||||||
number: item.quantity,
|
|
||||||
discount_code:discountInfo.value?.code
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Call checkoutCart API with orders array
|
|
||||||
const data = await checkoutCart(orders)
|
|
||||||
|
|
||||||
// Check for returnUrl (gateway payment)
|
|
||||||
let returnUrl = null
|
|
||||||
if (Array.isArray(data)) {
|
|
||||||
const itemWithReturnUrl = data.find(item => item?.returnUrl)
|
|
||||||
if (itemWithReturnUrl?.returnUrl) {
|
|
||||||
returnUrl = itemWithReturnUrl.returnUrl
|
|
||||||
}
|
|
||||||
} else if (data?.returnUrl) {
|
|
||||||
returnUrl = data.returnUrl
|
|
||||||
}
|
|
||||||
|
|
||||||
// If returnUrl exists, redirect to gateway and stop execution
|
|
||||||
if (returnUrl) {
|
|
||||||
window.location.href = returnUrl
|
|
||||||
return // Stop execution here
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no gateway, continue with normal flow
|
|
||||||
await walletStore.getMyWallet()
|
|
||||||
cartStore.clearCart()
|
|
||||||
await router.push({name: 'transactions'})
|
|
||||||
message.success('سفارشات شما با موفقیت ثبت شد')
|
|
||||||
await fundStore.getMyFund()
|
|
||||||
} catch (e: any) {
|
|
||||||
console.error('Error in checkout:', e)
|
|
||||||
message.error('خطا در ثبت سفارش. لطفا دوباره تلاش کنید.')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
infoVisible.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initPrice() {
|
|
||||||
try {
|
|
||||||
await getLastPrices()
|
|
||||||
await setIntervalGetLastPrice()
|
|
||||||
if (lastPrice.value) {
|
|
||||||
cartStore.recalculateCartPrices(lastPrice.value)
|
|
||||||
}
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function refreshCart() {
|
|
||||||
const removedCount = await cartStore.refreshCartFromServer()
|
|
||||||
if (removedCount > 0) {
|
|
||||||
message.warning(`${removedCount} محصول از سبد خرید حذف شد (دیگر در دسترس نیست)`)
|
|
||||||
}
|
|
||||||
if (lastPrice.value) {
|
|
||||||
cartStore.recalculateCartPrices(lastPrice.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
cartStore.loadCartFromStorage()
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
await initPrice()
|
|
||||||
await refreshCart()
|
|
||||||
const refreshCartInfo=setInterval(async () => {
|
|
||||||
await refreshCart()
|
|
||||||
// await getUpPrice()
|
|
||||||
}, 10000)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
stopPriceInterval()
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.text-primary {
|
.cart-page-root {
|
||||||
color: #d3a233;
|
min-height: 100%;
|
||||||
}
|
height: 100%;
|
||||||
|
|
||||||
@media screen and (min-width: 426px) {
|
|
||||||
.wrap-fix {
|
|
||||||
width: 426px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,142 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="absolute inset-0 bg-cover bg-center opacity-60 z--1" :style="{ backgroundImage: `url(${img})` }" />
|
||||||
|
<div class="mpage-header wrap-fix z-[1999]">
|
||||||
|
<div class="py-3 px-3 font-bold flex items-center justify-between w-full">
|
||||||
|
<div>سبد خرید</div>
|
||||||
|
<div v-if="price" class="flex gap-1 items-center text-xs flex-1 justify-end">
|
||||||
|
<span class="text-gray-600 text-xs">قیمت خرید از کشکول گلد:</span>
|
||||||
|
<div class="font-bold text-base" style="font-family: iran-sans; direction: ltr">
|
||||||
|
{{ usePriceWithoutType(price?.price_last ?? 0) }}
|
||||||
|
</div>
|
||||||
|
<span class="text-xs">ریال</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<GoldLoading v-model:show="infoVisible" title="" />
|
||||||
|
<div class="px-5 mpage-content pb-[calc(var(--app-bottom-chrome-height)+1rem)]" :class="loading ? 'h-[60vh]' : ''">
|
||||||
|
<template v-if="loading">
|
||||||
|
<TransactionSkeleton v-for="i in 3" :key="i" class="mt-4" />
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div v-if="cartStore.itemCount === 0" class="flex flex-col items-center justify-center h-[60vh]">
|
||||||
|
<div class="text-gray-500 text-lg font-semibold mb-4">سبد خرید شما خالی است</div>
|
||||||
|
<BasicButton type="primary" @click="router.push({ name: 'buyProduct' })">مشاهده محصولات</BasicButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else>
|
||||||
|
<div class="space-y-4 mb-20">
|
||||||
|
<div
|
||||||
|
v-for="item in cartStore.cartItems"
|
||||||
|
:key="item.id"
|
||||||
|
class="bg-white rounded-lg border border-gray-200 p-4 shadow-sm"
|
||||||
|
>
|
||||||
|
<div class="flex gap-4">
|
||||||
|
<div class="bg-gray-100 rounded-lg flex justify-center items-center p-1 min-w-[80px] h-[80px]">
|
||||||
|
<ProductImage :product="item.product" img-class="max-w-full max-h-full object-contain" />
|
||||||
|
</div>
|
||||||
|
<div class="flex-1 flex flex-col justify-between">
|
||||||
|
<div>
|
||||||
|
<div class="text-base font-semibold mb-1">{{ item.product.title }}</div>
|
||||||
|
<div class="text-xs text-gray-500 mb-2">
|
||||||
|
روش پرداخت: {{ item.method === 'cash' ? 'نقدی' : 'طلایی' }}
|
||||||
|
<span v-if="item.method === 'cash' && item.gateway" class="mr-2">(با درگاه)</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-xs text-gray-500">
|
||||||
|
تعداد: {{ item.quantity }} عدد
|
||||||
|
<span v-if="item.goldVazn" class="mr-2">| وزن: {{ formatWeight(item.goldVazn) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-between mt-2">
|
||||||
|
<div class="text-primary font-bold">{{ usePrice(item.totalPrice) }}</div>
|
||||||
|
<BasicIcon
|
||||||
|
icon="vuesax-linear:trash"
|
||||||
|
class="text-red-500 cursor-pointer"
|
||||||
|
@click.stop="handleRemoveItem(item.id)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-center fixed bottom-20 left-0 right-0 z-1">
|
||||||
|
<div class="md:w-[426px] w-full bg-white border-t border-gray-200 p-4 shadow-lg">
|
||||||
|
<div
|
||||||
|
v-if="discountInfo?.amount > 0"
|
||||||
|
class="mb-3 flex items-center justify-between rounded-lg bg-purple-50 px-3 py-2"
|
||||||
|
>
|
||||||
|
<div class="flex flex-col gap-0.5 text-sm">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span class="text-gray-600">کد تخفیف:</span>
|
||||||
|
<span class="font-semibold">{{ discountInfo.code }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-xs text-green-600">{{ discountPercentLabel }} تخفیف اعمال شد</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="flex items-center gap-1 text-xs text-red-500" @click="removeDiscount">
|
||||||
|
<BasicIcon icon="vuesax-linear:close-circle" size="18" />
|
||||||
|
<span>حذف</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-between items-center mb-4">
|
||||||
|
<div class="text-lg font-semibold">مجموع:</div>
|
||||||
|
<div class="flex flex-col items-end gap-1">
|
||||||
|
<div class="text-primary font-bold text-xl">{{ usePrice(displaytotalPrice) }}</div>
|
||||||
|
<div v-if="discountInfo?.amount > 0" class="text-xs text-gray-400 line-through">
|
||||||
|
{{ usePrice(totalPrice) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="!discountInfo?.amount" class="mb-3 text-center">
|
||||||
|
<span class="text-xs text-primary underline cursor-pointer" @click="showDiscountModal = true">
|
||||||
|
کد تخفیف دارم
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<BasicButton class="w-full py-3" type="primary" size="large" @click="handleCheckout">
|
||||||
|
تسویه حساب
|
||||||
|
</BasicButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import router from '@/router'
|
||||||
|
import img from '@/assets/img/user_ly1.svg'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import GoldLoading from '@/components/GoldLoading.vue'
|
||||||
|
import ProductImage from '@/components/ProductImage.vue'
|
||||||
|
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||||
|
import { usePrice, usePriceWithoutType } from '@/utils/usePrice'
|
||||||
|
import { useCartPageContext } from '../composables/useCartPage'
|
||||||
|
|
||||||
|
const {
|
||||||
|
cartStore,
|
||||||
|
loading,
|
||||||
|
infoVisible,
|
||||||
|
showDiscountModal,
|
||||||
|
discountInfo,
|
||||||
|
price,
|
||||||
|
totalPrice,
|
||||||
|
displaytotalPrice,
|
||||||
|
discountPercentLabel,
|
||||||
|
formatWeight,
|
||||||
|
handleRemoveItem,
|
||||||
|
handleCheckout,
|
||||||
|
removeDiscount,
|
||||||
|
} = useCartPageContext()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.text-primary {
|
||||||
|
color: #d3a233;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import { inject, onMounted, provide, ref, type InjectionKey } from 'vue'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { getEarnMoney } from '@/api/earnMoney'
|
||||||
|
import { useUserStore } from '@/store/userStore'
|
||||||
|
import { loading } from '@/utils'
|
||||||
|
import type { EarnMoney } from '@/models/earnMoney'
|
||||||
|
|
||||||
|
export interface EarnMoneyPageContext {
|
||||||
|
data: ReturnType<typeof ref<EarnMoney | undefined>>
|
||||||
|
userStore: ReturnType<typeof useUserStore>
|
||||||
|
isTransaction: ReturnType<typeof ref<boolean>>
|
||||||
|
setIsTransaction: (value: boolean) => void
|
||||||
|
copyCode: () => void
|
||||||
|
shareCode: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export const EARN_MONEY_PAGE_CONTEXT_KEY: InjectionKey<EarnMoneyPageContext> = Symbol('earnMoneyPageContext')
|
||||||
|
|
||||||
|
export function useEarnMoneyPage() {
|
||||||
|
const data = ref<EarnMoney>()
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const isTransaction = ref(false)
|
||||||
|
|
||||||
|
function setIsTransaction(value: boolean) {
|
||||||
|
isTransaction.value = value
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyCode() {
|
||||||
|
const val = userStore.userInfo?.referral_id
|
||||||
|
if (val) {
|
||||||
|
navigator.clipboard.writeText(val)
|
||||||
|
message.info('کد رونوشت شد')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function shareCode() {
|
||||||
|
const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر!
|
||||||
|
با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر!
|
||||||
|
|
||||||
|
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای کشکول گلد جا نمونید.
|
||||||
|
روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید.
|
||||||
|
|
||||||
|
kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}`
|
||||||
|
navigator.share({ title: 'کشکول گلد', text: val })
|
||||||
|
}
|
||||||
|
|
||||||
|
async function earnMoney() {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
data.value = await getEarnMoney()
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void earnMoney()
|
||||||
|
})
|
||||||
|
|
||||||
|
const context: EarnMoneyPageContext = {
|
||||||
|
data,
|
||||||
|
userStore,
|
||||||
|
isTransaction,
|
||||||
|
setIsTransaction,
|
||||||
|
copyCode,
|
||||||
|
shareCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
provide(EARN_MONEY_PAGE_CONTEXT_KEY, context)
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useEarnMoneyPageContext() {
|
||||||
|
const context = inject(EARN_MONEY_PAGE_CONTEXT_KEY)
|
||||||
|
if (!context) throw new Error('useEarnMoneyPageContext must be used within useEarnMoneyPage')
|
||||||
|
return context
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dinner earn-money-page">
|
||||||
|
<div class="dinner__container">
|
||||||
|
<DesktopPageTopbar title="کسب درآمد" show-back />
|
||||||
|
|
||||||
|
<section class="dinner-surface p-5 mb-4">
|
||||||
|
<div class="flex items-start gap-3">
|
||||||
|
<div class="bg-[#DBEAFE] h-10 w-10 rounded-full flex justify-center items-center flex-shrink-0">
|
||||||
|
<img :src="coin" alt="" class="w-6 h-6" />
|
||||||
|
</div>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<h2 class="font-bold mb-2">دعوت دوستان</h2>
|
||||||
|
<p class="text-sm text-gray-600 leading-6">
|
||||||
|
با دعوت دوستانتان به اپلیکیشن کشکول گلد، دوست شما اولین خرید خود را بدون کارمزد انجام میدهد
|
||||||
|
و شما نیز ۱۰٪ از کارمزد ۱۰ معاملهی اول او را بهعنوان پاداش دریافت میکنید.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-center gap-2 mt-4">
|
||||||
|
<span class="text-sm text-gray-500">کد بازاریابی</span>
|
||||||
|
<strong class="text-lg tracking-wide">{{ userStore.userInfo?.referral_id }}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-2 gap-2 mt-4 max-w-md mx-auto">
|
||||||
|
<BasicButton icon="vuesax-linear:share" size="small" icon-size="18" @click="shareCode">اشتراک گذاری</BasicButton>
|
||||||
|
<BasicButton icon="vuesax-linear:copy" size="small" icon-size="18" @click="copyCode">رونوشت</BasicButton>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="dearn-stats">
|
||||||
|
<div class="dearn-stat dearn-stat--blue">
|
||||||
|
<div class="dearn-stat__value">{{ data?.usersSum }} عدد</div>
|
||||||
|
<div class="dearn-stat__label">تعداد زیر مجموعه</div>
|
||||||
|
</div>
|
||||||
|
<div class="dearn-stat dearn-stat--yellow">
|
||||||
|
<div class="dearn-stat__value">{{ data?.giftsSum }} سوت</div>
|
||||||
|
<div class="dearn-stat__label">میزان کل پاداش ها</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dinner-surface p-2 mb-4 flex gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="dearn-tab"
|
||||||
|
:class="{ 'dearn-tab--active': isTransaction }"
|
||||||
|
@click="setIsTransaction(true)"
|
||||||
|
>
|
||||||
|
پاداش ها
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="dearn-tab"
|
||||||
|
:class="{ 'dearn-tab--active': !isTransaction }"
|
||||||
|
@click="setIsTransaction(false)"
|
||||||
|
>
|
||||||
|
فهرست زیر مجموعه
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dearn-list">
|
||||||
|
<template v-if="isTransaction">
|
||||||
|
<GiftCard v-for="(val, i) in data?.gifts" :key="`gift-${i}`" :item="val" />
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<EarnCard v-for="(val, i) in data?.users" :key="`user-${i}`" :item="val" />
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import coin from '@/assets/img/coin.png'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
|
||||||
|
import EarnCard from '../components/EarnCard.vue'
|
||||||
|
import GiftCard from '../components/GiftCard.vue'
|
||||||
|
import { useEarnMoneyPageContext } from '../composables/useEarnMoneyPage'
|
||||||
|
|
||||||
|
const { data, userStore, isTransaction, setIsTransaction, copyCode, shareCode } = useEarnMoneyPageContext()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.dearn-tab {
|
||||||
|
flex: 1;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #9ca3af;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&--active {
|
||||||
|
background: #fff;
|
||||||
|
color: @App-primary-color;
|
||||||
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,163 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="earn-money-page-root">
|
||||||
<div class="bg-white w-full py-3 px-3 text-primary font-bold drop-shadow flex">
|
<DesktopEarnMoneyView v-show="isDesktop" />
|
||||||
<div @click="router.back()">
|
<MobileEarnMoneyView v-show="!isDesktop" />
|
||||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
|
||||||
</div>
|
|
||||||
<div class="mr-2">کسب درآمد</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="p-4">
|
|
||||||
<div class=" p-3 border-solid border-1 rounded-[8px] border-[#a72b77] ">
|
|
||||||
<div class="flex items-center">
|
|
||||||
<div class=" bg-[#DBEAFE] h-10 w-10 rounded-100% flex justify-center items-center">
|
|
||||||
<img :src="coin" />
|
|
||||||
</div>
|
|
||||||
<div class="mr-2">
|
|
||||||
<div class="flex">
|
|
||||||
<div class="font-bold">دعوت دوستان</div>
|
|
||||||
<!-- <div class="text-xs ">راهنمای کسب درآمد</div>-->
|
|
||||||
</div>
|
|
||||||
<div class=" mt-2 text-xs">با دعوت دوستانتان به اپلیکیشن کشکول گلد،
|
|
||||||
دوست شما اولین خرید خود را بدون کارمزد انجام میدهد
|
|
||||||
و شما نیز ۱۰٪ از کارمزد ۱۰ معاملهی اول او را بهعنوان پاداش دریافت میکنید. 💰</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex justify-center mt-4">
|
|
||||||
<div class="text-[10px] content-center ">کد بازاریابی</div>
|
|
||||||
<div class="mr-2 font-bold">{{userStore.userInfo.referral_id}}</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex mt-4 gap-2">
|
|
||||||
<BasicButton icon="vuesax-linear:share" size="small" class="flex-1" icon-size="18" @click.stop="shareCode()">
|
|
||||||
اشتراک گذاری
|
|
||||||
</BasicButton>
|
|
||||||
<BasicButton icon="vuesax-linear:copy" size="small" class="flex-1" icon-size="18" @click.stop="copyCode()">
|
|
||||||
رونوشت
|
|
||||||
</BasicButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="grid grid-cols-2 gap-4 mt-4 ">
|
|
||||||
<div class="text-center bg-[#DBEAFE] p-2 rounded-[8px]">
|
|
||||||
<div class="font-bold text-[#2563EB] text-md">
|
|
||||||
{{data?.usersSum}} عدد
|
|
||||||
</div>
|
|
||||||
<div class="text-xs text-[#2563EB] mt-2">تعداد زیر مجموعه</div>
|
|
||||||
</div>
|
|
||||||
<div class="text-center bg-[#FEF9C3] p-2 rounded-[8px]">
|
|
||||||
<div class="font-bold text-[#CA8A04] text-md">
|
|
||||||
{{data?.giftsSum}} سوت
|
|
||||||
</div>
|
|
||||||
<div class="text-xs text-[#CA8A04] mt-2">میزان کل پاداش ها</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex justify-evenly w-full px-2 h-11 items-center bg-gray-50 relative rounded-lg mt-6 ">
|
|
||||||
<div :class="isTransaction?'text-primary bg-white h-8 w-1/2 rounded-lg':'text-gray-400'" class="w-full text-center z-2 flex items-center justify-center"
|
|
||||||
@click.stop="setIsTransaction(true) ">
|
|
||||||
پاداش ها
|
|
||||||
</div>
|
|
||||||
<div :class="!isTransaction?'text-primary bg-white h-8 w-1/2 rounded-lg':'text-gray-400'" class="w-full text-center z-2 flex items-center justify-center"
|
|
||||||
@click.stop="setIsTransaction(false) ">
|
|
||||||
فهرست زیر مجموعه
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- //**************************************-->
|
|
||||||
<!-- <div class="flex mt-6">-->
|
|
||||||
<!-- <div class="bg-[#a72b77] p-2 rounded-[8px] w-full">-->
|
|
||||||
<!-- <div class="text-white text-center">فهرست زیرمجموعه</div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="bg-[#a72b77] p-2 rounded-[8px] w-full mr-2">-->
|
|
||||||
<!-- <div class="text-white text-center">پاداش ها</div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<div class="border-solid border-1 border-[#E5E7EB] mt-6 "></div>
|
|
||||||
<div class="h-20rem overflow-y-scroll" v-if="isTransaction">
|
|
||||||
<GiftCard v-for="(val,i) in data?.gifts" :key="i" :item="val"/>
|
|
||||||
</div>
|
|
||||||
<div v-else class="h-20rem overflow-y-scroll">
|
|
||||||
<EarnCard v-for="(val,i) in data?.users" :key="i" :item="val"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
|
import { useEarnMoneyPage } from './composables/useEarnMoneyPage'
|
||||||
|
import DesktopEarnMoneyView from './desktop/DesktopEarnMoneyView.vue'
|
||||||
|
import MobileEarnMoneyView from './mobile/MobileEarnMoneyView.vue'
|
||||||
|
|
||||||
import router from '@/router'
|
const isDesktop = useDesktopBreakpoint()
|
||||||
import coin from '@/assets/img/coin.png'
|
useEarnMoneyPage()
|
||||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
|
||||||
import { useUserStore } from '@/store/userStore'
|
|
||||||
import { type FormInstance, message } from 'ant-design-vue'
|
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
|
||||||
import type { EarnMoney } from '@/models/earnMoney'
|
|
||||||
import { loading } from '@/utils'
|
|
||||||
import { getEarnMoney } from '@/api/earnMoney'
|
|
||||||
import EarnCard from '@/views/base/earnMoney/components/EarnCard.vue'
|
|
||||||
import TransactionCard from '@/views/base/transactions/components/Item.vue'
|
|
||||||
import GiftCard from '@/views/base/earnMoney/components/GiftCard.vue'
|
|
||||||
|
|
||||||
const data = ref<EarnMoney>()
|
|
||||||
|
|
||||||
const userStore = useUserStore()
|
|
||||||
|
|
||||||
const isTransaction = ref<boolean>(false)
|
|
||||||
|
|
||||||
function setIsTransaction(value: boolean) {
|
|
||||||
isTransaction.value = value
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyCode() {
|
|
||||||
// nextTick(() => {
|
|
||||||
const val = userStore.userInfo?.referral_id
|
|
||||||
navigator.clipboard.writeText(val)
|
|
||||||
message.info('کد رونوشت شد')
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
function shareCode() {
|
|
||||||
// nextTick(() => {
|
|
||||||
const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر!
|
|
||||||
با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر!
|
|
||||||
|
|
||||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای کشکول گلد جا نمونید.
|
|
||||||
روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید.
|
|
||||||
|
|
||||||
kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}`
|
|
||||||
navigator.share({
|
|
||||||
title: 'کشکول گلد',
|
|
||||||
text: val
|
|
||||||
})
|
|
||||||
// message.info('کد رونوشت شد')
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
async function earnMoney() {
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
data.value = await getEarnMoney()
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function subsetList(){
|
|
||||||
|
|
||||||
}
|
|
||||||
onMounted(async () => {
|
|
||||||
earnMoney()
|
|
||||||
})
|
|
||||||
|
|
||||||
function useStyle() {
|
|
||||||
if (data.value?.User) return 'right: 2%;'
|
|
||||||
// if (isbuy.value) return 'animation-direction: normal'
|
|
||||||
// else return 'animation-direction: reverse'
|
|
||||||
else return ' right: 98%; transform: translate(100%, 0);'
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.earn-money-page-root {
|
||||||
|
min-height: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="bg-white w-full py-3 px-3 text-primary font-bold drop-shadow flex">
|
||||||
|
<div @click="router.back()">
|
||||||
|
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||||
|
</div>
|
||||||
|
<div class="mr-2">کسب درآمد</div>
|
||||||
|
</div>
|
||||||
|
<div class="p-4">
|
||||||
|
<div class="p-3 border-solid border-1 rounded-[8px] border-[#a72b77]">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="bg-[#DBEAFE] h-10 w-10 rounded-100% flex justify-center items-center">
|
||||||
|
<img :src="coin" />
|
||||||
|
</div>
|
||||||
|
<div class="mr-2">
|
||||||
|
<div class="font-bold">دعوت دوستان</div>
|
||||||
|
<div class="mt-2 text-xs">
|
||||||
|
با دعوت دوستانتان به اپلیکیشن کشکول گلد، دوست شما اولین خرید خود را بدون کارمزد انجام میدهد
|
||||||
|
و شما نیز ۱۰٪ از کارمزد ۱۰ معاملهی اول او را بهعنوان پاداش دریافت میکنید. 💰
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-center mt-4">
|
||||||
|
<div class="text-[10px] content-center">کد بازاریابی</div>
|
||||||
|
<div class="mr-2 font-bold">{{ userStore.userInfo?.referral_id }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex mt-4 gap-2">
|
||||||
|
<BasicButton icon="vuesax-linear:share" size="small" class="flex-1" icon-size="18" @click="shareCode">
|
||||||
|
اشتراک گذاری
|
||||||
|
</BasicButton>
|
||||||
|
<BasicButton icon="vuesax-linear:copy" size="small" class="flex-1" icon-size="18" @click="copyCode">
|
||||||
|
رونوشت
|
||||||
|
</BasicButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-2 gap-4 mt-4">
|
||||||
|
<div class="text-center bg-[#DBEAFE] p-2 rounded-[8px]">
|
||||||
|
<div class="font-bold text-[#2563EB] text-md">{{ data?.usersSum }} عدد</div>
|
||||||
|
<div class="text-xs text-[#2563EB] mt-2">تعداد زیر مجموعه</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center bg-[#FEF9C3] p-2 rounded-[8px]">
|
||||||
|
<div class="font-bold text-[#CA8A04] text-md">{{ data?.giftsSum }} سوت</div>
|
||||||
|
<div class="text-xs text-[#CA8A04] mt-2">میزان کل پاداش ها</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-evenly w-full px-2 h-11 items-center bg-gray-50 relative rounded-lg mt-6">
|
||||||
|
<div
|
||||||
|
:class="isTransaction ? 'text-primary bg-white h-8 w-1/2 rounded-lg' : 'text-gray-400'"
|
||||||
|
class="w-full text-center z-2 flex items-center justify-center"
|
||||||
|
@click="setIsTransaction(true)"
|
||||||
|
>
|
||||||
|
پاداش ها
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
:class="!isTransaction ? 'text-primary bg-white h-8 w-1/2 rounded-lg' : 'text-gray-400'"
|
||||||
|
class="w-full text-center z-2 flex items-center justify-center"
|
||||||
|
@click="setIsTransaction(false)"
|
||||||
|
>
|
||||||
|
فهرست زیر مجموعه
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="border-solid border-1 border-[#E5E7EB] mt-6" />
|
||||||
|
<div v-if="isTransaction" class="h-20rem overflow-y-scroll">
|
||||||
|
<GiftCard v-for="(val, i) in data?.gifts" :key="i" :item="val" />
|
||||||
|
</div>
|
||||||
|
<div v-else class="h-20rem overflow-y-scroll">
|
||||||
|
<EarnCard v-for="(val, i) in data?.users" :key="i" :item="val" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import router from '@/router'
|
||||||
|
import coin from '@/assets/img/coin.png'
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import EarnCard from '../components/EarnCard.vue'
|
||||||
|
import GiftCard from '../components/GiftCard.vue'
|
||||||
|
import { useEarnMoneyPageContext } from '../composables/useEarnMoneyPage'
|
||||||
|
|
||||||
|
const { data, userStore, isTransaction, setIsTransaction, copyCode, shareCode } = useEarnMoneyPageContext()
|
||||||
|
</script>
|
||||||
@@ -1,69 +1,61 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="item" class="bg-white flex flex-col items-center p-3 rounded-xl">
|
<div
|
||||||
<img v-lazy="{ src: itemImg, loading: logo,error: logo}" alt="" class="w-[87px] ">
|
v-if="item"
|
||||||
<div class="mt-3">{{props.item?.title?? '-'}}</div>
|
class="bg-white flex flex-col items-center p-3 rounded-xl"
|
||||||
<div class="mt-1 flex gap-1"><div class="font-bold">{{props.item?.wallet[0]?.gold?? '-'}}</div> گرم</div>
|
:class="{ 'dfund-card': variant === 'desktop' }"
|
||||||
<!-- {{props.item?.wallet[0]?.cash}}-->
|
>
|
||||||
|
<img :src="displayImage" class="w-[87px] h-[87px] object-contain" alt="" @error="onImageError">
|
||||||
|
<div class="mt-3 text-center line-clamp-2">{{ item.title ?? '-' }}</div>
|
||||||
|
<div class="mt-1 flex flex-col items-center gap-0.5 text-center">
|
||||||
|
<div class="flex gap-1">
|
||||||
|
<div class="font-bold">{{ item.quantity ?? '-' }}</div>
|
||||||
|
{{ item.unit }}
|
||||||
|
</div>
|
||||||
|
<div v-if="item.unit_weight && item.display_type === 'count'" class="text-xs text-gray-500">
|
||||||
|
هر عدد {{ item.unit_weight }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import homeImg from '@/assets/img/cash_home.svg'
|
import { computed, ref, watch } from 'vue'
|
||||||
import giftImg from '@/assets/img/cash_gift.svg'
|
import type { WalletInventoryCard } from '@/models/walletAssets'
|
||||||
import circulationImg from '@/assets/img/cash_circulation.svg'
|
import { getProductDisplayImage } from '@/utils/productAssets'
|
||||||
import loveImg from '@/assets/img/cash_love.svg'
|
|
||||||
import repairsImg from '@/assets/img/cash_repairs.svg'
|
|
||||||
import savingImg from '@/assets/img/cash_saving.svg'
|
|
||||||
import {computed} from "vue";
|
|
||||||
import type {Fund} from "@/models/fund";
|
|
||||||
import logo from "@/assets/img/logo_full_.png";
|
|
||||||
/*function itemImg() {
|
|
||||||
|
|
||||||
}*/
|
|
||||||
interface Prop {
|
interface Prop {
|
||||||
item: Fund
|
item: WalletInventoryCard
|
||||||
|
variant?: 'mobile' | 'desktop'
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Prop>()
|
const props = withDefaults(defineProps<Prop>(), {
|
||||||
|
variant: 'mobile',
|
||||||
const itemImg = computed(() => {
|
|
||||||
switch (props.item?.title) {
|
|
||||||
case 'خرید لوازم منزل':
|
|
||||||
return homeImg
|
|
||||||
case 'هدیه':
|
|
||||||
return giftImg
|
|
||||||
case 'گردش':
|
|
||||||
return circulationImg
|
|
||||||
case 'ازدواج':
|
|
||||||
return loveImg
|
|
||||||
case 'تعمیرات':
|
|
||||||
return repairsImg
|
|
||||||
case 'پس انداز':
|
|
||||||
return savingImg
|
|
||||||
default: return savingImg
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
const imageSrc = ref('')
|
||||||
|
|
||||||
/*const itemName = computed(() => {
|
const displayImage = computed(() => imageSrc.value || resolveImage())
|
||||||
switch (props.type) {
|
|
||||||
case 'home':
|
|
||||||
return 'خرید لوازم منزل'
|
|
||||||
case 'gift':
|
|
||||||
return 'هدیه'
|
|
||||||
case 'circulation':
|
|
||||||
return 'گردش'
|
|
||||||
case 'love':
|
|
||||||
return 'ازدواج'
|
|
||||||
case 'repairs':
|
|
||||||
return 'تعمیرات'
|
|
||||||
case 'saving':
|
|
||||||
return 'پس انداز'
|
|
||||||
default: return null
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.item,
|
||||||
|
() => {
|
||||||
|
imageSrc.value = resolveImage()
|
||||||
|
},
|
||||||
|
{ immediate: true, deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
function resolveImage() {
|
||||||
|
return getProductDisplayImage({
|
||||||
|
title: props.item.title,
|
||||||
|
group_type: props.item.group_type,
|
||||||
|
file: props.item.file,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function onImageError() {
|
||||||
|
imageSrc.value = getProductDisplayImage({
|
||||||
|
title: props.item.title,
|
||||||
|
group_type: props.item.group_type,
|
||||||
|
file: null,
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import { computed, inject, onMounted, provide, type InjectionKey, type Ref } from 'vue'
|
||||||
|
import router from '@/router'
|
||||||
|
import { loading } from '@/utils'
|
||||||
|
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||||
|
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||||
|
import type { WalletMetalTotal } from '@/models/walletAssets'
|
||||||
|
import { fundPageInventoryCards, formatMetalTotal as buildMetalTotalLabel } from '@/utils/productAssets'
|
||||||
|
import { getLastPrices } from '@/utils/price'
|
||||||
|
import { getProjectBranding, isGhatreProject } from '@/utils/project'
|
||||||
|
import img from '@/assets/img/user_ly1.svg'
|
||||||
|
import empty from '@/assets/img/cash_empty.svg'
|
||||||
|
|
||||||
|
export interface FundPageContext {
|
||||||
|
meta: ReturnType<typeof computed>
|
||||||
|
inventoryCards: ReturnType<typeof computed>
|
||||||
|
metalTotals: ReturnType<typeof computed>
|
||||||
|
primaryMetalTotal: ReturnType<typeof computed>
|
||||||
|
cashWallet: ReturnType<typeof computed>
|
||||||
|
totalRialValue: ReturnType<typeof computed>
|
||||||
|
countBasedInventory: ReturnType<typeof computed>
|
||||||
|
fundHeaderBackground: string
|
||||||
|
fundEmptyImage: string
|
||||||
|
fundEmptyText: string
|
||||||
|
fundLabel: string
|
||||||
|
fundBalanceLabel: string
|
||||||
|
formatMetalTotal: (metal: WalletMetalTotal) => string
|
||||||
|
openFundInfo: (productId: number) => void
|
||||||
|
goBack: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FUND_PAGE_KEY: InjectionKey<FundPageContext> = Symbol('fundPage')
|
||||||
|
|
||||||
|
export function useFundPage(_isDesktop: Ref<boolean>) {
|
||||||
|
const { assetsSummary, loadWalletAssets } = useWalletAssets()
|
||||||
|
|
||||||
|
const meta = computed(() => assetsSummary.value?.meta)
|
||||||
|
const inventoryCards = computed(() =>
|
||||||
|
fundPageInventoryCards(assetsSummary.value?.inventory_cards ?? [])
|
||||||
|
)
|
||||||
|
const metalTotals = computed(() => assetsSummary.value?.metal_totals ?? [])
|
||||||
|
const primaryMetalTotal = computed(() => metalTotals.value[0])
|
||||||
|
const cashWallet = computed(() => assetsSummary.value?.cash_wallet ?? 0)
|
||||||
|
const totalRialValue = computed(() => assetsSummary.value?.total_rial_value ?? 0)
|
||||||
|
const countBasedInventory = computed(() =>
|
||||||
|
(assetsSummary.value?.count_products ?? []).reduce(
|
||||||
|
(sum, item) => sum + Number(item.quantity ?? 0),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
function formatMetalTotal(metal: WalletMetalTotal) {
|
||||||
|
return buildMetalTotalLabel(metal, inventoryCards.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function openFundInfo(productId: number) {
|
||||||
|
const id = Number(productId)
|
||||||
|
if (!Number.isFinite(id) || id <= 0) return
|
||||||
|
router.push({ name: 'fund_info', params: { id: String(id) } })
|
||||||
|
}
|
||||||
|
|
||||||
|
function goBack() {
|
||||||
|
router.back()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
await Promise.all([loadWalletAssets(true), getLastPrices()])
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const branding = getProjectBranding()
|
||||||
|
|
||||||
|
const context: FundPageContext = {
|
||||||
|
meta,
|
||||||
|
inventoryCards,
|
||||||
|
metalTotals,
|
||||||
|
primaryMetalTotal,
|
||||||
|
cashWallet,
|
||||||
|
totalRialValue,
|
||||||
|
countBasedInventory,
|
||||||
|
fundHeaderBackground: img,
|
||||||
|
fundEmptyImage: empty,
|
||||||
|
fundEmptyText: isGhatreProject() ? 'یک قلک جدید بساز!' : 'یک گنج جدید بساز!',
|
||||||
|
fundLabel: branding.fundLabel,
|
||||||
|
fundBalanceLabel: isGhatreProject() ? `موجودی ${branding.fundLabel} ها` : `موجودی ${branding.fundLabel}`,
|
||||||
|
formatMetalTotal,
|
||||||
|
openFundInfo,
|
||||||
|
goBack,
|
||||||
|
}
|
||||||
|
|
||||||
|
provide(FUND_PAGE_KEY, context)
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useFundPageContext() {
|
||||||
|
const context = inject(FUND_PAGE_KEY)
|
||||||
|
if (!context) {
|
||||||
|
throw new Error('useFundPageContext must be used within useFundPage')
|
||||||
|
}
|
||||||
|
return context
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dfund">
|
||||||
|
<div class="dfund__container">
|
||||||
|
<header class="dfund-topbar">
|
||||||
|
<button type="button" class="dfund-topbar__back" @click="goBack()">
|
||||||
|
<BasicIcon icon="vuesax-linear:arrow-right-1" size="18" />
|
||||||
|
بازگشت
|
||||||
|
</button>
|
||||||
|
<div class="dfund-topbar__meta">
|
||||||
|
<p class="dfund-topbar__eyebrow">{{ fundLabel }}</p>
|
||||||
|
<h1 class="dfund-topbar__title">{{ fundLabel }}</h1>
|
||||||
|
<p class="dfund-topbar__subtitle">نمای کلی موجودی محصولات و کیف پول</p>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section class="dfund-summary" :class="isGhatre ? 'dfund-summary--ghatreh' : ''">
|
||||||
|
<img :src="fundHeaderBackground" alt="" class="dfund-summary__bg" />
|
||||||
|
<div class="dfund-summary__content">
|
||||||
|
<h2 class="dfund-summary__title">{{ fundBalanceLabel }}</h2>
|
||||||
|
|
||||||
|
<div v-if="meta?.has_count_based_products" class="dfund-summary__row">
|
||||||
|
<span>محصولات</span>
|
||||||
|
<strong>{{ countBasedInventory }} عدد</strong>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-if="meta?.single_metal && primaryMetalTotal">
|
||||||
|
<div class="dfund-summary__row">
|
||||||
|
<span>{{ primaryMetalTotal.label }}</span>
|
||||||
|
<strong>{{ formatMetalTotal(primaryMetalTotal) }}</strong>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div
|
||||||
|
v-for="metal in metalTotals"
|
||||||
|
:key="`metal-${metal.metal_id}`"
|
||||||
|
class="dfund-summary__row"
|
||||||
|
>
|
||||||
|
<span>{{ metal.label }}</span>
|
||||||
|
<strong>{{ formatMetalTotal(metal) }}</strong>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div v-if="meta?.has_count_based_products" class="dfund-summary__row">
|
||||||
|
<span>مجموع موجودی</span>
|
||||||
|
<strong>{{ countBasedInventory }} عدد</strong>
|
||||||
|
</div>
|
||||||
|
<div class="dfund-summary__row">
|
||||||
|
<span>دارایی ریالی</span>
|
||||||
|
<strong class="number-ltr">{{ usePriceWithoutType(cashWallet) }} ریال</strong>
|
||||||
|
</div>
|
||||||
|
<div class="dfund-summary__row dfund-summary__row--highlight">
|
||||||
|
<span>معادل ریالی مجموع</span>
|
||||||
|
<strong class="number-ltr">{{ usePriceWithoutType(totalRialValue) }} ریال</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="dfund-inventory">
|
||||||
|
<div class="dfund-inventory__header">
|
||||||
|
<h3 class="dfund-inventory__title">لیست داراییها</h3>
|
||||||
|
<span class="dfund-inventory__count">{{ inventoryCards.length }} مورد</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="inventoryCards.length === 0 && !loading"
|
||||||
|
class="dfund-inventory__empty"
|
||||||
|
>
|
||||||
|
<img :src="fundEmptyImage" alt="" class="dfund-inventory__empty-img" />
|
||||||
|
<p>{{ fundEmptyText }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<div v-if="inventoryCards.length" class="dfund-inventory__grid">
|
||||||
|
<button
|
||||||
|
v-for="item in inventoryCards"
|
||||||
|
:key="item.product_id"
|
||||||
|
type="button"
|
||||||
|
class="dfund-inventory__card"
|
||||||
|
@click="openFundInfo(item.product_id)"
|
||||||
|
>
|
||||||
|
<Item :item="item" variant="desktop" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</a-spin>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import { loading } from '@/utils'
|
||||||
|
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||||
|
import Item from '../components/Item.vue'
|
||||||
|
import { useFundPageContext } from '../composables/useFundPage'
|
||||||
|
import { useProject } from '@/composables/useProject'
|
||||||
|
|
||||||
|
const { isGhatre } = useProject()
|
||||||
|
|
||||||
|
const {
|
||||||
|
meta,
|
||||||
|
inventoryCards,
|
||||||
|
metalTotals,
|
||||||
|
primaryMetalTotal,
|
||||||
|
cashWallet,
|
||||||
|
totalRialValue,
|
||||||
|
countBasedInventory,
|
||||||
|
fundHeaderBackground,
|
||||||
|
fundEmptyImage,
|
||||||
|
fundEmptyText,
|
||||||
|
fundLabel,
|
||||||
|
fundBalanceLabel,
|
||||||
|
formatMetalTotal,
|
||||||
|
openFundInfo,
|
||||||
|
goBack,
|
||||||
|
} = useFundPageContext()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" src="./styles/desktop-fund.less"></style>
|
||||||
@@ -0,0 +1,506 @@
|
|||||||
|
/* Premium desktop fund page */
|
||||||
|
|
||||||
|
.dfund {
|
||||||
|
min-height: 100%;
|
||||||
|
background: #f6f7f9;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund__container {
|
||||||
|
max-width: 1180px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 28px 36px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-topbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
|
||||||
|
&__back {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__meta {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__eyebrow {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #9ca3af;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
color: #111827;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__subtitle {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #6b7280;
|
||||||
|
margin: 6px 0 0;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-summary {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
background: @theme-primary;
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
&--bazretala {
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--ghatreh {
|
||||||
|
background: #efced9;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__bg {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
opacity: 0.08;
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
|
&--cover {
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
opacity: 0.35;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__content {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
padding: 24px 28px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 16px 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 13px;
|
||||||
|
|
||||||
|
span {
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--highlight {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
padding-top: 8px;
|
||||||
|
border-top: 1px solid rgba(255, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-surface {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-inventory {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 24px;
|
||||||
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||||
|
|
||||||
|
&__header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__count {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__card {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
padding: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: inherit;
|
||||||
|
text-align: inherit;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&:hover .dfund-card {
|
||||||
|
border-color: rgba(15, 23, 42, 0.12);
|
||||||
|
box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__empty {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 48px 24px;
|
||||||
|
text-align: center;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__empty-img {
|
||||||
|
width: 160px;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-card {
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.08) !important;
|
||||||
|
border-radius: 14px !important;
|
||||||
|
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1024px) {
|
||||||
|
.dfund-summary__content {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-inventory__grid {
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.dfund-inventory__grid {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fund info desktop */
|
||||||
|
|
||||||
|
.dfund-info {
|
||||||
|
min-height: 100%;
|
||||||
|
background: #f6f7f9;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__container {
|
||||||
|
max-width: 1180px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 28px 36px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info-topbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
|
||||||
|
&__back {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__meta {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__eyebrow {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #9ca3af;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
color: #111827;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__layout {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 280px minmax(0, 1fr);
|
||||||
|
gap: 20px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__hero {
|
||||||
|
padding: 28px 24px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__image {
|
||||||
|
width: 120px;
|
||||||
|
height: 120px;
|
||||||
|
margin: 0 auto 16px;
|
||||||
|
border-radius: 16px;
|
||||||
|
background: #e0f2fe;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 80%;
|
||||||
|
max-height: 80%;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__balance {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__balance-value {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: @theme-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__balance-unit {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__balance-label {
|
||||||
|
margin: 8px 0 0;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__transactions {
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__transactions-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__transactions-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__transactions-count {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-info__transactions-list {
|
||||||
|
max-height: 520px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1024px) {
|
||||||
|
.dfund-info__layout {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fund new desktop */
|
||||||
|
|
||||||
|
.dfund-new {
|
||||||
|
min-height: 100%;
|
||||||
|
background: #f6f7f9;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-new__container {
|
||||||
|
max-width: 640px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 28px 36px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-new-topbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
|
||||||
|
&__back {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__meta {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__eyebrow {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #9ca3af;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
color: #111827;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-new__card {
|
||||||
|
padding: 32px 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-new__preview {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-new__preview-img {
|
||||||
|
width: 120px;
|
||||||
|
height: 120px;
|
||||||
|
object-fit: contain;
|
||||||
|
border-radius: 16px;
|
||||||
|
background: #e0f2fe;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-new__label {
|
||||||
|
display: block;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #374151;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-new__tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
margin: 20px 0 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-new__tag {
|
||||||
|
padding: 8px 14px;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.1);
|
||||||
|
background: #f3f4f6;
|
||||||
|
color: #4b5563;
|
||||||
|
font-size: 12px;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&--active {
|
||||||
|
background: @theme-primary;
|
||||||
|
border-color: @theme-primary;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dfund-new__submit {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
+13
-112
@@ -1,122 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="fund-page-root main-with-bottom-chrome-inner--contained">
|
||||||
<div class="bg-white w-full py-3 px-3 text-black font-bold drop-shadow fixed md:absolute top-0 flex h-12 z-20">
|
<DesktopFundView v-show="isDesktop" />
|
||||||
<div @click="router.back()">
|
<MobileFundView v-show="!isDesktop" />
|
||||||
<BasicIcon icon="vuesax-linear:arrow-right-1"/>
|
|
||||||
</div>
|
|
||||||
<div class="mr-2">قلک</div>
|
|
||||||
</div>
|
|
||||||
<div class="bg-[#EFCED9] w-screen md:w-full h-[70vh] fixed md:absolute">
|
|
||||||
<div class="pt-15 flex flex-col">
|
|
||||||
<div class="text-gray-500 font-bold mr-5 z-20">موجودی قلک ها</div>
|
|
||||||
<div class="flex items-baseline justify-center mt-2 w-full z-20">
|
|
||||||
<div class="text-3xl font-bold">{{ inventory }}</div>
|
|
||||||
/گرم
|
|
||||||
</div>
|
|
||||||
<img :src="img" alt="" class="mt-[-4rem] mr-10 max-w-[22rem] self-end">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="pt-[20rem] ">
|
|
||||||
<div class="bg-gray-100 w-screen md:w-full z-20 relative rounded-t-3xl h-[calc(100vh-20rem-70px)] overflow-y-auto pb-15"
|
|
||||||
style="box-shadow: 0px -2px 4px -2px #0000001A;">
|
|
||||||
|
|
||||||
<div v-if="items.length === 0 && !loading" class="w-full h-full flex justify-center items-center">
|
|
||||||
<div>
|
|
||||||
<img :src="empty" alt="" class="w-70 ">
|
|
||||||
<div class="text-center text-lg">یک قلک جدید بساز!</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a-spin :spinning="loading">
|
|
||||||
<div :class="loading? 'h-[40vh]':''" class="grid grid-cols-2 gap-3 p-5">
|
|
||||||
<Item v-for="item in items" :item="item"
|
|
||||||
@click="router.push({name: 'fund_info', params:{id:item.id}})"/>
|
|
||||||
</div>
|
|
||||||
</a-spin>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="fixed w-full flex justify-center bottom-23 z-200 md:right-0">
|
|
||||||
<div class="rounded-3xl bg-primary text-white px-5 py-2" @click="router.push({name: 'fund_add'})">افزودن قلک
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
|
import { useFundPage } from './composables/useFundPage'
|
||||||
|
import DesktopFundView from './desktop/DesktopFundView.vue'
|
||||||
|
import MobileFundView from './mobile/MobileFundView.vue'
|
||||||
|
|
||||||
import router from "@/router";
|
const isDesktop = useDesktopBreakpoint()
|
||||||
import BasicIcon from "@/components/BasicPacks/BasicIcon.vue";
|
useFundPage(isDesktop)
|
||||||
import img from '@/assets/img/cash_img.svg'
|
|
||||||
import empty from '@/assets/img/cash_empty.svg'
|
|
||||||
import Item from './components/Item.vue'
|
|
||||||
import {onMounted, ref} from "vue";
|
|
||||||
import {loading} from "@/utils";
|
|
||||||
import type {TableOutput} from "@/models/table";
|
|
||||||
import type {Fund} from "@/models/fund";
|
|
||||||
import {useFundUserStore} from "@/store/fundStore";
|
|
||||||
|
|
||||||
const items = ref<Fund[]>([])
|
|
||||||
const tableOutput = ref<TableOutput<Fund> | null>(null)
|
|
||||||
const inventory = ref<number>(0)
|
|
||||||
const fundStore = useFundUserStore()
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
initTable()
|
|
||||||
})
|
|
||||||
|
|
||||||
async function initTable() {
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
tableOutput.value = fundStore.myFunds ?? await fundStore.getMyFund() ?? null
|
|
||||||
// console.log(tableOutput.value)
|
|
||||||
items.value.push(...tableOutput.value?.rows ?? [])
|
|
||||||
items.value.forEach(x => {
|
|
||||||
// console.log(x.wallet[0]?.gold)
|
|
||||||
inventory.value += x?.wallet[0]?.gold ?? 0
|
|
||||||
// console.log(inventory.value)
|
|
||||||
})
|
|
||||||
// console.log(tableOutput.value)
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*watch(()=> router.currentRoute.value.name, () =>{
|
|
||||||
console.log('salammmmmmmmmmmmmmmmmmmmmmmmmmm')
|
|
||||||
})*/
|
|
||||||
/*
|
|
||||||
const items = [
|
|
||||||
{
|
|
||||||
type: 'home',
|
|
||||||
amount: 2.7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'gift',
|
|
||||||
amount: 13.1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'saving',
|
|
||||||
amount: 6.4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'repairs',
|
|
||||||
amount: 16.6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'circulation',
|
|
||||||
amount: 5.4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'love',
|
|
||||||
amount: 3.7
|
|
||||||
},
|
|
||||||
]
|
|
||||||
*/
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.fund-page-root {
|
||||||
|
min-height: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,69 +1,63 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<div @click="infoVisible = true">
|
<div @click="infoVisible = true">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div :class="isUp? 'bg-green-50':'bg-red-50'"
|
<div
|
||||||
class="rounded-lg p-3 h-fit w-fit flex justify-center items-center ">
|
:class="isUp ? 'bg-green-50' : 'bg-red-50'"
|
||||||
<Icon :class="isUp? 'text-green-600':'text-red-600'"
|
class="rounded-lg p-3 h-fit w-fit flex justify-center items-center"
|
||||||
:icon="`vuesax-linear:${isUp? 'arrow-up-2':'arrow-down-2'}`"/>
|
>
|
||||||
|
<Icon
|
||||||
|
:class="isUp ? 'text-green-600' : 'text-red-600'"
|
||||||
|
:icon="`vuesax-linear:${isUp ? 'arrow-up-2' : 'arrow-down-2'}`"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full mr-3">
|
<div class="w-full mr-3">
|
||||||
<div class="flex justify-between w-full">
|
<div class="flex justify-between w-full">
|
||||||
<div>{{ item.type_str }}</div>
|
<div>{{ item.title }}</div>
|
||||||
<div>{{ toJalaliNotime(item.expire_at) }}</div>
|
<div>{{ toJalaliNotime(item.expire_at) }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between mt-2 ">
|
<div class="flex justify-between mt-2">
|
||||||
<div :class="item.gold >= 0? 'text-green-600':'text-red-600'" class="text-gray-500 text-xs number-ltr">
|
<div
|
||||||
</div>
|
:class="item.gold >= 0 ? 'text-green-600' : 'text-red-600'"
|
||||||
|
class="text-gray-500 text-xs number-ltr"
|
||||||
|
/>
|
||||||
<div class="text-gray-500 flex gap-1 text-xs items-center">
|
<div class="text-gray-500 flex gap-1 text-xs items-center">
|
||||||
<div :class="item.gold > 0 ? 'text-green-600':'text-red-600'" class="text-base number-ltr">
|
<div
|
||||||
{{ item.gold }}
|
:class="item.gold > 0 ? 'text-green-600' : 'text-red-600'"
|
||||||
|
class="text-base number-ltr"
|
||||||
|
>
|
||||||
|
{{ formatGoldAmount(item.gold) }}
|
||||||
</div>
|
</div>
|
||||||
گرم
|
{{ item.unit }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div v-if="isGold" class="flex w-full justify-between mt-2">
|
<a-divider class="!my-3" />
|
||||||
<div class="text-gray-500">قیمت معامله</div>
|
|
||||||
<div class="text-gray-500 flex gap-1 text-xs items-center">
|
|
||||||
<div class="text-base">{{ usePriceWithoutType(Math.abs(item.cash) / Math.abs(item.gold)) }}</div>
|
|
||||||
ریال
|
|
||||||
</div>
|
|
||||||
</div>-->
|
|
||||||
<!-- <div v-else class="h-8"></div>-->
|
|
||||||
<a-divider class="!my-3"/>
|
|
||||||
<BasicActionSheet v-model:show="infoVisible">
|
<BasicActionSheet v-model:show="infoVisible">
|
||||||
<div class="font-bold text-lg">{{ props.item.type_str }}</div>
|
<div class="font-bold text-lg">{{ props.item.title }}</div>
|
||||||
<div class="pb-20 mt-5">
|
<div class="pb-20 mt-5">
|
||||||
<div class="flex justify-between mb-3">
|
<div class="flex justify-between mb-3">
|
||||||
<div class="text-black">مقدار طلا مبادله شده:</div>
|
<div class="text-black">مقدار {{ props.title }} مبادله شده:</div>
|
||||||
<div :class="item.gold >= 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center">
|
<div
|
||||||
<div class="text-base ml-1 number-ltr">{{ item.gold }}</div>
|
:class="item.gold >= 0 ? 'text-green-600' : 'text-red-600'"
|
||||||
گرم
|
class="flex text-xs items-center"
|
||||||
|
>
|
||||||
|
<div class="text-base ml-1 number-ltr">{{ formatGoldAmount(item.gold) }}</div>
|
||||||
|
{{ item.unit }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between mb-3">
|
<div class="flex justify-between mb-3">
|
||||||
<div class="text-black">موجودی کیف طلا:</div>
|
<div class="text-black">موجودی {{ props.title }}:</div>
|
||||||
<div class="flex text-xs text-yellow-700 items-center">
|
<div class="flex text-xs text-yellow-700 items-center">
|
||||||
<div class="text-base ml-1">{{ item.balance_gold }}</div>
|
<div class="text-base ml-1">{{ formatGoldAmount(item.balance_gold) }}</div>
|
||||||
گرم
|
{{ item.unit }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="flex justify-between mb-3">
|
|
||||||
<div class="text-black">موجودی کیف پول:</div>
|
|
||||||
<div class="flex text-xs items-center" :class="isUp? 'text-green-600' : 'text-red-600'"><div class="text-base">{{usePriceWithoutType(12000000)}}</div>ریال</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex justify-between mb-3">
|
|
||||||
<div class="text-black">موجودی کیف طلا:</div>
|
|
||||||
<div class="flex items-center" :class="isUp? 'text-red-600' : 'text-green-600'">60 گرم</div>
|
|
||||||
</div>-->
|
|
||||||
<div class="flex justify-between mb-3">
|
<div class="flex justify-between mb-3">
|
||||||
<div class="text-black">وضعیت:</div>
|
<div class="text-black">وضعیت:</div>
|
||||||
<div class="flex text-xs items-center">
|
<div class="flex text-xs items-center">
|
||||||
<ATag :color="item.active? 'blue': 'red'" class="!py-1 !px-6 !ml-0">{{
|
<ATag :color="item.active ? 'blue' : 'red'" class="!py-1 !px-6 !ml-0">
|
||||||
item.active ? 'موفق' : 'نا موفق'
|
{{ item.active ? 'موفق' : 'نا موفق' }}
|
||||||
}}
|
|
||||||
</ATag>
|
</ATag>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -79,43 +73,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</BasicActionSheet>
|
</BasicActionSheet>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import Icon from "@/components/BasicPacks/BasicIcon.vue";
|
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
import BasicActionSheet from "@/components/BasicPacks/BasicActionSheet.vue";
|
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||||
import {computed, ref} from "vue";
|
import { computed, ref } from 'vue'
|
||||||
import BasicButton from "@/components/BasicPacks/BasicButton.vue";
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
import type {Transaction} from "@/models/transaction";
|
import type { Transaction } from '@/models/transaction'
|
||||||
import {toJalaliNotime, toTime} from "../../../../../utils/useDateTime";
|
import { formatGoldAmount } from '@/utils/usePrice'
|
||||||
|
import { toJalaliNotime, toTime } from '@/utils/useDateTime'
|
||||||
|
|
||||||
const infoVisible = ref<boolean>(false)
|
const infoVisible = ref<boolean>(false)
|
||||||
|
|
||||||
interface Prop {
|
interface Prop {
|
||||||
item: Transaction
|
item: Transaction
|
||||||
|
title?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Prop>(), {})
|
const props = withDefaults(defineProps<Prop>(), {})
|
||||||
const isUp = computed(() => props.item.type === 3 || props.item.type === 1)
|
const isUp = computed(() => props.item.type === 3 || props.item.type === 1)
|
||||||
const isGold = computed(() => props.item.type === 1 || props.item.type === 2)
|
|
||||||
/*const title = computed(() => {
|
|
||||||
if (isUp.value) {
|
|
||||||
if (isGold.value) {
|
|
||||||
return 'واریز ریالی'
|
|
||||||
} else {
|
|
||||||
return 'خرید طلا'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isGold.value) {
|
|
||||||
return 'برداشت ریالی'
|
|
||||||
} else {
|
|
||||||
return 'فروش طلا'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import { computed, inject, provide, ref, watch, type InjectionKey } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import router from '@/router'
|
||||||
|
import { loading } from '@/utils'
|
||||||
|
import { getFundTransactionTable } from '@/api/fund'
|
||||||
|
import { getOneProductWallet } from '@/api/products'
|
||||||
|
import type { Product } from '@/models/products'
|
||||||
|
import type { TableInput, TableOutput } from '@/models/table'
|
||||||
|
import type { Transaction } from '@/models/transaction'
|
||||||
|
|
||||||
|
export interface FundInfoPageContext {
|
||||||
|
info: ReturnType<typeof ref<Product | undefined>>
|
||||||
|
items: ReturnType<typeof ref<Transaction[]>>
|
||||||
|
infoId: ReturnType<typeof computed<number | null>>
|
||||||
|
goBack: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FUND_INFO_PAGE_KEY: InjectionKey<FundInfoPageContext> = Symbol('fundInfoPage')
|
||||||
|
|
||||||
|
function parseRouteProductId(raw: string | string[] | undefined): number | null {
|
||||||
|
const value = Array.isArray(raw) ? raw[0] : raw
|
||||||
|
if (value == null || value === '') return null
|
||||||
|
const id = Number.parseInt(String(value), 10)
|
||||||
|
return Number.isFinite(id) && id > 0 ? id : null
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useFundInfoPage() {
|
||||||
|
const route = useRoute()
|
||||||
|
const info = ref<Product>()
|
||||||
|
const items = ref<Transaction[]>([])
|
||||||
|
const tableOutput = ref<TableOutput<Transaction> | null>(null)
|
||||||
|
const pagination = ref<TableInput>({})
|
||||||
|
|
||||||
|
const infoId = computed(() => parseRouteProductId(route.params.id))
|
||||||
|
|
||||||
|
async function initTable() {
|
||||||
|
if (!info.value?.wallet?.id) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
items.value = []
|
||||||
|
Object.assign(pagination.value, { wallet_id: info.value.wallet.id })
|
||||||
|
tableOutput.value = await getFundTransactionTable(pagination.value)
|
||||||
|
items.value.push(...(tableOutput.value?.rows ?? []))
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initInfo() {
|
||||||
|
const id = infoId.value
|
||||||
|
if (id == null) {
|
||||||
|
console.error('Invalid fund product id in route')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
info.value = await getOneProductWallet(id)
|
||||||
|
await initTable()
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(infoId, (id) => {
|
||||||
|
if (id != null) void initInfo()
|
||||||
|
}, { immediate: true })
|
||||||
|
|
||||||
|
function goBack() {
|
||||||
|
router.back()
|
||||||
|
}
|
||||||
|
|
||||||
|
const context: FundInfoPageContext = {
|
||||||
|
info,
|
||||||
|
items,
|
||||||
|
infoId,
|
||||||
|
goBack,
|
||||||
|
}
|
||||||
|
|
||||||
|
provide(FUND_INFO_PAGE_KEY, context)
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useFundInfoPageContext() {
|
||||||
|
const context = inject(FUND_INFO_PAGE_KEY)
|
||||||
|
if (!context) throw new Error('useFundInfoPageContext must be used within useFundInfoPage')
|
||||||
|
return context
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dfund-info">
|
||||||
|
<div class="dfund-info__container">
|
||||||
|
<DesktopPageTopbar
|
||||||
|
eyebrow="جزئیات دارایی"
|
||||||
|
:title="info?.title ?? '—'"
|
||||||
|
show-back
|
||||||
|
sticky
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="dfund-info__layout">
|
||||||
|
<section class="dfund-info__hero dfund-surface">
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<div class="dfund-info__image">
|
||||||
|
<ProductImage
|
||||||
|
v-if="info"
|
||||||
|
:product="info"
|
||||||
|
img-class="max-w-full max-h-full object-contain"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-spin>
|
||||||
|
<div class="dfund-info__balance">
|
||||||
|
<span class="dfund-info__balance-value">{{ info?.wallet?.gold ?? 0 }}</span>
|
||||||
|
<span class="dfund-info__balance-unit">{{ info?.unit ?? 'عدد' }}</span>
|
||||||
|
</div>
|
||||||
|
<p class="dfund-info__balance-label">موجودی {{ info?.title }}</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="dfund-info__transactions dfund-surface">
|
||||||
|
<div class="dfund-info__transactions-header">
|
||||||
|
<h2 class="dfund-info__transactions-title">تراکنشها</h2>
|
||||||
|
<span class="dfund-info__transactions-count">{{ items.length }} مورد</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dfund-info__transactions-list">
|
||||||
|
<list-anim v-if="!loading">
|
||||||
|
<Item v-for="item in items" :key="item.id" :item="item" :title="info?.title" />
|
||||||
|
</list-anim>
|
||||||
|
<TransactionSkeleton v-for="i in 6" v-else :key="i" class="mt-1" />
|
||||||
|
<empty v-if="items.length === 0 && !loading" text="هیچ تراکنشی یافت نشد" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
|
||||||
|
import ProductImage from '@/components/ProductImage.vue'
|
||||||
|
import { loading } from '@/utils'
|
||||||
|
import ListAnim from '@/components/ListAnim.vue'
|
||||||
|
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||||
|
import Empty from '@/components/empty.vue'
|
||||||
|
import Item from '../components/Item.vue'
|
||||||
|
import { useFundInfoPageContext } from '../composables/useFundInfoPage'
|
||||||
|
|
||||||
|
const { info, items } = useFundInfoPageContext()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" src="../../desktop/styles/desktop-fund.less"></style>
|
||||||
@@ -1,291 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="fund-info-page-root">
|
||||||
<div class="bg-white wrap-fix py-3 px-3 text-black font-bold drop-shadow flex h-12 z-20 justify-between">
|
<DesktopFundInfoView v-show="isDesktop" />
|
||||||
<div class="flex ">
|
<MobileFundInfoView v-show="!isDesktop" />
|
||||||
<div @click="router.back()" class="cursor-pointer">
|
|
||||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
|
||||||
</div>
|
|
||||||
<div class="mr-2">{{ info?.title }}</div>
|
|
||||||
</div>
|
|
||||||
<div @click="editShow = true">
|
|
||||||
<BasicIcon icon="vuesax-linear:setting-4" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="pt-20 flex flex-col justify-center items-center">
|
|
||||||
<a-spin :spinning="loading">
|
|
||||||
<div class="bg-sky-100 w-[120px] aspect-square flex justify-center rounded-xl">
|
|
||||||
<img v-if="!loading" :src="itemImg" alt="">
|
|
||||||
</div>
|
|
||||||
</a-spin>
|
|
||||||
<div class="mt-2 font-bold flex text-xs items-center text-gray-500">
|
|
||||||
<div class="ml-1 text-base text-black">{{ info?.wallet[0]?.gold }}</div>
|
|
||||||
گرم
|
|
||||||
</div>
|
|
||||||
<div class="text-gray-400">موجودی قلک {{ info?.title }}</div>
|
|
||||||
<div class="w-full p-5">
|
|
||||||
<div class="w-full flex gap-3">
|
|
||||||
<BasicButton class="w-full !bg-[#F3F0E9] !border-0 !rounded" icon="vuesax-linear:add-square" icon-size="18"
|
|
||||||
@click="()=> {transactionShow = true; isDeposit= false}">برداشت
|
|
||||||
</BasicButton>
|
|
||||||
<BasicButton class="w-full !bg-[#F3F0E9] !border-0 !rounded" icon="vuesax-linear:arrow-up" icon-size="18"
|
|
||||||
@click="()=> {transactionShow = true; isDeposit= true}">واریز
|
|
||||||
</BasicButton>
|
|
||||||
</div>
|
|
||||||
<div class=" font-bold mt-5">تراکنش ها</div>
|
|
||||||
<!-- <a-spin :spinning="loading">-->
|
|
||||||
<div class="mt-5 pb-17 overflow-y-scroll h-[54vh]">
|
|
||||||
<list-anim v-if="!loading">
|
|
||||||
<Item v-for="item in items" :key="item.id" :item="item" />
|
|
||||||
</list-anim>
|
|
||||||
<TransactionSkeleton v-for="i in 8" v-else :key="i" class="mt-1" />
|
|
||||||
<empty v-if="items.length === 0 && !loading" text="هیچ تراکنشی یافت نشد" />
|
|
||||||
</div>
|
|
||||||
<!-- </a-spin>-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<BasicActionSheet v-model:show="transactionShow">
|
|
||||||
<div class="font-bold text-lg">{{ isDeposit ? 'واریز' : 'برداشت' }}</div>
|
|
||||||
<a-form ref="formRef" :model="userFormState" class="!mt-5" name="basic" @finish="transaction()">
|
|
||||||
<a-form-item :rules="[required()]" label="مقدار گرم طلا" name="value" class="!block">
|
|
||||||
<BasicInput v-model:value="userFormState.value"
|
|
||||||
addon-before="گرم" place-holder="گرم"
|
|
||||||
type="text" inputmode="decimal"
|
|
||||||
size="large" />
|
|
||||||
<div v-if="isDeposit" class="mt-2 text-xs font-bold leading-5">
|
|
||||||
<div>موجودی کیف طلا: {{ walletStore?.walletInfo?.gold }} گرم</div>
|
|
||||||
<div v-if="info?.wallet[0]?.gold !== 0">
|
|
||||||
{{ `موجودی قابل برداشت قلک: ${info?.wallet[0]?.gold ?? 0} گرم` }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else class="mt-2 text-xs font-bold">موجودی قلک {{ info.title }}: {{ info?.wallet[0]?.gold }} گرم
|
|
||||||
</div>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item>
|
|
||||||
<BasicButton
|
|
||||||
:disabled="transButtonDisable"
|
|
||||||
class=" w-full py-2 mt-2"
|
|
||||||
html-type="submit"
|
|
||||||
type="primary"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<a-spin v-if="loading" size="small" />
|
|
||||||
<div v-else>{{ isDeposit ? 'واریز' : 'برداشت' }}</div>
|
|
||||||
</div>
|
|
||||||
</BasicButton>
|
|
||||||
<BasicButton class="mb-20 mt-2 w-full" @click="transactionShow = false">بازگشت</BasicButton>
|
|
||||||
</a-form-item>
|
|
||||||
</a-form>
|
|
||||||
</BasicActionSheet>
|
|
||||||
<BasicActionSheet v-model:show="editShow">
|
|
||||||
<div class="font-bold text-lg">قلک {{ info?.title }}</div>
|
|
||||||
|
|
||||||
<BasicButton class="mt-12 w-full" icon="vuesax-linear:edit"
|
|
||||||
icon-size="16" @click="$router.push({name: 'fund_add', query:{id:infoId}})">
|
|
||||||
<div class="flex w-full justify-right">ویرایش</div>
|
|
||||||
</BasicButton>
|
|
||||||
<BasicButton :loading="loading" class="mb-10 mt-2 w-full !text-red-600"
|
|
||||||
icon="vuesax-linear:trash"
|
|
||||||
icon-size="16"
|
|
||||||
@click="deleteFundConfirm">
|
|
||||||
<div class="flex w-full justify-right">حذف</div>
|
|
||||||
</BasicButton>
|
|
||||||
|
|
||||||
<BasicButton class="mb-20 mt-2 w-full" type="primary" @click="transactionShow = false">بازگشت</BasicButton>
|
|
||||||
</BasicActionSheet>
|
|
||||||
<DialogVant v-model:show="showDeleteConfirm" :closeOnClickOverlay="true" :timeOut="-1">
|
|
||||||
<!-- <template v-slot:img>
|
|
||||||
<img :src="registerDelayImage" alt="" class="opacity-80">
|
|
||||||
</template>-->
|
|
||||||
|
|
||||||
<template v-slot:title>
|
|
||||||
<div class="p-5 text-sm">
|
|
||||||
آیا از حذف قلک خود اطمینان دارید؟
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:button>
|
|
||||||
<div class="text-center text-red" @click="deleteFundFunction">
|
|
||||||
حذف
|
|
||||||
</div>
|
|
||||||
<div class="text-center" @click="showDeleteConfirm = false">
|
|
||||||
انصراف
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</DialogVant>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
|
import { useFundInfoPage } from './composables/useFundInfoPage'
|
||||||
|
import DesktopFundInfoView from './desktop/DesktopFundInfoView.vue'
|
||||||
|
import MobileFundInfoView from './mobile/MobileFundInfoView.vue'
|
||||||
|
|
||||||
import router from '@/router'
|
const isDesktop = useDesktopBreakpoint()
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
useFundInfoPage()
|
||||||
import Item from './components/Item.vue'
|
|
||||||
import homeImg from '@/assets/img/cash_home.svg'
|
|
||||||
import giftImg from '@/assets/img/cash_gift.svg'
|
|
||||||
import circulationImg from '@/assets/img/cash_circulation.svg'
|
|
||||||
import loveImg from '@/assets/img/cash_love.svg'
|
|
||||||
import repairsImg from '@/assets/img/cash_repairs.svg'
|
|
||||||
import savingImg from '@/assets/img/cash_saving.svg'
|
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
|
||||||
import { loading } from '@/utils'
|
|
||||||
import { deleteFund, fundDeposit, fundWithdraw, getFundById, getFundTransactionTable } from '@/api/fund'
|
|
||||||
import type { Fund, FundTransaction } from '@/models/fund'
|
|
||||||
import type { TableInput, TableOutput } from '@/models/table'
|
|
||||||
import type { Transaction } from '@/models/transaction'
|
|
||||||
import Empty from '@/components/empty.vue'
|
|
||||||
import { required } from '@/utils/inputRules'
|
|
||||||
import type { FormInstance } from 'ant-design-vue'
|
|
||||||
import { message } from 'ant-design-vue'
|
|
||||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
|
||||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
|
||||||
import { useWalletStore } from '@/store/walletStore'
|
|
||||||
import ListAnim from '@/components/ListAnim.vue'
|
|
||||||
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
|
||||||
import DialogVant from '@/components/DialogVant.vue'
|
|
||||||
import { useFundUserStore } from '@/store/fundStore'
|
|
||||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
|
||||||
|
|
||||||
const info = ref<Fund>()
|
|
||||||
const items = ref<Transaction[]>([])
|
|
||||||
const tableOutput = ref<TableOutput<Transaction> | null>(null)
|
|
||||||
const pagination = ref<TableInput>({/*limit: 100, page: 0*/ })
|
|
||||||
const transactionShow = ref<boolean>()
|
|
||||||
const editShow = ref<boolean>()
|
|
||||||
const showDeleteConfirm = ref<boolean>()
|
|
||||||
const isDeposit = ref<boolean>()
|
|
||||||
const formRef = ref<FormInstance>()
|
|
||||||
let fundStore = useFundUserStore()
|
|
||||||
let walletStore = useWalletStore()
|
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
initInfo()
|
|
||||||
// initTable()
|
|
||||||
})
|
|
||||||
|
|
||||||
function deleteFundConfirm() {
|
|
||||||
if (info.value?.wallet[0] === undefined || info.value?.wallet[0]?.gold === 0) {
|
|
||||||
showDeleteConfirm.value = true
|
|
||||||
} else {
|
|
||||||
message.error('ابتدا قلک خود را خالی کنید')
|
|
||||||
editShow.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function deleteFundFunction() {
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
showDeleteConfirm.value = false
|
|
||||||
await deleteFund(infoId)
|
|
||||||
await fundStore.getMyFund()
|
|
||||||
router.back()
|
|
||||||
message.success('قلک با موفقیت حذف شد')
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const infoId: number = parseInt(<string>router.currentRoute.value.params.id)
|
|
||||||
const userFormState = reactive<FundTransaction>({
|
|
||||||
value: undefined,
|
|
||||||
fund_id: infoId
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(transactionShow, (n) => !n ? userFormState.value = undefined : '')
|
|
||||||
|
|
||||||
const transButtonDisable = computed(() => {
|
|
||||||
if (!loading.value) {
|
|
||||||
if (userFormState.value !== undefined) {
|
|
||||||
if (isDeposit.value) {
|
|
||||||
return userFormState.value > walletStore?.walletInfo?.gold
|
|
||||||
} else {
|
|
||||||
return userFormState.value > info.value?.wallet[0]?.gold
|
|
||||||
}
|
|
||||||
// return isDeposit.value ? userFormState.value > walletStore?.walletInfo?.gold : userFormState.value > info.value?.wallet[0]?.gold
|
|
||||||
} else return true
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
async function initInfo() {
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
info.value = await getFundById(infoId)
|
|
||||||
//pagination.value.page=0
|
|
||||||
await initTable()
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initTable() {
|
|
||||||
if (info.value?.wallet)
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
items.value = []
|
|
||||||
Object.assign(pagination.value, { wallet_id: info.value?.wallet[0]?.id })
|
|
||||||
// pagination.value.fund_id = infoId
|
|
||||||
tableOutput.value = await getFundTransactionTable(pagination.value)
|
|
||||||
items.value.push(...tableOutput.value.rows)
|
|
||||||
// console.log(tableOutput.value)
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function transaction() {
|
|
||||||
formRef.value?.validateFields().then(async () => {
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
userFormState.fund_id = infoId
|
|
||||||
isDeposit.value ? await fundDeposit(userFormState) : await fundWithdraw(userFormState)
|
|
||||||
await initInfo()
|
|
||||||
// await initTable()
|
|
||||||
await fundStore.getMyFund()
|
|
||||||
await walletStore.getMyWallet()
|
|
||||||
fundStore = useWalletStore()
|
|
||||||
walletStore = useWalletStore()
|
|
||||||
message.success(` با موفقیت${isDeposit.value ? ' واریز' : ' برداشت'} شد`)
|
|
||||||
transactionShow.value = false
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const itemImg = computed(() => {
|
|
||||||
switch (info.value?.title) {
|
|
||||||
case 'خرید لوازم منزل':
|
|
||||||
return homeImg
|
|
||||||
case 'هدیه':
|
|
||||||
return giftImg
|
|
||||||
case 'گردش':
|
|
||||||
return circulationImg
|
|
||||||
case 'ازدواج':
|
|
||||||
return loveImg
|
|
||||||
case 'تعمیرات':
|
|
||||||
return repairsImg
|
|
||||||
case 'پس انداز':
|
|
||||||
return savingImg
|
|
||||||
default:
|
|
||||||
return savingImg
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.fund-info-page-root {
|
||||||
|
min-height: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="bg-white wrap-fix py-3 px-3 text-black font-bold drop-shadow flex h-12 z-20">
|
||||||
|
<div class="flex">
|
||||||
|
<div class="cursor-pointer" @click="goBack()">
|
||||||
|
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||||
|
</div>
|
||||||
|
<div class="mr-2">{{ info?.title }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="pt-20 flex flex-col justify-center items-center">
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<div class="bg-gray-100 w-[120px] aspect-square flex justify-center items-center rounded-xl p-2">
|
||||||
|
<ProductImage
|
||||||
|
v-if="info"
|
||||||
|
:product="info"
|
||||||
|
img-class="max-h-full max-w-full object-contain"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-spin>
|
||||||
|
<div class="mt-2 font-bold flex text-xs items-center text-gray-500">
|
||||||
|
<div class="ml-1 text-base text-black">{{ info?.wallet?.gold ?? 0 }}</div>
|
||||||
|
{{ info?.unit ?? 'عدد' }}
|
||||||
|
</div>
|
||||||
|
<div class="text-gray-400">موجودی {{ info?.title }}</div>
|
||||||
|
<div class="w-full p-5">
|
||||||
|
<div class="font-bold mt-5">تراکنش ها</div>
|
||||||
|
<div class="mt-5 pb-17 overflow-y-scroll h-[54vh]">
|
||||||
|
<list-anim v-if="!loading">
|
||||||
|
<Item v-for="item in items" :key="item.id" :item="item" :title="info?.title" />
|
||||||
|
</list-anim>
|
||||||
|
<TransactionSkeleton v-for="i in 8" v-else :key="i" class="mt-1" />
|
||||||
|
<empty v-if="items.length === 0 && !loading" text="هیچ تراکنشی یافت نشد" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import ProductImage from '@/components/ProductImage.vue'
|
||||||
|
import { loading } from '@/utils'
|
||||||
|
import ListAnim from '@/components/ListAnim.vue'
|
||||||
|
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||||
|
import Empty from '@/components/empty.vue'
|
||||||
|
import Item from '../components/Item.vue'
|
||||||
|
import { useFundInfoPageContext } from '../composables/useFundInfoPage'
|
||||||
|
|
||||||
|
const { info, items, goBack } = useFundInfoPageContext()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
<template>
|
||||||
|
<div class="fund-mobile-root">
|
||||||
|
<div
|
||||||
|
class="fund-mobile-root__header bg-white w-full mobile-top-chrome px-3 pb-3 text-primary font-bold drop-shadow flex min-h-12 z-20"
|
||||||
|
>
|
||||||
|
<div class="cursor-pointer" @click="goBack()">
|
||||||
|
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||||
|
</div>
|
||||||
|
<div class="mr-2">{{ fundLabel }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="fund-mobile-root__hero text-tertiary"
|
||||||
|
:class="isGhatre ? 'fund-mobile-root__hero--ghatre' : 'bg-primary'"
|
||||||
|
:style="isGhatre ? { backgroundColor: fundHeroBg } : undefined"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="fundHeaderBackground"
|
||||||
|
alt=""
|
||||||
|
class="fund-mobile-root__hero-bg"
|
||||||
|
/>
|
||||||
|
<div class="fund-mobile-root__hero-content flex flex-col">
|
||||||
|
<div class="font-bold mr-5 z-20">{{ fundBalanceLabel }}</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="meta?.has_count_based_products"
|
||||||
|
class="flex justify-center mt-4 w-full z-20"
|
||||||
|
>
|
||||||
|
محصولات:
|
||||||
|
<div class="text-l mr-4 font-bold">{{ countBasedInventory }} عدد</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-if="meta?.single_metal && primaryMetalTotal">
|
||||||
|
<div class="flex justify-center mt-2 w-full z-20">
|
||||||
|
{{ primaryMetalTotal.label }}:
|
||||||
|
<div class="text-l mr-4 font-bold">{{ formatMetalTotal(primaryMetalTotal) }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div
|
||||||
|
v-for="metal in metalTotals"
|
||||||
|
:key="`metal-${metal.metal_id}`"
|
||||||
|
class="flex justify-center mt-2 w-full z-20"
|
||||||
|
>
|
||||||
|
{{ metal.label }}:
|
||||||
|
<div class="text-l mr-4 font-bold">{{ formatMetalTotal(metal) }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="meta?.has_count_based_products"
|
||||||
|
class="flex justify-center mt-2 w-full z-20"
|
||||||
|
>
|
||||||
|
مجموع موجودی:
|
||||||
|
<div class="text-l mr-4 font-bold">{{ countBasedInventory }} عدد</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-center mt-2 w-full z-20">
|
||||||
|
دارایی ریالی:
|
||||||
|
<div class="text-l mr-4 font-bold">{{ usePriceWithoutType(cashWallet) }} ریال</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-center mt-2 w-full z-20">
|
||||||
|
معادل ریالی مجموع دارایی ها:
|
||||||
|
<div class="text-l mr-4 font-bold">{{ usePriceWithoutType(totalRialValue) }} ریال</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fund-mobile-root__scroll">
|
||||||
|
<div class="fund-mobile-root__panel bg-gray-100 rounded-t-3xl">
|
||||||
|
<div
|
||||||
|
v-if="inventoryCards.length === 0 && !loading"
|
||||||
|
class="w-full min-h-[40vh] flex justify-center items-center"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<img :src="fundEmptyImage" alt="" class="w-70" />
|
||||||
|
<div class="text-center text-lg">{{ fundEmptyText }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<div :class="loading ? 'h-[40vh]' : ''" class="grid grid-cols-2 gap-3 p-5">
|
||||||
|
<Item
|
||||||
|
v-for="item in inventoryCards"
|
||||||
|
:key="item.product_id"
|
||||||
|
:item="item"
|
||||||
|
@click="openFundInfo(item.product_id)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { loading } from '@/utils'
|
||||||
|
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||||
|
import Item from '../components/Item.vue'
|
||||||
|
import { useFundPageContext } from '../composables/useFundPage'
|
||||||
|
import { useProject } from '@/composables/useProject'
|
||||||
|
|
||||||
|
const { isGhatre, branding } = useProject()
|
||||||
|
const fundHeroBg = computed(() => branding.value.fundHeroBg)
|
||||||
|
|
||||||
|
const {
|
||||||
|
meta,
|
||||||
|
inventoryCards,
|
||||||
|
metalTotals,
|
||||||
|
primaryMetalTotal,
|
||||||
|
cashWallet,
|
||||||
|
totalRialValue,
|
||||||
|
countBasedInventory,
|
||||||
|
fundHeaderBackground,
|
||||||
|
fundEmptyImage,
|
||||||
|
fundEmptyText,
|
||||||
|
fundLabel,
|
||||||
|
fundBalanceLabel,
|
||||||
|
formatMetalTotal,
|
||||||
|
openFundInfo,
|
||||||
|
goBack,
|
||||||
|
} = useFundPageContext()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.fund-mobile-root {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1 1 0;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fund-mobile-root__header {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fund-mobile-root__hero {
|
||||||
|
position: relative;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-bottom: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fund-mobile-root__hero-bg {
|
||||||
|
pointer-events: none;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 0;
|
||||||
|
width: 100%;
|
||||||
|
opacity: 0.05;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fund-mobile-root__hero-content {
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
|
padding: 1rem 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fund-mobile-root__scroll {
|
||||||
|
position: relative;
|
||||||
|
z-index: 20;
|
||||||
|
flex: 1 1 0;
|
||||||
|
min-height: 0;
|
||||||
|
margin-top: -2rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
overscroll-behavior-y: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fund-mobile-root__panel {
|
||||||
|
min-height: 100%;
|
||||||
|
padding-bottom: calc(var(--app-bottom-chrome-height, 80px) + 1rem);
|
||||||
|
box-shadow: 0 -2px 4px -2px #0000001a;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<template>
|
||||||
|
<a-form :model="form" class="!mt-0" name="gift-card-form" @finish="registerGiftCard">
|
||||||
|
<a-form-item :rules="[required()]" label="کد کارت هدیه" name="code">
|
||||||
|
<BasicInput
|
||||||
|
v-model:value="form.code"
|
||||||
|
place-holder="کد کارت هدیه را وارد کنید"
|
||||||
|
size="large"
|
||||||
|
type="text"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<p :class="variant === 'desktop' ? 'dgift-form__hint' : 'gift-card-form__hint'">
|
||||||
|
کد کارت هدیه خود را در فیلد بالا وارد کنید و سپس دکمه ثبت را بزنید.
|
||||||
|
</p>
|
||||||
|
<p :class="variant === 'desktop' ? 'dgift-form__case-note' : 'gift-card-form__case-note'">
|
||||||
|
*حساس به حروف بزرگ و کوچک
|
||||||
|
</p>
|
||||||
|
<a-form-item>
|
||||||
|
<BasicButton
|
||||||
|
:disabled="disableButton"
|
||||||
|
:class="variant === 'desktop' ? 'dgift-form__submit' : 'w-full py-2 mt-5'"
|
||||||
|
html-type="submit"
|
||||||
|
type="primary"
|
||||||
|
>
|
||||||
|
<a-spin v-if="loading" size="small" />
|
||||||
|
<span v-else>ثبت کد</span>
|
||||||
|
</BasicButton>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
|
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||||
|
import { loading } from '@/utils'
|
||||||
|
import { required } from '@/utils/inputRules'
|
||||||
|
import { useGiftCardPageContext } from '../composables/useGiftCardPage'
|
||||||
|
|
||||||
|
withDefaults(defineProps<{ variant?: 'mobile' | 'desktop' }>(), { variant: 'mobile' })
|
||||||
|
|
||||||
|
const { form, disableButton, registerGiftCard } = useGiftCardPageContext()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.gift-card-form__hint,
|
||||||
|
.gift-card-form__case-note {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.65;
|
||||||
|
word-break: break-word;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gift-card-form__hint {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gift-card-form__case-note {
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import { computed, inject, provide, ref, type InjectionKey } from 'vue'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { registerCodeGiftCard } from '@/api/giftCard'
|
||||||
|
import { loading } from '@/utils'
|
||||||
|
|
||||||
|
export interface GiftCardPageContext {
|
||||||
|
form: ReturnType<typeof ref<{ code: string }>>
|
||||||
|
disableButton: ReturnType<typeof computed<boolean>>
|
||||||
|
registerGiftCard: () => Promise<void>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GIFT_CARD_PAGE_CONTEXT_KEY: InjectionKey<GiftCardPageContext> = Symbol('giftCardPageContext')
|
||||||
|
|
||||||
|
export function useGiftCardPage() {
|
||||||
|
const form = ref({ code: '' })
|
||||||
|
|
||||||
|
const disableButton = computed(() => {
|
||||||
|
if (loading.value) return true
|
||||||
|
return !form.value.code || form.value.code.trim().length === 0
|
||||||
|
})
|
||||||
|
|
||||||
|
async function registerGiftCard() {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
await registerCodeGiftCard(form.value.code)
|
||||||
|
message.success('کد کارت هدیه با موفقیت ثبت شد')
|
||||||
|
form.value.code = ''
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const context: GiftCardPageContext = { form, disableButton, registerGiftCard }
|
||||||
|
provide(GIFT_CARD_PAGE_CONTEXT_KEY, context)
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGiftCardPageContext() {
|
||||||
|
const context = inject(GIFT_CARD_PAGE_CONTEXT_KEY)
|
||||||
|
if (!context) throw new Error('useGiftCardPageContext must be used within useGiftCardPage')
|
||||||
|
return context
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dgift gift-card-page">
|
||||||
|
<div class="dgift__container">
|
||||||
|
<DesktopPageTopbar eyebrow="مالی" title="کارت هدیه" show-back sticky />
|
||||||
|
|
||||||
|
<div class="dgift-layout">
|
||||||
|
<section class="dgift-surface dgift-form">
|
||||||
|
<div class="dgift-form__header">
|
||||||
|
<div class="dgift-form__icon">
|
||||||
|
<BasicIcon icon="vuesax-linear:gift" size="28" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2 class="dgift-form__title">ثبت کد کارت هدیه</h2>
|
||||||
|
<p class="dgift-form__subtitle">کد دریافتی خود را وارد کنید تا اعتبار به حساب شما اضافه شود</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<GiftCardForm variant="desktop" />
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<aside class="dgift-surface dgift-guide">
|
||||||
|
<h3 class="dgift-guide__title">راهنمای استفاده</h3>
|
||||||
|
<ol class="dgift-guide__steps">
|
||||||
|
<li>کد کارت هدیه را از پیامک یا کارت فیزیکی دریافت کنید.</li>
|
||||||
|
<li>کد را بدون فاصله اضافی در فیلد مربوطه وارد کنید.</li>
|
||||||
|
<li>روی «ثبت کد» بزنید و پیام تأیید را بررسی کنید.</li>
|
||||||
|
</ol>
|
||||||
|
<div class="dgift-guide__note">
|
||||||
|
<BasicIcon icon="vuesax-linear:info-circle" size="18" />
|
||||||
|
<p>هر کد فقط یکبار قابل استفاده است و پس از ثبت موفق، موجودی کیف پول بهروزرسانی میشود.</p>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
|
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
|
||||||
|
import GiftCardForm from '../components/GiftCardForm.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" src="./styles/desktop-gift-card.less"></style>
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
/* Premium desktop gift card page */
|
||||||
|
|
||||||
|
.dgift {
|
||||||
|
min-height: 100%;
|
||||||
|
background: #f6f7f9;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dgift__container {
|
||||||
|
max-width: 960px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 28px 36px 40px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dgift-layout {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
|
||||||
|
gap: 20px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dgift-surface {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dgift-form {
|
||||||
|
padding: 28px;
|
||||||
|
|
||||||
|
&__header {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
border-bottom: 1px solid #eef0f3;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
border-radius: 14px;
|
||||||
|
background: rgba(167, 43, 119, 0.08);
|
||||||
|
color: @theme-primary;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #111827;
|
||||||
|
margin: 0 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__subtitle {
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #6b7280;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__hint {
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: #6b7280;
|
||||||
|
margin: 0 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__case-note {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #9ca3af;
|
||||||
|
margin: 0 0 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__submit {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 44px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dgift-guide {
|
||||||
|
padding: 24px;
|
||||||
|
position: sticky;
|
||||||
|
top: 88px;
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111827;
|
||||||
|
margin: 0 0 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__steps {
|
||||||
|
margin: 0 0 20px;
|
||||||
|
padding: 0 20px 0 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: #4b5563;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__note {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: flex-start;
|
||||||
|
padding: 14px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: #f9fafb;
|
||||||
|
border: 1px solid #eef0f3;
|
||||||
|
color: #6b7280;
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.basic-icon {
|
||||||
|
color: @theme-primary;
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1023.98px) {
|
||||||
|
.dgift-layout {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dgift-guide {
|
||||||
|
position: static;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,81 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="gift-card-page-root">
|
||||||
<div class="bg-white py-3 px-3 text-black font-bold drop-shadow z-[1999] wrap-fix">کارت هدیه</div>
|
<DesktopGiftCardView v-show="isDesktop" />
|
||||||
<div class="px-5 pt-26 pb-2">
|
<MobileGiftCardView v-show="!isDesktop" />
|
||||||
<a-form :model="form" class="!mt-5" name="basic" @finish="registerGiftCard">
|
|
||||||
<div class="border-gray-200 border-1 rounded-xl p-5 trans h-40 relative">
|
|
||||||
<bg_main/>
|
|
||||||
<div class="z-100 relative">
|
|
||||||
<a-form-item :rules="[required()]" label="کد کارت هدیه" name="code">
|
|
||||||
<BasicInput
|
|
||||||
v-model:value="form.code"
|
|
||||||
place-holder="کد کارت هدیه را وارد کنید"
|
|
||||||
size="large"
|
|
||||||
type="text"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
<div class="font-bold text-xs mt-1">
|
|
||||||
کد کارت هدیه خود را در فیلد بالا وارد کنید و سپس دکمه ثبت را بزنید.
|
|
||||||
</div>
|
|
||||||
<div class="font-bold text-xs mt-3">
|
|
||||||
*حساس به حروف بزرگ و کوچک
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a-form-item>
|
|
||||||
<BasicButton
|
|
||||||
:disabled="disableButton"
|
|
||||||
class="w-full py-2 mt-5"
|
|
||||||
html-type="submit"
|
|
||||||
type="primary"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<a-spin v-if="loading" size="small"/>
|
|
||||||
<div v-else>ثبت کد</div>
|
|
||||||
</div>
|
|
||||||
</BasicButton>
|
|
||||||
</a-form-item>
|
|
||||||
</a-form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, ref} from 'vue'
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
import {loading} from '@/utils'
|
import { useGiftCardPage } from './composables/useGiftCardPage'
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
import DesktopGiftCardView from './desktop/DesktopGiftCardView.vue'
|
||||||
import Bg_main from '@/components/bg_main.vue'
|
import MobileGiftCardView from './mobile/MobileGiftCardView.vue'
|
||||||
import {registerCodeGiftCard} from '@/api/giftCard'
|
|
||||||
import {message} from 'ant-design-vue'
|
|
||||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
|
||||||
import {required} from '@/utils/inputRules'
|
|
||||||
|
|
||||||
const form = ref<{ code: string }>({
|
const isDesktop = useDesktopBreakpoint()
|
||||||
code: ''
|
useGiftCardPage()
|
||||||
})
|
|
||||||
|
|
||||||
const disableButton = computed(() => {
|
|
||||||
if (!loading.value) {
|
|
||||||
return !form.value.code || form.value.code.trim().length === 0
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
async function registerGiftCard() {
|
|
||||||
try {
|
|
||||||
loading.value = true
|
|
||||||
await registerCodeGiftCard(form.value.code)
|
|
||||||
message.success('کد کارت هدیه با موفقیت ثبت شد')
|
|
||||||
form.value.code = ''
|
|
||||||
} catch (e: any) {
|
|
||||||
// message.error(e?.response?.data?.message || 'خطا در ثبت کد کارت هدیه')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.gift-card-page-root {
|
||||||
|
min-height: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user