Compare commits
6
Commits
main-test
...
a5c714a15b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5c714a15b | ||
|
|
5d390fb225 | ||
|
|
51e3c3f0cb | ||
|
|
e4d92831c2 | ||
|
|
3561e8ae07 | ||
|
|
ce8029919c |
Vendored
+2
@@ -64,6 +64,8 @@ declare module 'vue' {
|
|||||||
Size: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/size.vue')['default']
|
Size: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/size.vue')['default']
|
||||||
StartEnd: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/start-end.vue')['default']
|
StartEnd: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/start-end.vue')['default']
|
||||||
Suffix: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/suffix.vue')['default']
|
Suffix: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/suffix.vue')['default']
|
||||||
|
SupportMessengerBrandIcon: typeof import('./src/components/SupportMessengerBrandIcon.vue')['default']
|
||||||
|
SupportMessengerPicker: typeof import('./src/components/SupportMessengerPicker.vue')['default']
|
||||||
Switchable: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/switchable.vue')['default']
|
Switchable: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/switchable.vue')['default']
|
||||||
Text: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/text.vue')['default']
|
Text: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/text.vue')['default']
|
||||||
Time: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/time.vue')['default']
|
Time: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/time.vue')['default']
|
||||||
|
|||||||
+16
-2
@@ -326,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() {
|
||||||
@@ -453,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 {
|
||||||
@@ -496,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -626,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()
|
||||||
|
|||||||
+54
-45
@@ -48,8 +48,9 @@
|
|||||||
<div
|
<div
|
||||||
v-if="showSupportButton && !showSplash"
|
v-if="showSupportButton && !showSplash"
|
||||||
id="support-button"
|
id="support-button"
|
||||||
|
ref="supportButtonEl"
|
||||||
class="draggable-support-button"
|
class="draggable-support-button"
|
||||||
:class="{ 'is-dragging': supportDragging }"
|
:class="{ 'is-dragging': supportDragging, 'is-picker-open': supportPickerOpen }"
|
||||||
:style="supportButtonStyle"
|
:style="supportButtonStyle"
|
||||||
title="پشتیبانی"
|
title="پشتیبانی"
|
||||||
@pointerdown="onSupportPointerDown"
|
@pointerdown="onSupportPointerDown"
|
||||||
@@ -63,6 +64,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<SupportMessengerPicker
|
||||||
|
v-model:open="supportPickerOpen"
|
||||||
|
:entries="supportMessengerEntries"
|
||||||
|
:anchor-el="supportButtonEl"
|
||||||
|
@select="openSupportMessengerEntry"
|
||||||
|
/>
|
||||||
|
|
||||||
<VersionUpdateModal />
|
<VersionUpdateModal />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -77,10 +85,13 @@ 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 BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
import {
|
import {
|
||||||
buildSupportMessengerUrl,
|
|
||||||
loadSupportMessengerFromSettings,
|
loadSupportMessengerFromSettings,
|
||||||
|
openSupportMessengerEntry,
|
||||||
|
resolveSupportMessengerEntries,
|
||||||
|
supportMessengerPickerOpen,
|
||||||
supportMessengerSettings,
|
supportMessengerSettings,
|
||||||
} from '@/utils/supportMessenger'
|
} from '@/utils/supportMessenger'
|
||||||
|
import SupportMessengerPicker from '@/components/SupportMessengerPicker.vue'
|
||||||
import { useDraggableFloatingButton } from '@/utils/useDraggableFloatingButton'
|
import { useDraggableFloatingButton } from '@/utils/useDraggableFloatingButton'
|
||||||
import { useApplyDesktopLayoutClass } from '@/layouts/composables/useAppLayout'
|
import { useApplyDesktopLayoutClass } from '@/layouts/composables/useAppLayout'
|
||||||
|
|
||||||
@@ -102,48 +113,41 @@ const showSplash = ref(true)
|
|||||||
|
|
||||||
useApplyDesktopLayoutClass()
|
useApplyDesktopLayoutClass()
|
||||||
|
|
||||||
const supportLink = computed(() =>
|
const supportButtonEl = ref<HTMLElement | null>(null)
|
||||||
buildSupportMessengerUrl(
|
const supportPickerOpen = supportMessengerPickerOpen
|
||||||
supportMessengerSettings.value.messenger,
|
|
||||||
supportMessengerSettings.value.messengerId
|
const supportMessengerEntries = computed(() =>
|
||||||
)
|
resolveSupportMessengerEntries(supportMessengerSettings.value),
|
||||||
)
|
)
|
||||||
|
|
||||||
const showSupportButton = computed(() => !!supportLink.value)
|
const showSupportButton = computed(() => supportMessengerEntries.value.length > 0)
|
||||||
|
|
||||||
const supportIcon = computed(() => {
|
const primaryEntry = computed(() => supportMessengerEntries.value[0] ?? null)
|
||||||
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 supportIcon = computed(() => primaryEntry.value?.icon ?? 'vuesax-linear:messages-2')
|
||||||
const messenger = (supportMessengerSettings.value.messenger ?? '').toLowerCase()
|
|
||||||
switch (messenger) {
|
const supportAccentColor = computed(() =>
|
||||||
case 'whatsapp':
|
(primaryEntry.value?.accent ?? colors.primary) || '#334155',
|
||||||
return '#22c55e'
|
)
|
||||||
case 'telegram':
|
|
||||||
return '#0ea5e9'
|
let supportPickerOpenedAt = 0
|
||||||
case 'bale':
|
|
||||||
return '#16a34a'
|
function openSupportLink() {
|
||||||
case 'rubika':
|
const entries = supportMessengerEntries.value
|
||||||
return '#7c3aed'
|
if (entries.length === 0) return
|
||||||
case 'eitaa':
|
if (entries.length === 1) {
|
||||||
return '#f59e0b'
|
void openSupportMessengerEntry(entries[0])
|
||||||
case 'soroush':
|
return
|
||||||
return '#2563eb'
|
|
||||||
default:
|
|
||||||
return colors.primary || '#334155'
|
|
||||||
}
|
}
|
||||||
})
|
const now = Date.now()
|
||||||
|
if (supportPickerOpen.value) {
|
||||||
|
if (now - supportPickerOpenedAt < 450) return
|
||||||
|
supportPickerOpen.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
supportPickerOpen.value = true
|
||||||
|
supportPickerOpenedAt = now
|
||||||
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
dragging: supportDragging,
|
dragging: supportDragging,
|
||||||
@@ -159,15 +163,15 @@ const {
|
|||||||
defaultRightOffset: 16,
|
defaultRightOffset: 16,
|
||||||
})
|
})
|
||||||
|
|
||||||
function openSupportLink() {
|
function openSupportLinkHandler() {
|
||||||
if (!supportLink.value) return
|
openSupportLink()
|
||||||
window.open(supportLink.value, '_blank', 'noopener,noreferrer')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSupportPointerUp(event: PointerEvent) {
|
function handleSupportPointerUp(event: PointerEvent) {
|
||||||
if (supportPointerUp(event)) {
|
const clicked = supportPointerUp(event)
|
||||||
openSupportLink()
|
if (!clicked) return
|
||||||
}
|
event.stopPropagation()
|
||||||
|
openSupportLinkHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
@@ -232,4 +236,9 @@ onMounted(async () => {
|
|||||||
#support-button.is-dragging .support-button-inner {
|
#support-button.is-dragging .support-button-inner {
|
||||||
box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
|
box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#support-button.is-picker-open .support-button-inner {
|
||||||
|
transform: scale(0.94);
|
||||||
|
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+1
-10
@@ -2,7 +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 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 {
|
||||||
@@ -17,7 +16,6 @@ import { recoverMobileViewportAfterAuth } from '@/layouts/composables/useMobileS
|
|||||||
|
|
||||||
export function setupRouterGuards() {
|
export function setupRouterGuards() {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const walletStore = useWalletStore()
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
const isApple: boolean = isIphone()
|
const isApple: boolean = isIphone()
|
||||||
@@ -30,16 +28,9 @@ export function setupRouterGuards() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const tasks: Promise<unknown>[] = [
|
|
||||||
walletStore.getLimitedPrice(),
|
|
||||||
walletStore.getLimitedBuyGold(),
|
|
||||||
]
|
|
||||||
|
|
||||||
if (!userStore.userInfo) {
|
if (!userStore.userInfo) {
|
||||||
tasks.push(userStore.getMyInfo())
|
await userStore.getMyInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(tasks)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
@import (less) '../../views/base/user/desktop/styles/desktop-user.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/priceTrigger/desktop/styles/desktop-price-trigger.less';
|
||||||
@import (less) '../../views/base/home/desktop/styles/desktop-home.less';
|
@import (less) '../../views/base/home/desktop/styles/desktop-home.less';
|
||||||
|
@import (less) '../../views/login/desktop/styles/desktop-login.less';
|
||||||
@import (less) '../../layouts/desktop/styles/desktop-inner-pages.less';
|
@import (less) '../../layouts/desktop/styles/desktop-inner-pages.less';
|
||||||
|
|
||||||
html {
|
html {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,7 @@
|
|||||||
|
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="48" height="48" rx="12" fill="#1CA0E2"/>
|
||||||
|
<g transform="translate(12 12)">
|
||||||
|
<path d="M14.4501 0.922337C14.4249 0.922337 14.3996 0.922337 14.3749 0.922337C13.9177 0.865759 13.4564 0.848106 12.9962 0.869568C12.3937 0.891042 11.7968 0.992415 11.2211 1.17103C10.5799 1.36599 9.98324 1.6851 9.46511 2.11021C9.27918 2.26684 9.10383 2.43563 8.94023 2.61545C8.62473 2.95789 8.39401 3.35478 8.19696 3.77245C8.09086 3.997 7.99543 4.22773 7.8955 4.45565C7.88203 4.48764 7.8708 4.5202 7.86014 4.55333C7.82589 4.66167 7.79558 4.77114 7.75853 4.87836C7.65492 5.2025 7.5737 5.53337 7.51545 5.86863C7.45552 6.17826 7.41539 6.4914 7.39532 6.80613C7.37904 7.03574 7.36669 7.2659 7.36613 7.49607C7.36593 7.89339 7.3888 8.29039 7.43461 8.68506C7.49075 9.19592 7.58787 9.70059 7.69341 10.2036C7.81298 10.7756 7.99094 11.3303 8.1644 11.8877C8.33787 12.4452 8.5394 12.9847 8.73757 13.5297C8.89756 13.9716 9.04576 14.4167 9.16702 14.8709C9.24027 15.1385 9.29245 15.4114 9.32309 15.6871C9.37053 16.0792 9.35422 16.4763 9.27481 16.8632C9.26358 16.9126 9.25179 16.9614 9.23719 17.0097C9.17854 17.206 9.10843 17.3987 9.02724 17.5868C8.97171 17.7142 8.90383 17.8359 8.82458 17.95C8.54294 18.3624 8.19617 18.7262 7.79782 19.0273C7.33066 19.3746 6.78803 19.6066 6.21418 19.7043C5.97198 19.7479 5.72653 19.7708 5.48046 19.7728C4.65255 19.785 3.84735 19.5021 3.20913 18.9745C3.06738 18.8636 2.93586 18.7402 2.81616 18.6057C2.79988 18.5866 2.78024 18.5704 2.76003 18.553C2.73982 18.5355 2.73701 18.5479 2.72578 18.553C2.70445 18.5423 2.69715 18.5198 2.68536 18.5019C2.53435 18.2655 2.37492 18.0348 2.23289 17.7923C2.02466 17.4393 1.83484 17.0758 1.66422 16.7032C1.4634 16.2612 1.29071 15.8068 1.14719 15.343C1.028 14.9577 0.929988 14.5662 0.853591 14.1703C0.802506 13.9081 0.760402 13.6437 0.730649 13.3776C0.707633 13.171 0.686862 12.9644 0.674512 12.7567C0.663846 12.6024 0.663846 12.448 0.655425 12.2942C0.647566 12.1645 0.644197 12.0354 0.647004 11.9062C0.650934 11.7204 0.654302 11.5341 0.666091 11.3488C0.679564 11.1349 0.696405 10.921 0.722229 10.7088C0.800805 10.0199 0.942301 9.33971 1.14495 8.67664C1.27499 8.25508 1.42887 7.84124 1.60584 7.43712C1.89207 6.78413 2.23982 6.15987 2.64438 5.57279C3.12563 4.87288 3.68354 4.22892 4.30774 3.65288C5.11591 2.9082 6.02747 2.28423 7.01414 1.80033C7.73201 1.44668 8.48602 1.17169 9.26302 0.980159C9.59984 0.898198 9.93667 0.829149 10.2814 0.776941C10.4554 0.750369 10.6303 0.728288 10.8062 0.710698C10.9943 0.691611 11.1829 0.681506 11.371 0.663542C11.4367 0.657367 11.5035 0.65849 11.5697 0.657367C11.9065 0.649508 12.2383 0.649508 12.5723 0.661297C12.7015 0.665788 12.83 0.681506 12.9586 0.69105C13.0338 0.696664 13.109 0.703962 13.1831 0.711259C13.4533 0.737083 13.7213 0.774508 13.987 0.823535C14.1229 0.848797 14.2587 0.875743 14.3951 0.901566C14.4154 0.901603 14.4349 0.908983 14.4501 0.922337Z" fill="#ffffff"/>
|
||||||
|
<path d="M5.25874 21.1173C5.27981 21.122 5.29921 21.1323 5.31488 21.1471C5.63283 21.3639 5.96476 21.5595 6.30852 21.7326C6.92863 22.0651 7.58142 22.3326 8.2565 22.5309C8.68006 22.6535 9.11143 22.7472 9.54766 22.8116C10.1444 22.8977 10.748 22.9264 11.3502 22.8974C11.7252 22.8804 12.0987 22.8397 12.4685 22.7756C12.6768 22.7403 12.8834 22.6976 13.0894 22.6516C13.6547 22.5202 14.2077 22.3411 14.7426 22.116C15.2004 21.927 15.6441 21.7057 16.0703 21.4536C16.5961 21.1443 17.0675 20.7507 17.4659 20.2887C17.8669 19.8343 18.2251 19.3438 18.5359 18.8235C19.0119 18.0108 19.35 17.1247 19.5362 16.2013C19.5979 15.8984 19.6419 15.5921 19.6682 15.2841C19.6987 14.9384 19.7084 14.5912 19.6974 14.2444C19.6623 13.1958 19.4489 12.1608 19.0664 11.1838C18.9917 10.9929 18.9131 10.8037 18.8351 10.614C18.8194 10.5763 18.8008 10.5399 18.7818 10.5017C18.4002 9.77858 17.9286 9.1067 17.3783 8.50205C17.0213 8.10516 16.6334 7.7397 16.2449 7.37481C15.9642 7.1132 15.6661 6.87687 15.3658 6.64109C15.1553 6.47267 14.938 6.31829 14.7365 6.1409C14.6708 6.07719 14.6006 6.01828 14.5265 5.96463C14.5033 5.94836 14.482 5.92953 14.4631 5.90849C14.3716 5.81306 14.2778 5.71931 14.1897 5.62106C13.9048 5.30938 13.7133 4.9238 13.6373 4.50841C13.5599 4.04993 13.605 3.57914 13.7681 3.14371C14.0347 2.46051 14.5209 2.00355 15.2063 1.7571C15.6623 1.58876 16.1576 1.55753 16.6311 1.66728C16.6586 1.67346 16.6873 1.67683 16.7148 1.68132C16.716 1.68322 16.7176 1.68484 16.7195 1.68607C16.7214 1.68729 16.7235 1.68809 16.7258 1.68841C16.728 1.68873 16.7303 1.68856 16.7325 1.68792C16.7346 1.68728 16.7366 1.68617 16.7383 1.68469C16.8039 1.70602 16.8668 1.73484 16.9258 1.77058C17.6094 2.10085 18.2582 2.4986 18.8626 2.95789C19.1186 3.1525 19.366 3.35834 19.6047 3.57541C19.8577 3.8037 20.1001 4.04303 20.3317 4.29341C21.5814 5.64007 22.4838 7.27123 22.9606 9.04547C23.0482 9.37163 23.1201 9.70059 23.1801 10.0324C23.2149 10.2277 23.2434 10.424 23.2655 10.6213C23.2885 10.8312 23.3087 11.0412 23.3216 11.2517C23.3312 11.3836 23.3345 11.5161 23.339 11.6486C23.3424 11.7608 23.3508 11.8686 23.3491 11.9792C23.3463 12.1998 23.3441 12.421 23.33 12.6411C23.3147 12.8858 23.2926 13.1304 23.2638 13.3748C23.0982 14.7647 22.6752 16.1116 22.0164 17.3466C21.8345 17.6892 21.6334 18.0213 21.4141 18.3413C21.3957 18.3665 21.3825 18.3952 21.3754 18.4255C21.3682 18.4559 21.3673 18.4874 21.3725 18.5181C21.3966 18.677 21.4185 18.8359 21.4404 18.9953C21.4623 19.1547 21.4837 19.3198 21.505 19.482C21.528 19.6566 21.551 19.8318 21.5735 20.0064C21.5886 20.1287 21.6016 20.2506 21.6167 20.3724C21.633 20.5071 21.6509 20.6413 21.6672 20.7754C21.6835 20.9096 21.6975 21.032 21.7127 21.16C21.7279 21.288 21.7413 21.4042 21.7565 21.526C21.7722 21.6574 21.789 21.7887 21.8053 21.919C21.8233 22.0627 21.8407 22.207 21.8581 22.3507C21.8733 22.4759 21.8873 22.6005 21.9019 22.7257C21.9097 22.7913 21.9182 22.857 21.926 22.9227C21.9339 22.9884 21.9182 23.0064 21.8463 22.9884C21.7851 22.9732 21.7245 22.9558 21.6639 22.9396L20.2486 22.5612C19.7995 22.4416 19.3538 22.3232 18.9069 22.2025C18.5662 22.111 18.226 22.0166 17.8858 21.9218C17.8224 21.9044 17.7578 21.8881 17.6949 21.8656C17.6773 21.8594 17.6585 21.8573 17.6399 21.8594C17.6213 21.8616 17.6035 21.8679 17.5877 21.878C17.3474 22.0172 17.0993 22.1424 16.8489 22.262C16.493 22.4309 16.1283 22.5808 15.7565 22.7111C15.361 22.8498 14.958 22.9664 14.5495 23.0602C14.3008 23.1164 14.051 23.1686 13.7984 23.204C13.6395 23.2264 13.4812 23.255 13.3218 23.2724C13.1467 23.291 12.9709 23.3073 12.7947 23.319C12.4674 23.3404 12.1395 23.3544 11.8117 23.3482C11.6444 23.3449 11.4775 23.3385 11.3109 23.3291C11.1599 23.3202 11.0089 23.3089 10.8585 23.2921C10.6429 23.2674 10.4273 23.241 10.2129 23.2068C9.96701 23.1675 9.72281 23.122 9.4831 23.067C8.84985 22.9227 8.23008 22.7246 7.63056 22.4747C7.28999 22.3321 6.9571 22.1735 6.63187 21.9987C6.17367 21.752 5.73289 21.4742 5.31264 21.1673C5.28962 21.1555 5.26492 21.1448 5.25874 21.1173Z" fill="#ffffff"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.7 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 256"><defs><linearGradient id="SVG6DaOZcwt" x1="50%" x2="50%" y1="0%" y2="100%"><stop offset="0%" stop-color="#2aabee"/><stop offset="100%" stop-color="#229ed9"/></linearGradient></defs><path fill="url(#SVG6DaOZcwt)" d="M128 0C94.06 0 61.48 13.494 37.5 37.49A128.04 128.04 0 0 0 0 128c0 33.934 13.5 66.514 37.5 90.51C61.48 242.506 94.06 256 128 256s66.52-13.494 90.5-37.49c24-23.996 37.5-56.576 37.5-90.51s-13.5-66.514-37.5-90.51C194.52 13.494 161.94 0 128 0"/><path fill="#fff" d="M57.94 126.648q55.98-24.384 74.64-32.152c35.56-14.786 42.94-17.354 47.76-17.441c1.06-.017 3.42.245 4.96 1.49c1.28 1.05 1.64 2.47 1.82 3.467c.16.996.38 3.266.2 5.038c-1.92 20.24-10.26 69.356-14.5 92.026c-1.78 9.592-5.32 12.808-8.74 13.122c-7.44.684-13.08-4.912-20.28-9.63c-11.26-7.386-17.62-11.982-28.56-19.188c-12.64-8.328-4.44-12.906 2.76-20.386c1.88-1.958 34.64-31.748 35.26-34.45c.08-.338.16-1.598-.6-2.262c-.74-.666-1.84-.438-2.64-.258c-1.14.256-19.12 12.152-54 35.686c-5.1 3.508-9.72 5.218-13.88 5.128c-4.56-.098-13.36-2.584-19.9-4.708c-8-2.606-14.38-3.984-13.82-8.41c.28-2.304 3.46-4.662 9.52-7.072"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 258"><defs><linearGradient id="SVGK3KZq49U" x1="50%" x2="50%" y1="100%" y2="0%"><stop offset="0%" stop-color="#1faf38"/><stop offset="100%" stop-color="#60d669"/></linearGradient><linearGradient id="SVGefMkoEOd" x1="50%" x2="50%" y1="100%" y2="0%"><stop offset="0%" stop-color="#f9f9f9"/><stop offset="100%" stop-color="#fff"/></linearGradient></defs><path fill="url(#SVGK3KZq49U)" d="M5.463 127.456c-.006 21.677 5.658 42.843 16.428 61.499L4.433 252.697l65.232-17.104a123 123 0 0 0 58.8 14.97h.054c67.815 0 123.018-55.183 123.047-123.01c.013-32.867-12.775-63.773-36.009-87.025c-23.23-23.25-54.125-36.061-87.043-36.076c-67.823 0-123.022 55.18-123.05 123.004"/><path fill="url(#SVGefMkoEOd)" d="M1.07 127.416c-.007 22.457 5.86 44.38 17.014 63.704L0 257.147l67.571-17.717c18.618 10.151 39.58 15.503 60.91 15.511h.055c70.248 0 127.434-57.168 127.464-127.423c.012-34.048-13.236-66.065-37.3-90.15C194.633 13.286 162.633.014 128.536 0C58.276 0 1.099 57.16 1.071 127.416m40.24 60.376l-2.523-4.005c-10.606-16.864-16.204-36.352-16.196-56.363C22.614 69.029 70.138 21.52 128.576 21.52c28.3.012 54.896 11.044 74.9 31.06c20.003 20.018 31.01 46.628 31.003 74.93c-.026 58.395-47.551 105.91-105.943 105.91h-.042c-19.013-.01-37.66-5.116-53.922-14.765l-3.87-2.295l-40.098 10.513z"/><path fill="#fff" d="M96.678 74.148c-2.386-5.303-4.897-5.41-7.166-5.503c-1.858-.08-3.982-.074-6.104-.074c-2.124 0-5.575.799-8.492 3.984c-2.92 3.188-11.148 10.892-11.148 26.561s11.413 30.813 13.004 32.94c1.593 2.123 22.033 35.307 54.405 48.073c26.904 10.609 32.379 8.499 38.218 7.967c5.84-.53 18.844-7.702 21.497-15.139c2.655-7.436 2.655-13.81 1.859-15.142c-.796-1.327-2.92-2.124-6.105-3.716s-18.844-9.298-21.763-10.361c-2.92-1.062-5.043-1.592-7.167 1.597c-2.124 3.184-8.223 10.356-10.082 12.48c-1.857 2.129-3.716 2.394-6.9.801c-3.187-1.598-13.444-4.957-25.613-15.806c-9.468-8.442-15.86-18.867-17.718-22.056c-1.858-3.184-.199-4.91 1.398-6.497c1.431-1.427 3.186-3.719 4.78-5.578c1.588-1.86 2.118-3.187 3.18-5.311c1.063-2.126.531-3.986-.264-5.579c-.798-1.593-6.987-17.343-9.819-23.64"/></svg>
|
||||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -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,68 @@
|
|||||||
|
<template>
|
||||||
|
<span
|
||||||
|
class="support-brand-icon"
|
||||||
|
:class="{ 'support-brand-icon--eitaa': normalized === 'eitaa' }"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="logoSrc"
|
||||||
|
:src="logoSrc"
|
||||||
|
:alt="normalized"
|
||||||
|
class="support-brand-icon__img"
|
||||||
|
draggable="false"
|
||||||
|
/>
|
||||||
|
<svg v-else viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" class="support-brand-icon__svg">
|
||||||
|
<circle cx="24" cy="24" r="24" fill="#64748B" />
|
||||||
|
<path fill="#fff" d="M16 18h16v2H16v-2zm0 5h16v2H16v-2zm0 5h10v2H16v-2z" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import baleLogo from '@/assets/messengers/bale.png'
|
||||||
|
import eitaaLogo from '@/assets/messengers/eitaa.png'
|
||||||
|
import rubikaLogo from '@/assets/messengers/rubika.png'
|
||||||
|
import soroushLogo from '@/assets/messengers/soroush.svg'
|
||||||
|
import telegramLogo from '@/assets/messengers/telegram.svg'
|
||||||
|
import whatsappLogo from '@/assets/messengers/whatsapp.svg'
|
||||||
|
|
||||||
|
const LOGOS: Record<string, string> = {
|
||||||
|
bale: baleLogo,
|
||||||
|
telegram: telegramLogo,
|
||||||
|
whatsapp: whatsappLogo,
|
||||||
|
rubika: rubikaLogo,
|
||||||
|
eitaa: eitaaLogo,
|
||||||
|
soroush: soroushLogo,
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<{ messenger: string }>()
|
||||||
|
const normalized = computed(() => (props.messenger ?? '').trim().toLowerCase())
|
||||||
|
const logoSrc = computed(() => LOGOS[normalized.value])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.support-brand-icon {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-brand-icon--eitaa {
|
||||||
|
background: #e37600;
|
||||||
|
|
||||||
|
.support-brand-icon__img {
|
||||||
|
filter: brightness(0) invert(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-brand-icon__img,
|
||||||
|
.support-brand-icon__svg {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,293 @@
|
|||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<Transition name="support-picker-backdrop">
|
||||||
|
<div
|
||||||
|
v-if="open"
|
||||||
|
class="support-messenger-picker__backdrop"
|
||||||
|
:class="{ 'is-active': backdropActive }"
|
||||||
|
@click="onBackdropClick"
|
||||||
|
/>
|
||||||
|
</Transition>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-show="open || closing"
|
||||||
|
class="support-messenger-picker__stack"
|
||||||
|
:class="[
|
||||||
|
{ 'is-open': open },
|
||||||
|
expandUp ? 'support-messenger-picker__stack--up' : 'support-messenger-picker__stack--down',
|
||||||
|
]"
|
||||||
|
:style="stackStyle"
|
||||||
|
role="menu"
|
||||||
|
aria-label="انتخاب پیامرسان"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
v-for="(entry, index) in entries"
|
||||||
|
:key="`${entry.messenger}-${entry.id}`"
|
||||||
|
type="button"
|
||||||
|
class="support-messenger-picker__btn"
|
||||||
|
:style="{ '--i': index, '--total': entries.length }"
|
||||||
|
:title="entry.label"
|
||||||
|
:aria-label="entry.label"
|
||||||
|
@click.stop="select(entry)"
|
||||||
|
>
|
||||||
|
<SupportMessengerBrandIcon :messenger="entry.messenger" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
||||||
|
import SupportMessengerBrandIcon from '@/components/SupportMessengerBrandIcon.vue'
|
||||||
|
import type { ResolvedSupportMessengerEntry } from '@/utils/supportMessenger'
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
open: boolean
|
||||||
|
entries: ResolvedSupportMessengerEntry[]
|
||||||
|
anchorEl?: HTMLElement | null
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
anchorEl: null,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:open': [value: boolean]
|
||||||
|
select: [entry: ResolvedSupportMessengerEntry]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const BTN_SIZE = 46
|
||||||
|
const GAP = 12
|
||||||
|
const STACK_GAP = 10
|
||||||
|
const CLOSE_MS = 220
|
||||||
|
const BACKDROP_GUARD_MS = 380
|
||||||
|
|
||||||
|
const stackStyle = ref<Record<string, string>>({})
|
||||||
|
const closing = ref(false)
|
||||||
|
const expandUp = ref(true)
|
||||||
|
const backdropActive = ref(false)
|
||||||
|
let closeTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
|
let backdropTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
emit('update:open', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
function select(entry: ResolvedSupportMessengerEntry) {
|
||||||
|
emit('select', entry)
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearTimers() {
|
||||||
|
if (closeTimer) {
|
||||||
|
clearTimeout(closeTimer)
|
||||||
|
closeTimer = null
|
||||||
|
}
|
||||||
|
if (backdropTimer) {
|
||||||
|
clearTimeout(backdropTimer)
|
||||||
|
backdropTimer = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onBackdropClick() {
|
||||||
|
if (!backdropActive.value) return
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
|
||||||
|
function armBackdropGuard() {
|
||||||
|
backdropActive.value = false
|
||||||
|
if (backdropTimer) clearTimeout(backdropTimer)
|
||||||
|
backdropTimer = setTimeout(() => {
|
||||||
|
backdropActive.value = true
|
||||||
|
backdropTimer = null
|
||||||
|
}, BACKDROP_GUARD_MS)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reposition() {
|
||||||
|
await nextTick()
|
||||||
|
|
||||||
|
const anchor = props.anchorEl
|
||||||
|
const count = props.entries.length
|
||||||
|
if (!anchor || count === 0) {
|
||||||
|
expandUp.value = true
|
||||||
|
stackStyle.value = {
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
right: 'auto',
|
||||||
|
bottom: 'auto',
|
||||||
|
'--stack-rise': '56px',
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const rect = anchor.getBoundingClientRect()
|
||||||
|
const stackHeight = count * BTN_SIZE + Math.max(0, count - 1) * GAP
|
||||||
|
const anchorCenterX = rect.left + rect.width / 2
|
||||||
|
const anchorCenterY = rect.top + rect.height / 2
|
||||||
|
const right = Math.max(12, window.innerWidth - anchorCenterX - BTN_SIZE / 2)
|
||||||
|
|
||||||
|
expandUp.value = anchorCenterY > window.innerHeight / 2
|
||||||
|
|
||||||
|
if (expandUp.value) {
|
||||||
|
const bottom = Math.max(12, window.innerHeight - rect.top + STACK_GAP)
|
||||||
|
stackStyle.value = {
|
||||||
|
right: `${right}px`,
|
||||||
|
bottom: `${bottom}px`,
|
||||||
|
left: 'auto',
|
||||||
|
top: 'auto',
|
||||||
|
transform: 'none',
|
||||||
|
'--stack-rise': `${Math.min(stackHeight + 6, 220)}px`,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const top = Math.max(12, rect.bottom + STACK_GAP)
|
||||||
|
stackStyle.value = {
|
||||||
|
right: `${right}px`,
|
||||||
|
top: `${top}px`,
|
||||||
|
left: 'auto',
|
||||||
|
bottom: 'auto',
|
||||||
|
transform: 'none',
|
||||||
|
'--stack-rise': `${Math.min(stackHeight + 6, 220)}px`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.open,
|
||||||
|
(isOpen) => {
|
||||||
|
clearTimers()
|
||||||
|
if (isOpen) {
|
||||||
|
closing.value = false
|
||||||
|
armBackdropGuard()
|
||||||
|
void reposition()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
backdropActive.value = false
|
||||||
|
closing.value = true
|
||||||
|
const delay = CLOSE_MS + Math.max(0, props.entries.length - 1) * 28
|
||||||
|
closeTimer = setTimeout(() => {
|
||||||
|
closing.value = false
|
||||||
|
closeTimer = null
|
||||||
|
}, delay)
|
||||||
|
},
|
||||||
|
{ flush: 'post' },
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [props.entries.length, props.anchorEl] as const,
|
||||||
|
() => {
|
||||||
|
if (props.open) void reposition()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
function onViewportChange() {
|
||||||
|
if (props.open || closing.value) void reposition()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.addEventListener('resize', onViewportChange, { passive: true })
|
||||||
|
window.addEventListener('scroll', onViewportChange, { passive: true, capture: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
clearTimers()
|
||||||
|
if (typeof window === 'undefined') return
|
||||||
|
window.removeEventListener('resize', onViewportChange, { capture: true })
|
||||||
|
window.removeEventListener('scroll', onViewportChange, { capture: true })
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.support-messenger-picker__backdrop {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 5195;
|
||||||
|
background: rgba(15, 23, 42, 0.2);
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__stack {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 5205;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__stack--up {
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__stack--down {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__btn {
|
||||||
|
--i: 0;
|
||||||
|
--total: 1;
|
||||||
|
--stack-rise: 56px;
|
||||||
|
pointer-events: auto;
|
||||||
|
width: 46px;
|
||||||
|
height: 46px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
|
||||||
|
opacity: 0;
|
||||||
|
will-change: transform, opacity;
|
||||||
|
transition:
|
||||||
|
transform 0.22s cubic-bezier(0.2, 1, 0.3, 1),
|
||||||
|
opacity 0.16s ease,
|
||||||
|
box-shadow 0.16s ease;
|
||||||
|
transition-delay: calc(var(--i) * 38ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__stack--up .support-messenger-picker__btn {
|
||||||
|
transform-origin: center bottom;
|
||||||
|
transform: translateY(calc(var(--stack-rise) * 0.55)) scale(0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__stack--down .support-messenger-picker__btn {
|
||||||
|
transform-origin: center top;
|
||||||
|
transform: translateY(calc(var(--stack-rise) * -0.55)) scale(0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__stack.is-open .support-messenger-picker__btn {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0) scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__stack:not(.is-open) .support-messenger-picker__btn {
|
||||||
|
transition-delay: calc((var(--total) - 1 - var(--i)) * 24ms);
|
||||||
|
transition-duration: 0.18s, 0.14s, 0.14s;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__stack--up:not(.is-open) .support-messenger-picker__btn {
|
||||||
|
transform: translateY(calc(var(--stack-rise) * 0.4)) scale(0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-messenger-picker__stack--down:not(.is-open) .support-messenger-picker__btn {
|
||||||
|
transform: translateY(calc(var(--stack-rise) * -0.4)) scale(0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-picker-backdrop-enter-active,
|
||||||
|
.support-picker-backdrop-leave-active {
|
||||||
|
transition: opacity 0.16s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-picker-backdrop-enter-from,
|
||||||
|
.support-picker-backdrop-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -4,10 +4,56 @@ type RawAppConfig = AppConfig & {
|
|||||||
user?: Record<string, any>
|
user?: Record<string, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const EMPTY_STRING_CONFIG_KEYS = new Set([
|
||||||
|
'color',
|
||||||
|
'secondary_color',
|
||||||
|
'background_color',
|
||||||
|
'theme_config',
|
||||||
|
])
|
||||||
|
|
||||||
|
function emptyStringToNull(value: unknown) {
|
||||||
|
if (typeof value === 'string' && value.trim() === '') {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeUserConfig(user?: Record<string, any>) {
|
||||||
|
if (!user || typeof user !== 'object') {
|
||||||
|
return user
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalized: Record<string, any> = { ...user }
|
||||||
|
|
||||||
|
for (const key of EMPTY_STRING_CONFIG_KEYS) {
|
||||||
|
if (key in normalized) {
|
||||||
|
normalized[key] = emptyStringToNull(normalized[key])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalized
|
||||||
|
}
|
||||||
|
|
||||||
|
export function normalizeAppConfig(config: RawAppConfig): RawAppConfig {
|
||||||
|
if (!config || typeof config !== 'object') {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config.user || typeof config.user !== 'object') {
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...config,
|
||||||
|
user: normalizeUserConfig(config.user),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let appConfig: RawAppConfig | null = null
|
let appConfig: RawAppConfig | null = null
|
||||||
|
|
||||||
export function setAppConfig(config: RawAppConfig) {
|
export function setAppConfig(config: RawAppConfig) {
|
||||||
appConfig = config || {}
|
appConfig = normalizeAppConfig(config || {})
|
||||||
window.__APP_CONFIG__ = appConfig
|
window.__APP_CONFIG__ = appConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +77,7 @@ export function getTenantConfig() {
|
|||||||
|
|
||||||
export function getConfig<T = any>(key: string, fallback?: T): T {
|
export function getConfig<T = any>(key: string, fallback?: T): T {
|
||||||
const config = getTenantConfig()
|
const config = getTenantConfig()
|
||||||
const value = config?.[key]
|
const value = emptyStringToNull(config?.[key])
|
||||||
|
|
||||||
return (value ?? fallback ?? null) as T
|
return (value ?? fallback ?? null) as T
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-13
@@ -1,7 +1,9 @@
|
|||||||
import type { AppConfig } from '@/config/types'
|
import type { AppConfig } from '@/config/types'
|
||||||
|
import { normalizeAppConfig } from '@/config/app-config'
|
||||||
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 +31,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)
|
||||||
@@ -53,28 +61,31 @@ async function fetchConfig(url: string, timeout = 3000): Promise<AppConfig> {
|
|||||||
throw new Error('Config response is not JSON')
|
throw new Error('Config response is not JSON')
|
||||||
}
|
}
|
||||||
|
|
||||||
return await response.json()
|
return normalizeAppConfig(await response.json())
|
||||||
} finally {
|
} finally {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +96,7 @@ export async function loadAppConfig(): Promise<AppConfig> {
|
|||||||
const cachedConfig = readCachedAppConfig()
|
const cachedConfig = readCachedAppConfig()
|
||||||
|
|
||||||
if (cachedConfig) {
|
if (cachedConfig) {
|
||||||
return cachedConfig
|
return normalizeAppConfig(cachedConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await fetchFreshAppConfig()
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,3 +172,10 @@ html.app-layout--desktop .app-splash-screen {
|
|||||||
left: 0 !important;
|
left: 0 !important;
|
||||||
width: 100vw !important;
|
width: 100vw !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html.app-layout--desktop .login-page-root {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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*/ }
|
|
||||||
})
|
})
|
||||||
|
|||||||
+14
-6
@@ -15,7 +15,7 @@ let lastSubscribers = 0
|
|||||||
|
|
||||||
export const price = ref<Price>()
|
export const price = ref<Price>()
|
||||||
export const lastPrice = ref<Price>()
|
export const lastPrice = ref<Price>()
|
||||||
export const olderPrice = ref<number | undefined>(0)
|
export const olderPrice = ref<number | null>(null)
|
||||||
|
|
||||||
let lastPriceSourceAt = 0
|
let lastPriceSourceAt = 0
|
||||||
let consecutivePriceFetchFailures = 0
|
let consecutivePriceFetchFailures = 0
|
||||||
@@ -162,13 +162,17 @@ export async function getLastPrices(): Promise<boolean> {
|
|||||||
|
|
||||||
export function applyLastPricePayload(dataLast: Price) {
|
export function applyLastPricePayload(dataLast: Price) {
|
||||||
const normalized = normalizePriceResponse(dataLast)
|
const normalized = normalizePriceResponse(dataLast)
|
||||||
if (lastPrice.value?.price_last != normalized.price_last) {
|
const nextBuy = getTradeBuyPrice(normalized)
|
||||||
olderPrice.value = lastPrice.value?.price_last
|
const prevBuy = getTradeBuyPrice(lastPrice.value)
|
||||||
|
|
||||||
|
if (prevBuy > 0 && nextBuy > 0 && prevBuy !== nextBuy) {
|
||||||
|
olderPrice.value = prevBuy
|
||||||
}
|
}
|
||||||
|
|
||||||
lastPrice.value = normalized
|
lastPrice.value = normalized
|
||||||
price.value = {
|
price.value = {
|
||||||
...normalized,
|
...normalized,
|
||||||
buy: getTradeBuyPrice(normalized),
|
buy: nextBuy,
|
||||||
sell: getTradeSellPrice(normalized),
|
sell: getTradeSellPrice(normalized),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,9 +181,13 @@ export function applyLastPricePayload(dataLast: Price) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** تغییر درصدی نسبت به قیمت خرید قبلی (آخرین بهروزرسانی) */
|
||||||
export function percentPriceChanged() {
|
export function percentPriceChanged() {
|
||||||
if (!olderPrice.value) {
|
const currentBuy = getTradeBuyPrice(lastPrice.value)
|
||||||
|
const prevBuy = olderPrice.value
|
||||||
|
if (!currentBuy || prevBuy == null || prevBuy <= 0 || prevBuy === currentBuy) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return ((lastPrice.value?.price_last! - olderPrice.value) * 100) / olderPrice.value
|
|
||||||
|
return ((currentBuy - prevBuy) * 100) / prevBuy
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,13 @@ export function getProductDisplayImage(product?: {
|
|||||||
return resolveProductImageSrc(product)
|
return resolveProductImageSrc(product)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import { formatGoldAmount } from '@/utils/usePrice'
|
||||||
|
|
||||||
export function formatMetalTotal(
|
export function formatMetalTotal(
|
||||||
metal: WalletMetalTotal,
|
metal: WalletMetalTotal,
|
||||||
inventoryCards: WalletInventoryCard[]
|
inventoryCards: WalletInventoryCard[]
|
||||||
): string {
|
): string {
|
||||||
return `${resolveSummaryMetalWeight(metal, inventoryCards)}${metal.unit}`
|
return `${formatGoldAmount(resolveSummaryMetalWeight(metal, inventoryCards))}${metal.unit}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveAssetsRialValue(
|
export function resolveAssetsRialValue(
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -9,28 +9,111 @@ export type SupportMessengerType =
|
|||||||
| 'eitaa'
|
| 'eitaa'
|
||||||
| 'soroush'
|
| 'soroush'
|
||||||
|
|
||||||
|
export interface SupportMessengerEntry {
|
||||||
|
messenger: string
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface SupportMessengerSettings {
|
export interface SupportMessengerSettings {
|
||||||
|
messengers?: SupportMessengerEntry[]
|
||||||
messenger?: SupportMessengerType | string
|
messenger?: SupportMessengerType | string
|
||||||
messengerId?: string
|
messengerId?: string
|
||||||
messengerText?: string
|
messengerText?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SupportMessengerMeta {
|
||||||
|
label: string
|
||||||
|
icon: string
|
||||||
|
accent: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResolvedSupportMessengerEntry extends SupportMessengerEntry {
|
||||||
|
label: string
|
||||||
|
icon: string
|
||||||
|
accent: string
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
|
||||||
export const supportMessengerSettings = ref<SupportMessengerSettings>({})
|
export const supportMessengerSettings = ref<SupportMessengerSettings>({})
|
||||||
|
export const supportMessengerPickerOpen = ref(false)
|
||||||
|
|
||||||
|
const VALID_SUPPORT_MESSENGERS = new Set([
|
||||||
|
'bale',
|
||||||
|
'telegram',
|
||||||
|
'whatsapp',
|
||||||
|
'rubika',
|
||||||
|
'eitaa',
|
||||||
|
'soroush',
|
||||||
|
])
|
||||||
|
|
||||||
|
export const SUPPORT_MESSENGER_META: Record<string, SupportMessengerMeta> = {
|
||||||
|
bale: { label: 'بله', icon: 'vuesax-linear:messages-2', accent: '#16a34a' },
|
||||||
|
telegram: { label: 'تلگرام', icon: 'vuesax-linear:send-2', accent: '#0ea5e9' },
|
||||||
|
whatsapp: { label: 'واتساپ', icon: 'vuesax-linear:whatsapp', accent: '#22c55e' },
|
||||||
|
rubika: { label: 'روبیکا', icon: 'vuesax-linear:messages-2', accent: '#7c3aed' },
|
||||||
|
eitaa: { label: 'ایتا', icon: 'vuesax-linear:messages-2', accent: '#f59e0b' },
|
||||||
|
soroush: { label: 'سروش', icon: 'vuesax-linear:messages-2', accent: '#2563eb' },
|
||||||
|
}
|
||||||
|
|
||||||
function getSupportSettingValue(
|
function getSupportSettingValue(
|
||||||
settings: Array<{ key?: string; is_active?: boolean | number; value?: unknown }>,
|
settings: Array<{ key?: string; value?: unknown }>,
|
||||||
key: string
|
key: string,
|
||||||
) {
|
) {
|
||||||
const setting = settings.find((item) => item?.key === key)
|
const setting = settings.find((item) => item?.key === key)
|
||||||
if (!setting) return ''
|
if (!setting) return ''
|
||||||
|
|
||||||
const value = setting.value
|
const value = setting.value
|
||||||
if (value === undefined || value === null) return ''
|
if (value === undefined || value === null) return ''
|
||||||
|
|
||||||
return String(value).trim()
|
return String(value).trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildSupportMessengerUrl(messenger?: string, messengerId?: string) {
|
export function parseSupportMessengersJson(raw?: string | null): SupportMessengerEntry[] {
|
||||||
|
const value = (raw ?? '').trim()
|
||||||
|
if (!value) return []
|
||||||
|
|
||||||
|
try {
|
||||||
|
const decoded = JSON.parse(value)
|
||||||
|
if (!Array.isArray(decoded)) return []
|
||||||
|
|
||||||
|
return decoded
|
||||||
|
.map((row) => ({
|
||||||
|
messenger: String(row?.messenger ?? '').trim().toLowerCase(),
|
||||||
|
id: String(row?.id ?? '').trim(),
|
||||||
|
}))
|
||||||
|
.filter((row) => VALID_SUPPORT_MESSENGERS.has(row.messenger) && row.id !== '')
|
||||||
|
} catch {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveSupportMessengersFromSettings(
|
||||||
|
settings: Array<{ key?: string; value?: unknown }>,
|
||||||
|
): SupportMessengerEntry[] {
|
||||||
|
const fromJson = parseSupportMessengersJson(getSupportSettingValue(settings, 'support_messengers'))
|
||||||
|
if (fromJson.length > 0) return fromJson
|
||||||
|
|
||||||
|
const legacyMessenger = getSupportSettingValue(settings, 'support_messenger').toLowerCase()
|
||||||
|
const legacyId = getSupportSettingValue(settings, 'support_messenger_id')
|
||||||
|
if (!legacyId) return []
|
||||||
|
|
||||||
|
const messenger = legacyMessenger || 'bale'
|
||||||
|
if (!VALID_SUPPORT_MESSENGERS.has(messenger)) return []
|
||||||
|
|
||||||
|
return [{ messenger, id: legacyId }]
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveSupportMessengerMeta(messenger?: string): SupportMessengerMeta {
|
||||||
|
const type = (messenger ?? '').trim().toLowerCase()
|
||||||
|
return SUPPORT_MESSENGER_META[type] ?? {
|
||||||
|
label: 'پشتیبانی',
|
||||||
|
icon: 'vuesax-linear:headphone',
|
||||||
|
accent: '#334155',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildSupportMessengerUrl(
|
||||||
|
messenger?: string,
|
||||||
|
messengerId?: string,
|
||||||
|
) {
|
||||||
const id = (messengerId ?? '').trim()
|
const id = (messengerId ?? '').trim()
|
||||||
if (!id) return ''
|
if (!id) return ''
|
||||||
|
|
||||||
@@ -62,12 +145,48 @@ export function buildSupportMessengerUrl(messenger?: string, messengerId?: strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resolveSupportMessengerEntries(
|
||||||
|
settings?: SupportMessengerSettings,
|
||||||
|
): ResolvedSupportMessengerEntry[] {
|
||||||
|
const resolved = settings ?? supportMessengerSettings.value
|
||||||
|
const source = resolved.messengers?.length
|
||||||
|
? resolved.messengers
|
||||||
|
: resolveLegacySingleMessenger(resolved)
|
||||||
|
|
||||||
|
return source
|
||||||
|
.map((entry) => {
|
||||||
|
const meta = resolveSupportMessengerMeta(entry.messenger)
|
||||||
|
const url = buildSupportMessengerUrl(entry.messenger, entry.id)
|
||||||
|
if (!url) return null
|
||||||
|
return { ...entry, ...meta, url }
|
||||||
|
})
|
||||||
|
.filter((entry): entry is ResolvedSupportMessengerEntry => entry !== null)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveLegacySingleMessenger(settings: SupportMessengerSettings): SupportMessengerEntry[] {
|
||||||
|
const messenger = (settings.messenger ?? '').trim().toLowerCase()
|
||||||
|
const id = (settings.messengerId ?? '').trim()
|
||||||
|
if (!messenger || !id) return []
|
||||||
|
if (!VALID_SUPPORT_MESSENGERS.has(messenger)) return []
|
||||||
|
return [{ messenger, id }]
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function openSupportMessengerEntry(entry: ResolvedSupportMessengerEntry | SupportMessengerEntry) {
|
||||||
|
const url = 'url' in entry && entry.url
|
||||||
|
? entry.url
|
||||||
|
: buildSupportMessengerUrl(entry.messenger, entry.id)
|
||||||
|
if (!url) return false
|
||||||
|
window.open(url, '_blank', 'noopener,noreferrer')
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
export async function loadSupportMessengerFromSettings() {
|
export async function loadSupportMessengerFromSettings() {
|
||||||
try {
|
try {
|
||||||
const settings = await getSettings()
|
const settings = await getSettings()
|
||||||
if (!settings || !Array.isArray(settings)) return
|
if (!settings || !Array.isArray(settings)) return
|
||||||
|
|
||||||
supportMessengerSettings.value = {
|
supportMessengerSettings.value = {
|
||||||
|
messengers: resolveSupportMessengersFromSettings(settings),
|
||||||
messenger: getSupportSettingValue(settings, 'support_messenger'),
|
messenger: getSupportSettingValue(settings, 'support_messenger'),
|
||||||
messengerId: getSupportSettingValue(settings, 'support_messenger_id'),
|
messengerId: getSupportSettingValue(settings, 'support_messenger_id'),
|
||||||
messengerText: getSupportSettingValue(settings, 'support_messenger_text'),
|
messengerText: getSupportSettingValue(settings, 'support_messenger_text'),
|
||||||
|
|||||||
+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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,10 @@ export function useFundInfoPage() {
|
|||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
items.value = []
|
items.value = []
|
||||||
Object.assign(pagination.value, { wallet_id: info.value.wallet.id })
|
Object.assign(pagination.value, {
|
||||||
|
wallet_id: info.value.wallet.id,
|
||||||
|
product_id: infoId.value ?? undefined,
|
||||||
|
})
|
||||||
tableOutput.value = await getFundTransactionTable(pagination.value)
|
tableOutput.value = await getFundTransactionTable(pagination.value)
|
||||||
items.value.push(...(tableOutput.value?.rows ?? []))
|
items.value.push(...(tableOutput.value?.rows ?? []))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
+157
-104
@@ -24,14 +24,9 @@
|
|||||||
<img :src="img1" alt="" class="h-[88px] absolute">
|
<img :src="img1" alt="" class="h-[88px] absolute">
|
||||||
<div class="w-full items-center flex flex-col">
|
<div class="w-full items-center flex flex-col">
|
||||||
<div class="text-gray-700 font-bold">{{ !isBuy ? 'قیمت فروش' : 'قیمت خرید' }}</div>
|
<div class="text-gray-700 font-bold">{{ !isBuy ? 'قیمت فروش' : 'قیمت خرید' }}</div>
|
||||||
<div class="flex gap-1 mt-3 text-xs items-center">
|
<div v-if="price" class="flex gap-1 mt-3 text-xs items-center">
|
||||||
<div class="gold-live-price">
|
<div :class="!isBuy ? 'text-red-700' : 'text-green-700'" class="font-bold text-2xl color-transition">
|
||||||
<Vue3Odometer
|
{{ usePriceWithoutType(goldPriceValue) }}
|
||||||
:key="isBuy ? 'buy' : 'sell'"
|
|
||||||
:value="displayedGoldPrice"
|
|
||||||
:class="[!isBuy ? 'text-red-700' : 'text-green-700', 'o-text !text-2xl font-bold color-transition']"
|
|
||||||
style="font-family: iran-sans; direction: ltr"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
ریال
|
ریال
|
||||||
</div>
|
</div>
|
||||||
@@ -40,11 +35,6 @@
|
|||||||
<div v-else class="w-full h-[88px]">
|
<div v-else class="w-full h-[88px]">
|
||||||
<GoldSkeleton class="w-full" />
|
<GoldSkeleton class="w-full" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="limitedPrice !== undefined && userStore?.userInfo.trade_active !== 1"
|
|
||||||
class="text-red text-xs flex gap-1 items-center justify-center my-2">
|
|
||||||
<Icon icon="vuesax-linear:info-circle" size="16" />
|
|
||||||
حداقل مبلغ اولیه برای ثبت سفارش {{ usePriceWithoutType(limitedPrice.value as number ?? 0) }} ریال می باشد.
|
|
||||||
</div>
|
|
||||||
</a-spin>
|
</a-spin>
|
||||||
<a-form :model="form" class="!mt-5" name="basic" @finish="okConfirm()">
|
<a-form :model="form" class="!mt-5" name="basic" @finish="okConfirm()">
|
||||||
<div class="border-gray-200 border-1 rounded-xl p-5 h-58 relative">
|
<div class="border-gray-200 border-1 rounded-xl p-5 h-58 relative">
|
||||||
@@ -66,7 +56,7 @@
|
|||||||
<!-- {{walletStore?.walletInfo?.gold}}-->
|
<!-- {{walletStore?.walletInfo?.gold}}-->
|
||||||
<Transition mode="out-in" name="fade">
|
<Transition mode="out-in" name="fade">
|
||||||
<div v-if="!isBuy" class="font-bold text-xs">
|
<div v-if="!isBuy" class="font-bold text-xs">
|
||||||
<div> {{ `موجودی کیف طلا: ${walletStore?.walletInfo?.gold ?? 0} گرم` }}</div>
|
<div> {{ `موجودی کیف طلا: ${formatGoldAmount(walletStore?.walletInfo?.gold ?? 0)} گرم` }}</div>
|
||||||
<!-- <div v-if="walletStore?.walletInfo?.gold_block !== 0">
|
<!-- <div v-if="walletStore?.walletInfo?.gold_block !== 0">
|
||||||
{{ `موجودی قابل برداشت طلا: ${walletStore?.walletInfo?.gold_block ?? 0} گرم` }}
|
{{ `موجودی قابل برداشت طلا: ${walletStore?.walletInfo?.gold_block ?? 0} گرم` }}
|
||||||
</div>-->
|
</div>-->
|
||||||
@@ -88,13 +78,6 @@
|
|||||||
@change="percentChange" />
|
@change="percentChange" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</Transition>
|
</Transition>
|
||||||
<Transition mode="out-in" name="fade">
|
|
||||||
<div v-if="priceErrorVisible" class="flex gap-1 items-center text-xs mt-[-15px] text-blue-600">
|
|
||||||
<BasicIcon icon="vuesax-linear:info-circle" />
|
|
||||||
ارزش کل وارد شده بر حسب گرم طلا محاسبه خواهد شد و قیمت وارد شده معادل {{ usePrice(parseInt(finalPrice.toFixed(0))) }} می
|
|
||||||
باشد!
|
|
||||||
</div>
|
|
||||||
</Transition>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<GoldLoading v-model:show="infoVisible" />
|
<GoldLoading v-model:show="infoVisible" />
|
||||||
@@ -111,10 +94,11 @@
|
|||||||
<div v-else>{{ !isBuy ? 'فروش' : 'خرید' }}</div>
|
<div v-else>{{ !isBuy ? 'فروش' : 'خرید' }}</div>
|
||||||
</div>
|
</div>
|
||||||
</BasicButton>
|
</BasicButton>
|
||||||
<div v-if="!isBuy && form.goldValue > walletStore?.walletInfo?.gold"
|
<div v-if="!isBuy && sellGoldDebit > (walletStore?.walletInfo?.gold ?? 0)"
|
||||||
class="text-red-700 text-xs font-bold mt-2">
|
class="text-red-700 text-xs font-bold mt-2">
|
||||||
مقدار گرم طلای وارد شده جهت فروش ({{ form.goldValue }}گرم) بیشتر از مقدار موجودی شما
|
مقدار گرم طلای وارد شده جهت فروش ({{ form.goldValue }}گرم) بیشتر از مقدار موجودی شما
|
||||||
({{ walletStore?.walletInfo?.gold }}گرم) می باشد.
|
({{ walletStore?.walletInfo?.gold }}گرم) می باشد.
|
||||||
|
<span v-if="feeDeductFromGold"> (با احتساب {{ feeInGrams }} گرم کارمزد، مجموعاً {{ sellGoldDebit }} گرم کسر میشود)</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div>{{form?.goldValue? true: false}}</div>-->
|
<!-- <div>{{form?.goldValue? true: false}}</div>-->
|
||||||
<div v-if="isBuy? ((form?.goldValue || form.goldValue === 0)? form?.goldCash < 500000: false) : false"
|
<div v-if="isBuy? ((form?.goldValue || form.goldValue === 0)? form?.goldCash < 500000: false) : false"
|
||||||
@@ -128,7 +112,7 @@
|
|||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<div>کارمزد:</div>
|
<div>کارمزد:</div>
|
||||||
<div class="flex gap-2 items-center">
|
<div class="flex gap-2 items-center">
|
||||||
<div class="">{{ parseFloat(((form.goldValue ?? 0) * 0.01).toFixed(4)) }}</div>
|
<div class="">{{ feeInGrams }}</div>
|
||||||
<!-- <div class="font-bold text-2xl">{{ 0 }}</div>-->
|
<!-- <div class="font-bold text-2xl">{{ 0 }}</div>-->
|
||||||
<div>
|
<div>
|
||||||
گرم
|
گرم
|
||||||
@@ -154,25 +138,39 @@
|
|||||||
<div class="flex justify-between ">
|
<div class="flex justify-between ">
|
||||||
<div>وزن:</div>
|
<div>وزن:</div>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<div class="font-bold">{{ form.goldValue }}</div>
|
<div class="font-bold">{{ displayTradeGoldAmount }}</div>
|
||||||
<div class="text-xs mr-1">گرم</div>
|
<div class="text-xs mr-1">گرم</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between mt-3">
|
<div class="flex justify-between mt-3">
|
||||||
<div>مظنه:</div>
|
<div>مظنه:</div>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<div class="font-bold">{{ usePriceWithoutType(isBuy ? price.buy ?? 0 : price.sell ?? 0) }}</div>
|
<div class="font-bold">{{ usePriceWithoutType(Math.round(goldPriceValue)) }}</div>
|
||||||
<div class="text-xs mr-1">ریال</div>
|
<div class="text-xs mr-1">ریال</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between mt-3">
|
<div class="flex justify-between mt-3">
|
||||||
<div>کارمزد:</div>
|
<div>کارمزد:</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<div class="font-bold text-xl">{{ parseFloat(((form.goldValue ?? 0) * 0.01).toFixed(4)) }}</div>
|
<div class="font-bold text-xl">{{ feeInGrams }}</div>
|
||||||
<div class="text-xs mr-1">گرم</div>
|
<div class="text-xs mr-1">گرم</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div >(معادل {{ equivalentPrice }} ریال)</div>
|
<div >(معادل {{ equivalentPrice }} ریال)</div>
|
||||||
|
<div v-if="isBuy && feeDeductFromGold" class="flex justify-between mt-3">
|
||||||
|
<div>طلا دریافتی:</div>
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="font-bold">{{ displayTradeGoldAmount }}</div>
|
||||||
|
<div class="text-xs mr-1">گرم (دقیق — کارمزد از ریال)</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="!isBuy && feeDeductFromGold" class="flex justify-between mt-3">
|
||||||
|
<div>کسر از کیف طلا:</div>
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="font-bold">{{ sellGoldDebit }}</div>
|
||||||
|
<div class="text-xs mr-1">گرم</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="flex justify-between mt-3">
|
<div class="flex justify-between mt-3">
|
||||||
<div>{{ isBuy ? 'قیمت قابل پرداخت:' : 'مبلغ دریافتی:' }}</div>
|
<div>{{ isBuy ? 'قیمت قابل پرداخت:' : 'مبلغ دریافتی:' }}</div>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
@@ -203,10 +201,10 @@
|
|||||||
|
|
||||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
import img1 from '@/assets/img/home_ly2.svg'
|
import img1 from '@/assets/img/home_ly2.svg'
|
||||||
import { usePrice, usePriceWithoutType } from '@/utils/usePrice'
|
import { usePrice, usePriceWithoutType, formatGoldAmount } from '@/utils/usePrice'
|
||||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||||
import type { Gold } from '@/models/gold'
|
import type { Gold } from '@/models/gold'
|
||||||
import { isIphone, loading, loadingMore, toFixedDownThreeChar } from '@/utils'
|
import { isIphone, loading, loadingMore } from '@/utils'
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { useWalletStore } from '@/store/walletStore'
|
import { useWalletStore } from '@/store/walletStore'
|
||||||
@@ -228,12 +226,27 @@ import type { Transaction } from '@/models/transaction'
|
|||||||
import type { TableEngineInput, TableOutput } from '@/models/table'
|
import type { TableEngineInput, TableOutput } from '@/models/table'
|
||||||
import { useInfiniteScroll } from '@vueuse/core'
|
import { useInfiniteScroll } from '@vueuse/core'
|
||||||
import { getTransactionTable } from '@/api/transaction'
|
import { getTransactionTable } from '@/api/transaction'
|
||||||
import { getLastPrices, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price'
|
import { getLastPrices, getTradeBuyPrice, getTradeSellPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price'
|
||||||
|
import { isStoreClosed, getStoreClosedMessage } from '@/utils/storeHours'
|
||||||
import type { Product } from '@/models/products'
|
import type { Product } from '@/models/products'
|
||||||
import { useFundUserStore } from '@/store/fundStore'
|
import { useFundUserStore } from '@/store/fundStore'
|
||||||
|
import {
|
||||||
|
calcFeeInGrams,
|
||||||
|
calcGramFromLockedRial,
|
||||||
|
calcOrderGoldAmount,
|
||||||
|
calcPayablePriceRial,
|
||||||
|
calcRialFromLockedGram,
|
||||||
|
calcSellGoldDebit,
|
||||||
|
calcSellTargetCash,
|
||||||
|
calcTradeTargetCash,
|
||||||
|
feeDeductFromGold,
|
||||||
|
formatTradeGramDisplay,
|
||||||
|
loadServiceFeeFromSettings,
|
||||||
|
normalizeOrderGoldAmount,
|
||||||
|
serviceFeePercentage,
|
||||||
|
type TradeInputLock,
|
||||||
|
} from '@/utils/serviceFee'
|
||||||
import Bg_main from '@/components/bg_main.vue'
|
import Bg_main from '@/components/bg_main.vue'
|
||||||
import Vue3Odometer from 'vue3-odometer'
|
|
||||||
import 'odometer/themes/odometer-theme-default.css'
|
|
||||||
const infoVisible = ref(false)
|
const infoVisible = ref(false)
|
||||||
const walletStore = useWalletStore()
|
const walletStore = useWalletStore()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
@@ -242,7 +255,6 @@ const confirmAction = ref<boolean>(false)
|
|||||||
const noCompleteVisible = ref<boolean>(false)
|
const noCompleteVisible = ref<boolean>(false)
|
||||||
const buyItems = ref<Transaction[]>([])
|
const buyItems = ref<Transaction[]>([])
|
||||||
const sellItems = ref<Transaction[]>([])
|
const sellItems = ref<Transaction[]>([])
|
||||||
const priceErrorVisible = ref<boolean>(false)
|
|
||||||
const buyTableOutput = ref<TableOutput<Transaction> | null>(null)
|
const buyTableOutput = ref<TableOutput<Transaction> | null>(null)
|
||||||
const sellTableOutput = ref<TableOutput<Transaction> | null>(null)
|
const sellTableOutput = ref<TableOutput<Transaction> | null>(null)
|
||||||
const el = ref()
|
const el = ref()
|
||||||
@@ -253,6 +265,7 @@ interface Prop {
|
|||||||
|
|
||||||
const props = withDefaults(defineProps<Prop>(), {})
|
const props = withDefaults(defineProps<Prop>(), {})
|
||||||
const isBuy = ref<boolean>(true)
|
const isBuy = ref<boolean>(true)
|
||||||
|
const inputLock = ref<TradeInputLock>(null)
|
||||||
|
|
||||||
const buyPagination = ref<TableEngineInput>({
|
const buyPagination = ref<TableEngineInput>({
|
||||||
filters: [{
|
filters: [{
|
||||||
@@ -273,20 +286,52 @@ const sellPagination = ref<TableEngineInput>({
|
|||||||
}], limit: 6, page: 0
|
}], limit: 6, page: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
const finalPrice = computed(() => (form.value?.goldValue * (isBuy.value ? price.value?.buy ?? 0 : price.value?.sell ?? 0)))
|
const unitPrice = computed(() =>
|
||||||
// const payablePrice = computed(() => finalPrice.value + finalPrice.value * 0.007)
|
isBuy.value ? getTradeBuyPrice(lastPrice.value) : getTradeSellPrice(lastPrice.value)
|
||||||
const payablePrice = computed(() => finalPrice.value)
|
)
|
||||||
const equivalentPrice = computed(() => usePriceWithoutType(((isBuy ? price.value?.buy ?? 0 : price.value?.sell ?? 0) * (parseFloat(((form.value?.goldValue ?? 0) * 0.01).toFixed(4))) ).toFixed(0)) )
|
const orderGoldAmount = computed(() =>
|
||||||
|
calcOrderGoldAmount(
|
||||||
|
form.value?.goldValue,
|
||||||
|
form.value?.goldCash,
|
||||||
|
unitPrice.value,
|
||||||
|
isBuy.value,
|
||||||
|
inputLock.value
|
||||||
|
)
|
||||||
|
)
|
||||||
|
const feeInGrams = computed(() => calcFeeInGrams(orderGoldAmount.value))
|
||||||
|
const finalPrice = computed(() => orderGoldAmount.value * unitPrice.value)
|
||||||
|
const feeInRial = computed(() => unitPrice.value * feeInGrams.value)
|
||||||
|
const equivalentPrice = computed(() => usePriceWithoutType(feeInRial.value.toFixed(0)))
|
||||||
|
const payablePrice = computed(() =>
|
||||||
|
calcPayablePriceRial(
|
||||||
|
finalPrice.value,
|
||||||
|
feeInRial.value,
|
||||||
|
isBuy.value,
|
||||||
|
inputLock.value === 'rial' ? form.value?.goldCash : undefined
|
||||||
|
)
|
||||||
|
)
|
||||||
|
const sellGoldDebit = computed(() => calcSellGoldDebit(orderGoldAmount.value, feeInGrams.value))
|
||||||
|
|
||||||
|
const displayTradeGoldAmount = computed(() =>
|
||||||
|
formatTradeGramDisplay(orderGoldAmount.value)
|
||||||
|
)
|
||||||
|
|
||||||
|
const priceUnavailable = computed(() => {
|
||||||
|
const unit = unitPrice.value
|
||||||
|
return !unit || Number.isNaN(unit) || unit <= 0
|
||||||
|
})
|
||||||
|
|
||||||
const disableTransaction = computed(() =>
|
const disableTransaction = computed(() =>
|
||||||
loading.value ||
|
loading.value ||
|
||||||
|
isStoreClosed() ||
|
||||||
form.value?.goldValue === undefined ||
|
form.value?.goldValue === undefined ||
|
||||||
form.value?.goldValue === '' ||
|
form.value?.goldValue === '' ||
|
||||||
form.value?.goldCash === '' ||
|
form.value?.goldCash === '' ||
|
||||||
form.value?.goldCash === undefined ||
|
form.value?.goldCash === undefined ||
|
||||||
(isBuy.value ? (form.value?.goldCash ?? 0) < 500000 : (form.value?.goldValue ?? 0) < 0.001) ||
|
(isBuy.value ? (form.value?.goldCash ?? 0) < 500000 : (form.value?.goldValue ?? 0) < 0.001) ||
|
||||||
(!isBuy.value && form.value.goldValue > walletStore?.walletInfo?.gold) ||
|
(!isBuy.value && sellGoldDebit.value > (walletStore?.walletInfo?.gold ?? 0)) ||
|
||||||
price.value?.buy === undefined)
|
(isBuy.value && payablePrice.value > (walletStore?.walletInfo?.cash ?? 0)) ||
|
||||||
|
priceUnavailable.value)
|
||||||
|
|
||||||
function refreshTable() {
|
function refreshTable() {
|
||||||
sellItems.value = []
|
sellItems.value = []
|
||||||
@@ -388,6 +433,7 @@ onMounted(async () => {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
await initPrice()
|
await initPrice()
|
||||||
|
await loadServiceFeeFromSettings()
|
||||||
/* await initSellTable()
|
/* await initSellTable()
|
||||||
await initBuyTable()*/
|
await initBuyTable()*/
|
||||||
})
|
})
|
||||||
@@ -482,20 +528,18 @@ onUnmounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function percentChange(val: number) {
|
function percentChange(val: number) {
|
||||||
if (val !== 0)
|
if (val !== 0) {
|
||||||
if (isBuy.value) {
|
if (isBuy.value) {
|
||||||
form.value.goldCash = unitCashCalculator.value * val
|
form.value.goldCash = unitCashCalculator.value * val
|
||||||
calculateGold(form.value.goldCash)
|
calculateGold(form.value.goldCash)
|
||||||
calculateCash(form.value.goldValue)
|
|
||||||
} else {
|
} else {
|
||||||
// console.log((unitGoldCalculator.value * val).toFixed(2))
|
form.value.goldValue = formatTradeGramDisplay(parseFloat(String(unitGoldCalculator.value * val)))
|
||||||
// form.value.goldValue = parseFloat((unitGoldCalculator.value * val).toFixed(2))
|
|
||||||
form.value.goldValue = toFixedDownThreeChar(parseFloat(unitGoldCalculator.value * val))
|
|
||||||
calculateCash(form.value.goldValue)
|
calculateCash(form.value.goldValue)
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
form.value.goldValue = undefined
|
form.value.goldValue = undefined
|
||||||
form.value.goldCash = undefined
|
form.value.goldCash = undefined
|
||||||
|
inputLock.value = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,55 +552,61 @@ const unitCashCalculator = computed(() => {
|
|||||||
return (walletStore?.walletInfo?.cash ?? 0) / 100
|
return (walletStore?.walletInfo?.cash ?? 0) / 100
|
||||||
})
|
})
|
||||||
|
|
||||||
const limitedPrice = computed(() => {
|
function syncFormWithLatestPrice() {
|
||||||
if (walletStore.limitedPrice)
|
const unit = unitPrice.value
|
||||||
return walletStore?.limitedPrice[0]
|
if (!unit || Number.isNaN(unit) || !inputLock.value) return
|
||||||
})
|
|
||||||
|
|
||||||
function calculateCash(val: number) {
|
if (inputLock.value === 'gram') {
|
||||||
priceErrorVisible.value = false
|
const goldValue = form.value.goldValue
|
||||||
// console.log(val)
|
if (goldValue !== undefined && goldValue !== null && goldValue !== '' && !isNaN(Number(goldValue))) {
|
||||||
if (price.value) {
|
calculateCash(Number(goldValue))
|
||||||
if (isBuy.value) {
|
|
||||||
if (val) form.value.goldCash = parseFloat((val * price?.value?.buy).toFixed(0))
|
|
||||||
else form.value.goldCash = undefined
|
|
||||||
} else {
|
|
||||||
if (val) form.value.goldCash = parseFloat((val * price?.value?.sell).toFixed(0))
|
|
||||||
else form.value.goldCash = undefined
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const goldCash = form.value.goldCash
|
||||||
|
if (goldCash !== undefined && goldCash !== null && goldCash !== '' && !isNaN(Number(goldCash))) {
|
||||||
|
calculateGold(Number(goldCash))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [unitPrice.value, isBuy.value],
|
||||||
|
() => {
|
||||||
|
syncFormWithLatestPrice()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
watch([feeDeductFromGold, () => serviceFeePercentage.value], () => {
|
||||||
|
syncFormWithLatestPrice()
|
||||||
|
})
|
||||||
|
|
||||||
|
function calculateCash(val: number) {
|
||||||
|
inputLock.value = 'gram'
|
||||||
|
const unit = unitPrice.value
|
||||||
|
if (!unit || Number.isNaN(unit)) return
|
||||||
|
|
||||||
|
if (val === undefined || val === null || Number.isNaN(val)) {
|
||||||
|
form.value.goldCash = undefined
|
||||||
|
inputLock.value = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
form.value.goldCash = calcRialFromLockedGram(val, unit, isBuy.value)
|
||||||
|
}
|
||||||
|
|
||||||
function calculateGold(val: number) {
|
function calculateGold(val: number) {
|
||||||
// console.log(val)
|
inputLock.value = 'rial'
|
||||||
// form.value.goldCash = usePriceWithoutType(form.value.goldCash)
|
const unit = unitPrice.value
|
||||||
if (price.value) {
|
if (!unit || Number.isNaN(unit)) return
|
||||||
if (isBuy.value) {
|
|
||||||
if (val) {
|
if (val) {
|
||||||
form.value.goldValue = toFixedDownThreeChar(parseFloat(val / price?.value?.buy))
|
form.value.goldValue = formatTradeGramDisplay(calcGramFromLockedRial(val, unit, isBuy.value))
|
||||||
if (parseInt(finalPrice.value) > 0) priceErrorVisible.value = true
|
} else if (val.toString() === '') {
|
||||||
if (parseInt(finalPrice.value) === 0) priceErrorVisible.value = false
|
form.value.goldValue = undefined
|
||||||
} else if (val.toString() === '') {
|
inputLock.value = null
|
||||||
form.value.goldValue = undefined
|
} else {
|
||||||
priceErrorVisible.value = false
|
form.value.goldValue = 0
|
||||||
} else {
|
|
||||||
form.value.goldValue = 0
|
|
||||||
priceErrorVisible.value = false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (val) {
|
|
||||||
form.value.goldValue = toFixedDownThreeChar(parseFloat((val / price?.value?.sell)))
|
|
||||||
if (parseInt(finalPrice.value) > 0) priceErrorVisible.value = true
|
|
||||||
if (parseInt(finalPrice.value) === 0) priceErrorVisible.value = false
|
|
||||||
} else if (val.toString() === '') {
|
|
||||||
// console.log('sasasasasasa')
|
|
||||||
form.value.goldValue = undefined
|
|
||||||
priceErrorVisible.value = false
|
|
||||||
} else {
|
|
||||||
form.value.goldValue = 0
|
|
||||||
priceErrorVisible.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,7 +628,7 @@ function setIsBuy(val: boolean) {
|
|||||||
form.value.goldValue = undefined
|
form.value.goldValue = undefined
|
||||||
form.value.goldCash = undefined
|
form.value.goldCash = undefined
|
||||||
form.value.percentWallet = 0
|
form.value.percentWallet = 0
|
||||||
priceErrorVisible.value = false
|
inputLock.value = null
|
||||||
// console.log(bganim.value.classList)
|
// console.log(bganim.value.classList)
|
||||||
// bganim?.value?.classList.add(val?'right':'left')
|
// bganim?.value?.classList.add(val?'right':'left')
|
||||||
// bganim?.value?.style.transform = `translateX(${val ? '0' : '-100'});`
|
// bganim?.value?.style.transform = `translateX(${val ? '0' : '-100'});`
|
||||||
@@ -594,10 +644,7 @@ const formatter = (value: number) => {
|
|||||||
|
|
||||||
const price = computed((): Price => <Price>lastPrice.value ?? 0)
|
const price = computed((): Price => <Price>lastPrice.value ?? 0)
|
||||||
|
|
||||||
const displayedGoldPrice = computed(() => {
|
const goldPriceValue = computed(() => unitPrice.value)
|
||||||
if (!lastPrice.value) return 0
|
|
||||||
return isBuy.value ? (lastPrice.value.buy ?? 0) : (lastPrice.value.sell ?? 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
async function initPrice() {
|
async function initPrice() {
|
||||||
try {
|
try {
|
||||||
@@ -613,17 +660,32 @@ async function initPrice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function okConfirm() {
|
function okConfirm() {
|
||||||
|
if (isStoreClosed()) {
|
||||||
|
message.warning(getStoreClosedMessage())
|
||||||
|
return
|
||||||
|
}
|
||||||
confirmAction.value = true
|
confirmAction.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ok() {
|
async function ok() {
|
||||||
|
if (isStoreClosed()) {
|
||||||
|
message.warning(getStoreClosedMessage())
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
infoVisible.value = true
|
infoVisible.value = true
|
||||||
await createOrder({
|
await createOrder({
|
||||||
direction: isBuy.value ? 1 : 2,
|
direction: isBuy.value ? 1 : 2,
|
||||||
price: isBuy.value ? price.value?.buy : price.value?.sell,
|
price: Math.round(unitPrice.value),
|
||||||
amount: form.value.goldValue ?? 0
|
amount: normalizeOrderGoldAmount(orderGoldAmount.value),
|
||||||
|
target_cash: calcTradeTargetCash(form.value.goldCash, inputLock.value)
|
||||||
|
?? calcSellTargetCash(
|
||||||
|
form.value.goldCash,
|
||||||
|
form.value.goldValue,
|
||||||
|
unitPrice.value,
|
||||||
|
inputLock.value
|
||||||
|
),
|
||||||
})
|
})
|
||||||
await walletStore.getMyWallet()
|
await walletStore.getMyWallet()
|
||||||
await router.push({ name: 'transactions' })
|
await router.push({ name: 'transactions' })
|
||||||
@@ -632,6 +694,7 @@ async function ok() {
|
|||||||
goldCash: undefined,
|
goldCash: undefined,
|
||||||
percentWallet: undefined
|
percentWallet: undefined
|
||||||
}
|
}
|
||||||
|
inputLock.value = null
|
||||||
// refreshTable()
|
// refreshTable()
|
||||||
message.success('سفارش شما با موفقیت انجام شد')
|
message.success('سفارش شما با موفقیت انجام شد')
|
||||||
await fundStore.getMyFund()
|
await fundStore.getMyFund()
|
||||||
@@ -680,14 +743,4 @@ async function ok() {
|
|||||||
right: 100%;
|
right: 100%;
|
||||||
transform: translate(100%, 0);
|
transform: translate(100%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.gold-live-price {
|
|
||||||
:deep(.odometer) {
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.odometer-digit) {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ import { useUserStore } from '@/store/userStore'
|
|||||||
import { useWalletStore } from '@/store/walletStore'
|
import { useWalletStore } from '@/store/walletStore'
|
||||||
import { useWalletAssets } from '@/composables/useWalletAssets'
|
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||||
import { resolveAssetsRialValue } from '@/utils/productAssets'
|
import { resolveAssetsRialValue } from '@/utils/productAssets'
|
||||||
import { usePrice, usePriceWithoutType, useTowDecimal } from '@/utils/usePrice'
|
import { usePrice, usePriceWithoutType, useTowDecimal, formatGoldAmount } from '@/utils/usePrice'
|
||||||
import {
|
import {
|
||||||
getLastPrices,
|
getLastPrices,
|
||||||
getTradeBuyPrice,
|
getTradeBuyPrice,
|
||||||
@@ -210,10 +210,10 @@ const balanceLabel = computed(() => {
|
|||||||
}
|
}
|
||||||
const metal = primaryMetalTotal.value
|
const metal = primaryMetalTotal.value
|
||||||
if (metal && Number(metal.total_weight) > 0) {
|
if (metal && Number(metal.total_weight) > 0) {
|
||||||
return `${Number(metal.total_weight).toFixed(3)} ${metal.unit}`
|
return `${formatGoldAmount(metal.total_weight)} ${metal.unit}`
|
||||||
}
|
}
|
||||||
const fallback = walletStore.walletInfo?.gold_sum ?? userStore.userInfo?.wallet?.count_gold ?? 0
|
const fallback = walletStore.walletInfo?.gold_sum ?? userStore.userInfo?.wallet?.count_gold ?? 0
|
||||||
return `${Number(fallback).toFixed(3)} گرم`
|
return `${formatGoldAmount(fallback)} گرم`
|
||||||
})
|
})
|
||||||
|
|
||||||
const totalRialDisplay = computed(() =>
|
const totalRialDisplay = computed(() =>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ const metrics = computed<MetricItem[]>(() => {
|
|||||||
label: metal.label,
|
label: metal.label,
|
||||||
value: formatMetalTotal(metal),
|
value: formatMetalTotal(metal),
|
||||||
metal,
|
metal,
|
||||||
showInfo: index === 0,
|
showInfo: true,
|
||||||
onInfo: 'gold',
|
onInfo: 'gold',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,36 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, inject } from 'vue'
|
import { inject } from 'vue'
|
||||||
import { useUserStore } from '@/store/userStore'
|
|
||||||
import { usePriceWithoutType } from '@/utils/usePrice'
|
|
||||||
import { isBoursecuProject } from '@/utils/config'
|
import { isBoursecuProject } from '@/utils/config'
|
||||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
|
||||||
import { HOME_PAGE_CONTEXT_KEY } from '../../composables/useHomePage'
|
import { HOME_PAGE_CONTEXT_KEY } from '../../composables/useHomePage'
|
||||||
|
|
||||||
const ctx = inject(HOME_PAGE_CONTEXT_KEY)!
|
const ctx = inject(HOME_PAGE_CONTEXT_KEY)!
|
||||||
const userStore = useUserStore()
|
|
||||||
const isBoursecu = isBoursecuProject()
|
const isBoursecu = isBoursecuProject()
|
||||||
|
|
||||||
const showLimitedPrice = computed(
|
|
||||||
() =>
|
|
||||||
ctx.limitedPrice.value !== undefined &&
|
|
||||||
userStore.userInfo?.trade_active !== 1,
|
|
||||||
)
|
|
||||||
|
|
||||||
const limitedPriceText = computed(() =>
|
|
||||||
usePriceWithoutType(Number(ctx.limitedPrice.value?.value ?? 0)),
|
|
||||||
)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="showLimitedPrice || ctx.showClosedMessage.value" class="dhome-alerts">
|
<div v-if="!isBoursecu && ctx.showClosedMessage.value" class="dhome-alerts">
|
||||||
<div v-if="showLimitedPrice" class="dhome-alert dhome-alert--warning">
|
|
||||||
<BasicIcon icon="vuesax-linear:info-circle" size="14" />
|
|
||||||
<span>
|
|
||||||
حداقل مبلغ اولیه برای ثبت سفارش {{ limitedPriceText }} ریال میباشد.
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div
|
<div
|
||||||
v-if="!isBoursecu && ctx.showClosedMessage.value"
|
|
||||||
class="dhome-alert dhome-alert--info"
|
class="dhome-alert dhome-alert--info"
|
||||||
v-html="ctx.closedMessage.value"
|
v-html="ctx.closedMessage.value"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,15 +11,6 @@
|
|||||||
v-if="!loading"
|
v-if="!loading"
|
||||||
class="bg-white w-full md:w-auto h-fit px-5 m-[-1px]"
|
class="bg-white w-full md:w-auto h-fit px-5 m-[-1px]"
|
||||||
>
|
>
|
||||||
<div
|
|
||||||
v-if="limitedPrice !== undefined && userStore?.userInfo.trade_active !== 1"
|
|
||||||
class="text-red text-xs flex gap-1 items-center justify-center mb-2"
|
|
||||||
>
|
|
||||||
<Icon icon="vuesax-linear:info-circle" size="16" />
|
|
||||||
حداقل مبلغ اولیه برای ثبت سفارش
|
|
||||||
{{ usePriceWithoutType(parseInt(limitedPrice.value) ?? 0) }} ریال می باشد.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="px-5 py-5 shadow-lg rounded-2xl text-white relative overflow-hidden shadow-lg"
|
class="px-5 py-5 shadow-lg rounded-2xl text-white relative overflow-hidden shadow-lg"
|
||||||
style=" background: linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%); "
|
style=" background: linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%); "
|
||||||
@@ -466,7 +457,7 @@ import { Swiper, SwiperSlide } from 'swiper/vue';
|
|||||||
import 'swiper/swiper-bundle.css';
|
import 'swiper/swiper-bundle.css';
|
||||||
import img2 from '@/assets/img/banner/2.png'
|
import img2 from '@/assets/img/banner/2.png'
|
||||||
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
||||||
import { usePrice, usePriceWithoutType, useTowDecimal } from '../../../utils/usePrice'
|
import { usePrice, usePriceWithoutType, useTowDecimal, formatGoldAmount } from '../../../utils/usePrice'
|
||||||
import {computed, createVNode, onActivated, onMounted, onUnmounted, ref, watch} from 'vue'
|
import {computed, createVNode, onActivated, onMounted, onUnmounted, ref, watch} from 'vue'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
@@ -535,14 +526,14 @@ const balanceLabel = computed(() => {
|
|||||||
|
|
||||||
const metal = primaryMetalTotal.value
|
const metal = primaryMetalTotal.value
|
||||||
if (metal && Number(metal.total_weight) > 0) {
|
if (metal && Number(metal.total_weight) > 0) {
|
||||||
return `${Number(metal.total_weight).toFixed(3)} ${metal.unit}`
|
return `${formatGoldAmount(metal.total_weight)} ${metal.unit}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const fallback =
|
const fallback =
|
||||||
walletStore.walletInfo?.gold_sum ??
|
walletStore.walletInfo?.gold_sum ??
|
||||||
userStore.userInfo?.wallet?.count_gold ??
|
userStore.userInfo?.wallet?.count_gold ??
|
||||||
0
|
0
|
||||||
return `${Number(fallback).toFixed(3)} گرم`
|
return `${formatGoldAmount(fallback)} گرم`
|
||||||
})
|
})
|
||||||
|
|
||||||
const totalRialDisplay = computed(() =>
|
const totalRialDisplay = computed(() =>
|
||||||
@@ -752,10 +743,6 @@ const updateData = (timeline) => {
|
|||||||
fetchPrices()
|
fetchPrices()
|
||||||
}
|
}
|
||||||
|
|
||||||
const limitedPrice = computed(() => {
|
|
||||||
if (walletStore.limitedPrice) return walletStore?.limitedPrice[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
const test_series = [
|
const test_series = [
|
||||||
{
|
{
|
||||||
name: 'candle',
|
name: 'candle',
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
export type HomeLayoutId = 'default' | 'boursecu'
|
export type HomeLayoutId = 'default' | 'boursecu'
|
||||||
|
|
||||||
export type HomeSectionId =
|
export type HomeSectionId =
|
||||||
| 'limitedPriceAlert'
|
|
||||||
| 'garoosiAssets'
|
| 'garoosiAssets'
|
||||||
| 'mainActions'
|
| 'mainActions'
|
||||||
| 'boursecuQuickActions'
|
| 'boursecuQuickActions'
|
||||||
|
|||||||
@@ -42,11 +42,6 @@
|
|||||||
<div v-else class="w-full h-[88px]">
|
<div v-else class="w-full h-[88px]">
|
||||||
<GoldSkeleton class="w-full" />
|
<GoldSkeleton class="w-full" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="limitedPrice !== undefined && userStore?.userInfo.trade_active !== 1"
|
|
||||||
class="text-red text-xs flex gap-1 items-center justify-center my-2">
|
|
||||||
<Icon icon="vuesax-linear:info-circle" size="16" />
|
|
||||||
حداقل مبلغ اولیه برای ثبت سفارش {{ usePriceWithoutType(limitedPrice.value as number ?? 0) }} ریال می باشد.
|
|
||||||
</div>
|
|
||||||
<!-- </a-spin>-->
|
<!-- </a-spin>-->
|
||||||
<a-form ref="refInput" :model="form" class="!mt-5" name="basic" @finish="okConfirm()">
|
<a-form ref="refInput" :model="form" class="!mt-5" name="basic" @finish="okConfirm()">
|
||||||
<div class="border-gray-200 border-1 rounded-xl p-5 relative">
|
<div class="border-gray-200 border-1 rounded-xl p-5 relative">
|
||||||
@@ -505,11 +500,6 @@ const unitCashCalculator = computed(() => {
|
|||||||
return (walletStore?.walletInfo?.cash ?? 0) / 100
|
return (walletStore?.walletInfo?.cash ?? 0) / 100
|
||||||
})
|
})
|
||||||
|
|
||||||
const limitedPrice = computed(() => {
|
|
||||||
if (walletStore.limitedPrice)
|
|
||||||
return walletStore?.limitedPrice[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
function calculateCash(val: number) {
|
function calculateCash(val: number) {
|
||||||
priceErrorVisible.value = false
|
priceErrorVisible.value = false
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div class="w-full flex justify-between" v-for="item in props.item.transaction">
|
<div class="w-full flex justify-between" v-for="item in props.item.transaction">
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
<div class="w-7 h-7 flex justify-center rounded-lg bg-gray-100 ">
|
<div class="w-7 h-7 flex justify-center rounded-lg bg-gray-100 ">
|
||||||
<img width="30" class="p-1" :src="item.product.group_type=='گوی'?goyImg:mokaabImg">
|
<ProductImage :product="item.product" img-class="p-1 max-h-full max-w-full object-contain" />
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs">{{ item?.title }}</div>
|
<div class="text-xs">{{ item?.title }}</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -38,8 +38,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type {Physicalreceive} from "@/models/physicalreceive";
|
import type {Physicalreceive} from "@/models/physicalreceive";
|
||||||
import {toJalali} from "../../../../utils/useDateTime";
|
import {toJalali} from "../../../../utils/useDateTime";
|
||||||
import goyImg from "@/assets/img/goyImg.svg"
|
import ProductImage from "@/components/ProductImage.vue";
|
||||||
import mokaabImg from "@/assets/img/mokaabImg.svg"
|
|
||||||
|
|
||||||
interface Prop {
|
interface Prop {
|
||||||
item: Physicalreceive
|
item: Physicalreceive
|
||||||
|
|||||||
@@ -38,11 +38,6 @@
|
|||||||
<div v-else class="w-full h-[88px]">
|
<div v-else class="w-full h-[88px]">
|
||||||
<GoldSkeleton class="w-full" />
|
<GoldSkeleton class="w-full" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="limitedPrice !== undefined && userStore?.userInfo.trade_active !== 1"
|
|
||||||
class="text-red text-xs flex gap-1 items-center justify-center my-2">
|
|
||||||
<Icon icon="vuesax-linear:info-circle" size="16" />
|
|
||||||
حداقل مبلغ اولیه برای ثبت سفارش {{ usePriceWithoutType(limitedPrice.value as number ?? 0) }} ریال می باشد.
|
|
||||||
</div>
|
|
||||||
<!-- </a-spin>-->
|
<!-- </a-spin>-->
|
||||||
<a-form ref="refInput" :model="form" class="!mt-5" name="basic" @finish="okConfirm()" @finishFailed="(errorInfo) => { console.log('Form submit failed:', errorInfo); console.log('Error fields details:', JSON.stringify(errorInfo.errorFields, null, 2)); if (errorInfo.errorFields && errorInfo.errorFields.length > 0) { const firstError = errorInfo.errorFields[0]; console.log('First error field:', firstError.name, 'errors:', firstError.errors); message.error(firstError.errors?.[0] || 'لطفا تمام فیلدها را به درستی پر کنید') } }">
|
<a-form ref="refInput" :model="form" class="!mt-5" name="basic" @finish="okConfirm()" @finishFailed="(errorInfo) => { console.log('Form submit failed:', errorInfo); console.log('Error fields details:', JSON.stringify(errorInfo.errorFields, null, 2)); if (errorInfo.errorFields && errorInfo.errorFields.length > 0) { const firstError = errorInfo.errorFields[0]; console.log('First error field:', firstError.name, 'errors:', firstError.errors); message.error(firstError.errors?.[0] || 'لطفا تمام فیلدها را به درستی پر کنید') } }">
|
||||||
<div class="border-gray-200 border-1 rounded-xl p-5 relative">
|
<div class="border-gray-200 border-1 rounded-xl p-5 relative">
|
||||||
@@ -552,11 +547,6 @@ const unitCashCalculator = computed(() => {
|
|||||||
return (walletStore?.walletInfo?.cash ?? 0) / 100
|
return (walletStore?.walletInfo?.cash ?? 0) / 100
|
||||||
})
|
})
|
||||||
|
|
||||||
const limitedPrice = computed(() => {
|
|
||||||
if (walletStore.limitedPrice)
|
|
||||||
return walletStore?.limitedPrice[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
function calculateCash(val: number) {
|
function calculateCash(val: number) {
|
||||||
priceErrorVisible.value = false
|
priceErrorVisible.value = false
|
||||||
console.log("val",val,props?.ProductItem)
|
console.log("val",val,props?.ProductItem)
|
||||||
|
|||||||
@@ -190,13 +190,6 @@ function setIsSMS(val: boolean) {
|
|||||||
if (!val) stepTwoVerify.value = false
|
if (!val) stepTwoVerify.value = false
|
||||||
userFormState.token = ''
|
userFormState.token = ''
|
||||||
userFormState.password = ''
|
userFormState.password = ''
|
||||||
// console.log(bganim.value.classList)
|
|
||||||
// bganim?.value?.classList.add(val?'right':'left')
|
|
||||||
// bganim?.value?.style.transform = `translateX(${val ? '0' : '-100'});`
|
|
||||||
// bganim?.value?.style.animationDirection = val? 'normal':'reverse'
|
|
||||||
// val? bganim?.value?.classList?.add("move") : bganim?.value?.classList?.remove("move")
|
|
||||||
// const el = bganim.value?.
|
|
||||||
// el.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function enterFingerPrint() {
|
async function enterFingerPrint() {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
export function useLoginPage() {
|
||||||
|
const enterType = ref(false)
|
||||||
|
|
||||||
|
function setEnterType(val: boolean) {
|
||||||
|
enterType.value = val
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (router.currentRoute.value.query.id) {
|
||||||
|
enterType.value = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
enterType,
|
||||||
|
setEnterType,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dlogin login-page">
|
||||||
|
<div class="dlogin__bg" aria-hidden="true">
|
||||||
|
<div class="dlogin__bg-top">
|
||||||
|
<img :src="img_topGradiant" alt="" class="dlogin__bg-cover" />
|
||||||
|
<img :src="img_pattern" alt="" class="dlogin__bg-pattern" />
|
||||||
|
</div>
|
||||||
|
<div class="dlogin__bg-bottom">
|
||||||
|
<img :src="img_bottomGradiant" alt="" class="dlogin__bg-cover" />
|
||||||
|
<img :src="img_pattern" alt="" class="dlogin__bg-pattern" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dlogin__container">
|
||||||
|
<div class="dlogin__card">
|
||||||
|
<transition mode="out-in" name="fade">
|
||||||
|
<Login v-if="!enterType" class="dlogin__form" @register="setEnterType" />
|
||||||
|
<Register v-else class="dlogin__form" @register="setEnterType" />
|
||||||
|
</transition>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" class="dlogin__back" @click="router.push({ name: 'buyProduct' })">
|
||||||
|
بازگشت به فروشگاه
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import Login from '@/views/login/components/Login.vue'
|
||||||
|
import Register from '@/views/login/components/Register.vue'
|
||||||
|
import img_topGradiant from '../assets/img/gr_top_white.svg'
|
||||||
|
import img_bottomGradiant from '../assets/img/gr_bottom_white.svg'
|
||||||
|
import img_pattern from '../assets/img/pattern.svg'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
enterType: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
register: [val: boolean]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
function setEnterType(val: boolean) {
|
||||||
|
emit('register', val)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" src="./styles/desktop-login.less"></style>
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
html.app-layout--desktop {
|
||||||
|
.login-page-root {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 100vh;
|
||||||
|
height: 100%;
|
||||||
|
padding: 32px 24px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow-y: auto;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__bg {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__bg-top,
|
||||||
|
.dlogin__bg-bottom {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 34%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__bg-top {
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__bg-bottom {
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__bg-cover {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 1;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__bg-pattern {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__container {
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 460px;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__card {
|
||||||
|
width: 100%;
|
||||||
|
max-height: calc(100vh - 120px);
|
||||||
|
padding: 36px 32px 28px;
|
||||||
|
border-radius: 20px;
|
||||||
|
background: rgba(255, 255, 255, 0.96);
|
||||||
|
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||||
|
box-shadow:
|
||||||
|
0 18px 48px rgba(15, 23, 42, 0.08),
|
||||||
|
0 2px 8px rgba(15, 23, 42, 0.04);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__form {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__form img {
|
||||||
|
width: 132px !important;
|
||||||
|
height: auto;
|
||||||
|
margin-bottom: 28px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlogin__back {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: @primary-color;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px 12px;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+34
-37
@@ -1,49 +1,46 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex items-center h-[92vh] justify-center ">
|
<div class="login-page-root">
|
||||||
<!-- <PhoneVerify/>-->
|
<DesktopLoginView
|
||||||
<div class="fixed top-0 right-0 left-0 h-1/3 w-screen flex">
|
v-show="isDesktop"
|
||||||
<img :src="img_topGradiant" alt="" class="absolute z-10 w-screen h-full object-cover">
|
:enter-type="enterType"
|
||||||
<img :src="img_pattern" alt="" class="absolute w-screen h-full object-none">
|
@register="setEnterType"
|
||||||
</div>
|
/>
|
||||||
<div class="fixed bottom-0 right-0 left-0 h-1/3 w-screen">
|
<MobileLoginView
|
||||||
<img :src="img_bottomGradiant" alt="" class="absolute z-10 w-screen h-full object-cover">
|
v-show="!isDesktop"
|
||||||
<img :src="img_pattern" alt="" class="absolute w-screen h-full object-none">
|
:enter-type="enterType"
|
||||||
</div>
|
@register="setEnterType"
|
||||||
<div class="z-1000 w-full p-5">
|
/>
|
||||||
<transition mode="out-in" name="fade">
|
|
||||||
<Login v-if="!enterType" @register="setEnterType"/>
|
|
||||||
<Register v-else @register="setEnterType"/>
|
|
||||||
</transition>
|
|
||||||
<div class="text-center text-primary font-500" @click="router.push({name:'buyProduct'})">بازگشت به فروشگاه</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { onUnmounted, watch } from 'vue'
|
||||||
|
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||||
|
import { useLoginPage } from './composables/useLoginPage'
|
||||||
|
import DesktopLoginView from './desktop/DesktopLoginView.vue'
|
||||||
|
import MobileLoginView from './mobile/MobileLoginView.vue'
|
||||||
|
|
||||||
import Login from "@/views/login/components/Login.vue";
|
const NO_SIDEBAR_CLASS = 'app-layout--desktop-no-sidebar'
|
||||||
import Register from "@/views/login/components/Register.vue";
|
const isDesktop = useDesktopBreakpoint()
|
||||||
import { onMounted, ref } from 'vue'
|
const { enterType, setEnterType } = useLoginPage()
|
||||||
import img_topGradiant from './assets/img/gr_top_white.svg'
|
|
||||||
import img_bottomGradiant from './assets/img/gr_bottom_white.svg'
|
|
||||||
import img_pattern from './assets/img/pattern.svg'
|
|
||||||
import router from '@/router'
|
|
||||||
|
|
||||||
const enterType = ref<boolean>(false)
|
watch(
|
||||||
|
isDesktop,
|
||||||
|
(desktop) => {
|
||||||
|
document.documentElement.classList.toggle(NO_SIDEBAR_CLASS, desktop)
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
function setEnterType(val: boolean) {
|
onUnmounted(() => {
|
||||||
enterType.value = val
|
document.documentElement.classList.remove(NO_SIDEBAR_CLASS)
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
if (router.currentRoute.value.query.id)
|
|
||||||
enterType.value = true
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
<style>
|
.login-page-root {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<template>
|
||||||
|
<div class="login-page flex items-center h-[92vh] justify-center">
|
||||||
|
<div class="fixed top-0 right-0 left-0 h-1/3 w-screen flex">
|
||||||
|
<img :src="img_topGradiant" alt="" class="absolute z-10 w-screen h-full object-cover" />
|
||||||
|
<img :src="img_pattern" alt="" class="absolute w-screen h-full object-none" />
|
||||||
|
</div>
|
||||||
|
<div class="fixed bottom-0 right-0 left-0 h-1/3 w-screen">
|
||||||
|
<img :src="img_bottomGradiant" alt="" class="absolute z-10 w-screen h-full object-cover" />
|
||||||
|
<img :src="img_pattern" alt="" class="absolute w-screen h-full object-none" />
|
||||||
|
</div>
|
||||||
|
<div class="z-1000 w-full p-5">
|
||||||
|
<transition mode="out-in" name="fade">
|
||||||
|
<Login v-if="!enterType" @register="setEnterType" />
|
||||||
|
<Register v-else @register="setEnterType" />
|
||||||
|
</transition>
|
||||||
|
<div class="text-center text-primary font-500" @click="router.push({ name: 'buyProduct' })">
|
||||||
|
بازگشت به فروشگاه
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import Login from '@/views/login/components/Login.vue'
|
||||||
|
import Register from '@/views/login/components/Register.vue'
|
||||||
|
import img_topGradiant from '../assets/img/gr_top_white.svg'
|
||||||
|
import img_bottomGradiant from '../assets/img/gr_bottom_white.svg'
|
||||||
|
import img_pattern from '../assets/img/pattern.svg'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
enterType: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
register: [val: boolean]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
function setEnterType(val: boolean) {
|
||||||
|
emit('register', val)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user