Compare commits
7
Commits
4fa2c0d57d
...
mian-test2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12382656e8 | ||
|
|
51e3c3f0cb | ||
|
|
e4d92831c2 | ||
|
|
3561e8ae07 | ||
|
|
ce8029919c | ||
|
|
3a3a55287b | ||
|
|
c3aaeaf91a |
Binary file not shown.
+16
-2
@@ -326,7 +326,15 @@
|
||||
}
|
||||
|
||||
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() {
|
||||
@@ -453,6 +461,9 @@
|
||||
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
|
||||
return version
|
||||
} catch (error) {
|
||||
if (localStorage.getItem(VERSION_SUCCESS_URL_KEY) === url) {
|
||||
localStorage.removeItem(VERSION_SUCCESS_URL_KEY)
|
||||
}
|
||||
console.warn('Version failed:', url, error)
|
||||
return undefined
|
||||
} finally {
|
||||
@@ -496,6 +507,9 @@
|
||||
url: url
|
||||
}
|
||||
} catch (error) {
|
||||
if (localStorage.getItem(CONFIG_SUCCESS_URL_KEY) === url) {
|
||||
localStorage.removeItem(CONFIG_SUCCESS_URL_KEY)
|
||||
}
|
||||
console.warn('Config failed:', url, 'round:', round, error)
|
||||
}
|
||||
}
|
||||
@@ -626,7 +640,7 @@
|
||||
renderRecovering('در حال دریافت تنظیمات جدید برنامه...')
|
||||
|
||||
var version = await loadRemoteVersion(5)
|
||||
var freshConfigResult = await fetchFreshConfig(2)
|
||||
var freshConfigResult = await fetchFreshConfig(5)
|
||||
|
||||
clearReadableCookies()
|
||||
// clearLocalStorageExceptToken()
|
||||
|
||||
+19
-13
@@ -3,14 +3,7 @@
|
||||
<transition mode="out-in" name="fade">
|
||||
<AConfigProvider
|
||||
v-if="!showSplash"
|
||||
:theme="{
|
||||
token: {
|
||||
colorPrimary: colors.primary,
|
||||
colorLink: colors.primary,
|
||||
colorLinkActive: colors.primary,
|
||||
colorLinkHover: colors['primary-rgba']
|
||||
}
|
||||
}"
|
||||
:theme="antDesignTheme"
|
||||
direction="rtl"
|
||||
>
|
||||
<router-view v-slot="{ Component, route }">
|
||||
@@ -68,10 +61,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { colors } from './themeConfig'
|
||||
import pkg from '../package.json'
|
||||
import { getDisplayAppVersion } from '@/config/config-cache'
|
||||
import { computed, defineAsyncComponent, h, onMounted, ref } from 'vue'
|
||||
import pkg from '../package.json'
|
||||
import img_topGradiant from '@/views/login/assets/img/gr_top_white.svg'
|
||||
import img_pattern from '@/views/login/assets/img/pattern.svg'
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||
@@ -83,6 +75,7 @@ import {
|
||||
} from '@/utils/supportMessenger'
|
||||
import { useDraggableFloatingButton } from '@/utils/useDraggableFloatingButton'
|
||||
import { useApplyDesktopLayoutClass } from '@/layouts/composables/useAppLayout'
|
||||
import { getProjectBranding } from '@/utils/project'
|
||||
|
||||
import img_bottomGradiant from '@/views/login/assets/img/gr_bottom_white.svg'
|
||||
import logoFull from '@/assets/img/logo_full_.png'
|
||||
@@ -100,6 +93,19 @@ const indicator = h(LoadingOutlined, {
|
||||
const displayVersion = getDisplayAppVersion(pkg.version)
|
||||
const showSplash = ref(true)
|
||||
|
||||
const antDesignTheme = computed(() => {
|
||||
const primary = getProjectBranding().accentColor
|
||||
|
||||
return {
|
||||
token: {
|
||||
colorPrimary: primary,
|
||||
colorLink: primary,
|
||||
colorLinkActive: primary,
|
||||
colorLinkHover: primary,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
useApplyDesktopLayoutClass()
|
||||
|
||||
const supportLink = computed(() =>
|
||||
@@ -141,7 +147,7 @@ const supportAccentColor = computed(() => {
|
||||
case 'soroush':
|
||||
return '#2563eb'
|
||||
default:
|
||||
return colors.primary || '#334155'
|
||||
return getProjectBranding().accentColor
|
||||
}
|
||||
})
|
||||
|
||||
@@ -155,7 +161,7 @@ const {
|
||||
} = useDraggableFloatingButton('ghatreh_support_button_position_v1', {
|
||||
width: 118,
|
||||
height: 42,
|
||||
defaultBottomOffset: 100,
|
||||
defaultBottomGap: 12,
|
||||
defaultRightOffset: 16,
|
||||
})
|
||||
|
||||
@@ -181,7 +187,7 @@ onMounted(async () => {
|
||||
|
||||
<style lang="less">
|
||||
.updateButton .van-dialog__confirm .van-button__text {
|
||||
color: @primary-color !important;
|
||||
color: @theme-primary !important;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { createVueApp } from '@/app/createApp'
|
||||
import { setupRouterGuards } from '@/app/setupRouter'
|
||||
import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { initPriceRealtimeChannel } from '@/utils/priceSocket'
|
||||
import { initMobileScrollRestoration } from '@/layouts/composables/useMobileScrollReset'
|
||||
|
||||
type BootWindow = Window & {
|
||||
__BOOT_TIMEOUT__?: number
|
||||
@@ -74,6 +75,7 @@ export async function bootstrapApp() {
|
||||
await withTimeout(settingsStore.fetchSettings(), 45000, 'Settings loading timeout')
|
||||
initPriceRealtimeChannel((key) => settingsStore.getSettingByKey(key))
|
||||
|
||||
initMobileScrollRestoration()
|
||||
setupRouterGuards()
|
||||
|
||||
app.mount('#app')
|
||||
|
||||
+17
-13
@@ -2,7 +2,6 @@ import { computed, watch } from 'vue'
|
||||
import router from '@/router'
|
||||
import { authenticateWithFingerprint, getToken, isIphone, removeToken } from '@/utils'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { useWalletStore } from '@/store/walletStore'
|
||||
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
|
||||
import { useAuthStore } from '@/store/useAuthStore'
|
||||
import {
|
||||
@@ -13,10 +12,11 @@ import {
|
||||
setFingerTimeOut,
|
||||
setHasFingerPrint
|
||||
} from '@/app/authBoot'
|
||||
import { recoverMobileViewportAfterAuth } from '@/layouts/composables/useMobileScrollReset'
|
||||
import { getProjectDefaultRoute, isGhatreProject } from '@/utils/project'
|
||||
|
||||
export function setupRouterGuards() {
|
||||
const userStore = useUserStore()
|
||||
const walletStore = useWalletStore()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const isApple: boolean = isIphone()
|
||||
@@ -29,16 +29,9 @@ export function setupRouterGuards() {
|
||||
return
|
||||
}
|
||||
|
||||
const tasks: Promise<unknown>[] = [
|
||||
walletStore.getLimitedPrice(),
|
||||
walletStore.getLimitedBuyGold(),
|
||||
]
|
||||
|
||||
if (!userStore.userInfo) {
|
||||
tasks.push(userStore.getMyInfo())
|
||||
await userStore.getMyInfo()
|
||||
}
|
||||
|
||||
await Promise.all(tasks)
|
||||
}
|
||||
|
||||
function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||
@@ -52,13 +45,17 @@ export function setupRouterGuards() {
|
||||
}
|
||||
|
||||
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||
if (to.name !== 'buyProduct') {
|
||||
return next({ name: 'buyProduct' })
|
||||
const defaultRoute = getProjectDefaultRoute()
|
||||
if (to.name !== defaultRoute) {
|
||||
return next({ name: defaultRoute })
|
||||
}
|
||||
return next()
|
||||
}
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.name === 'home' && isGhatreProject()) {
|
||||
return next({ name: 'buyProduct' })
|
||||
}
|
||||
authStore.setLoading(true)
|
||||
clearFingerTimeout()
|
||||
setFingerTimeOut(to)
|
||||
@@ -96,7 +93,7 @@ export function setupRouterGuards() {
|
||||
if (getFingerPosition()) {
|
||||
if (getToken()) {
|
||||
if (to.name === 'login') {
|
||||
return next({ name: from.name || 'buyProduct' })
|
||||
return next({ name: from.name || getProjectDefaultRoute() })
|
||||
}
|
||||
return next()
|
||||
}
|
||||
@@ -115,5 +112,12 @@ export function setupRouterGuards() {
|
||||
}
|
||||
})
|
||||
|
||||
router.afterEach((to, from) => {
|
||||
if (document.documentElement.classList.contains('app-layout--desktop')) return
|
||||
if (from.name === 'login') {
|
||||
recoverMobileViewportAfterAuth()
|
||||
}
|
||||
})
|
||||
|
||||
watch(currentRoute, async () => (userStore.userInfo ? '' : await start()))
|
||||
}
|
||||
|
||||
+39
-10
@@ -2,11 +2,13 @@
|
||||
@import (less) './fonts.less';
|
||||
@import (less) '../../layouts/styles/desktop-shell.less';
|
||||
@import (less) '../../layouts/styles/mobile-frame.less';
|
||||
@import (less) '../../layouts/styles/mobile-page-common.less';
|
||||
@import (less) '../../layouts/desktop/styles/desktop-page-common.less';
|
||||
@import (less) '../../views/base/fund/desktop/styles/desktop-fund.less';
|
||||
@import (less) '../../views/base/transactions/desktop/styles/desktop-transactions.less';
|
||||
@import (less) '../../views/base/wallet/desktop/styles/desktop-wallet.less';
|
||||
@import (less) '../../views/base/user/desktop/styles/desktop-user.less';
|
||||
@import (less) '../../views/base/priceTrigger/desktop/styles/desktop-price-trigger.less';
|
||||
@import (less) '../../views/base/home/desktop/styles/desktop-home.less';
|
||||
@import (less) '../../layouts/desktop/styles/desktop-inner-pages.less';
|
||||
|
||||
@@ -59,6 +61,33 @@ body {
|
||||
|
||||
:root {
|
||||
color-scheme: only light;
|
||||
--app-primary-color: #a72b77;
|
||||
--project-hero-gradient: linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%);
|
||||
--app-safe-top: env(safe-area-inset-top, 0px);
|
||||
--app-safe-bottom: env(safe-area-inset-bottom, 0px);
|
||||
--app-credit-bar-inner: 0px;
|
||||
--app-home-header-offset: calc(4.25rem + var(--app-safe-top));
|
||||
--app-credit-footer-offset: var(--app-safe-bottom);
|
||||
--app-nav-height: 80px;
|
||||
--app-bottom-chrome-height: calc(var(--app-nav-height) + var(--app-safe-bottom));
|
||||
--app-add-card-height: 88px;
|
||||
--wallet-card-dock-overlap: 52px;
|
||||
--app-z-nav: 5000;
|
||||
--app-z-wallet-dock: 4490;
|
||||
--app-z-wallet-add-bar: 4510;
|
||||
--app-z-action-sheet: 5200;
|
||||
--app-z-dialog: 5300;
|
||||
--app-z-modal: 5500;
|
||||
}
|
||||
|
||||
:root[data-project='ghatre'] {
|
||||
--app-primary-color: #521620;
|
||||
--project-hero-gradient: linear-gradient(145deg, #521620 0%, #7a2a1e 40%, #521620 100%);
|
||||
}
|
||||
|
||||
:root[data-project='kashkool'] {
|
||||
--app-primary-color: #a72b77;
|
||||
--project-hero-gradient: linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%);
|
||||
}
|
||||
|
||||
.ant-form-item {
|
||||
@@ -83,13 +112,13 @@ body {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/*.van-action-sheet{
|
||||
z-index: 2001 !important;
|
||||
.van-action-sheet{
|
||||
z-index: 5001 !important;
|
||||
}
|
||||
|
||||
.van-overlay{
|
||||
z-index: 2000 !important;
|
||||
}*/
|
||||
//.van-overlay{
|
||||
// z-index: 2000 !important;
|
||||
//}
|
||||
|
||||
.color-transition {
|
||||
transition: color 0.3s ease;
|
||||
@@ -147,7 +176,7 @@ body {
|
||||
background-color: #fff;
|
||||
//display: none;
|
||||
outline: none;
|
||||
border: 1px solid #a72b77 !important;
|
||||
border: 1px solid var(--app-primary-color, #a72b77) !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,18 +374,18 @@ body {
|
||||
}
|
||||
.ant-radio-group-solid
|
||||
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover{
|
||||
color: #a72b77 !important;
|
||||
color: var(--app-primary-color, #a72b77) !important;
|
||||
}
|
||||
.ant-input-group-addon{
|
||||
background-color: #a72b77 !important;
|
||||
background-color: var(--app-primary-color, #a72b77) !important;
|
||||
color: #e0be7f !important;
|
||||
}
|
||||
.ant-slider-track{
|
||||
background-color: #a72b77 !important;
|
||||
background-color: var(--app-primary-color, #a72b77) !important;
|
||||
|
||||
}
|
||||
.ant-slider-handle {
|
||||
background-color: #a72b77 !important;
|
||||
background-color: var(--app-primary-color, #a72b77) !important;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
@primary-color: #a72b77;
|
||||
@secondary-color: #a72b77;
|
||||
@App-primary-color: #a72b77;
|
||||
@theme-primary: var(--app-primary-color, #a72b77);
|
||||
@prefixCls-font-family: 'iran-sans';
|
||||
@prefixCls-background-color: #fff;
|
||||
|
||||
|
||||
@@ -1,17 +1 @@
|
||||
export function usePrice(price: number, digit = true, unit = 'ریال') {
|
||||
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)
|
||||
}
|
||||
export { usePrice, usePriceWithoutType, useTowDecimal, useFormat } from '@/utils/usePrice'
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { computed } from 'vue'
|
||||
import {
|
||||
getProjectBranding,
|
||||
getProjectId,
|
||||
isBoursecuProject,
|
||||
isGhatreProject,
|
||||
isKashkoolProject,
|
||||
type ProjectBranding,
|
||||
type ProjectId,
|
||||
} from '@/utils/project'
|
||||
|
||||
export function useProject() {
|
||||
const projectId = computed<ProjectId>(() => getProjectId())
|
||||
const branding = computed<ProjectBranding>(() => getProjectBranding())
|
||||
|
||||
const isGhatre = computed(() => isGhatreProject())
|
||||
const isKashkool = computed(() => isKashkoolProject())
|
||||
const isBoursecu = computed(() => isBoursecuProject())
|
||||
|
||||
const projectNameFa = computed(() => branding.value.nameFa)
|
||||
const heroGradient = computed(() => branding.value.heroGradient)
|
||||
const accentColor = computed(() => branding.value.accentColor)
|
||||
const fundLabel = computed(() => branding.value.fundLabel)
|
||||
const showHomeRoute = computed(() => branding.value.showHomeRoute)
|
||||
const defaultRoute = computed(() => branding.value.defaultRoute)
|
||||
|
||||
return {
|
||||
projectId,
|
||||
branding,
|
||||
isGhatre,
|
||||
isKashkool,
|
||||
isBoursecu,
|
||||
projectNameFa,
|
||||
heroGradient,
|
||||
accentColor,
|
||||
fundLabel,
|
||||
showHomeRoute,
|
||||
defaultRoute,
|
||||
}
|
||||
}
|
||||
@@ -15,14 +15,33 @@ export function getRawAppConfig() {
|
||||
return appConfig ?? window.__APP_CONFIG__ ?? null
|
||||
}
|
||||
|
||||
function isPlainObject(value: unknown): value is Record<string, any> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
}
|
||||
|
||||
export function getTenantConfig() {
|
||||
const rawConfig = getRawAppConfig()
|
||||
if (!rawConfig) return {}
|
||||
|
||||
if (rawConfig?.user && typeof rawConfig.user === 'object') {
|
||||
return rawConfig.user
|
||||
const user = rawConfig.user
|
||||
|
||||
if (isPlainObject(user)) {
|
||||
return {
|
||||
...user,
|
||||
name: rawConfig.name ?? user.name,
|
||||
name_fa: rawConfig.name_fa ?? user.name_fa,
|
||||
}
|
||||
}
|
||||
|
||||
if (rawConfig && Object.keys(rawConfig).length > 0) {
|
||||
if (Array.isArray(user) && isPlainObject(user[0])) {
|
||||
return {
|
||||
...user[0],
|
||||
name: rawConfig.name ?? user[0].name,
|
||||
name_fa: rawConfig.name_fa ?? user[0].name_fa,
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(rawConfig).length > 0) {
|
||||
return rawConfig
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,37 @@
|
||||
import { getConfig } from '@/config/app-config'
|
||||
import { isPwaManifestReady } from '@/modules/pwa/manifest'
|
||||
import { getProjectBranding } from '@/utils/project'
|
||||
|
||||
export function applyAppConfig() {
|
||||
if (isPwaManifestReady()) return
|
||||
applyProjectTheme()
|
||||
|
||||
if (isPwaManifestReady()) {
|
||||
setTitle()
|
||||
return
|
||||
}
|
||||
|
||||
setTitle()
|
||||
setFavicon()
|
||||
setAppleTouchIconFallback()
|
||||
}
|
||||
|
||||
function applyProjectTheme() {
|
||||
const branding = getProjectBranding()
|
||||
const root = document.documentElement
|
||||
const primary = branding.accentColor
|
||||
|
||||
root.style.setProperty('--project-accent', primary)
|
||||
root.style.setProperty('--project-hero-gradient', branding.heroGradient)
|
||||
root.style.setProperty('--app-primary-color', primary)
|
||||
root.style.setProperty('--primary-color', primary)
|
||||
root.dataset.project = branding.id
|
||||
|
||||
const secondaryColor = getConfig<string>('secondary_color')
|
||||
if (secondaryColor) {
|
||||
root.style.setProperty('--secondary-color', secondaryColor)
|
||||
}
|
||||
}
|
||||
|
||||
function setTitle() {
|
||||
document.title = getConfig('name_fa', 'در حال بارگذاری...')
|
||||
}
|
||||
|
||||
+31
-16
@@ -2,6 +2,7 @@ import type { AppConfig } from '@/config/types'
|
||||
import { readCachedAppConfig, writeCachedAppConfig } from '@/config/config-cache'
|
||||
|
||||
const CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
|
||||
export const CONFIG_RETRY_ROUNDS = 5
|
||||
|
||||
function getProtocol() {
|
||||
return window.location.protocol === 'https:' ? 'https:' : 'http:'
|
||||
@@ -29,6 +30,12 @@ export function sortConfigUrls(urls: string[]) {
|
||||
})
|
||||
}
|
||||
|
||||
function clearStaleConfigSuccessUrl(url: string) {
|
||||
if (localStorage.getItem(CONFIG_SUCCESS_URL_KEY) === url) {
|
||||
localStorage.removeItem(CONFIG_SUCCESS_URL_KEY)
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchConfig(url: string, timeout = 3000): Promise<AppConfig> {
|
||||
const controller = new AbortController()
|
||||
const timeoutId = window.setTimeout(() => controller.abort(), timeout)
|
||||
@@ -59,22 +66,25 @@ async function fetchConfig(url: string, timeout = 3000): Promise<AppConfig> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchFreshAppConfig(): Promise<AppConfig> {
|
||||
export async function fetchFreshAppConfig(rounds = CONFIG_RETRY_ROUNDS): Promise<AppConfig> {
|
||||
const urls = sortConfigUrls(getConfigUrls())
|
||||
|
||||
for (let index = 0; index < urls.length; index++) {
|
||||
const url = urls[index]
|
||||
for (let round = 1; round <= rounds; round++) {
|
||||
for (let index = 0; index < urls.length; index++) {
|
||||
const url = urls[index]
|
||||
|
||||
try {
|
||||
const timeout = index === urls.length - 1 ? 5000 : 2500
|
||||
const config = await fetchConfig(url, timeout)
|
||||
try {
|
||||
const timeout = index === urls.length - 1 ? 7000 : 4000
|
||||
const config = await fetchConfig(url, timeout)
|
||||
|
||||
localStorage.setItem(CONFIG_SUCCESS_URL_KEY, url)
|
||||
writeCachedAppConfig(config)
|
||||
localStorage.setItem(CONFIG_SUCCESS_URL_KEY, url)
|
||||
writeCachedAppConfig(config)
|
||||
|
||||
return config
|
||||
} catch (error) {
|
||||
console.warn(`Config failed from ${url}`, error)
|
||||
return config
|
||||
} catch (error) {
|
||||
clearStaleConfigSuccessUrl(url)
|
||||
console.warn(`Config failed from ${url}. Round: ${round}`, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,11 +92,16 @@ export async function fetchFreshAppConfig(): Promise<AppConfig> {
|
||||
}
|
||||
|
||||
export async function loadAppConfig(): Promise<AppConfig> {
|
||||
const cachedConfig = readCachedAppConfig()
|
||||
try {
|
||||
return await fetchFreshAppConfig()
|
||||
} catch (error) {
|
||||
const cachedConfig = readCachedAppConfig()
|
||||
|
||||
if (cachedConfig) {
|
||||
return cachedConfig
|
||||
if (cachedConfig) {
|
||||
console.warn('Using cached app config because fresh fetch failed', error)
|
||||
return cachedConfig
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
|
||||
return await fetchFreshAppConfig()
|
||||
}
|
||||
|
||||
@@ -9,16 +9,24 @@ type VersionResponse =
|
||||
}
|
||||
|
||||
const VERSION_SUCCESS_URL_KEY = 'VERSION_Success_URL'
|
||||
const VERSION_RETRY_ROUNDS = 5
|
||||
export const VERSION_RETRY_ROUNDS = 5
|
||||
|
||||
let versionFetchPromise: Promise<string | null> | null = null
|
||||
let cachedVersionResult: string | null | undefined
|
||||
|
||||
function getProtocol() {
|
||||
return window.location.protocol === 'https:' ? 'https:' : 'http:'
|
||||
}
|
||||
|
||||
function getVersionUrls() {
|
||||
const protocol = getProtocol()
|
||||
|
||||
return [
|
||||
'https://nerkh.gold/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]
|
||||
}
|
||||
|
||||
function clearStaleVersionSuccessUrl(url: string) {
|
||||
if (localStorage.getItem(VERSION_SUCCESS_URL_KEY) === url) {
|
||||
localStorage.removeItem(VERSION_SUCCESS_URL_KEY)
|
||||
}
|
||||
}
|
||||
|
||||
function readUserVersion(user: unknown) {
|
||||
if (!user || typeof user !== 'object' || Array.isArray(user)) {
|
||||
return ''
|
||||
@@ -82,7 +96,6 @@ async function fetchVersion(url: string, timeout = 3500): Promise<string | null>
|
||||
})
|
||||
|
||||
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}`)
|
||||
}
|
||||
|
||||
@@ -94,10 +107,8 @@ async function fetchVersion(url: string, timeout = 3500): Promise<string | null>
|
||||
|
||||
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) {
|
||||
return null
|
||||
throw new Error('Version response is empty')
|
||||
}
|
||||
|
||||
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
|
||||
@@ -118,10 +129,11 @@ async function fetchVersionWithRetry(rounds = VERSION_RETRY_ROUNDS): Promise<str
|
||||
|
||||
try {
|
||||
const version = await fetchVersion(url, timeout)
|
||||
// fetchVersion only throws on real request failures (non-ok / timeout).
|
||||
// If it returns null, we got HTTP 200 but empty version => stop immediately.
|
||||
return version
|
||||
if (version) {
|
||||
return version
|
||||
}
|
||||
} catch (error) {
|
||||
clearStaleVersionSuccessUrl(url)
|
||||
console.warn(`Version failed from ${url}. Round: ${round}`, error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<template>
|
||||
<div class="mpage-header wrap-fix">
|
||||
<button
|
||||
v-if="showBack"
|
||||
type="button"
|
||||
class="mpage-header__back"
|
||||
@click="handleBack"
|
||||
>
|
||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||
</button>
|
||||
<div class="mpage-header__title">{{ title }}</div>
|
||||
<div v-if="$slots.trailing" class="mpage-header__trailing">
|
||||
<slot name="trailing" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import router from '@/router'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
title: string
|
||||
showBack?: boolean
|
||||
}>(),
|
||||
{
|
||||
showBack: false,
|
||||
},
|
||||
)
|
||||
|
||||
function handleBack() {
|
||||
router.back()
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,125 @@
|
||||
import { nextTick } from 'vue'
|
||||
import router from '@/router'
|
||||
|
||||
let recoveryTimers: ReturnType<typeof setTimeout>[] = []
|
||||
|
||||
function clearRecoveryTimers() {
|
||||
recoveryTimers.forEach(clearTimeout)
|
||||
recoveryTimers = []
|
||||
}
|
||||
|
||||
function blurFocusedField() {
|
||||
const active = document.activeElement
|
||||
if (active instanceof HTMLElement && active !== document.body) {
|
||||
active.blur()
|
||||
}
|
||||
}
|
||||
|
||||
function clearBodyScrollLock() {
|
||||
document.body.classList.remove('van-overflow-hidden')
|
||||
document.body.style.removeProperty('position')
|
||||
document.body.style.removeProperty('top')
|
||||
document.body.style.removeProperty('left')
|
||||
document.body.style.removeProperty('right')
|
||||
document.body.style.removeProperty('width')
|
||||
document.body.style.removeProperty('height')
|
||||
document.body.style.removeProperty('min-height')
|
||||
document.body.style.removeProperty('overflow')
|
||||
document.body.style.removeProperty('transform')
|
||||
document.documentElement.style.removeProperty('overflow')
|
||||
document.documentElement.style.removeProperty('height')
|
||||
document.documentElement.style.removeProperty('transform')
|
||||
|
||||
const appRoot = document.getElementById('app')
|
||||
if (appRoot) {
|
||||
appRoot.style.removeProperty('position')
|
||||
appRoot.style.removeProperty('top')
|
||||
appRoot.style.removeProperty('height')
|
||||
appRoot.style.removeProperty('min-height')
|
||||
appRoot.style.removeProperty('overflow')
|
||||
appRoot.style.removeProperty('transform')
|
||||
}
|
||||
}
|
||||
|
||||
function resetAllScrollPositions() {
|
||||
window.scrollTo(0, 0)
|
||||
document.documentElement.scrollTop = 0
|
||||
document.body.scrollTop = 0
|
||||
|
||||
document
|
||||
.querySelectorAll('.main-with-bottom-chrome-inner, .login-page, .login-page-root')
|
||||
.forEach((node) => {
|
||||
if (node instanceof HTMLElement) {
|
||||
node.scrollTop = 0
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function kickViewportReflow() {
|
||||
window.dispatchEvent(new Event('resize'))
|
||||
|
||||
if (window.visualViewport) {
|
||||
window.scrollTo(0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
function runViewportRecovery() {
|
||||
clearBodyScrollLock()
|
||||
resetAllScrollPositions()
|
||||
kickViewportReflow()
|
||||
}
|
||||
|
||||
function scheduleViewportRecovery() {
|
||||
clearRecoveryTimers()
|
||||
runViewportRecovery()
|
||||
|
||||
nextTick(() => {
|
||||
requestAnimationFrame(() => {
|
||||
runViewportRecovery()
|
||||
|
||||
for (const delay of [50, 150, 300, 500]) {
|
||||
recoveryTimers.push(window.setTimeout(runViewportRecovery, delay))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/** Reset scroll offsets after navigation — fixes iOS safe-area drift. */
|
||||
export function resetMobileAppScroll() {
|
||||
runViewportRecovery()
|
||||
|
||||
nextTick(() => {
|
||||
requestAnimationFrame(runViewportRecovery)
|
||||
})
|
||||
}
|
||||
|
||||
export async function dismissMobileKeyboard() {
|
||||
blurFocusedField()
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 120))
|
||||
}
|
||||
|
||||
export async function prepareMobileViewportForAppShell() {
|
||||
blurFocusedField()
|
||||
resetAllScrollPositions()
|
||||
await dismissMobileKeyboard()
|
||||
}
|
||||
|
||||
/** Full recovery after auth — runs after home shell is mounted. */
|
||||
export function recoverMobileViewportAfterAuth() {
|
||||
scheduleViewportRecovery()
|
||||
}
|
||||
|
||||
export const resetMobileAppScrollAfterLogin = recoverMobileViewportAfterAuth
|
||||
|
||||
export async function completeLoginNavigation() {
|
||||
await prepareMobileViewportForAppShell()
|
||||
await router.push({ name: 'buyProduct' })
|
||||
await router.isReady()
|
||||
recoverMobileViewportAfterAuth()
|
||||
}
|
||||
|
||||
export function initMobileScrollRestoration() {
|
||||
if (typeof history !== 'undefined' && 'scrollRestoration' in history) {
|
||||
history.scrollRestoration = 'manual'
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { AppNavItem } from '../types'
|
||||
import { getProjectBranding, isGhatreProject } from '@/utils/project'
|
||||
|
||||
/** تبهای پایین موبایل — کاربر لاگینشده */
|
||||
/** تبهای پایین موبایل — کاربر لاگینشده (کشکول) */
|
||||
export const AUTH_PRIMARY_NAV: AppNavItem[] = [
|
||||
{ id: 'home', routeName: 'home', label: 'صفحه اصلی', icon: 'vuesax-linear:home' },
|
||||
{ id: 'transactions', routeName: 'transactions', label: 'گزارش', icon: 'vuesax-linear:receipt-item' },
|
||||
@@ -8,6 +9,14 @@ export const AUTH_PRIMARY_NAV: AppNavItem[] = [
|
||||
{ id: 'cart', routeName: 'cart', label: 'سبد خرید', icon: 'vuesax-linear:shopping-cart' },
|
||||
]
|
||||
|
||||
/** تبهای پایین موبایل — کاربر لاگینشده (قطره) */
|
||||
export const GHATRE_AUTH_PRIMARY_NAV: AppNavItem[] = [
|
||||
{ id: 'buyProduct', routeName: 'buyProduct', label: 'فروشگاه', icon: 'vuesax-linear:coin' },
|
||||
{ id: 'transactions', routeName: 'transactions', label: 'گزارش', icon: 'vuesax-linear:receipt-item' },
|
||||
{ id: 'wallet', routeName: 'wallet', label: 'کیف پول', icon: 'vuesax-linear:wallet-1' },
|
||||
{ id: 'cart', routeName: 'cart', label: 'سبد خرید', icon: 'vuesax-linear:shopping-cart' },
|
||||
]
|
||||
|
||||
/** تبهای پایین موبایل — مهمان */
|
||||
export const GUEST_PRIMARY_NAV: AppNavItem[] = [
|
||||
{ id: 'buyProduct', routeName: 'buyProduct', label: 'فروشگاه', icon: 'vuesax-linear:coin' },
|
||||
@@ -18,6 +27,7 @@ export const GUEST_PRIMARY_NAV: AppNavItem[] = [
|
||||
|
||||
/** منوی FAB موبایل + بخش فرعی سایدبار دسکتاپ — کاربر لاگینشده */
|
||||
export const AUTH_SECONDARY_NAV: AppNavItem[] = [
|
||||
{ id: 'notifyTrigger', routeName: 'notifyTrigger', label: 'هشدار قیمت', icon: 'vuesax-linear:bill' },
|
||||
{ id: 'buyProduct', routeName: 'buyProduct', label: 'فروشگاه', icon: 'vuesax-linear:coin' },
|
||||
{ id: 'fund', routeName: 'fund', label: 'دارایی ها', icon: 'vuesax-linear:archive-1' },
|
||||
{ id: 'user', routeName: 'user', label: 'حساب کاربری', icon: 'vuesax-linear:user' },
|
||||
@@ -30,9 +40,16 @@ export const AUTH_SECONDARY_NAV: AppNavItem[] = [
|
||||
]
|
||||
|
||||
export function getPrimaryNavItems(isAuthenticated: boolean): AppNavItem[] {
|
||||
return isAuthenticated ? AUTH_PRIMARY_NAV : GUEST_PRIMARY_NAV
|
||||
if (!isAuthenticated) return GUEST_PRIMARY_NAV
|
||||
return isGhatreProject() ? GHATRE_AUTH_PRIMARY_NAV : AUTH_PRIMARY_NAV
|
||||
}
|
||||
|
||||
export function getSecondaryNavItems(isAuthenticated: boolean): AppNavItem[] {
|
||||
return isAuthenticated ? AUTH_SECONDARY_NAV : []
|
||||
if (!isAuthenticated) return []
|
||||
|
||||
const fundLabel = getProjectBranding().fundLabel
|
||||
|
||||
return AUTH_SECONDARY_NAV.map((item) =>
|
||||
item.id === 'fund' ? { ...item, label: fundLabel } : item
|
||||
)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ defineEmits<{
|
||||
height: 18px;
|
||||
padding: 0 4px;
|
||||
border-radius: 999px;
|
||||
background: #a72b77;
|
||||
background: var(--app-primary-color, #a72b77);
|
||||
color: #fff;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<aside class="desktop-sidebar">
|
||||
<div class="desktop-sidebar__brand">
|
||||
<img :src="navLogo" alt="کشکول گلد" class="desktop-sidebar__logo" />
|
||||
<img :src="navLogo" :alt="projectNameFa" class="desktop-sidebar__logo" />
|
||||
</div>
|
||||
|
||||
<nav class="desktop-sidebar__section" aria-label="منوی اصلی">
|
||||
@@ -45,7 +45,9 @@ import { useCartStore } from '@/store/cartStore'
|
||||
import { getPrimaryNavItems, getSecondaryNavItems } from '../config/navigation'
|
||||
import { useAppNavigation } from '../composables/useAppNavigation'
|
||||
import DesktopNavItem from './DesktopNavItem.vue'
|
||||
import { useProject } from '@/composables/useProject'
|
||||
|
||||
const { projectNameFa } = useProject()
|
||||
const cartStore = useCartStore()
|
||||
const authenticated = computed(() => isToken())
|
||||
const navLogo = logoFull
|
||||
|
||||
@@ -110,15 +110,15 @@
|
||||
|
||||
&:hover {
|
||||
background: rgba(167, 43, 119, 0.06);
|
||||
color: @primary-color;
|
||||
color: @theme-primary;
|
||||
}
|
||||
|
||||
&--active {
|
||||
background: rgba(167, 43, 119, 0.1);
|
||||
color: @primary-color;
|
||||
color: @theme-primary;
|
||||
|
||||
.desktop-nav-item__icon {
|
||||
color: @primary-color;
|
||||
color: @theme-primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
&__price {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
&__total {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
.dproduct-info__price {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
}
|
||||
|
||||
.dproduct-info__desc {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="mobile-app-layout">
|
||||
<MobileOverflowMenu
|
||||
:show="popVisible"
|
||||
@close="closeOverflowMenu"
|
||||
@@ -7,27 +7,34 @@
|
||||
/>
|
||||
|
||||
<div :class="['main-with-bottom-chrome', { 'main-with-bottom-chrome--no-nav': hideMenu }]">
|
||||
<router-view v-slot="{ Component, route }">
|
||||
<transition :name="route.meta.transition || 'fade'">
|
||||
<component :is="Component" class="main-with-bottom-chrome-inner" />
|
||||
<router-view v-slot="{ Component, route: activeRoute }">
|
||||
<transition :name="activeRoute.meta.transition || 'fade'">
|
||||
<component :is="Component" :key="activeRoute.fullPath" class="main-with-bottom-chrome-inner" />
|
||||
</transition>
|
||||
</router-view>
|
||||
</div>
|
||||
|
||||
<MobileBottomNav
|
||||
v-if="!hideMenu"
|
||||
:nav-item-class="navItemClass"
|
||||
@navigate="navigateTo"
|
||||
@toggle-overflow="toggleOverflowMenu"
|
||||
/>
|
||||
<Teleport to="body">
|
||||
<MobileBottomNav
|
||||
v-if="!hideMenu"
|
||||
:nav-item-class="navItemClass"
|
||||
@navigate="navigateTo"
|
||||
@toggle-overflow="toggleOverflowMenu"
|
||||
/>
|
||||
</Teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useAppNavigation } from '../composables/useAppNavigation'
|
||||
import { recoverMobileViewportAfterAuth, resetMobileAppScroll } from '../composables/useMobileScrollReset'
|
||||
import MobileBottomNav from './MobileBottomNav.vue'
|
||||
import MobileOverflowMenu from './MobileOverflowMenu.vue'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const {
|
||||
popVisible,
|
||||
hideMenu,
|
||||
@@ -36,6 +43,19 @@ const {
|
||||
toggleOverflowMenu,
|
||||
closeOverflowMenu,
|
||||
} = useAppNavigation()
|
||||
|
||||
watch(
|
||||
() => route.fullPath,
|
||||
() => {
|
||||
resetMobileAppScroll()
|
||||
},
|
||||
{ flush: 'post' },
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
resetMobileAppScroll()
|
||||
recoverMobileViewportAfterAuth()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" src="./mobile-layout.less"></style>
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
<div class="tabs bottom-0">
|
||||
<template v-for="item in leftTabs" :key="item.id">
|
||||
<div :class="navItemClass(item.routeName)" class="tab" @click="$emit('navigate', item.routeName)">
|
||||
<a-badge v-if="item.routeName === 'cart'" :count="cartCount">
|
||||
<Icon :icon="item.icon" size="24" />
|
||||
</a-badge>
|
||||
<Icon v-else :icon="item.icon" size="24" />
|
||||
<div class="tab__icon">
|
||||
<a-badge v-if="item.routeName === 'cart'" :count="cartCount">
|
||||
<Icon :icon="item.icon" size="24" />
|
||||
</a-badge>
|
||||
<Icon v-else :icon="item.icon" size="24" />
|
||||
</div>
|
||||
<div class="text-xs mt-1 font-bold">{{ item.label }}</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -21,10 +23,12 @@
|
||||
|
||||
<template v-for="item in rightTabs" :key="item.id">
|
||||
<div :class="navItemClass(item.routeName)" class="tab" @click="$emit('navigate', item.routeName)">
|
||||
<a-badge v-if="item.routeName === 'cart'" :count="cartCount">
|
||||
<Icon :icon="item.icon" size="24" />
|
||||
</a-badge>
|
||||
<Icon v-else :icon="item.icon" size="24" />
|
||||
<div class="tab__icon">
|
||||
<a-badge v-if="item.routeName === 'cart'" :count="cartCount">
|
||||
<Icon :icon="item.icon" size="24" />
|
||||
</a-badge>
|
||||
<Icon v-else :icon="item.icon" size="24" />
|
||||
</div>
|
||||
<div class="text-xs mt-1 font-bold">{{ item.label }}</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -61,3 +65,19 @@ const primaryItems = computed(() => getPrimaryNavItems(isToken()))
|
||||
const leftTabs = computed(() => primaryItems.value.slice(0, 2))
|
||||
const rightTabs = computed(() => primaryItems.value.slice(2))
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.tab__icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
flex-shrink: 0;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.tab__icon :deep(.ant-badge) {
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<Transition>
|
||||
<div
|
||||
v-if="show"
|
||||
class="top-0 bottom-0 bg-black wrap-fix z-2000 opacity-60"
|
||||
class="top-0 bottom-0 bg-black wrap-fix z-5000 opacity-60"
|
||||
@click="$emit('close')"
|
||||
/>
|
||||
</Transition>
|
||||
<Transition name="slide-fade">
|
||||
<div v-if="show" class="wrap-fix bottom-11vh z-2000">
|
||||
<div v-if="show" class="wrap-fix bottom-11vh z-5000 flex justify-center items-end">
|
||||
<div class="relative flex flex-col items-center">
|
||||
<div
|
||||
class="flex items-center justify-center bg-white rounded-full w-[30px] h-[30px] mb-2"
|
||||
@@ -37,6 +37,17 @@
|
||||
<div>دریافت طلای فیزیکی</div>
|
||||
</div>
|
||||
</BasicButton>
|
||||
<BasicButton
|
||||
v-if="authenticated"
|
||||
icon-size="16"
|
||||
class="!font-bold w-15rem"
|
||||
@click="go('notifyTrigger')"
|
||||
>
|
||||
<div class="flex gap-2 items-center">
|
||||
<BasicIcon icon="vuesax-linear:bill" size="16" class="absolute right-2" />
|
||||
<div>هشدار قیمت</div>
|
||||
</div>
|
||||
</BasicButton>
|
||||
<BasicButton
|
||||
v-if="authenticated"
|
||||
icon-size="16"
|
||||
@@ -48,17 +59,17 @@
|
||||
<div>خرید محصول</div>
|
||||
</div>
|
||||
</BasicButton>
|
||||
<BasicButton
|
||||
v-if="authenticated"
|
||||
icon-size="16"
|
||||
class="!font-bold w-15rem"
|
||||
@click="go('list')"
|
||||
>
|
||||
<div class="flex gap-2 items-center">
|
||||
<BasicIcon icon="vuesax-linear:receipt-item" size="16" class="absolute right-2" />
|
||||
<div>لیست دریافتی ها</div>
|
||||
</div>
|
||||
</BasicButton>
|
||||
<!-- <BasicButton-->
|
||||
<!-- v-if="authenticated"-->
|
||||
<!-- icon-size="16"-->
|
||||
<!-- class="!font-bold w-15rem"-->
|
||||
<!-- @click="go('list')"-->
|
||||
<!-- >-->
|
||||
<!-- <div class="flex gap-2 items-center">-->
|
||||
<!-- <BasicIcon icon="vuesax-linear:receipt-item" size="16" class="absolute right-2" />-->
|
||||
<!-- <div>لیست دریافتی ها</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </BasicButton>-->
|
||||
<BasicButton
|
||||
v-if="authenticated"
|
||||
icon-size="16"
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
.bottom-appbar {
|
||||
z-index: var(--app-z-nav, 5000);
|
||||
height: var(--app-nav-height, 80px);
|
||||
position: fixed;
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
background: #fff;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
max-width: 100vw;
|
||||
height: calc(var(--app-nav-height, 80px) + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
|
||||
padding-bottom: var(--app-safe-bottom, env(safe-area-inset-bottom, 0px));
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
background: #fff;
|
||||
|
||||
@media screen and (min-width: 426px) {
|
||||
width: 426px;
|
||||
@@ -39,6 +40,16 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
|
||||
&.text-primary .tab__icon,
|
||||
&.text-primary .tab__icon .ant-badge {
|
||||
color: @theme-primary;
|
||||
}
|
||||
|
||||
&.text-gray-400 .tab__icon,
|
||||
&.text-gray-400 .tab__icon .ant-badge {
|
||||
color: #9ca3af;
|
||||
}
|
||||
}
|
||||
|
||||
.main_in {
|
||||
@@ -57,11 +68,11 @@
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #a72b77;
|
||||
background-color: @theme-primary;
|
||||
|
||||
.circle_into {
|
||||
overflow: hidden;
|
||||
background-color: @primary-color;
|
||||
background-color: @theme-primary;
|
||||
border-radius: 50%;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
@@ -121,19 +132,38 @@
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.mobile-app-layout {
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.main-with-bottom-chrome {
|
||||
min-height: calc(100vh - var(--app-bottom-chrome-height, 80px));
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.main-with-bottom-chrome-inner {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
min-height: min(100%, calc(100vh - var(--app-bottom-chrome-height, 80px)));
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overscroll-behavior-y: contain;
|
||||
}
|
||||
|
||||
.main-with-bottom-chrome-inner--contained {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.main-with-bottom-chrome--no-nav,
|
||||
.main-with-bottom-chrome--no-nav .main-with-bottom-chrome-inner {
|
||||
min-height: 100vh;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,42 @@
|
||||
/**
|
||||
* Mobile shell width rules.
|
||||
* Below 426px: full viewport (phones).
|
||||
* 426px–767px: centered 426px frame (tablet-ish mobile).
|
||||
*/
|
||||
|
||||
html:not(.app-layout--desktop) {
|
||||
html,
|
||||
body,
|
||||
#app {
|
||||
min-height: 0;
|
||||
height: 100dvh;
|
||||
max-height: 100dvh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body {
|
||||
overscroll-behavior: none;
|
||||
}
|
||||
|
||||
.desktopConfig,
|
||||
.app-main {
|
||||
min-height: 0;
|
||||
height: 100dvh;
|
||||
max-height: 100dvh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-main > * {
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-dock-add-bar,
|
||||
.wallet-card-slider {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 425.98px) {
|
||||
body {
|
||||
display: block !important;
|
||||
@@ -8,6 +46,7 @@ html:not(.app-layout--desktop) {
|
||||
|
||||
#app,
|
||||
.desktopConfig,
|
||||
.app-main,
|
||||
.main-with-bottom-chrome,
|
||||
.main-with-bottom-chrome-inner {
|
||||
width: 100% !important;
|
||||
@@ -25,6 +64,16 @@ html:not(.app-layout--desktop) {
|
||||
margin: 0 !important;
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
.app-dock-add-bar,
|
||||
.wallet-card-slider {
|
||||
width: 100% !important;
|
||||
max-width: 100vw !important;
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
margin: 0 !important;
|
||||
transform: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 426px) and (max-width: 767.98px) {
|
||||
@@ -47,5 +96,15 @@ html:not(.app-layout--desktop) {
|
||||
margin: 0 !important;
|
||||
transform: translateX(-50%) !important;
|
||||
}
|
||||
|
||||
.app-dock-add-bar,
|
||||
.wallet-card-slider {
|
||||
width: 426px !important;
|
||||
max-width: 426px !important;
|
||||
left: 50% !important;
|
||||
right: auto !important;
|
||||
margin: 0 !important;
|
||||
transform: translateX(-50%) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
/* Shared mobile page chrome (inner pages — not home .app-header) */
|
||||
|
||||
:root {
|
||||
--mpage-header-bar: 2.75rem;
|
||||
--mpage-header-offset: calc(4rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
--mpage-subheader-offset: calc(var(--mpage-header-bar) + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
--mpage-content-with-subheader: calc(6.5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
--mpage-scroll-max-height: calc(100dvh - 50px - var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
--mobile-info-support-block: calc(5rem + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
|
||||
}
|
||||
|
||||
/* Fixed top bar: background fills under status bar; content sits below safe area */
|
||||
.mobile-top-chrome {
|
||||
top: 0;
|
||||
box-sizing: border-box;
|
||||
padding-top: calc(0.75rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
}
|
||||
|
||||
.mobile-top-chrome.h-12,
|
||||
.mobile-top-chrome.min-h-12 {
|
||||
height: auto;
|
||||
min-height: calc(3rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
}
|
||||
|
||||
.mpage-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
top: 0;
|
||||
box-sizing: border-box;
|
||||
padding: 0.75rem;
|
||||
padding-top: calc(0.75rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
background: #fff;
|
||||
color: @theme-primary;
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.5;
|
||||
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
|
||||
z-index: 1999;
|
||||
|
||||
&__back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
&__title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__trailing {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.mpage-subheader {
|
||||
top: var(--mpage-subheader-offset);
|
||||
z-index: 1999;
|
||||
padding: 0.75rem;
|
||||
background: #fff;
|
||||
color: @theme-primary;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.mpage-content {
|
||||
padding-top: var(--mpage-header-offset);
|
||||
}
|
||||
|
||||
.mpage-content--with-subheader {
|
||||
padding-top: var(--mpage-content-with-subheader);
|
||||
}
|
||||
|
||||
.mpage-scroll {
|
||||
overflow-y: auto;
|
||||
max-height: var(--mpage-scroll-max-height);
|
||||
}
|
||||
|
||||
.mobile-page-body--pt10 {
|
||||
padding-top: calc(2.5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
}
|
||||
|
||||
.mobile-page-body--pt15 {
|
||||
padding-top: calc(3.75rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
}
|
||||
|
||||
.mobile-page-body--pt20 {
|
||||
padding-top: calc(5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
}
|
||||
|
||||
/* Info pages (about, educate): fixed shell, scroll inside content box only */
|
||||
.mobile-info-page {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
max-height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.mobile-info-page__header {
|
||||
z-index: 1999;
|
||||
}
|
||||
|
||||
/* Decorative page background — fixed to viewport, never scrolls on iOS */
|
||||
.mobile-page-bg,
|
||||
.mobile-info-page__bg {
|
||||
pointer-events: none;
|
||||
position: fixed;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: var(--app-bottom-chrome-height, 80px);
|
||||
overflow: hidden;
|
||||
max-width: 100vw;
|
||||
box-sizing: border-box;
|
||||
|
||||
img {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.mobile-page-bg--no-nav,
|
||||
.mobile-info-page__bg {
|
||||
bottom: var(--app-credit-footer-offset, 0px);
|
||||
}
|
||||
|
||||
.mobile-page-bg--cover {
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
html:not(.app-layout--desktop) {
|
||||
@media screen and (min-width: 426px) and (max-width: 767.98px) {
|
||||
.mobile-page-bg,
|
||||
.mobile-info-page__bg {
|
||||
width: 426px;
|
||||
max-width: 426px;
|
||||
left: 50%;
|
||||
right: auto;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mobile-info-page__main {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding-top: calc(var(--mpage-header-offset) + 1rem);
|
||||
padding-right: 2.5rem;
|
||||
padding-left: 2.5rem;
|
||||
padding-bottom: calc(
|
||||
var(--mobile-info-support-block, 5rem) + var(--app-credit-footer-offset, 0px) + 1.25rem
|
||||
);
|
||||
pointer-events: none;
|
||||
|
||||
> * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.mobile-info-page__support {
|
||||
bottom: var(--app-credit-footer-offset, 0px);
|
||||
box-sizing: border-box;
|
||||
padding: 1rem 2.5rem;
|
||||
padding-bottom: calc(1rem + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
|
||||
background: #fff;
|
||||
box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.06);
|
||||
z-index: 1998;
|
||||
}
|
||||
|
||||
.mobile-content-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.mobile-content-box__scroll {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overscroll-behavior-y: contain;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ export interface Order {
|
||||
sts_str?: string
|
||||
payment_sts?: number
|
||||
payment_amount?: number
|
||||
target_cash?: number
|
||||
service_charge_price?: number
|
||||
total_fee?: number
|
||||
total_price?: number
|
||||
|
||||
+5
-20
@@ -1,4 +1,5 @@
|
||||
import {createRouter, createWebHistory} from 'vue-router'
|
||||
import { getProjectDefaultRoute } from '@/utils/project'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
@@ -8,16 +9,10 @@ const router = createRouter({
|
||||
name: 'login',
|
||||
component: () => import('../views/login/index.vue')
|
||||
},
|
||||
/* {
|
||||
path: '/',
|
||||
name: 'null',
|
||||
redirect: {name: 'home'},
|
||||
// component: () => import('../views/login/index.vue')
|
||||
},*/
|
||||
{
|
||||
path: `/`,
|
||||
name: 'main',
|
||||
redirect: {name: 'buyProduct'},
|
||||
redirect: () => ({ name: getProjectDefaultRoute() }),
|
||||
component: () => import('../views/base/index.vue'),
|
||||
children: [
|
||||
{
|
||||
@@ -85,22 +80,12 @@ const router = createRouter({
|
||||
name: 'address',
|
||||
component: () => import('@/views/base/address/index.vue')
|
||||
},
|
||||
/* {
|
||||
path: 'physicalReceive',
|
||||
name: 'physicalReceive',
|
||||
component: () => import('@/views/base/physicalReceive/index.vue'),
|
||||
},*/
|
||||
// {
|
||||
// path: 'list',
|
||||
// name: 'list',
|
||||
// component: () => import('@/views/base/physicalReceive/components/RequestList.vue'),
|
||||
// },
|
||||
{
|
||||
path: 'physicalReceive',
|
||||
name: 'physicalReceive',
|
||||
redirect:{name: 'list'},
|
||||
// component: () => import('@/views/base/physicalReceive/index.vue'),
|
||||
children:[
|
||||
redirect: { name: 'list' },
|
||||
component: () => import('@/views/base/physicalReceive/index.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'list',
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { type ComputedRef, ref } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import {defineStore} from "pinia";
|
||||
import {getMe} from "@/api/me";
|
||||
import type {User} from "@/models/login";
|
||||
import type {Wallet} from "@/models/wallet";
|
||||
import {getWallet} from "@/api/wallet";
|
||||
import type {Const} from "@/models/const";
|
||||
import {getConstByKey} from "@/api/const";
|
||||
export const useWalletStore = defineStore('wallet', () => {
|
||||
const walletInfo = ref<Wallet | undefined>(undefined)
|
||||
const limitedPrice = ref<Const[]>()
|
||||
const limitedBuyGold = ref<Const[]>()
|
||||
|
||||
async function getMyWallet() {
|
||||
try {
|
||||
@@ -19,40 +13,6 @@ export const useWalletStore = defineStore('wallet', () => {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
async function getLimitedPrice(){
|
||||
try {
|
||||
limitedPrice.value = await getConstByKey('limited_price')
|
||||
return limitedPrice.value
|
||||
}catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function getLimitedBuyGold(){
|
||||
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*/ }
|
||||
return { walletInfo, getMyWallet }
|
||||
})
|
||||
|
||||
+17
-6
@@ -1,8 +1,19 @@
|
||||
export function getConfigApp(key: string) {
|
||||
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user : {}
|
||||
import { getTenantConfig } from '@/config/app-config'
|
||||
|
||||
if (config) {
|
||||
return config[key]
|
||||
}
|
||||
return null
|
||||
export function getConfigApp(key: string) {
|
||||
const config = getTenantConfig()
|
||||
const value = config?.[key]
|
||||
|
||||
return value ?? null
|
||||
}
|
||||
|
||||
export {
|
||||
getProjectId,
|
||||
getProjectBranding,
|
||||
getProjectDefaultRoute,
|
||||
isGhatreProject,
|
||||
isKashkoolProject,
|
||||
isBoursecuProject,
|
||||
} from '@/utils/project'
|
||||
|
||||
export type { ProjectId, ProjectBranding } from '@/utils/project'
|
||||
|
||||
@@ -39,11 +39,13 @@ export function getProductDisplayImage(product?: {
|
||||
return resolveProductImageSrc(product)
|
||||
}
|
||||
|
||||
import { formatGoldAmount } from '@/utils/usePrice'
|
||||
|
||||
export function formatMetalTotal(
|
||||
metal: WalletMetalTotal,
|
||||
inventoryCards: WalletInventoryCard[]
|
||||
): string {
|
||||
return `${resolveSummaryMetalWeight(metal, inventoryCards)}${metal.unit}`
|
||||
return `${formatGoldAmount(resolveSummaryMetalWeight(metal, inventoryCards))}${metal.unit}`
|
||||
}
|
||||
|
||||
export function resolveAssetsRialValue(
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
function normalizeGroupType(value: unknown): string {
|
||||
return String(value ?? '').trim().toLowerCase()
|
||||
}
|
||||
|
||||
export function isKatodMesGroup(groupType: unknown): boolean {
|
||||
const type = normalizeGroupType(groupType)
|
||||
return type.includes('کاتد') || type.includes('katod')
|
||||
}
|
||||
|
||||
export function isMaftolMesGroup(groupType: unknown): boolean {
|
||||
const type = normalizeGroupType(groupType)
|
||||
return type.includes('مفتول') || type.includes('maftol')
|
||||
}
|
||||
|
||||
export function isShamshMesGroup(groupType: unknown, title?: unknown): boolean {
|
||||
const type = normalizeGroupType(groupType)
|
||||
const name = normalizeGroupType(title)
|
||||
|
||||
return (
|
||||
type.includes('شمش') ||
|
||||
type.includes('shamsh') ||
|
||||
name.includes('شمش') ||
|
||||
name.includes('shamsh')
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import { getRawAppConfig } from '@/config/app-config'
|
||||
import type { AppConfig } from '@/config/types'
|
||||
|
||||
export type ProjectId = 'ghatre' | 'kashkool' | 'boursecu'
|
||||
|
||||
export interface ProjectBranding {
|
||||
id: ProjectId
|
||||
nameFa: string
|
||||
heroGradient: string
|
||||
accentColor: string
|
||||
borderAccent: string
|
||||
fundLabel: string
|
||||
fundHeroBg: string
|
||||
idCardLabel: string
|
||||
buyPriceLabel: string
|
||||
defaultRoute: string
|
||||
showHomeRoute: boolean
|
||||
referralDomain: string
|
||||
}
|
||||
|
||||
const PROJECT_BRANDING: Record<ProjectId, ProjectBranding> = {
|
||||
ghatre: {
|
||||
id: 'ghatre',
|
||||
nameFa: 'قطره',
|
||||
heroGradient: 'linear-gradient(145deg, #521620 0%, #7a2a1e 40%, #521620 100%)',
|
||||
accentColor: '#521620',
|
||||
borderAccent: '#521620',
|
||||
fundLabel: 'قلک',
|
||||
fundHeroBg: '#EFCED9',
|
||||
idCardLabel: 'شناسه شما در قطره',
|
||||
buyPriceLabel: 'قیمت خرید از قطره',
|
||||
defaultRoute: 'buyProduct',
|
||||
showHomeRoute: false,
|
||||
referralDomain: 'ghatre.gold',
|
||||
},
|
||||
kashkool: {
|
||||
id: 'kashkool',
|
||||
nameFa: 'کشکول',
|
||||
heroGradient: 'linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%)',
|
||||
accentColor: '#a72b77',
|
||||
borderAccent: '#a72b77',
|
||||
fundLabel: 'دارایی ها',
|
||||
fundHeroBg: '',
|
||||
idCardLabel: 'شناسه شما در کشکول',
|
||||
buyPriceLabel: 'قیمت خرید از کشکول',
|
||||
defaultRoute: 'home',
|
||||
showHomeRoute: true,
|
||||
referralDomain: 'kh.kashkolgold.ir',
|
||||
},
|
||||
boursecu: {
|
||||
id: 'boursecu',
|
||||
nameFa: 'بورسکو',
|
||||
heroGradient: 'linear-gradient(145deg, #1e2229 0%, #374151 40%, #1e2229 100%)',
|
||||
accentColor: '#1e2229',
|
||||
borderAccent: '#1e2229',
|
||||
fundLabel: 'دارایی ها',
|
||||
fundHeroBg: '',
|
||||
idCardLabel: 'شناسه شما',
|
||||
buyPriceLabel: 'قیمت خرید',
|
||||
defaultRoute: 'home',
|
||||
showHomeRoute: true,
|
||||
referralDomain: '',
|
||||
},
|
||||
}
|
||||
|
||||
function normalizeProjectName(value: unknown): string {
|
||||
return String(value ?? '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '')
|
||||
}
|
||||
|
||||
export function resolveProjectNameFromConfig(raw: AppConfig | null | undefined): string {
|
||||
if (!raw) return ''
|
||||
|
||||
const candidates: unknown[] = [
|
||||
raw.name,
|
||||
typeof raw.user === 'object' && raw.user !== null && !Array.isArray(raw.user)
|
||||
? (raw.user as Record<string, unknown>).name
|
||||
: undefined,
|
||||
Array.isArray(raw.user) && raw.user[0] && typeof raw.user[0] === 'object'
|
||||
? (raw.user[0] as Record<string, unknown>).name
|
||||
: undefined,
|
||||
]
|
||||
|
||||
for (const value of candidates) {
|
||||
const normalized = normalizeProjectName(value)
|
||||
if (normalized) return normalized
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
function getProjectNameRaw(): string {
|
||||
return resolveProjectNameFromConfig(getRawAppConfig())
|
||||
}
|
||||
|
||||
function matchesProjectName(name: string, aliases: string[]): boolean {
|
||||
return aliases.some((alias) => name.includes(normalizeProjectName(alias)))
|
||||
}
|
||||
|
||||
export function getProjectId(): ProjectId {
|
||||
const name = getProjectNameRaw()
|
||||
|
||||
if (name === 'ghatreh') {
|
||||
return 'ghatre'
|
||||
}
|
||||
|
||||
if (name === 'kashkolgold') {
|
||||
return 'kashkool'
|
||||
}
|
||||
|
||||
if (matchesProjectName(name, ['boursecu', 'bourse', 'بورسکو', 'بورس'])) {
|
||||
return 'boursecu'
|
||||
}
|
||||
|
||||
if (matchesProjectName(name, ['ghatre', 'qatre', 'قطره'])) {
|
||||
return 'ghatre'
|
||||
}
|
||||
|
||||
if (matchesProjectName(name, ['kashkool', 'kashkol', 'کشکول'])) {
|
||||
return 'kashkool'
|
||||
}
|
||||
|
||||
return 'kashkool'
|
||||
}
|
||||
|
||||
export function isGhatreProject(): boolean {
|
||||
return getProjectId() === 'ghatre'
|
||||
}
|
||||
|
||||
export function isKashkoolProject(): boolean {
|
||||
return getProjectId() === 'kashkool'
|
||||
}
|
||||
|
||||
export function isBoursecuProject(): boolean {
|
||||
return getProjectId() === 'boursecu'
|
||||
}
|
||||
|
||||
export function getProjectBranding(): ProjectBranding {
|
||||
const id = getProjectId()
|
||||
const defaults = PROJECT_BRANDING[id]
|
||||
|
||||
return {
|
||||
...defaults,
|
||||
nameFa: defaults.nameFa,
|
||||
accentColor: defaults.accentColor,
|
||||
borderAccent: defaults.borderAccent,
|
||||
heroGradient: defaults.heroGradient,
|
||||
}
|
||||
}
|
||||
|
||||
export function getProjectDefaultRoute(): string {
|
||||
return getProjectBranding().defaultRoute
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
import { ref } from 'vue'
|
||||
import { getSettings } from '@/api/configuration'
|
||||
|
||||
export const serviceFeePercentage = ref<number>(0.01)
|
||||
|
||||
/** true = مبالغ رند: فروش → ریال دقیق (کارمزد از طلا)؛ خرید → وزن دقیق (کارمزد از ریال) */
|
||||
export const feeDeductFromGold = ref(false)
|
||||
|
||||
/** آخرین فیلدی که کاربر مستقیم ویرایش کرده — مبنای بهروزرسانی هنگام تغییر قیمت */
|
||||
export type TradeInputLock = 'gram' | 'rial' | null
|
||||
|
||||
/** حداکثر اعشار ذخیره/ارسال به سرور (مطابق orders.amount) */
|
||||
export const TRADE_GRAM_STORAGE_DECIMALS = 10
|
||||
|
||||
/** حداکثر اعشار نمایش به کاربر در اپ */
|
||||
export const TRADE_GRAM_DISPLAY_DECIMALS = 8
|
||||
|
||||
export function normalizeOrderGoldAmount(grams?: number | null): number {
|
||||
const value = Number(grams ?? 0)
|
||||
if (!Number.isFinite(value) || value === 0) return 0
|
||||
return parseFloat(value.toFixed(TRADE_GRAM_STORAGE_DECIMALS))
|
||||
}
|
||||
|
||||
export function formatTradeGramDisplay(grams?: number | null): number {
|
||||
const value = Number(grams ?? 0)
|
||||
if (!Number.isFinite(value)) return 0
|
||||
return parseFloat(value.toFixed(TRADE_GRAM_DISPLAY_DECIMALS))
|
||||
}
|
||||
|
||||
function feeRate() {
|
||||
return Number(serviceFeePercentage.value)
|
||||
}
|
||||
|
||||
export async function loadServiceFeeFromSettings() {
|
||||
try {
|
||||
const settings = await getSettings()
|
||||
if (settings && Array.isArray(settings)) {
|
||||
const feeSetting = settings.find(
|
||||
(s) => s?.key === 'fee_service_charge_percentage' && s?.is_active === true
|
||||
)
|
||||
if (feeSetting?.value !== undefined && feeSetting?.value !== null) {
|
||||
serviceFeePercentage.value = Number(feeSetting.value)
|
||||
}
|
||||
|
||||
const feeModeSetting = settings.find(
|
||||
(s) => s?.key === 'fee_deduct_from_gold' && s?.is_active === true
|
||||
)
|
||||
if (feeModeSetting?.value !== undefined && feeModeSetting?.value !== null) {
|
||||
const raw = String(feeModeSetting.value).trim().toLowerCase()
|
||||
feeDeductFromGold.value = raw === 'true' || raw === '1'
|
||||
} else {
|
||||
feeDeductFromGold.value = false
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
export function calcFeeInGrams(goldValue?: number | null) {
|
||||
return parseFloat(((goldValue ?? 0) * Number(serviceFeePercentage.value)).toFixed(4))
|
||||
}
|
||||
|
||||
/** گرم معادل برای دریافت دقیق مبلغ ریالی در فروش */
|
||||
export function calcGoldAmountFromTargetRial(rialAmount: number, unitPriceRial: number) {
|
||||
if (!rialAmount || !unitPriceRial) return 0
|
||||
return normalizeOrderGoldAmount(rialAmount / unitPriceRial)
|
||||
}
|
||||
|
||||
/** وقتی کاربر گرم را قفل کرده — ریال نمایشی/قابل پرداخت از همان گرم */
|
||||
export function calcRialFromLockedGram(displayGram: number, unitPriceRial: number, isBuy: boolean) {
|
||||
const grams = Number(displayGram)
|
||||
const unit = Number(unitPriceRial)
|
||||
if (!grams || !unit) return 0
|
||||
const fee = feeRate()
|
||||
|
||||
if (isBuy) {
|
||||
if (feeDeductFromGold.value) {
|
||||
return Math.round(grams * unit * (1 + fee))
|
||||
}
|
||||
return Math.round(grams * unit)
|
||||
}
|
||||
|
||||
if (feeDeductFromGold.value) {
|
||||
return Math.round(grams * unit)
|
||||
}
|
||||
return Math.round(grams * unit * (1 - fee))
|
||||
}
|
||||
|
||||
/** وقتی کاربر ریال را قفل کرده — گرم نمایشی از همان مبلغ */
|
||||
export function calcGramFromLockedRial(rialAmount: number, unitPriceRial: number, isBuy: boolean) {
|
||||
const rial = Number(rialAmount)
|
||||
const unit = Number(unitPriceRial)
|
||||
if (!rial || !unit) return 0
|
||||
const fee = feeRate()
|
||||
|
||||
if (isBuy) {
|
||||
if (feeDeductFromGold.value) {
|
||||
return rial / (unit * (1 + fee))
|
||||
}
|
||||
return (rial / unit) * (1 - fee)
|
||||
}
|
||||
|
||||
if (feeDeductFromGold.value) {
|
||||
return rial / unit
|
||||
}
|
||||
return rial / (unit * (1 - fee))
|
||||
}
|
||||
|
||||
/** مبلغ ریالی قفلشده توسط کاربر — برای ارسال به سرور */
|
||||
export function calcTradeTargetCash(
|
||||
goldCash?: number | null,
|
||||
inputLock?: TradeInputLock,
|
||||
): number | undefined {
|
||||
if (inputLock !== 'rial') return undefined
|
||||
const cash = Number(goldCash ?? 0)
|
||||
if (cash <= 0) return undefined
|
||||
return Math.round(cash)
|
||||
}
|
||||
|
||||
/** مبلغ نهایی قابل پرداخت (خرید) یا دریافت (فروش) به ریال */
|
||||
export function calcPayablePriceRial(
|
||||
finalPriceRial: number,
|
||||
feeInRial: number,
|
||||
isBuy: boolean,
|
||||
targetRialCash?: number | null
|
||||
) {
|
||||
if (targetRialCash != null && Number(targetRialCash) > 0) {
|
||||
return Number(targetRialCash)
|
||||
}
|
||||
|
||||
if (feeDeductFromGold.value) {
|
||||
if (isBuy) return finalPriceRial + feeInRial
|
||||
return finalPriceRial
|
||||
}
|
||||
return isBuy ? finalPriceRial : Math.max(0, finalPriceRial - feeInRial)
|
||||
}
|
||||
|
||||
/** وزن ارسالی به سرور */
|
||||
export function calcOrderGoldAmount(
|
||||
goldValue?: number | null,
|
||||
goldCash?: number | null,
|
||||
unitPriceRial?: number,
|
||||
isBuy?: boolean,
|
||||
inputLock?: TradeInputLock
|
||||
) {
|
||||
const gold = Number(goldValue ?? 0)
|
||||
const cash = Number(goldCash ?? 0)
|
||||
const unit = Number(unitPriceRial ?? 0)
|
||||
|
||||
if (isBuy && inputLock === 'rial' && cash > 0 && unit > 0) {
|
||||
if (feeDeductFromGold.value) {
|
||||
const fee = feeRate()
|
||||
return normalizeOrderGoldAmount(cash / (unit * (1 + fee)))
|
||||
}
|
||||
return normalizeOrderGoldAmount(cash / unit)
|
||||
}
|
||||
|
||||
if (!isBuy && feeDeductFromGold.value) {
|
||||
if (inputLock === 'rial' && cash > 0 && unit > 0) {
|
||||
return calcGoldAmountFromTargetRial(cash, unit)
|
||||
}
|
||||
if (inputLock !== 'rial') {
|
||||
return normalizeOrderGoldAmount(gold)
|
||||
}
|
||||
const targetCash = calcSellTargetCash(goldCash, goldValue, unitPriceRial, inputLock)
|
||||
if (targetCash != null && unit > 0) {
|
||||
return calcGoldAmountFromTargetRial(targetCash, unit)
|
||||
}
|
||||
}
|
||||
|
||||
return normalizeOrderGoldAmount(gold)
|
||||
}
|
||||
|
||||
/** مبلغ ریالی دقیق دریافتی در فروش (فقط وقتی کاربر با ریال وارد کرده) */
|
||||
export function calcSellTargetCash(
|
||||
goldCash?: number | null,
|
||||
goldValue?: number | null,
|
||||
unitPriceRial?: number,
|
||||
inputLock?: TradeInputLock
|
||||
) {
|
||||
if (!feeDeductFromGold.value) return undefined
|
||||
if (inputLock === 'gram') return undefined
|
||||
|
||||
const cash = Number(goldCash ?? 0)
|
||||
if (cash <= 0) return undefined
|
||||
if (inputLock === 'rial') return Math.round(cash)
|
||||
|
||||
const gold = Number(goldValue ?? 0)
|
||||
const unit = Number(unitPriceRial ?? 0)
|
||||
if (gold > 0 && unit > 0) {
|
||||
const derived = Math.round(gold * unit)
|
||||
if (Math.abs(derived - Math.round(cash)) <= 1) return undefined
|
||||
}
|
||||
return Math.round(cash)
|
||||
}
|
||||
|
||||
/** کل طلای کسرشونده از کیف در فروش (شامل کارمزد وقتی fee_deduct_from_gold روشن است) */
|
||||
export function calcSellGoldDebit(goldValue?: number | null, feeInGrams?: number | null) {
|
||||
const gold = Number(goldValue ?? 0)
|
||||
const fee = Number(feeInGrams ?? 0)
|
||||
if (feeDeductFromGold.value) {
|
||||
return parseFloat((gold + fee).toFixed(4))
|
||||
}
|
||||
return gold
|
||||
}
|
||||
@@ -1,24 +1,53 @@
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
|
||||
const DRAG_THRESHOLD = 6
|
||||
const POSITION_VERSION = 1
|
||||
|
||||
type FabPosition = { x: number; y: number }
|
||||
|
||||
type SavedFabOffset = {
|
||||
version: number
|
||||
dx: number
|
||||
dy: number
|
||||
}
|
||||
|
||||
type DraggableFloatingOptions = {
|
||||
width?: number
|
||||
height?: number
|
||||
defaultBottomOffset?: number
|
||||
defaultBottomGap?: number
|
||||
defaultRightOffset?: number
|
||||
}
|
||||
|
||||
function readBottomChromeHeight(): number {
|
||||
const styles = getComputedStyle(document.documentElement)
|
||||
const direct = parseFloat(styles.getPropertyValue('--app-bottom-chrome-height'))
|
||||
if (!Number.isNaN(direct) && direct > 0) {
|
||||
return direct
|
||||
}
|
||||
|
||||
const nav = parseFloat(styles.getPropertyValue('--app-nav-height')) || 80
|
||||
const creditOffset = parseFloat(styles.getPropertyValue('--app-credit-footer-offset'))
|
||||
if (!Number.isNaN(creditOffset) && creditOffset > 0) {
|
||||
return nav + creditOffset
|
||||
}
|
||||
|
||||
const probe = document.createElement('div')
|
||||
probe.style.cssText = 'position:fixed;visibility:hidden;pointer-events:none;height:var(--app-bottom-chrome-height)'
|
||||
document.body.appendChild(probe)
|
||||
const measured = probe.getBoundingClientRect().height
|
||||
document.body.removeChild(probe)
|
||||
|
||||
return measured > 0 ? measured : nav
|
||||
}
|
||||
|
||||
export function useDraggableFloatingButton(
|
||||
storageKey: string,
|
||||
options: DraggableFloatingOptions = {}
|
||||
) {
|
||||
const width = options.width ?? 96
|
||||
const height = options.height ?? 44
|
||||
const defaultBottomOffset = options.defaultBottomOffset ?? 92
|
||||
const defaultRightOffset = options.defaultRightOffset ?? 20
|
||||
const defaultBottomGap = options.defaultBottomGap ?? 12
|
||||
const defaultRightOffset = options.defaultRightOffset ?? 16
|
||||
|
||||
const pos = ref<FabPosition>({ x: 0, y: 0 })
|
||||
const dragging = ref(false)
|
||||
@@ -44,26 +73,40 @@ export function useDraggableFloatingButton(
|
||||
function getHorizontalOffset() {
|
||||
const vw = window.innerWidth
|
||||
const contentWidth = getViewportWidth()
|
||||
|
||||
return Math.max(0, (vw - contentWidth) / 2)
|
||||
}
|
||||
|
||||
function resetToDefault() {
|
||||
function getDefaultPosition(): FabPosition {
|
||||
const vh = window.innerHeight
|
||||
const offsetX = getHorizontalOffset()
|
||||
const contentWidth = getViewportWidth()
|
||||
const bottomChrome = readBottomChromeHeight()
|
||||
|
||||
pos.value = {
|
||||
return {
|
||||
x: offsetX + contentWidth - width - defaultRightOffset,
|
||||
y: vh - defaultBottomOffset - height
|
||||
y: vh - bottomChrome - defaultBottomGap - height
|
||||
}
|
||||
}
|
||||
|
||||
function applySavedOffset(dx: number, dy: number) {
|
||||
const base = getDefaultPosition()
|
||||
pos.value = {
|
||||
x: base.x + dx,
|
||||
y: base.y + dy
|
||||
}
|
||||
clampToViewport()
|
||||
}
|
||||
|
||||
function clampToViewport() {
|
||||
const vw = window.innerWidth
|
||||
const vh = window.innerHeight
|
||||
const offsetX = getHorizontalOffset()
|
||||
const contentWidth = getViewportWidth()
|
||||
const minX = offsetX
|
||||
const maxX = offsetX + contentWidth - width
|
||||
|
||||
pos.value = {
|
||||
x: Math.max(0, Math.min(vw - width, pos.value.x)),
|
||||
x: Math.max(minX, Math.min(maxX, pos.value.x)),
|
||||
y: Math.max(0, Math.min(vh - height, pos.value.y))
|
||||
}
|
||||
}
|
||||
@@ -72,25 +115,56 @@ export function useDraggableFloatingButton(
|
||||
try {
|
||||
const raw = localStorage.getItem(storageKey)
|
||||
if (!raw) return false
|
||||
const parsed = JSON.parse(raw) as FabPosition
|
||||
if (typeof parsed?.x === 'number' && typeof parsed?.y === 'number') {
|
||||
pos.value = parsed
|
||||
clampToViewport()
|
||||
|
||||
const parsed = JSON.parse(raw) as SavedFabOffset
|
||||
if (
|
||||
parsed?.version === POSITION_VERSION
|
||||
&& typeof parsed.dx === 'number'
|
||||
&& typeof parsed.dy === 'number'
|
||||
) {
|
||||
applySavedOffset(parsed.dx, parsed.dy)
|
||||
return true
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
function savePosition() {
|
||||
localStorage.setItem(storageKey, JSON.stringify(pos.value))
|
||||
const base = getDefaultPosition()
|
||||
const payload: SavedFabOffset = {
|
||||
version: POSITION_VERSION,
|
||||
dx: pos.value.x - base.x,
|
||||
dy: pos.value.y - base.y
|
||||
}
|
||||
localStorage.setItem(storageKey, JSON.stringify(payload))
|
||||
}
|
||||
|
||||
function resetToDefault() {
|
||||
pos.value = getDefaultPosition()
|
||||
}
|
||||
|
||||
function handleResize() {
|
||||
clampToViewport()
|
||||
savePosition()
|
||||
try {
|
||||
const raw = localStorage.getItem(storageKey)
|
||||
if (raw) {
|
||||
const parsed = JSON.parse(raw) as SavedFabOffset
|
||||
if (
|
||||
parsed?.version === POSITION_VERSION
|
||||
&& typeof parsed.dx === 'number'
|
||||
&& typeof parsed.dy === 'number'
|
||||
) {
|
||||
applySavedOffset(parsed.dx, parsed.dy)
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
resetToDefault()
|
||||
}
|
||||
|
||||
function handlePointerDown(event: PointerEvent) {
|
||||
|
||||
+88
-14
@@ -1,24 +1,46 @@
|
||||
export function usePrice(price: number, digit = true, unit = 'ریال') {
|
||||
price= price??0
|
||||
let _price = price.toString()
|
||||
function formatGroupedPrice(price: string | number | null | undefined, digit: boolean) {
|
||||
let value = price === null || price === undefined ? '' : String(price)
|
||||
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()
|
||||
if (digit) {
|
||||
_price = _price?.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||
/** مبلغ ریالی — بدون اعشار، گرد به بالا */
|
||||
export function ceilRial(price?: number | string | null): number {
|
||||
const num = Number(price ?? 0)
|
||||
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 {
|
||||
const temp = num.toString().match(/^-?\d+(?:\.\d{0,2})?/)
|
||||
if (temp && temp.length > 0) return temp[0]
|
||||
return Math.round(+num * 100) / 100
|
||||
if (temp && temp.length > 0) return formatGroupedPrice(temp[0], false)
|
||||
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 = '') {
|
||||
@@ -28,11 +50,26 @@ export function useFormat(num: string | number, unit = '') {
|
||||
type TransactionPriceSource = {
|
||||
cash?: number | null
|
||||
gold?: number | null
|
||||
type?: number | null
|
||||
order?: {
|
||||
price?: number | null
|
||||
total_price?: number | null
|
||||
amount?: number | null
|
||||
sts?: number | null
|
||||
sts_str?: string | number | null
|
||||
payment_sts?: number | 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 {
|
||||
@@ -57,6 +94,38 @@ export function getTransactionTradePrice(item: TransactionPriceSource): number {
|
||||
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 {
|
||||
const gold = Number(item.gold) || 0
|
||||
if (Math.abs(gold) > 0) {
|
||||
@@ -74,8 +143,13 @@ export function getTransactionGoldAmount(item: TransactionPriceSource): number {
|
||||
return gold
|
||||
}
|
||||
|
||||
export function formatGoldAmount(amount?: number | null): string {
|
||||
export function formatGoldAmount(amount?: number | null, decimals = 8): string {
|
||||
const num = Number(amount)
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
height: 56px;
|
||||
border-radius: 14px;
|
||||
background: rgba(9, 61, 81, 0.08);
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
border: 1px solid rgba(9, 61, 81, 0.15);
|
||||
border-radius: 12px;
|
||||
background: rgba(9, 61, 81, 0.03);
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="bg-white wrap-fix z-200001 py-3 px-3 text-primary font-bold drop-shadow flex">
|
||||
<div class="cursor-pointer" @click="router.back()">
|
||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||
</div>
|
||||
<div class="mr-2">درباره ما</div>
|
||||
</div>
|
||||
<div class="pt-20 pb-24">
|
||||
<MobilePageHeader title="درباره ما" show-back />
|
||||
<div class="mpage-content pb-[calc(var(--app-bottom-chrome-height)+1rem)]">
|
||||
<div class="px-5">
|
||||
<AboutSectionsContent variant="mobile" />
|
||||
</div>
|
||||
@@ -16,8 +11,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import router from '@/router'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||
import AboutSectionsContent from '../components/AboutSectionsContent.vue'
|
||||
import AboutSupportActions from '../components/AboutSupportActions.vue'
|
||||
</script>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="absolute inset-0 bg-cover bg-center opacity-60 z--1" :style="{ backgroundImage: `url(${img})` }" />
|
||||
<div class="bg-white drop-shadow z-[1999] wrap-fix">
|
||||
<div class="py-3 px-3 font-bold flex items-center justify-between">
|
||||
<div class="mpage-header wrap-fix z-[1999]">
|
||||
<div class="py-3 px-3 font-bold flex items-center justify-between w-full">
|
||||
<div>سبد خرید</div>
|
||||
<div v-if="price" class="flex gap-1 items-center text-xs flex-1 justify-end">
|
||||
<span class="text-gray-600 text-xs">قیمت خرید از کشکول گلد:</span>
|
||||
@@ -15,7 +15,7 @@
|
||||
</div>
|
||||
|
||||
<GoldLoading v-model:show="infoVisible" title="" />
|
||||
<div class="px-5 pt-26 pb-30" :class="loading ? 'h-[60vh]' : ''">
|
||||
<div class="px-5 mpage-content pb-[calc(var(--app-bottom-chrome-height)+1rem)]" :class="loading ? 'h-[60vh]' : ''">
|
||||
<template v-if="loading">
|
||||
<TransactionSkeleton v-for="i in 3" :key="i" class="mt-4" />
|
||||
</template>
|
||||
|
||||
@@ -6,7 +6,8 @@ import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||
import type { WalletMetalTotal } from '@/models/walletAssets'
|
||||
import { fundPageInventoryCards, formatMetalTotal as buildMetalTotalLabel } from '@/utils/productAssets'
|
||||
import { getLastPrices } from '@/utils/price'
|
||||
import img from '@/assets/img/cash_img.svg'
|
||||
import { getProjectBranding, isGhatreProject } from '@/utils/project'
|
||||
import img from '@/assets/img/user_ly1.svg'
|
||||
import empty from '@/assets/img/cash_empty.svg'
|
||||
|
||||
export interface FundPageContext {
|
||||
@@ -20,6 +21,8 @@ export interface FundPageContext {
|
||||
fundHeaderBackground: string
|
||||
fundEmptyImage: string
|
||||
fundEmptyText: string
|
||||
fundLabel: string
|
||||
fundBalanceLabel: string
|
||||
formatMetalTotal: (metal: WalletMetalTotal) => string
|
||||
openFundInfo: (productId: number) => void
|
||||
goBack: () => void
|
||||
@@ -70,6 +73,8 @@ export function useFundPage(_isDesktop: Ref<boolean>) {
|
||||
}
|
||||
})
|
||||
|
||||
const branding = getProjectBranding()
|
||||
|
||||
const context: FundPageContext = {
|
||||
meta,
|
||||
inventoryCards,
|
||||
@@ -80,7 +85,9 @@ export function useFundPage(_isDesktop: Ref<boolean>) {
|
||||
countBasedInventory,
|
||||
fundHeaderBackground: img,
|
||||
fundEmptyImage: empty,
|
||||
fundEmptyText: 'هنوز محصولی خریداری نکردهاید',
|
||||
fundEmptyText: isGhatreProject() ? 'یک قلک جدید بساز!' : 'یک گنج جدید بساز!',
|
||||
fundLabel: branding.fundLabel,
|
||||
fundBalanceLabel: isGhatreProject() ? `موجودی ${branding.fundLabel} ها` : `موجودی ${branding.fundLabel}`,
|
||||
formatMetalTotal,
|
||||
openFundInfo,
|
||||
goBack,
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
بازگشت
|
||||
</button>
|
||||
<div class="dfund-topbar__meta">
|
||||
<p class="dfund-topbar__eyebrow">دارایی</p>
|
||||
<h1 class="dfund-topbar__title">داراییها</h1>
|
||||
<p class="dfund-topbar__eyebrow">{{ fundLabel }}</p>
|
||||
<h1 class="dfund-topbar__title">{{ fundLabel }}</h1>
|
||||
<p class="dfund-topbar__subtitle">نمای کلی موجودی محصولات و کیف پول</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="dfund-summary dfund-summary--ghatreh">
|
||||
<section class="dfund-summary" :class="isGhatre ? 'dfund-summary--ghatreh' : ''">
|
||||
<img :src="fundHeaderBackground" alt="" class="dfund-summary__bg" />
|
||||
<div class="dfund-summary__content">
|
||||
<h2 class="dfund-summary__title">موجودی داراییها</h2>
|
||||
<h2 class="dfund-summary__title">{{ fundBalanceLabel }}</h2>
|
||||
|
||||
<div v-if="meta?.has_count_based_products" class="dfund-summary__row">
|
||||
<span>محصولات</span>
|
||||
@@ -93,6 +93,9 @@ import { loading } from '@/utils'
|
||||
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||
import Item from '../components/Item.vue'
|
||||
import { useFundPageContext } from '../composables/useFundPage'
|
||||
import { useProject } from '@/composables/useProject'
|
||||
|
||||
const { isGhatre } = useProject()
|
||||
|
||||
const {
|
||||
meta,
|
||||
@@ -105,6 +108,8 @@ const {
|
||||
fundHeaderBackground,
|
||||
fundEmptyImage,
|
||||
fundEmptyText,
|
||||
fundLabel,
|
||||
fundBalanceLabel,
|
||||
formatMetalTotal,
|
||||
openFundInfo,
|
||||
goBack,
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
overflow: hidden;
|
||||
border-radius: 16px;
|
||||
margin-bottom: 24px;
|
||||
background: @App-primary-color;
|
||||
background: @theme-primary;
|
||||
color: #fff;
|
||||
|
||||
&--bazretala {
|
||||
@@ -339,7 +339,7 @@
|
||||
.dfund-info__balance-value {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
}
|
||||
|
||||
.dfund-info__balance-unit {
|
||||
@@ -495,8 +495,8 @@
|
||||
cursor: pointer;
|
||||
|
||||
&--active {
|
||||
background: @App-primary-color;
|
||||
border-color: @App-primary-color;
|
||||
background: @theme-primary;
|
||||
border-color: @theme-primary;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="fund-page-root">
|
||||
<div class="fund-page-root main-with-bottom-chrome-inner--contained">
|
||||
<DesktopFundView v-show="isDesktop" />
|
||||
<MobileFundView v-show="!isDesktop" />
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="bg-white w-full py-3 px-3 text-black font-bold drop-shadow fixed md:absolute top-0 flex h-12 z-20">
|
||||
<div @click="goBack()">
|
||||
<div class="fund-mobile-root">
|
||||
<div
|
||||
class="fund-mobile-root__header bg-white w-full mobile-top-chrome px-3 pb-3 text-primary font-bold drop-shadow flex min-h-12 z-20"
|
||||
>
|
||||
<div class="cursor-pointer" @click="goBack()">
|
||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||
</div>
|
||||
<div class="mr-2">دارایی ها</div>
|
||||
<div class="mr-2">{{ fundLabel }}</div>
|
||||
</div>
|
||||
<div class="bg-[#EFCED9] w-screen md:w-full h-[70vh] fixed md:absolute overflow-hidden">
|
||||
|
||||
<div
|
||||
class="fund-mobile-root__hero text-tertiary"
|
||||
:class="isGhatre ? 'fund-mobile-root__hero--ghatre' : 'bg-primary'"
|
||||
:style="isGhatre ? { backgroundColor: fundHeroBg } : undefined"
|
||||
>
|
||||
<img
|
||||
:src="fundHeaderBackground"
|
||||
alt=""
|
||||
class="mt-[-4rem] mr-10 max-w-[22rem] self-end pointer-events-none absolute bottom-0 left-0 opacity-20"
|
||||
class="fund-mobile-root__hero-bg"
|
||||
/>
|
||||
<div class="pt-15 flex flex-col relative z-10">
|
||||
<div class="text-gray-700 font-bold mr-5 z-20">موجودی دارایی ها</div>
|
||||
<div class="fund-mobile-root__hero-content flex flex-col">
|
||||
<div class="font-bold mr-5 z-20">{{ fundBalanceLabel }}</div>
|
||||
|
||||
<div
|
||||
v-if="meta?.has_count_based_products"
|
||||
@@ -59,14 +66,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt-[20rem]">
|
||||
<div
|
||||
class="bg-gray-100 w-screen md:w-full z-20 relative rounded-t-3xl h-[calc(100vh-20rem-70px)] overflow-y-auto pb-15"
|
||||
style="box-shadow: 0px -2px 4px -2px #0000001a"
|
||||
>
|
||||
<div class="fund-mobile-root__scroll">
|
||||
<div class="fund-mobile-root__panel bg-gray-100 rounded-t-3xl">
|
||||
<div
|
||||
v-if="inventoryCards.length === 0 && !loading"
|
||||
class="w-full h-full flex justify-center items-center"
|
||||
class="w-full min-h-[40vh] flex justify-center items-center"
|
||||
>
|
||||
<div>
|
||||
<img :src="fundEmptyImage" alt="" class="w-70" />
|
||||
@@ -91,10 +95,15 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import { computed } from 'vue'
|
||||
import { loading } from '@/utils'
|
||||
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||
import Item from '../components/Item.vue'
|
||||
import { useFundPageContext } from '../composables/useFundPage'
|
||||
import { useProject } from '@/composables/useProject'
|
||||
|
||||
const { isGhatre, branding } = useProject()
|
||||
const fundHeroBg = computed(() => branding.value.fundHeroBg)
|
||||
|
||||
const {
|
||||
meta,
|
||||
@@ -107,8 +116,67 @@ const {
|
||||
fundHeaderBackground,
|
||||
fundEmptyImage,
|
||||
fundEmptyText,
|
||||
fundLabel,
|
||||
fundBalanceLabel,
|
||||
formatMetalTotal,
|
||||
openFundInfo,
|
||||
goBack,
|
||||
} = useFundPageContext()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.fund-mobile-root {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.fund-mobile-root__header {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.fund-mobile-root__hero {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
overflow: hidden;
|
||||
padding-bottom: 2.5rem;
|
||||
}
|
||||
|
||||
.fund-mobile-root__hero-bg {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 0;
|
||||
width: 100%;
|
||||
opacity: 0.05;
|
||||
}
|
||||
|
||||
.fund-mobile-root__hero-content {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
padding: 1rem 0 0;
|
||||
}
|
||||
|
||||
.fund-mobile-root__scroll {
|
||||
position: relative;
|
||||
z-index: 20;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
margin-top: -2rem;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overscroll-behavior-y: contain;
|
||||
}
|
||||
|
||||
.fund-mobile-root__panel {
|
||||
min-height: 100%;
|
||||
padding-bottom: calc(var(--app-bottom-chrome-height, 80px) + 1rem);
|
||||
box-shadow: 0 -2px 4px -2px #0000001a;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
type="text"
|
||||
/>
|
||||
</a-form-item>
|
||||
<p :class="variant === 'desktop' ? 'dgift-form__hint' : 'font-bold text-xs mt-1'">
|
||||
<p :class="variant === 'desktop' ? 'dgift-form__hint' : 'gift-card-form__hint'">
|
||||
کد کارت هدیه خود را در فیلد بالا وارد کنید و سپس دکمه ثبت را بزنید.
|
||||
</p>
|
||||
<p :class="variant === 'desktop' ? 'dgift-form__case-note' : 'font-bold text-xs mt-3'">
|
||||
<p :class="variant === 'desktop' ? 'dgift-form__case-note' : 'gift-card-form__case-note'">
|
||||
*حساس به حروف بزرگ و کوچک
|
||||
</p>
|
||||
<a-form-item>
|
||||
@@ -39,3 +39,24 @@ withDefaults(defineProps<{ variant?: 'mobile' | 'desktop' }>(), { variant: 'mobi
|
||||
|
||||
const { form, disableButton, registerGiftCard } = useGiftCardPageContext()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.gift-card-form__hint,
|
||||
.gift-card-form__case-note {
|
||||
margin: 0;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.65;
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.gift-card-form__hint {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.gift-card-form__case-note {
|
||||
margin-top: 0.75rem;
|
||||
color: #64748b;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
height: 56px;
|
||||
border-radius: 14px;
|
||||
background: rgba(167, 43, 119, 0.08);
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
}
|
||||
|
||||
.basic-icon {
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
flex-shrink: 0;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
@@ -1,48 +1,26 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="bg-white py-3 px-3 text-black font-bold drop-shadow z-[1999] wrap-fix">کارت هدیه</div>
|
||||
<div class="px-5 pt-26 pb-2">
|
||||
<a-form :model="form" class="!mt-5" name="basic" @finish="registerGiftCard">
|
||||
<div class="border-gray-200 border-1 rounded-xl p-5 trans h-40 relative">
|
||||
<bg_main />
|
||||
<div class="z-100 relative">
|
||||
<a-form-item :rules="[required()]" label="کد کارت هدیه" name="code">
|
||||
<BasicInput
|
||||
v-model:value="form.code"
|
||||
place-holder="کد کارت هدیه را وارد کنید"
|
||||
size="large"
|
||||
type="text"
|
||||
/>
|
||||
</a-form-item>
|
||||
<div class="font-bold text-xs mt-1">
|
||||
کد کارت هدیه خود را در فیلد بالا وارد کنید و سپس دکمه ثبت را بزنید.
|
||||
</div>
|
||||
<div class="font-bold text-xs mt-3">*حساس به حروف بزرگ و کوچک</div>
|
||||
</div>
|
||||
<div class="gift-card-mobile">
|
||||
<MobilePageHeader title="کارت هدیه" show-back />
|
||||
|
||||
<div class="gift-card-mobile__content mpage-content px-5 pb-[calc(var(--app-bottom-chrome-height)+1rem)]">
|
||||
<div class="gift-card-mobile__card border-gray-200 border-1 rounded-xl p-5 relative overflow-hidden">
|
||||
<bg_main />
|
||||
<div class="relative z-10">
|
||||
<GiftCardForm variant="mobile" />
|
||||
</div>
|
||||
<a-form-item>
|
||||
<BasicButton
|
||||
:disabled="disableButton"
|
||||
class="w-full py-2 mt-5"
|
||||
html-type="submit"
|
||||
type="primary"
|
||||
>
|
||||
<a-spin v-if="loading" size="small" />
|
||||
<div v-else>ثبت کد</div>
|
||||
</BasicButton>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { loading } from '@/utils'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import Bg_main from '@/components/bg_main.vue'
|
||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||
import { required } from '@/utils/inputRules'
|
||||
import { useGiftCardPageContext } from '../composables/useGiftCardPage'
|
||||
|
||||
const { form, disableButton, registerGiftCard } = useGiftCardPageContext()
|
||||
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||
import GiftCardForm from '../components/GiftCardForm.vue'
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.gift-card-mobile__card {
|
||||
min-height: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
+159
-99
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="h-35rem overflow-y-auto">
|
||||
<div class="h-35rem overflow-y-auto px-5">
|
||||
<div class=" !overflow-y-scroll bg-white py-3 text-primary font-bold flex justify-evenly">
|
||||
<!-- <div @click="isBuy = false" class="w-full text-center" :class="!isBuy?'text-primary':'text-gray-400'">خرید طلا</div>
|
||||
<div @click="isBuy = true" class="w-full text-center" :class="isBuy?'text-primary':'text-gray-400'">فروش طلا</div>-->
|
||||
@@ -24,12 +24,10 @@
|
||||
<img :src="img1" alt="" class="h-[88px] absolute">
|
||||
<div class="w-full items-center flex flex-col">
|
||||
<div class="text-gray-700 font-bold">{{ !isBuy ? 'قیمت فروش' : 'قیمت خرید' }}</div>
|
||||
<div class="flex gap-1 mt-3 text-xs items-center">
|
||||
<Vue3Odometer
|
||||
: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 v-if="price" class="flex gap-1 mt-3 text-xs items-center">
|
||||
<div :class="!isBuy ? 'text-red-700' : 'text-green-700'" class="font-bold text-2xl color-transition">
|
||||
{{ usePriceWithoutType(goldPriceValue) }}
|
||||
</div>
|
||||
ریال
|
||||
</div>
|
||||
</div>
|
||||
@@ -37,11 +35,6 @@
|
||||
<div v-else class="w-full h-[88px]">
|
||||
<GoldSkeleton class="w-full" />
|
||||
</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-form :model="form" class="!mt-5" name="basic" @finish="okConfirm()">
|
||||
<div class="border-gray-200 border-1 rounded-xl p-5 h-58 relative">
|
||||
@@ -63,7 +56,7 @@
|
||||
<!-- {{walletStore?.walletInfo?.gold}}-->
|
||||
<Transition mode="out-in" name="fade">
|
||||
<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">
|
||||
{{ `موجودی قابل برداشت طلا: ${walletStore?.walletInfo?.gold_block ?? 0} گرم` }}
|
||||
</div>-->
|
||||
@@ -85,13 +78,6 @@
|
||||
@change="percentChange" />
|
||||
</a-form-item>
|
||||
</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>
|
||||
<GoldLoading v-model:show="infoVisible" />
|
||||
@@ -108,10 +94,11 @@
|
||||
<div v-else>{{ !isBuy ? 'فروش' : 'خرید' }}</div>
|
||||
</div>
|
||||
</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">
|
||||
مقدار گرم طلای وارد شده جهت فروش ({{ form.goldValue }}گرم) بیشتر از مقدار موجودی شما
|
||||
({{ walletStore?.walletInfo?.gold }}گرم) می باشد.
|
||||
<span v-if="feeDeductFromGold"> (با احتساب {{ feeInGrams }} گرم کارمزد، مجموعاً {{ sellGoldDebit }} گرم کسر میشود)</span>
|
||||
</div>
|
||||
<!-- <div>{{form?.goldValue? true: false}}</div>-->
|
||||
<div v-if="isBuy? ((form?.goldValue || form.goldValue === 0)? form?.goldCash < 500000: false) : false"
|
||||
@@ -125,7 +112,7 @@
|
||||
<div class="flex justify-between items-center">
|
||||
<div>کارمزد:</div>
|
||||
<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>
|
||||
گرم
|
||||
@@ -151,25 +138,39 @@
|
||||
<div class="flex justify-between ">
|
||||
<div>وزن:</div>
|
||||
<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>
|
||||
</div>
|
||||
<div class="flex justify-between mt-3">
|
||||
<div>مظنه:</div>
|
||||
<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>
|
||||
</div>
|
||||
<div class="flex justify-between mt-3">
|
||||
<div>کارمزد:</div>
|
||||
<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>
|
||||
</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>{{ isBuy ? 'قیمت قابل پرداخت:' : 'مبلغ دریافتی:' }}</div>
|
||||
<div class="flex items-center">
|
||||
@@ -200,10 +201,10 @@
|
||||
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
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 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 router from '@/router'
|
||||
import { useWalletStore } from '@/store/walletStore'
|
||||
@@ -225,12 +226,27 @@ import type { Transaction } from '@/models/transaction'
|
||||
import type { TableEngineInput, TableOutput } from '@/models/table'
|
||||
import { useInfiniteScroll } from '@vueuse/core'
|
||||
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 { 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 Vue3Odometer from 'vue3-odometer'
|
||||
import 'odometer/themes/odometer-theme-default.css'
|
||||
const infoVisible = ref(false)
|
||||
const walletStore = useWalletStore()
|
||||
const userStore = useUserStore()
|
||||
@@ -239,7 +255,6 @@ const confirmAction = ref<boolean>(false)
|
||||
const noCompleteVisible = ref<boolean>(false)
|
||||
const buyItems = ref<Transaction[]>([])
|
||||
const sellItems = ref<Transaction[]>([])
|
||||
const priceErrorVisible = ref<boolean>(false)
|
||||
const buyTableOutput = ref<TableOutput<Transaction> | null>(null)
|
||||
const sellTableOutput = ref<TableOutput<Transaction> | null>(null)
|
||||
const el = ref()
|
||||
@@ -250,6 +265,7 @@ interface Prop {
|
||||
|
||||
const props = withDefaults(defineProps<Prop>(), {})
|
||||
const isBuy = ref<boolean>(true)
|
||||
const inputLock = ref<TradeInputLock>(null)
|
||||
|
||||
const buyPagination = ref<TableEngineInput>({
|
||||
filters: [{
|
||||
@@ -270,20 +286,52 @@ const sellPagination = ref<TableEngineInput>({
|
||||
}], limit: 6, page: 0
|
||||
})
|
||||
|
||||
const finalPrice = computed(() => (form.value?.goldValue * (isBuy.value ? price.value?.buy ?? 0 : price.value?.sell ?? 0)))
|
||||
// const payablePrice = computed(() => finalPrice.value + finalPrice.value * 0.007)
|
||||
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 unitPrice = computed(() =>
|
||||
isBuy.value ? getTradeBuyPrice(lastPrice.value) : getTradeSellPrice(lastPrice.value)
|
||||
)
|
||||
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(() =>
|
||||
loading.value ||
|
||||
isStoreClosed() ||
|
||||
form.value?.goldValue === undefined ||
|
||||
form.value?.goldValue === '' ||
|
||||
form.value?.goldCash === '' ||
|
||||
form.value?.goldCash === undefined ||
|
||||
(isBuy.value ? (form.value?.goldCash ?? 0) < 500000 : (form.value?.goldValue ?? 0) < 0.001) ||
|
||||
(!isBuy.value && form.value.goldValue > walletStore?.walletInfo?.gold) ||
|
||||
price.value?.buy === undefined)
|
||||
(!isBuy.value && sellGoldDebit.value > (walletStore?.walletInfo?.gold ?? 0)) ||
|
||||
(isBuy.value && payablePrice.value > (walletStore?.walletInfo?.cash ?? 0)) ||
|
||||
priceUnavailable.value)
|
||||
|
||||
function refreshTable() {
|
||||
sellItems.value = []
|
||||
@@ -385,6 +433,7 @@ onMounted(async () => {
|
||||
break
|
||||
}
|
||||
await initPrice()
|
||||
await loadServiceFeeFromSettings()
|
||||
/* await initSellTable()
|
||||
await initBuyTable()*/
|
||||
})
|
||||
@@ -479,20 +528,18 @@ onUnmounted(() => {
|
||||
})
|
||||
|
||||
function percentChange(val: number) {
|
||||
if (val !== 0)
|
||||
if (val !== 0) {
|
||||
if (isBuy.value) {
|
||||
form.value.goldCash = unitCashCalculator.value * val
|
||||
calculateGold(form.value.goldCash)
|
||||
calculateCash(form.value.goldValue)
|
||||
} else {
|
||||
// console.log((unitGoldCalculator.value * val).toFixed(2))
|
||||
// form.value.goldValue = parseFloat((unitGoldCalculator.value * val).toFixed(2))
|
||||
form.value.goldValue = toFixedDownThreeChar(parseFloat(unitGoldCalculator.value * val))
|
||||
form.value.goldValue = formatTradeGramDisplay(parseFloat(String(unitGoldCalculator.value * val)))
|
||||
calculateCash(form.value.goldValue)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
form.value.goldValue = undefined
|
||||
form.value.goldCash = undefined
|
||||
inputLock.value = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,55 +552,61 @@ const unitCashCalculator = computed(() => {
|
||||
return (walletStore?.walletInfo?.cash ?? 0) / 100
|
||||
})
|
||||
|
||||
const limitedPrice = computed(() => {
|
||||
if (walletStore.limitedPrice)
|
||||
return walletStore?.limitedPrice[0]
|
||||
})
|
||||
function syncFormWithLatestPrice() {
|
||||
const unit = unitPrice.value
|
||||
if (!unit || Number.isNaN(unit) || !inputLock.value) return
|
||||
|
||||
function calculateCash(val: number) {
|
||||
priceErrorVisible.value = false
|
||||
// console.log(val)
|
||||
if (price.value) {
|
||||
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
|
||||
if (inputLock.value === 'gram') {
|
||||
const goldValue = form.value.goldValue
|
||||
if (goldValue !== undefined && goldValue !== null && goldValue !== '' && !isNaN(Number(goldValue))) {
|
||||
calculateCash(Number(goldValue))
|
||||
}
|
||||
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) {
|
||||
// console.log(val)
|
||||
// form.value.goldCash = usePriceWithoutType(form.value.goldCash)
|
||||
if (price.value) {
|
||||
if (isBuy.value) {
|
||||
if (val) {
|
||||
form.value.goldValue = toFixedDownThreeChar(parseFloat(val / price?.value?.buy))
|
||||
if (parseInt(finalPrice.value) > 0) priceErrorVisible.value = true
|
||||
if (parseInt(finalPrice.value) === 0) priceErrorVisible.value = false
|
||||
} else if (val.toString() === '') {
|
||||
form.value.goldValue = undefined
|
||||
priceErrorVisible.value = false
|
||||
} 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
|
||||
}
|
||||
}
|
||||
inputLock.value = 'rial'
|
||||
const unit = unitPrice.value
|
||||
if (!unit || Number.isNaN(unit)) return
|
||||
|
||||
if (val) {
|
||||
form.value.goldValue = formatTradeGramDisplay(calcGramFromLockedRial(val, unit, isBuy.value))
|
||||
} else if (val.toString() === '') {
|
||||
form.value.goldValue = undefined
|
||||
inputLock.value = null
|
||||
} else {
|
||||
form.value.goldValue = 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,7 +628,7 @@ function setIsBuy(val: boolean) {
|
||||
form.value.goldValue = undefined
|
||||
form.value.goldCash = undefined
|
||||
form.value.percentWallet = 0
|
||||
priceErrorVisible.value = false
|
||||
inputLock.value = null
|
||||
// console.log(bganim.value.classList)
|
||||
// bganim?.value?.classList.add(val?'right':'left')
|
||||
// bganim?.value?.style.transform = `translateX(${val ? '0' : '-100'});`
|
||||
@@ -591,13 +644,7 @@ const formatter = (value: number) => {
|
||||
|
||||
const price = computed((): Price => <Price>lastPrice.value ?? 0)
|
||||
|
||||
const displayedGoldPrice = ref<number>(0)
|
||||
|
||||
watch([() => lastPrice.value, isBuy], () => {
|
||||
if (lastPrice.value) {
|
||||
displayedGoldPrice.value = isBuy.value ? (lastPrice.value.buy ?? 0) : (lastPrice.value.sell ?? 0)
|
||||
}
|
||||
}, { immediate: true })
|
||||
const goldPriceValue = computed(() => unitPrice.value)
|
||||
|
||||
async function initPrice() {
|
||||
try {
|
||||
@@ -605,9 +652,6 @@ async function initPrice() {
|
||||
await setIntervalGetAllPrice()
|
||||
loading.value = true
|
||||
price.value = lastPrice.value
|
||||
if (lastPrice.value) {
|
||||
displayedGoldPrice.value = isBuy.value ? (lastPrice.value.buy ?? 0) : (lastPrice.value.sell ?? 0)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
@@ -616,17 +660,32 @@ async function initPrice() {
|
||||
}
|
||||
|
||||
function okConfirm() {
|
||||
if (isStoreClosed()) {
|
||||
message.warning(getStoreClosedMessage())
|
||||
return
|
||||
}
|
||||
confirmAction.value = true
|
||||
}
|
||||
|
||||
async function ok() {
|
||||
if (isStoreClosed()) {
|
||||
message.warning(getStoreClosedMessage())
|
||||
return
|
||||
}
|
||||
try {
|
||||
loading.value = true
|
||||
infoVisible.value = true
|
||||
await createOrder({
|
||||
direction: isBuy.value ? 1 : 2,
|
||||
price: isBuy.value ? price.value?.buy : price.value?.sell,
|
||||
amount: form.value.goldValue ?? 0
|
||||
price: Math.round(unitPrice.value),
|
||||
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 router.push({ name: 'transactions' })
|
||||
@@ -635,6 +694,7 @@ async function ok() {
|
||||
goldCash: undefined,
|
||||
percentWallet: undefined
|
||||
}
|
||||
inputLock.value = null
|
||||
// refreshTable()
|
||||
message.success('سفارش شما با موفقیت انجام شد')
|
||||
await fundStore.getMyFund()
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
<template>
|
||||
<div
|
||||
ref="headerRef"
|
||||
class="app-header px-4 pb-2 top-0 wrap-fix background-color-transition"
|
||||
:class="{ 'app-header--scrolled': isHeaderScrolled }"
|
||||
>
|
||||
<div class="flex justify-between my-2 items-center">
|
||||
<div class="flex items-center gap-2" @click.stop="router.push({ name: 'user' })">
|
||||
<div class="z-100000 rounded-full border-1 text-primary border-primary">
|
||||
<Icon icon="vuesax-linear:user" size="20" />
|
||||
</div>
|
||||
<div class="text-primary color-transition font-bold">
|
||||
{{ userStore.userInfo?.name }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="mhome-header-btn mhome-header-btn--logout"
|
||||
@click="$emit('logout')"
|
||||
>
|
||||
<Icon icon="vuesax-linear:logout" size="18" />
|
||||
<span>خروج</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { nextTick, onActivated, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import router from '@/router'
|
||||
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
|
||||
const headerRef = ref<HTMLElement | null>(null)
|
||||
const isHeaderScrolled = ref(false)
|
||||
const route = useRoute()
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
let intersectionObserver: IntersectionObserver | null = null
|
||||
let scrollTarget: HTMLElement | Window | null = null
|
||||
|
||||
function isScrollableOverflow(value: string) {
|
||||
return value === 'auto' || value === 'scroll' || value === 'overlay'
|
||||
}
|
||||
|
||||
function findScrollParent(el: HTMLElement | null): HTMLElement | null {
|
||||
let node = el?.parentElement ?? null
|
||||
|
||||
while (node) {
|
||||
const style = getComputedStyle(node)
|
||||
const overflowY = style.overflowY
|
||||
const overflow = style.overflow
|
||||
|
||||
if (isScrollableOverflow(overflowY) || isScrollableOverflow(overflow)) {
|
||||
return node
|
||||
}
|
||||
|
||||
node = node.parentElement
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function resolveScrollRoot(): HTMLElement | null {
|
||||
const header = headerRef.value
|
||||
if (!header) return null
|
||||
|
||||
const chromeInner = header.closest('.main-with-bottom-chrome-inner')
|
||||
if (chromeInner instanceof HTMLElement) {
|
||||
return chromeInner
|
||||
}
|
||||
|
||||
const fromParent = findScrollParent(header)
|
||||
if (fromParent) {
|
||||
return fromParent
|
||||
}
|
||||
|
||||
const global = document.querySelector('.main-with-bottom-chrome-inner')
|
||||
return global instanceof HTMLElement ? global : null
|
||||
}
|
||||
|
||||
function resolveScrollSentinel(scrollRoot: HTMLElement | null): HTMLElement | null {
|
||||
if (!scrollRoot) return null
|
||||
|
||||
const local = scrollRoot.querySelector('.app-header-scroll-sentinel')
|
||||
if (local instanceof HTMLElement) {
|
||||
return local
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function updateScrollStateFromPosition() {
|
||||
if (!scrollTarget) return
|
||||
|
||||
const next =
|
||||
scrollTarget instanceof Window
|
||||
? scrollTarget.scrollY > 50
|
||||
: scrollTarget.scrollTop > 50
|
||||
|
||||
isHeaderScrolled.value = next
|
||||
}
|
||||
|
||||
function teardownScrollTracking() {
|
||||
intersectionObserver?.disconnect()
|
||||
intersectionObserver = null
|
||||
|
||||
scrollTarget?.removeEventListener('scroll', updateScrollStateFromPosition)
|
||||
scrollTarget = null
|
||||
}
|
||||
|
||||
function setupScrollTracking() {
|
||||
teardownScrollTracking()
|
||||
|
||||
const scrollRoot = resolveScrollRoot()
|
||||
const sentinel = resolveScrollSentinel(scrollRoot)
|
||||
|
||||
if (scrollRoot && sentinel && typeof IntersectionObserver !== 'undefined') {
|
||||
intersectionObserver = new IntersectionObserver(
|
||||
([entry]) => {
|
||||
isHeaderScrolled.value = !entry?.isIntersecting
|
||||
},
|
||||
{
|
||||
root: scrollRoot,
|
||||
threshold: 0,
|
||||
rootMargin: '-1px 0px 0px 0px',
|
||||
},
|
||||
)
|
||||
intersectionObserver.observe(sentinel)
|
||||
return
|
||||
}
|
||||
|
||||
scrollTarget = scrollRoot ?? window
|
||||
scrollTarget.addEventListener('scroll', updateScrollStateFromPosition, { passive: true })
|
||||
updateScrollStateFromPosition()
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
setupScrollTracking()
|
||||
await nextTick()
|
||||
setupScrollTracking()
|
||||
requestAnimationFrame(() => setupScrollTracking())
|
||||
})
|
||||
|
||||
onActivated(() => {
|
||||
isHeaderScrolled.value = false
|
||||
setupScrollTracking()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => route.fullPath,
|
||||
() => {
|
||||
if (route.name === 'home') {
|
||||
isHeaderScrolled.value = false
|
||||
nextTick(() => setupScrollTracking())
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
onUnmounted(() => {
|
||||
teardownScrollTracking()
|
||||
})
|
||||
|
||||
defineEmits<{
|
||||
logout: []
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.app-header {
|
||||
z-index: 1999;
|
||||
box-sizing: border-box;
|
||||
padding-top: calc(0.5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.app-header--scrolled {
|
||||
background-color: rgba(255, 255, 255, 0.92);
|
||||
box-shadow:
|
||||
0 1px 3px 0 rgb(0 0 0 / 0.1),
|
||||
0 1px 2px -1px rgb(0 0 0 / 0.1);
|
||||
}
|
||||
|
||||
.mhome-header-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
color: #0a1b37;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.mhome-header-btn--logout {
|
||||
color: #dc2626;
|
||||
border-color: #fecaca;
|
||||
background: #fef2f2;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,94 @@
|
||||
import { computed, inject, provide, type InjectionKey } from 'vue'
|
||||
import router from '@/router'
|
||||
import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { getStoreClosedMessage, isStoreClosed } from '@/utils/storeHours'
|
||||
import { isKashkoolProject } from '@/utils/project'
|
||||
import { getHomeLayoutId } from '../layouts/registry'
|
||||
import { useBanners } from './useBanners'
|
||||
import { usePriceChart } from './usePriceChart'
|
||||
import { initHomePageData } from './useHomePageData'
|
||||
import type { HomeActionItem } from '../layouts/types'
|
||||
|
||||
export const HOME_PAGE_CONTEXT_KEY: InjectionKey<ReturnType<typeof createHomePageContext>> =
|
||||
Symbol('homePageContext')
|
||||
|
||||
function createHomePageContext() {
|
||||
const settingsStore = useSettingsStore()
|
||||
const { banners } = useBanners()
|
||||
const chart = usePriceChart()
|
||||
|
||||
const isBoursecuHomeLayout = computed(() => getHomeLayoutId() === 'boursecu')
|
||||
const isGaroosi = computed(() => isKashkoolProject())
|
||||
const bannerEnabled = computed(() => settingsStore.isSettingTruthy('banner_enabled'))
|
||||
const showClosedMessage = computed(() => isStoreClosed())
|
||||
const closedMessage = computed(() => getStoreClosedMessage())
|
||||
|
||||
const mainActions = computed<HomeActionItem[]>(() => [
|
||||
{
|
||||
name: 'buySell',
|
||||
icon: 'vuesax-linear:money-receive',
|
||||
label: 'خرید و فروش',
|
||||
handler: () => router.push({ name: 'gold' }),
|
||||
},
|
||||
{
|
||||
name: 'deposit',
|
||||
icon: 'vuesax-linear:card-add',
|
||||
label: 'واریز نقدی',
|
||||
handler: () => router.push({ name: 'wallet', query: { state: 'deposit' } }),
|
||||
},
|
||||
{
|
||||
name: 'balance',
|
||||
icon: 'vuesax-linear:receipt-item',
|
||||
label: 'موجودی',
|
||||
handler: () => {},
|
||||
},
|
||||
{
|
||||
name: 'fund',
|
||||
icon: 'vuesax-linear:archive-1',
|
||||
label: 'دارایی ها',
|
||||
handler: () => router.push({ name: 'fund' }),
|
||||
},
|
||||
{
|
||||
name: 'earn',
|
||||
icon: 'vuesax-linear:dollar-circle',
|
||||
label: 'کسب درآمد',
|
||||
handler: () => router.push({ name: 'earnMoney' }),
|
||||
},
|
||||
])
|
||||
|
||||
function openGoldModal() {}
|
||||
function openRialModal() {}
|
||||
function handleBannerClick() {}
|
||||
|
||||
void initHomePageData()
|
||||
|
||||
return {
|
||||
isBoursecuHomeLayout,
|
||||
isGaroosi,
|
||||
bannerEnabled,
|
||||
banners,
|
||||
showClosedMessage,
|
||||
closedMessage,
|
||||
mainActions,
|
||||
priceChartSeries: chart.priceChartSeries,
|
||||
chartSelection: chart.chartSelection,
|
||||
selectedChartMetal: chart.selectedChartMetal,
|
||||
updateChartData: chart.updateChartData,
|
||||
setChartMetal: chart.setChartMetal,
|
||||
openGoldModal,
|
||||
openRialModal,
|
||||
handleBannerClick,
|
||||
}
|
||||
}
|
||||
|
||||
export function useHomePageProvider() {
|
||||
const context = createHomePageContext()
|
||||
provide(HOME_PAGE_CONTEXT_KEY, context)
|
||||
return context
|
||||
}
|
||||
|
||||
export function useHomePageContext() {
|
||||
const existing = inject(HOME_PAGE_CONTEXT_KEY, null)
|
||||
if (existing) return existing
|
||||
return useHomePageProvider()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export async function loadHomeFunds(_force = false) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
export function resetHomeFunds() {
|
||||
// no-op — fund list is loaded via wallet assets on the home page
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
<template v-else-if="userStore.userInfo">
|
||||
<section class="dhome-hero-row">
|
||||
<div class="dhome-surface dhome-hero-price">
|
||||
<span class="dhome-label">قیمت خرید از کشکول گلد</span>
|
||||
<span class="dhome-label">{{ branding.buyPriceLabel }}</span>
|
||||
<div class="dhome-hero-price__value-row">
|
||||
<span
|
||||
v-if="percentPriceChanged() !== 0"
|
||||
@@ -160,7 +160,7 @@ import { useUserStore } from '@/store/userStore'
|
||||
import { useWalletStore } from '@/store/walletStore'
|
||||
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||
import { resolveAssetsRialValue } from '@/utils/productAssets'
|
||||
import { usePrice, usePriceWithoutType, useTowDecimal } from '@/utils/usePrice'
|
||||
import { usePrice, usePriceWithoutType, useTowDecimal, formatGoldAmount } from '@/utils/usePrice'
|
||||
import {
|
||||
getLastPrices,
|
||||
getTradeBuyPrice,
|
||||
@@ -174,8 +174,9 @@ import DesktopHomeTopbar from '@/views/base/home/components/DesktopHomeTopbar.vu
|
||||
import HomeSkeleton from '@/views/base/home/components/HomeSkeleton.vue'
|
||||
import bannerImg from '@/assets/img/banner/2.png'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useProject } from '@/composables/useProject'
|
||||
|
||||
const emit = defineEmits<{ logout: []; openBalance: [] }>()
|
||||
const { branding, projectNameFa } = useProject()
|
||||
const userStore = useUserStore()
|
||||
const walletStore = useWalletStore()
|
||||
const { assetsSummary, loadWalletAssets } = useWalletAssets()
|
||||
@@ -210,10 +211,10 @@ const balanceLabel = computed(() => {
|
||||
}
|
||||
const metal = primaryMetalTotal.value
|
||||
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
|
||||
return `${Number(fallback).toFixed(3)} گرم`
|
||||
return `${formatGoldAmount(fallback)} گرم`
|
||||
})
|
||||
|
||||
const totalRialDisplay = computed(() =>
|
||||
@@ -263,7 +264,7 @@ function shareReferral() {
|
||||
const text = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر!
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" برای شما ارسال شده.
|
||||
kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}`
|
||||
navigator.share({ title: 'کشکول گلد', text })
|
||||
navigator.share({ title: projectNameFa.value, text })
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -8,10 +8,12 @@ import { computed } from 'vue'
|
||||
import { getHomeLayoutId } from '../layouts/registry'
|
||||
import BoursecuDesktopHome from './layouts/BoursecuDesktopHome.vue'
|
||||
import DefaultDesktopHome from './layouts/DefaultDesktopHome.vue'
|
||||
import { useHomePageProvider } from '../composables/useHomePage'
|
||||
|
||||
defineEmits<{
|
||||
logout: []
|
||||
}>()
|
||||
|
||||
useHomePageProvider()
|
||||
const layoutId = computed(() => getHomeLayoutId())
|
||||
</script>
|
||||
|
||||
@@ -1,36 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, inject } from 'vue'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||
import { inject } from 'vue'
|
||||
import { isBoursecuProject } from '@/utils/config'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import { HOME_PAGE_CONTEXT_KEY } from '../../composables/useHomePage'
|
||||
|
||||
const ctx = inject(HOME_PAGE_CONTEXT_KEY)!
|
||||
const userStore = useUserStore()
|
||||
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>
|
||||
|
||||
<template>
|
||||
<div v-if="showLimitedPrice || 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 v-if="!isBoursecu && ctx.showClosedMessage.value" class="dhome-alerts">
|
||||
<div
|
||||
v-if="!isBoursecu && ctx.showClosedMessage.value"
|
||||
class="dhome-alert dhome-alert--info"
|
||||
v-html="ctx.closedMessage.value"
|
||||
/>
|
||||
|
||||
@@ -420,7 +420,7 @@
|
||||
height: 36px;
|
||||
border-radius: 10px;
|
||||
background: #f3f4f6;
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
flex-shrink: 0;
|
||||
transition: background 0.15s ease;
|
||||
overflow: visible;
|
||||
@@ -498,7 +498,7 @@
|
||||
height: 40px;
|
||||
border-radius: 12px;
|
||||
background: #ffffff;
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@
|
||||
transition: background 0.15s ease, color 0.15s ease;
|
||||
|
||||
&--active {
|
||||
background: @App-primary-color;
|
||||
background: @theme-primary;
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
<template>
|
||||
<div class="home-page-root">
|
||||
<GhatrehHomeDesktopView
|
||||
v-show="isDesktop"
|
||||
v-if="isDesktop && !isGhatre"
|
||||
@logout="showLogoutConfirm = true"
|
||||
@open-balance="openWholeBalanceVisible()"
|
||||
/>
|
||||
<div v-show="!isDesktop" class="mt-20">
|
||||
<div v-show="!isDesktop || isGhatre" class="home-mobile-root pb-[calc(var(--app-bottom-chrome-height)+1rem)]">
|
||||
<div class="app-header-scroll-sentinel" aria-hidden="true" />
|
||||
<div
|
||||
v-if="!loading"
|
||||
class="bg-white w-full md:w-auto h-fit px-5 m-[-1px]"
|
||||
>
|
||||
<div
|
||||
v-if="limitedPrice !== undefined && userStore?.userInfo.trade_active !== 1"
|
||||
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
|
||||
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: heroGradient }"
|
||||
>
|
||||
<div
|
||||
class="absolute inset-0 opacity-20"
|
||||
@@ -32,13 +24,13 @@
|
||||
<div class="relative z-10">
|
||||
<div class="flex font-bold text-lg items-center gap-2 mb-3">
|
||||
<img src='@/assets/img/logo.png' alt='' class='h-8 drop-shadow-md' />
|
||||
<div class="tracking-wide">کشکول گلد </div>
|
||||
<div class="tracking-wide">{{ projectNameFa }}</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-between items-end mb-3">
|
||||
<div class="text-sm" />
|
||||
<div>
|
||||
<div class="text-xs opacity-75" style="justify-self: end;">شناسه شما در کشکول گلد</div>
|
||||
<div class="text-xs opacity-75" style="justify-self: end;">{{ branding.idCardLabel }}</div>
|
||||
<div class="flex">
|
||||
<div v-if="userStore?.userInfo?.virtual_card_number" class="ml-2 " @click.stop="copyCode()">
|
||||
<BasicIcon
|
||||
@@ -83,7 +75,7 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[42px] h-[42px] bg-primary flex items-center justify-center"
|
||||
style="border: solid 1px #a72b77"
|
||||
:style="actionBorderStyle"
|
||||
|
||||
>
|
||||
<Icon class="text-tertiary" icon="vuesax-linear:money-send" />
|
||||
@@ -97,7 +89,7 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
|
||||
style="border: solid 1px #a72b77"
|
||||
:style="actionBorderStyle"
|
||||
|
||||
>
|
||||
<Icon class="text-white" icon="vuesax-linear:money-receive" />
|
||||
@@ -111,7 +103,7 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
|
||||
style="border: solid 1px #a72b77"
|
||||
:style="actionBorderStyle"
|
||||
|
||||
>
|
||||
<Icon class="text-white" icon="vuesax-linear:card-add" />
|
||||
@@ -125,7 +117,7 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center "
|
||||
style="border: solid 1px #a72b77"
|
||||
:style="actionBorderStyle"
|
||||
>
|
||||
<Icon class="text-white" icon="vuesax-linear:receipt-item" />
|
||||
</div>
|
||||
@@ -138,7 +130,7 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
|
||||
style=" border: solid 1px #a72b77"
|
||||
:style="actionBorderStyle"
|
||||
>
|
||||
<Icon class="text-white font-bold" icon="vuesax-linear:archive-1" />
|
||||
</div>
|
||||
@@ -151,7 +143,7 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
|
||||
style=" border: solid 1px #a72b77"
|
||||
:style="actionBorderStyle"
|
||||
|
||||
>
|
||||
<Icon class="text-white font-bold" icon="vuesax-linear:dollar-circle" />
|
||||
@@ -253,7 +245,7 @@
|
||||
>
|
||||
|
||||
<div class="w-full items-center flex flex-col">
|
||||
<div class="text-gray-600">قیمت خرید از کشکول گلد</div>
|
||||
<div class="text-gray-600">{{ branding.buyPriceLabel }}</div>
|
||||
<div v-if="price" class="flex gap-1 mt-3 text-xs items-center">
|
||||
<!-- <div id="odometer" class="font-bold text-2xl odometer animated fadeIn">
|
||||
<!– {{ usePriceWithoutType(useCounterAnim(price.price_last) ?? 0) }}–>
|
||||
@@ -335,7 +327,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class=" w-full flex justify-evenly rounded-lg py-2 home_appear_fade_in mt-6 pb-25">
|
||||
<div class=" w-full flex justify-evenly rounded-lg py-2 home_appear_fade_in mt-6 pb-[calc(var(--app-bottom-chrome-height)+1rem)]">
|
||||
<div class="text-center w-full">
|
||||
<div>بالاترین قیمت امروز</div>
|
||||
<div v-if="lastPrice" class="flex flex-col items-center mt-3">
|
||||
@@ -363,32 +355,7 @@
|
||||
<div v-else class="bg-white w-full md:w-auto h-[80vh] px-5 m-[-1px] flex justify-center">
|
||||
<HomeSkeleton class="w-full" />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="!isDesktop"
|
||||
:class="y > 50 ? 'bg-white shadow opacity-95' : ''"
|
||||
class="px-4 py-2 top-0 z-5 wrap-fix background-color-transition"
|
||||
>
|
||||
<div class="flex justify-between my-2">
|
||||
<div class="flex items-center gap-2" @click.stop="router.push({ name: 'user' })">
|
||||
<!-- <img :src="testimg" alt="" class="w-[24px] h-[24px]">-->
|
||||
<div
|
||||
class="z-100000 rounded-full border-1"
|
||||
:class="y > 50 ? '' : 'border-black'"
|
||||
>
|
||||
<Icon icon="vuesax-linear:user" size="20" />
|
||||
</div>
|
||||
<div :class="y > 50 ? '' : ''" class="color-transition font-bold">
|
||||
{{ userStore.userInfo?.name }}
|
||||
</div>
|
||||
</div>
|
||||
<Icon
|
||||
:color="y > 50 ? '' : ''"
|
||||
class="color-transition"
|
||||
icon="vuesax-linear:logout"
|
||||
@click="showLogoutConfirm = true"
|
||||
/>
|
||||
</div>
|
||||
<AppHeader @logout="showLogoutConfirm = true" />
|
||||
</div>
|
||||
<DialogVant v-model:show="showLogoutConfirm" :closeOnClickOverlay="false" :timeOut="-1">
|
||||
<!-- <template v-slot:img>
|
||||
@@ -470,7 +437,7 @@
|
||||
<div class="text-center">
|
||||
<div class="mt-2">
|
||||
<div>🔥یه فرصت طلایی واقعی جلوتِ !🔥</div>
|
||||
<div>دوستاتو همین الان به کشکول گلد دعوت کن!</div>
|
||||
<div>دوستاتو همین الان به {{ projectNameFa }} دعوت کن!</div>
|
||||
<div>اونا اولین خریدشونو کاملاً بدون کارمزد انجام میدن،۱۰٪ از کارمزد ۱۰ معاملهی اولشون هم، مستقیم میاد تو حساب تو!</div>
|
||||
<div>زود باش، این فرصت همیشه باز نیست! ⏳✨</div>
|
||||
</div>
|
||||
@@ -490,11 +457,11 @@ import { Swiper, SwiperSlide } from 'swiper/vue';
|
||||
import 'swiper/swiper-bundle.css';
|
||||
import img2 from '@/assets/img/banner/2.png'
|
||||
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import { usePrice, usePriceWithoutType, useTowDecimal } from '../../../utils/usePrice'
|
||||
import { usePrice, usePriceWithoutType, useTowDecimal, formatGoldAmount } from '../../../utils/usePrice'
|
||||
import {computed, createVNode, onActivated, onMounted, onUnmounted, ref, watch} from 'vue'
|
||||
import router from '@/router'
|
||||
import * as echarts from 'echarts'
|
||||
import { useIntersectionObserver, useWindowScroll } from '@vueuse/core'
|
||||
import { useIntersectionObserver } from '@vueuse/core'
|
||||
import { loading, removeToken } from '@/utils'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { useWalletStore } from '@/store/walletStore'
|
||||
@@ -504,6 +471,7 @@ import Vue3Odometer from 'vue3-odometer'
|
||||
import 'odometer/themes/odometer-theme-default.css'
|
||||
import HomeSkeleton from '@/views/base/home/components/HomeSkeleton.vue'
|
||||
import GhatrehHomeDesktopView from '@/views/base/home/desktop/GhatrehHomeDesktopView.vue'
|
||||
import { useProject } from '@/composables/useProject'
|
||||
import {
|
||||
getLastPrices,
|
||||
getTradeBuyPrice,
|
||||
@@ -526,14 +494,18 @@ import { message, Modal } from 'ant-design-vue'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicModal from '@/components/BasicPacks/BasicModal.vue'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import AppHeader from '@/views/base/home/components/AppHeader.vue'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const walletStore = useWalletStore()
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
const { branding, projectNameFa, heroGradient, isGhatre, accentColor } = useProject()
|
||||
const actionBorderStyle = computed(() => ({
|
||||
border: `solid 1px ${accentColor.value}`,
|
||||
}))
|
||||
const chartLoading = ref<boolean>(false)
|
||||
const openModal = ref<boolean>(false)
|
||||
const wholeBalanceVisible = ref<boolean>(false)
|
||||
const { x, y } = useWindowScroll()
|
||||
const series = ref<Chart[]>([{ data: [] }])
|
||||
const key = ref<number>(0)
|
||||
const main = ref(null)
|
||||
@@ -559,14 +531,14 @@ const balanceLabel = computed(() => {
|
||||
|
||||
const metal = primaryMetalTotal.value
|
||||
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
|
||||
return `${Number(fallback).toFixed(3)} گرم`
|
||||
return `${formatGoldAmount(fallback)} گرم`
|
||||
})
|
||||
|
||||
const totalRialDisplay = computed(() =>
|
||||
@@ -741,7 +713,7 @@ const priceChartOptions = ref({
|
||||
show: false
|
||||
}
|
||||
},
|
||||
colors: ['#a72b77'],
|
||||
colors: [accentColor.value],
|
||||
fill: {
|
||||
type: 'gradient',
|
||||
gradient: {
|
||||
@@ -753,6 +725,11 @@ const priceChartOptions = ref({
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
watch(accentColor, (color) => {
|
||||
priceChartOptions.value.colors = [color]
|
||||
}, { immediate: true })
|
||||
|
||||
const toPersianNumber = (num) => {
|
||||
return num.toString().replace(/\d/g, (d) => '۰۱۲۳۴۵۶۷۸۹'[d])
|
||||
}
|
||||
@@ -776,10 +753,6 @@ const updateData = (timeline) => {
|
||||
fetchPrices()
|
||||
}
|
||||
|
||||
const limitedPrice = computed(() => {
|
||||
if (walletStore.limitedPrice) return walletStore?.limitedPrice[0]
|
||||
})
|
||||
|
||||
const test_series = [
|
||||
{
|
||||
name: 'candle',
|
||||
@@ -939,6 +912,20 @@ function copyCode() {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.home-mobile-root {
|
||||
position: relative;
|
||||
padding-top: var(--app-home-header-offset, calc(4.25rem + env(safe-area-inset-top, 0px)));
|
||||
}
|
||||
|
||||
.app-header-scroll-sentinel {
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.home-page-root.main-with-bottom-chrome-inner {
|
||||
scroll-padding-top: var(--app-home-header-offset, calc(4.25rem + env(safe-area-inset-top, 0px)));
|
||||
}
|
||||
|
||||
.home-banner {
|
||||
width: 100%;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<template>
|
||||
<HomeDesktopView @logout="$emit('logout')" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import HomeDesktopView from '../desktop/HomeDesktopView.vue'
|
||||
|
||||
defineEmits<{
|
||||
logout: []
|
||||
}>()
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { HomeLayoutConfig } from '../types'
|
||||
|
||||
export const boursecuHomeLayoutConfig: HomeLayoutConfig = {
|
||||
id: 'boursecu',
|
||||
wrapperClass: 'dhome--boursecu',
|
||||
sections: [
|
||||
{ id: 'assets', visible: true },
|
||||
{ id: 'currentPrice', visible: true },
|
||||
{ id: 'priceChart', visible: true },
|
||||
{ id: 'boursecuQuickActions', visible: true },
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { HomeQuickActionItem } from '../types'
|
||||
|
||||
export const boursecuQuickActions: HomeQuickActionItem[] = [
|
||||
{
|
||||
id: 'buy',
|
||||
label: 'خرید',
|
||||
icon: 'vuesax-linear:money-receive',
|
||||
route: { name: 'gold', query: { state: 'buy' } },
|
||||
},
|
||||
{
|
||||
id: 'sell',
|
||||
label: 'فروش',
|
||||
icon: 'vuesax-linear:money-send',
|
||||
route: { name: 'gold', query: { state: 'sell' } },
|
||||
},
|
||||
{
|
||||
id: 'wallet',
|
||||
label: 'کیف پول',
|
||||
icon: 'vuesax-linear:wallet-1',
|
||||
route: { name: 'wallet' },
|
||||
},
|
||||
{
|
||||
id: 'transactions',
|
||||
label: 'گزارش',
|
||||
icon: 'vuesax-linear:receipt-item',
|
||||
route: { name: 'transactions' },
|
||||
},
|
||||
{
|
||||
id: 'fund',
|
||||
label: 'دارایی ها',
|
||||
icon: 'vuesax-linear:archive-1',
|
||||
route: { name: 'fund' },
|
||||
},
|
||||
{
|
||||
id: 'shop',
|
||||
label: 'فروشگاه',
|
||||
icon: 'vuesax-linear:coin',
|
||||
route: { name: 'buyProduct' },
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { HomeLayoutConfig } from '../types'
|
||||
|
||||
export const defaultHomeLayoutConfig: HomeLayoutConfig = {
|
||||
id: 'default',
|
||||
sections: [
|
||||
{ id: 'currentPrice', visible: true },
|
||||
{ id: 'assets', visible: true },
|
||||
{ id: 'mainActions', visible: true },
|
||||
{ id: 'priceChart', visible: true },
|
||||
{ id: 'banners', visible: true },
|
||||
],
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
export type HomeLayoutId = 'default' | 'boursecu'
|
||||
|
||||
export type HomeSectionId =
|
||||
| 'limitedPriceAlert'
|
||||
| 'garoosiAssets'
|
||||
| 'mainActions'
|
||||
| 'boursecuQuickActions'
|
||||
|
||||
@@ -1,221 +1,14 @@
|
||||
<template>
|
||||
<div class="">
|
||||
<div ref="el" class="px-3 pt-15"
|
||||
>
|
||||
<div class="flex gap-2">
|
||||
<BasicSelect v-model:value="selectedProduct" :items="items"
|
||||
class="w-full"
|
||||
key-name="id"
|
||||
:show-search="false"
|
||||
value-name="title"
|
||||
size="large"
|
||||
placeholder="لطفا محصول را انتخاب کنید"
|
||||
:has-tooltip="true"/>
|
||||
<BasicButton :disabled-b="selectedProduct==null" type="primary" @click="handleAdd">افزودن</BasicButton>
|
||||
</div>
|
||||
<div class="h-70vh rounded-lg bg-white mt-2 border-gray-200 border-1 overflow-y-auto p-2">
|
||||
<div v-for="(val,index) in selectedProducts" class="rounded-lg p-2 bg-gray-100 mb-2">
|
||||
<div class="flex">
|
||||
<div class="bg-gray-100 m-2 rounded-lg w-28 h-28 flex justify-center p-2">
|
||||
<img v-if="val.product.group_type=='گوی'" :src="goyImg">
|
||||
<img v-if="val.product.group_type=='مکعب'" :src="mokaabImg">
|
||||
<img v-if="val.product.group_type=='سکه'" :src="sekkeImg">
|
||||
<img v-if="val.product.group_type=='شمش ونوس'" :src="venusImg">
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<div class="flex justify-between">
|
||||
<div class="font-bold text-lg">
|
||||
{{ val.product.title }}
|
||||
</div>
|
||||
<BasicButton icon="vuesax-linear:trash" icon-class="text-red" @click="handleRemove(val.product.id)"/>
|
||||
</div>
|
||||
<div class="flex mt-3 justify-between items-center">
|
||||
<div>تعداد موجودی:</div>
|
||||
<div class="flex gap-1 items-center">
|
||||
<div class="font-bold">{{ val.product.wallet.gold }}</div>
|
||||
<div>{{ val.product.unit }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center mt-2">
|
||||
<div>تعداد درخواستی:</div>
|
||||
<div class="flex gap-1 items-center w-40%">
|
||||
<BasicInput v-model:value="val.count" addon-before="عدد"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<BasicButton :disabled-b="selectedProducts.length==0" class="w-full absolute bottom-10 mt-2"
|
||||
@click="handelFirstSubmit()">ثبت
|
||||
</BasicButton>
|
||||
</div>
|
||||
<!-- <ActionSheet v-model:show="editPassVisible">salam</ActionSheet>-->
|
||||
</div>
|
||||
<BasicActionSheet v-model:show="showAddress">
|
||||
<div class="h-120 flex flex-col ">
|
||||
<div class="text-center">
|
||||
انتخاب آدرس
|
||||
</div>
|
||||
<div class="overflow-y-scroll h-85">
|
||||
<ARadioGroup v-model:value="selectedAddressID">
|
||||
<div class="flex flex-col ">
|
||||
<div class="text-base rounded-lg p-4 m-2 shadow-md font-medium" v-for="item in address">
|
||||
<ARadio :value="item.id">{{ item.province }} / {{ item.city }} / {{ item.address }}</ARadio>
|
||||
</div>
|
||||
</div>
|
||||
</ARadioGroup>
|
||||
</div>
|
||||
<div class="flex gap-2 pt-2">
|
||||
|
||||
<BasicButton class=" " @click="showAddress=false;addAddressVisible=true">افزودن آدرس +</BasicButton>
|
||||
<BasicButton class="w-2/3 " type="primary" @click="handelsubmit">ثبت نهایی</BasicButton>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</BasicActionSheet>
|
||||
<BasicActionSheet v-model:show="addAddressVisible" >
|
||||
<div class=" ">
|
||||
<New_EditAddress @onOk="handleAddress"></New_EditAddress>
|
||||
</div>
|
||||
|
||||
</BasicActionSheet>
|
||||
<MobileNewRequestView v-if="!isDesktop" />
|
||||
<DesktopNewRequestView v-if="isDesktop" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useNewPhysicalRequestPage } from '../composables/useNewPhysicalRequestPage'
|
||||
import { usePhysicalReceiveShellContext } from '../composables/usePhysicalReceiveShell'
|
||||
import DesktopNewRequestView from '../desktop/DesktopNewRequestView.vue'
|
||||
import MobileNewRequestView from '../mobile/MobileNewRequestView.vue'
|
||||
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import router from '@/router'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
||||
import {onMounted, ref} from 'vue'
|
||||
import {loading} from '@/utils'
|
||||
import {getProductInventory} from '@/api/products'
|
||||
import type {CountPInventory, PInventory} from '@/models/products'
|
||||
import goyImg from '@/assets/img/goyImg.svg'
|
||||
import mokaabImg from '@/assets/img/mokaabImg.svg'
|
||||
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
||||
import venusImg from "@/assets/img/venousImg.svg"
|
||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||
import {cloneDeep} from 'lodash'
|
||||
import BasicActionSheet from "@/components/BasicPacks/BasicActionSheet.vue"
|
||||
import {getCity, tableAddress} from "@/api/address"
|
||||
import type {Address} from "@/models/address"
|
||||
import Item from "@/views/base/address/components/Item.vue"
|
||||
import {physicalReceiveApi} from "@/api/physicalreceive"
|
||||
import {message} from "ant-design-vue"
|
||||
import {required} from "@/utils/inputRules"
|
||||
import BasicTextArea from "@/components/BasicPacks/BasicTextArea.vue"
|
||||
import New_EditAddress from "@/views/base/address/components/New_EditAddress.vue"
|
||||
|
||||
const items = ref<PInventory[]>()
|
||||
const baseItems = ref<PInventory[]>()
|
||||
const selectedAddressID = ref<number>()
|
||||
const selectedProduct = ref<number>()
|
||||
const productsByWalletId = ref<Array>([])
|
||||
const address = ref<Address>()
|
||||
const selectedProducts = ref<CountPInventory[]>([])
|
||||
const showAddress = ref<boolean>(false)
|
||||
const addAddressVisible = ref<boolean>(false)
|
||||
|
||||
function handleAdd() {
|
||||
console.log(selectedProducts.value)
|
||||
selectedProducts.value?.push({
|
||||
count: 0,
|
||||
product: items.value?.find(x => x.id === selectedProduct.value)
|
||||
})
|
||||
items.value?.splice(items.value?.findIndex(x => x.id === selectedProduct.value), 1)
|
||||
selectedProduct.value = undefined
|
||||
}
|
||||
function handleAddress() {
|
||||
getAddress()
|
||||
addAddressVisible.value = false
|
||||
showAddress.value = true
|
||||
}
|
||||
|
||||
function handleRemove(id: number) {
|
||||
const findItem = baseItems.value?.find(x => x.id === id)
|
||||
console.log(baseItems.value, id)
|
||||
if (findItem) {
|
||||
items.value?.push(findItem)
|
||||
}
|
||||
selectedProducts.value?.splice(selectedProducts.value?.findIndex(x => x.product.id === id), 1)
|
||||
}
|
||||
|
||||
async function initProductWallet() {
|
||||
try {
|
||||
loading.value = true
|
||||
items.value = (await getProductInventory()).rows.filter(x => (x.title !== 'آبشده نقدی' && x.wallet?.gold && x.wallet?.gold > 0))
|
||||
baseItems.value = cloneDeep(items.value)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handelFirstSubmit() {
|
||||
try {
|
||||
const zeroAmount = selectedProducts.value.map(item => item.count <= 0)
|
||||
if (zeroAmount.includes(true)) {
|
||||
message.error(`لطفاً تعداد درخواستی محصول را وارد کنید.`)
|
||||
}
|
||||
else {
|
||||
showAddress.value = true
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function handelsubmit() {
|
||||
try {
|
||||
loading.value = true
|
||||
productsByWalletId.value = selectedProducts.value.map((val) => {
|
||||
return {
|
||||
wallet_id: val.product.wallet.id,
|
||||
value: val.count
|
||||
}
|
||||
})
|
||||
await physicalReceiveApi({
|
||||
address_id: selectedAddressID.value,
|
||||
wallets: productsByWalletId.value
|
||||
}
|
||||
)
|
||||
await initProductWallet()
|
||||
message.success("درخواست شما با موفقیت ارسال شد")
|
||||
selectedProducts.value = []
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
showAddress.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await initProductWallet()
|
||||
await getAddress()
|
||||
})
|
||||
async function getAddress(){
|
||||
let {rows} = await tableAddress({page: 0, limit: 150})
|
||||
address.value = rows
|
||||
}
|
||||
|
||||
const { isDesktop } = usePhysicalReceiveShellContext()
|
||||
useNewPhysicalRequestPage()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/*.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}*/
|
||||
/*.trans{
|
||||
transition: height 1s;
|
||||
}*/
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<div class="h-120 flex flex-col">
|
||||
<div class="text-center">انتخاب آدرس</div>
|
||||
<div class="overflow-y-scroll h-85">
|
||||
<ARadioGroup v-model:value="selectedAddressID">
|
||||
<div class="flex flex-col">
|
||||
<div
|
||||
v-for="addr in addresses"
|
||||
:key="addr.id"
|
||||
class="text-base rounded-lg p-4 m-2 shadow-md font-medium"
|
||||
>
|
||||
<ARadio :value="addr.id">
|
||||
{{ addr.province }} / {{ addr.city }} / {{ addr.address }}
|
||||
</ARadio>
|
||||
</div>
|
||||
</div>
|
||||
</ARadioGroup>
|
||||
</div>
|
||||
<div class="flex gap-2 pt-2">
|
||||
<BasicButton @click="emit('addAddress')">افزودن آدرس +</BasicButton>
|
||||
<BasicButton class="w-2/3" type="primary" @click="emit('submit')">
|
||||
ثبت نهایی
|
||||
</BasicButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import type { Address } from '@/models/address'
|
||||
|
||||
interface Props {
|
||||
addresses?: Address[]
|
||||
selectedAddressId?: number
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
addAddress: []
|
||||
submit: []
|
||||
'update:selectedAddressId': [value: number | undefined]
|
||||
}>()
|
||||
|
||||
const selectedAddressID = computed({
|
||||
get: () => props.selectedAddressId,
|
||||
set: (value: number | undefined) => emit('update:selectedAddressId', value),
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex">
|
||||
<div class="bg-gray-100 m-2 rounded-lg w-18 h-18 flex justify-center p-1 shrink-0">
|
||||
<img :src="displayImage" class="object-contain w-full h-full" alt="" />
|
||||
</div>
|
||||
<div class="w-full min-w-0">
|
||||
<div class="pr-cart-row__head">
|
||||
<div class="truncate text-base font-bold">{{ item.product.title }}</div>
|
||||
<BasicButton
|
||||
icon="vuesax-linear:trash"
|
||||
icon-class="text-red"
|
||||
class="pr-cart-row__trash shrink-0"
|
||||
@click="emit('remove', item.product.id)"
|
||||
/>
|
||||
<div class="pr-cart-row__stock text-xs">
|
||||
<span>مقدار موجودی</span>
|
||||
<span class="font-bold">{{ item.product.wallet.gold }}</span>
|
||||
<span>{{ item.product.unit }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 flex justify-between items-center gap-2">
|
||||
<div class="shrink-0">تعداد درخواستی:</div>
|
||||
<div class="flex items-center gap-1 pr-cart-row__input">
|
||||
<BasicInput
|
||||
v-model:value="item.count"
|
||||
:addon-before="item.product.unit"
|
||||
addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
type="text"
|
||||
inputmode="numeric"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||
import type { CountPInventory } from '@/models/products'
|
||||
import { getProductDisplayImage } from '@/utils/productAssets'
|
||||
|
||||
interface Props {
|
||||
item: CountPInventory
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const displayImage = computed(() =>
|
||||
getProductDisplayImage({
|
||||
group_type: props.item.product.group_type,
|
||||
title: props.item.product.title,
|
||||
file: props.item.product.file,
|
||||
}),
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
remove: [id: number]
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.pr-cart-row__head {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
grid-template-rows: auto auto;
|
||||
column-gap: 0.5rem;
|
||||
row-gap: 0.125rem;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.pr-cart-row__trash {
|
||||
grid-column: 2;
|
||||
grid-row: 1 / span 2;
|
||||
justify-self: end;
|
||||
}
|
||||
|
||||
.pr-cart-row__stock {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.pr-cart-row__input {
|
||||
width: auto;
|
||||
max-width: 10rem;
|
||||
|
||||
:deep(.noname-input),
|
||||
:deep(.ant-input-group-wrapper) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.ant-input-group-addon) {
|
||||
min-width: 3.75rem;
|
||||
padding-inline: 6px;
|
||||
white-space: nowrap;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -42,11 +42,6 @@
|
||||
<div v-else class="w-full h-[88px]">
|
||||
<GoldSkeleton class="w-full" />
|
||||
</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-form ref="refInput" :model="form" class="!mt-5" name="basic" @finish="okConfirm()">
|
||||
<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
|
||||
})
|
||||
|
||||
const limitedPrice = computed(() => {
|
||||
if (walletStore.limitedPrice)
|
||||
return walletStore?.limitedPrice[0]
|
||||
})
|
||||
|
||||
function calculateCash(val: number) {
|
||||
priceErrorVisible.value = false
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="w-full flex justify-between" v-for="item in props.item.transaction">
|
||||
<div class="flex items-center gap-1">
|
||||
<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 class="text-xs">{{ item?.title }}</div>
|
||||
</div>
|
||||
@@ -38,8 +38,7 @@
|
||||
<script setup lang="ts">
|
||||
import type {Physicalreceive} from "@/models/physicalreceive";
|
||||
import {toJalali} from "../../../../utils/useDateTime";
|
||||
import goyImg from "@/assets/img/goyImg.svg"
|
||||
import mokaabImg from "@/assets/img/mokaabImg.svg"
|
||||
import ProductImage from "@/components/ProductImage.vue";
|
||||
|
||||
interface Prop {
|
||||
item: Physicalreceive
|
||||
|
||||
@@ -1,59 +1,18 @@
|
||||
<template>
|
||||
<div class="physical-receive-page-root">
|
||||
<DesktopPhysicalReceiveListView
|
||||
v-show="isDesktop"
|
||||
:request-items="requestItems"
|
||||
@add="openAdd"
|
||||
/>
|
||||
<div v-show="!isDesktop">
|
||||
<div class="absolute inset-0 bg-cover bg-center opacity-60" :style="{ backgroundImage: `url(${img})` }" />
|
||||
<div class="bg-white w-full transaction-list py-3 px-3 font-bold drop-shadow flex justify-between z-10">
|
||||
<div>لیست دریافت فیزیکی</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4 pt-13 pb-35 px-2">
|
||||
<RequestItem v-for="item in requestItems" :key="item.id" :item="item" />
|
||||
</div>
|
||||
<Transition mode="out-in" name="fade">
|
||||
<div
|
||||
class="wrap-fix bottom-0 h-[19vh] bg-[#FBFBFC] shadow-lg rounded-3xl flex justify-center pt-3 z-200"
|
||||
style="box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 26px 11px"
|
||||
@click="openAdd"
|
||||
>
|
||||
<BasicIcon icon="vuesax-linear:add" />
|
||||
<div class="cursor-pointer">افزودن درخواست جدید</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
</div>
|
||||
<MobileRequestListView v-show="!isDesktop" />
|
||||
<DesktopPhysicalReceiveListView
|
||||
v-show="isDesktop"
|
||||
:request-items="requestItems"
|
||||
@add="openAdd"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { getPhysicalReceiveList } from '@/api/physicalreceive'
|
||||
import type { Physicalreceive } from '@/models/physicalreceive'
|
||||
import RequestItem from '@/views/base/physicalReceive/components/RequestItem.vue'
|
||||
import router from '@/router'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import img from '@/assets/img/user_ly1.svg'
|
||||
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||
import { usePhysicalReceiveList } from '../composables/usePhysicalReceiveList'
|
||||
import { usePhysicalReceiveShellContext } from '../composables/usePhysicalReceiveShell'
|
||||
import DesktopPhysicalReceiveListView from '../desktop/DesktopPhysicalReceiveListView.vue'
|
||||
import MobileRequestListView from '../mobile/MobileRequestListView.vue'
|
||||
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
const requestItems = ref<Physicalreceive[]>([])
|
||||
|
||||
const openAdd = () => {
|
||||
router.push({ name: 'new' })
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const { rows } = await getPhysicalReceiveList()
|
||||
requestItems.value = rows
|
||||
})
|
||||
const { isDesktop } = usePhysicalReceiveShellContext()
|
||||
const { requestItems, openAdd } = usePhysicalReceiveList()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.physical-receive-page-root {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
import { inject, nextTick, onMounted, provide, ref, type InjectionKey, type Ref } from 'vue'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { message } from 'ant-design-vue'
|
||||
import router from '@/router'
|
||||
import { getProductInventory } from '@/api/products'
|
||||
import { physicalReceiveApi } from '@/api/physicalreceive'
|
||||
import { tableAddress } from '@/api/address'
|
||||
import type { CountPInventory, PInventory } from '@/models/products'
|
||||
import type { Address } from '@/models/address'
|
||||
import { loading } from '@/utils'
|
||||
import { usePhysicalReceiveShellContext } from './usePhysicalReceiveShell'
|
||||
|
||||
export interface NewPhysicalRequestContext {
|
||||
isDesktop: Ref<boolean>
|
||||
items: Ref<PInventory[] | undefined>
|
||||
selectedProduct: Ref<number | undefined>
|
||||
selectedProducts: Ref<CountPInventory[]>
|
||||
address: Ref<Address[] | undefined>
|
||||
selectedAddressID: Ref<number | undefined>
|
||||
showAddress: Ref<boolean>
|
||||
addAddressVisible: Ref<boolean>
|
||||
handleAdd: () => void
|
||||
handleRemove: (id: number) => void
|
||||
handelFirstSubmit: () => Promise<void>
|
||||
handelsubmit: () => Promise<void>
|
||||
handleAddress: () => void
|
||||
}
|
||||
|
||||
export const NEW_PHYSICAL_REQUEST_KEY: InjectionKey<NewPhysicalRequestContext> =
|
||||
Symbol('newPhysicalRequest')
|
||||
|
||||
export function useNewPhysicalRequestPage() {
|
||||
const { isDesktop } = usePhysicalReceiveShellContext()
|
||||
|
||||
const items = ref<PInventory[]>()
|
||||
const baseItems = ref<PInventory[]>()
|
||||
const selectedAddressID = ref<number>()
|
||||
const selectedProduct = ref<number>()
|
||||
const productsByWalletId = ref<Array<{ wallet_id: number; value: number }>>([])
|
||||
const address = ref<Address[]>()
|
||||
const selectedProducts = ref<CountPInventory[]>([])
|
||||
const showAddress = ref(false)
|
||||
const addAddressVisible = ref(false)
|
||||
|
||||
function handleAdd() {
|
||||
const product = items.value?.find((x) => x.id === selectedProduct.value)
|
||||
if (!product) return
|
||||
|
||||
selectedProducts.value.push({
|
||||
count: 0,
|
||||
product,
|
||||
})
|
||||
items.value?.splice(items.value.findIndex((x) => x.id === selectedProduct.value), 1)
|
||||
selectedProduct.value = undefined
|
||||
}
|
||||
|
||||
function handleAddress() {
|
||||
getAddress()
|
||||
addAddressVisible.value = false
|
||||
showAddress.value = true
|
||||
}
|
||||
|
||||
function handleRemove(id: number) {
|
||||
const findItem = baseItems.value?.find((x) => x.id === id)
|
||||
if (findItem) {
|
||||
items.value?.push(findItem)
|
||||
}
|
||||
selectedProducts.value.splice(
|
||||
selectedProducts.value.findIndex((x) => x.product.id === id),
|
||||
1,
|
||||
)
|
||||
}
|
||||
|
||||
async function initProductWallet() {
|
||||
try {
|
||||
loading.value = true
|
||||
const inventory = (await getProductInventory()).rows.filter(
|
||||
(x) => x.title !== 'آبشده نقدی' && x.wallet?.gold && x.wallet.gold > 0,
|
||||
)
|
||||
items.value = inventory
|
||||
baseItems.value = cloneDeep(inventory)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handelFirstSubmit() {
|
||||
try {
|
||||
const zeroAmount = selectedProducts.value.map((item) => item.count <= 0)
|
||||
if (zeroAmount.includes(true)) {
|
||||
message.error('لطفاً تعداد درخواستی محصول را وارد کنید.')
|
||||
} else {
|
||||
showAddress.value = true
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function handelsubmit() {
|
||||
if (!selectedAddressID.value) {
|
||||
message.error('لطفاً آدرس را انتخاب کنید.')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
productsByWalletId.value = selectedProducts.value.map((val) => ({
|
||||
wallet_id: val.product.wallet.id,
|
||||
value: val.count,
|
||||
}))
|
||||
await physicalReceiveApi({
|
||||
address_id: selectedAddressID.value,
|
||||
wallets: productsByWalletId.value,
|
||||
})
|
||||
|
||||
showAddress.value = false
|
||||
selectedAddressID.value = undefined
|
||||
selectedProducts.value = []
|
||||
await nextTick()
|
||||
|
||||
message.success('درخواست شما با موفقیت ارسال شد')
|
||||
await initProductWallet()
|
||||
await router.push({ name: 'list' })
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAddress() {
|
||||
const { rows } = await tableAddress({ page: 0, limit: 150 })
|
||||
address.value = rows
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await initProductWallet()
|
||||
await getAddress()
|
||||
})
|
||||
|
||||
const context: NewPhysicalRequestContext = {
|
||||
isDesktop,
|
||||
items,
|
||||
selectedProduct,
|
||||
selectedProducts,
|
||||
address,
|
||||
selectedAddressID,
|
||||
showAddress,
|
||||
addAddressVisible,
|
||||
handleAdd,
|
||||
handleRemove,
|
||||
handelFirstSubmit,
|
||||
handelsubmit,
|
||||
handleAddress,
|
||||
}
|
||||
|
||||
provide(NEW_PHYSICAL_REQUEST_KEY, context)
|
||||
return context
|
||||
}
|
||||
|
||||
export function useNewPhysicalRequestContext() {
|
||||
const context = inject(NEW_PHYSICAL_REQUEST_KEY)
|
||||
if (!context) {
|
||||
throw new Error('useNewPhysicalRequestContext must be used within useNewPhysicalRequestPage')
|
||||
}
|
||||
return context
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { inject, onMounted, provide, ref, type InjectionKey, type Ref } from 'vue'
|
||||
import { getPhysicalReceiveList } from '@/api/physicalreceive'
|
||||
import type { Physicalreceive } from '@/models/physicalreceive'
|
||||
import router from '@/router'
|
||||
|
||||
export interface PhysicalReceiveListContext {
|
||||
requestItems: Ref<Physicalreceive[]>
|
||||
openAdd: () => void
|
||||
}
|
||||
|
||||
export const PHYSICAL_RECEIVE_LIST_KEY: InjectionKey<PhysicalReceiveListContext> =
|
||||
Symbol('physicalReceiveList')
|
||||
|
||||
export function usePhysicalReceiveList() {
|
||||
const requestItems = ref<Physicalreceive[]>([])
|
||||
|
||||
function openAdd() {
|
||||
router.push({ name: 'new' })
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const { rows } = await getPhysicalReceiveList()
|
||||
requestItems.value = rows
|
||||
})
|
||||
|
||||
const context: PhysicalReceiveListContext = { requestItems, openAdd }
|
||||
provide(PHYSICAL_RECEIVE_LIST_KEY, context)
|
||||
return context
|
||||
}
|
||||
|
||||
export function usePhysicalReceiveListContext() {
|
||||
const context = inject(PHYSICAL_RECEIVE_LIST_KEY)
|
||||
if (!context) {
|
||||
throw new Error('usePhysicalReceiveListContext must be used within usePhysicalReceiveList')
|
||||
}
|
||||
return context
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { inject, provide, type InjectionKey } from 'vue'
|
||||
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||
|
||||
export interface PhysicalReceiveShellContext {
|
||||
isDesktop: ReturnType<typeof useDesktopBreakpoint>
|
||||
}
|
||||
|
||||
export const PHYSICAL_RECEIVE_SHELL_KEY: InjectionKey<PhysicalReceiveShellContext> =
|
||||
Symbol('physicalReceiveShell')
|
||||
|
||||
export function usePhysicalReceiveShell() {
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
provide(PHYSICAL_RECEIVE_SHELL_KEY, { isDesktop })
|
||||
return { isDesktop }
|
||||
}
|
||||
|
||||
export function usePhysicalReceiveShellContext() {
|
||||
const context = inject(PHYSICAL_RECEIVE_SHELL_KEY)
|
||||
if (!context) {
|
||||
throw new Error('usePhysicalReceiveShellContext must be used within physical receive shell')
|
||||
}
|
||||
return context
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<div class="dinner physical-receive-page">
|
||||
<div class="dinner__container">
|
||||
<DesktopPageTopbar title="درخواست جدید" show-back />
|
||||
|
||||
<div class="dinner-surface p-5 space-y-4">
|
||||
<div class="physical-new-request__picker-row">
|
||||
<div class="physical-new-request__select">
|
||||
<BasicSelect
|
||||
v-model:value="selectedProduct"
|
||||
:items="items"
|
||||
key-name="id"
|
||||
:show-search="false"
|
||||
value-name="title"
|
||||
size="large"
|
||||
placeholder="لطفا محصول را انتخاب کنید"
|
||||
:has-tooltip="false"
|
||||
/>
|
||||
</div>
|
||||
<BasicButton
|
||||
class="physical-new-request__add-btn"
|
||||
:disabled-b="selectedProduct == null"
|
||||
type="primary"
|
||||
@click="handleAdd"
|
||||
>
|
||||
افزودن
|
||||
</BasicButton>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="val in selectedProducts"
|
||||
:key="val.product.id"
|
||||
class="rounded-lg p-2 bg-gray-100"
|
||||
>
|
||||
<PhysicalReceiveCartRow :item="val" @remove="handleRemove" />
|
||||
</div>
|
||||
<div v-if="selectedProducts.length === 0" class="text-center text-gray-500 py-8">
|
||||
محصولی به سبد اضافه نشده است.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BasicButton
|
||||
:disabled-b="selectedProducts.length == 0"
|
||||
class="w-full"
|
||||
type="primary"
|
||||
@click="handelFirstSubmit()"
|
||||
>
|
||||
ادامه و انتخاب آدرس
|
||||
</BasicButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BasicActionSheet v-model:show="showAddress">
|
||||
<PhysicalReceiveAddressPicker
|
||||
v-model:selected-address-id="selectedAddressID"
|
||||
:addresses="address"
|
||||
@add-address="addAddressVisible = true; showAddress = false"
|
||||
@submit="handelsubmit"
|
||||
/>
|
||||
</BasicActionSheet>
|
||||
|
||||
<BasicActionSheet v-model:show="addAddressVisible">
|
||||
<New_EditAddress v-if="addAddressVisible" :visible="addAddressVisible" @onOk="handleAddress" />
|
||||
</BasicActionSheet>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
|
||||
import New_EditAddress from '@/views/base/address/components/New_EditAddress.vue'
|
||||
import PhysicalReceiveCartRow from '../components/PhysicalReceiveCartRow.vue'
|
||||
import PhysicalReceiveAddressPicker from '../components/PhysicalReceiveAddressPicker.vue'
|
||||
import { useNewPhysicalRequestContext } from '../composables/useNewPhysicalRequestPage'
|
||||
|
||||
const {
|
||||
items,
|
||||
selectedProduct,
|
||||
selectedProducts,
|
||||
address,
|
||||
selectedAddressID,
|
||||
showAddress,
|
||||
addAddressVisible,
|
||||
handleAdd,
|
||||
handleRemove,
|
||||
handelFirstSubmit,
|
||||
handelsubmit,
|
||||
handleAddress,
|
||||
} = useNewPhysicalRequestContext()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.physical-new-request__picker-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.physical-new-request__select {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.physical-new-request__select :deep(.ant-select) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.physical-new-request__select :deep(.ant-select-selector) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.physical-new-request__select :deep(.ant-select-selection-item),
|
||||
.physical-new-request__select :deep(.ant-select-selection-placeholder) {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.physical-new-request__add-btn {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,196 +1,67 @@
|
||||
<template>
|
||||
<div class="flex justify-center items-center text-5">
|
||||
در حال بروزرسانی...
|
||||
<div
|
||||
class="physical-receive-page-root main-with-bottom-chrome-inner--contained"
|
||||
:class="{ 'physical-receive-page-root--desktop': isDesktop }"
|
||||
>
|
||||
<MobilePhysicalReceiveChrome v-show="!isDesktop" />
|
||||
|
||||
<div :class="isDesktop ? '' : 'physical-receive-page-root__shell'">
|
||||
<div :class="isDesktop ? '' : 'physical-receive-page-root__content'">
|
||||
<router-view />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!--<template>-->
|
||||
<!-- <div class="bottom-0 fixed top-0">-->
|
||||
<!-- <img :src="img" alt="" class=" w-inherit "-->
|
||||
<!-- :style="{ backgroundRepeat: 'repeat', }"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
<!-- <a-spin :spinning="loading">-->
|
||||
<script lang="ts" setup>
|
||||
import { usePhysicalReceiveShell } from './composables/usePhysicalReceiveShell'
|
||||
import MobilePhysicalReceiveChrome from './mobile/MobilePhysicalReceiveChrome.vue'
|
||||
|
||||
<!-- <div class=" !h-full overflow-y-scroll">-->
|
||||
const { isDesktop } = usePhysicalReceiveShell()
|
||||
</script>
|
||||
|
||||
<!-- <div class="w-full flex justify-center top-0 py-5" style="align-self: center">-->
|
||||
<!-- <ARadioGroup @change="changeTab" v-model:value="activekey" button-style="solid">-->
|
||||
<!-- <ARadioButton class="cats" value="همه">همه</ARadioButton>-->
|
||||
<!-- <ARadioButton class="cats" v-for="item in typeItems.filter(a => a != 'آبشده')" :value="item">{{ item }}</ARadioButton>-->
|
||||
<!-- </ARadioGroup>-->
|
||||
<!-- </div>-->
|
||||
<style scoped>
|
||||
.physical-receive-page-root {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
<!-- <div class="mx-5 pb-30 pt-2" style="color: #1b2b07">-->
|
||||
<!-- <div class="mt-3" v-for="item in items?.filter(a => a.group_type != 'آبشده')">-->
|
||||
<!-- <ProductItem :ProductItem="item" @click="clickProduct(item)"></ProductItem>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </a-spin>-->
|
||||
<!-- <!– <BasicActionSheet v-model:show="showFilter">–>-->
|
||||
<!-- <!– <indexGold ></indexGold>–>-->
|
||||
<!-- <!– </BasicActionSheet>–>-->
|
||||
.physical-receive-page-root__shell {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
<!-- <BasicActionSheet placement="bottom" v-model:show="showFilter">-->
|
||||
<!-- <div class="">-->
|
||||
<!--<!– <indexGold v-if="selectedProduct?.group_type=='آبشده'" :ProductItem="selectedProduct"></indexGold>–>-->
|
||||
<!-- <ReceiveDealProduct :ProductItem="selectedProduct"></ReceiveDealProduct>-->
|
||||
<!-- </div>-->
|
||||
<!-- </BasicActionSheet>-->
|
||||
.physical-receive-page-root__content {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
<!--</template>-->
|
||||
.physical-receive-page-root__content > * {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
<!--<script setup lang="ts">-->
|
||||
<!--import { onMounted, onUnmounted, ref, watch } from 'vue'-->
|
||||
<!--import router from '@/router'-->
|
||||
<!--import ProductItem from '@/views/base/products/components/ProductItem.vue'-->
|
||||
<!--import { getProducts } from '@/api/products'-->
|
||||
<!--import {-->
|
||||
<!-- getLastPrices,-->
|
||||
<!-- lastPrice,-->
|
||||
<!-- stopPriceInterval-->
|
||||
<!--} from '@/utils/price'-->
|
||||
<!--import { loading } from '@/utils'-->
|
||||
<!--import { Price } from '@/models/home'-->
|
||||
<!--import type { Product } from '@/models/products'-->
|
||||
<!--import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'-->
|
||||
<!--import { cloneDeep } from 'lodash'-->
|
||||
<!--import img from "@/assets/img/user_ly1.svg";-->
|
||||
<!--import ReceiveDealProduct from '@/views/base/physicalReceive/components/ReceiveDealProduct.vue'-->
|
||||
.physical-receive-page-root--desktop {
|
||||
height: auto;
|
||||
min-height: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!--const activekey = ref('آبشده')-->
|
||||
<!--const showFilter = ref()-->
|
||||
<!--const selectedProduct = ref<Product>()-->
|
||||
|
||||
<!--function clickProduct(item: Product) {-->
|
||||
<!-- if(item?.show){-->
|
||||
<!-- showFilter.value = true-->
|
||||
<!-- selectedProduct.value = cloneDeep(item)-->
|
||||
<!-- }-->
|
||||
<!--}-->
|
||||
|
||||
<!--function changeTab() {-->
|
||||
<!-- if (activekey.value != 'همه') {-->
|
||||
<!-- items.value = firstItems.value?.filter((val) =>-->
|
||||
<!-- val.group_type == activekey.value-->
|
||||
<!-- )-->
|
||||
<!-- } else items.value = firstItems.value-->
|
||||
|
||||
<!--}-->
|
||||
|
||||
<!--const firstItems = ref<Product[]>()-->
|
||||
<!--const price = ref<Price>()-->
|
||||
<!--const items = ref<Product[]>()-->
|
||||
<!--const typeItems = ref([])-->
|
||||
<!--onMounted(async () => {-->
|
||||
<!-- try {-->
|
||||
<!-- loading.value = true-->
|
||||
<!-- items.value = await getProducts()-->
|
||||
<!-- items.value?.forEach((val, index) => {-->
|
||||
<!-- if (!typeItems.value.includes(val.group_type)){-->
|
||||
<!-- typeItems.value.push(val.group_type)-->
|
||||
<!-- }-->
|
||||
<!-- // typeItems.value[index] = val.group_type-->
|
||||
<!-- })-->
|
||||
<!-- firstItems.value = items.value-->
|
||||
<!-- await initPrice()-->
|
||||
<!-- // await setIntervalGetLastPrice()-->
|
||||
<!-- // console.log('run product')-->
|
||||
|
||||
<!-- } catch (e) {-->
|
||||
<!-- console.log(e)-->
|
||||
<!-- } finally {-->
|
||||
<!-- loading.value = false-->
|
||||
<!-- if (router.currentRoute.value.query.cat=="coin"){-->
|
||||
<!-- activekey.value="سکه"-->
|
||||
<!-- changeTab()-->
|
||||
<!-- }-->
|
||||
|
||||
<!-- if (router.currentRoute.value.query.state) {-->
|
||||
<!-- if (router.currentRoute.value.query.product) {-->
|
||||
<!-- clickProduct(items.value?.find(x => x.title === 'سکه'))-->
|
||||
<!-- } else {-->
|
||||
<!-- clickProduct(items.value?.find(x => x.title === 'آبشده نقدی'))-->
|
||||
<!-- }-->
|
||||
<!-- }-->
|
||||
<!-- }-->
|
||||
<!--})-->
|
||||
<!--onUnmounted(() => {-->
|
||||
<!-- stopPriceInterval()-->
|
||||
<!-- // console.log('stop product')-->
|
||||
<!--})-->
|
||||
|
||||
<!--async function initPrice() {-->
|
||||
<!-- try {-->
|
||||
<!-- // chartLoading.value = true-->
|
||||
<!-- await getLastPrices()-->
|
||||
<!-- // await setIntervalGetPrice()-->
|
||||
<!-- loading.value = true-->
|
||||
<!-- price.value = lastPrice.value-->
|
||||
<!-- } catch (e) {-->
|
||||
<!-- console.log(e)-->
|
||||
<!-- } finally {-->
|
||||
<!-- loading.value = false-->
|
||||
<!-- // chartLoading.value = false-->
|
||||
<!-- }-->
|
||||
<!--}-->
|
||||
<!--</script>-->
|
||||
|
||||
<!--<style lang="less">-->
|
||||
<!--.cats{-->
|
||||
<!-- font-size: x-small;-->
|
||||
<!--}-->
|
||||
<!--.cats:hover span {-->
|
||||
<!-- --un-text-opacity: 1;-->
|
||||
<!-- color: rgba(206, 163, 76, var(--un-text-opacity))!important;-->
|
||||
<!--}-->
|
||||
|
||||
<!--</style>-->
|
||||
|
||||
|
||||
<!--<!–-->
|
||||
<!--<template>-->
|
||||
<!-- <div style="max-height: calc(100vh - 50px)">-->
|
||||
<!-- <div class="bg-white py-3 px-3 z-100000 text-primary font-bold drop-shadow flex flex-col wrap-fix">-->
|
||||
<!-- <div class="flex">-->
|
||||
<!-- <div @click="router.back()">-->
|
||||
<!-- <BasicIcon icon="vuesax-linear:arrow-right-1"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div v-if="route.name=='list'" class="mr-2">دریافت طلای فیزیکی</div>-->
|
||||
<!-- <div v-else class="mr-2">دریافت طلای فیزیکی-درخواست جدید</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div>-->
|
||||
<!-- <router-view></router-view>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!--</template>-->
|
||||
|
||||
<!--<script lang="ts" setup>-->
|
||||
<!--import {ref} from "vue";-->
|
||||
<!--import RequestList from "@/views/base/physicalReceive/components/RequestList.vue";-->
|
||||
<!--import NewRequest from "@/views/base/physicalReceive/components/NewRequest.vue";-->
|
||||
<!--import router from "@/router";-->
|
||||
<!--import BasicIcon from "@/components/BasicPacks/BasicIcon.vue";-->
|
||||
<!--import {useRoute} from "vue-router";-->
|
||||
|
||||
<!--const activekey=ref(1)-->
|
||||
<!--const route=useRoute()-->
|
||||
<!--</script>-->
|
||||
|
||||
<!--<style scoped>-->
|
||||
<!--/*.fade-enter-active,-->
|
||||
<!--.fade-leave-active {-->
|
||||
<!-- transition: opacity 0.2s ease;-->
|
||||
<!--}-->
|
||||
|
||||
<!--.fade-enter-from,-->
|
||||
<!--.fade-leave-to {-->
|
||||
<!-- opacity: 0;-->
|
||||
<!--}*/-->
|
||||
<!--/*.trans{-->
|
||||
<!-- transition: height 1s;-->
|
||||
<!--}*/-->
|
||||
<!--</style>-->
|
||||
<!--–>-->
|
||||
<style lang="less">
|
||||
.physical-receive-page-root.main-with-bottom-chrome-inner {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<div class="physical-new-request">
|
||||
<div class="physical-new-request__toolbar mpage-content">
|
||||
<div class="physical-new-request__picker-row px-3">
|
||||
<div class="physical-new-request__select">
|
||||
<BasicSelect
|
||||
v-model:value="selectedProduct"
|
||||
:items="items"
|
||||
key-name="id"
|
||||
:show-search="false"
|
||||
value-name="title"
|
||||
size="large"
|
||||
placeholder="لطفا محصول را انتخاب کنید"
|
||||
:has-tooltip="false"
|
||||
/>
|
||||
</div>
|
||||
<BasicButton
|
||||
class="physical-new-request__add-btn"
|
||||
:disabled-b="selectedProduct == null"
|
||||
type="primary"
|
||||
@click="handleAdd"
|
||||
>
|
||||
افزودن
|
||||
</BasicButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="physical-new-request__items px-3">
|
||||
<div class="physical-new-request__items-scroll">
|
||||
<div
|
||||
v-for="val in selectedProducts"
|
||||
:key="val.product.id"
|
||||
class="rounded-lg p-2 bg-gray-100 mb-2 last:mb-0"
|
||||
>
|
||||
<PhysicalReceiveCartRow :item="val" @remove="handleRemove" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="physical-new-request__footer px-3">
|
||||
<BasicButton
|
||||
:disabled-b="selectedProducts.length == 0"
|
||||
class="w-full"
|
||||
@click="handelFirstSubmit()"
|
||||
>
|
||||
ثبت
|
||||
</BasicButton>
|
||||
</div>
|
||||
|
||||
<BasicActionSheet v-model:show="showAddress">
|
||||
<PhysicalReceiveAddressPicker
|
||||
v-model:selected-address-id="selectedAddressID"
|
||||
:addresses="address"
|
||||
@add-address="addAddressVisible = true; showAddress = false"
|
||||
@submit="handelsubmit"
|
||||
/>
|
||||
</BasicActionSheet>
|
||||
|
||||
<BasicActionSheet v-model:show="addAddressVisible">
|
||||
<New_EditAddress v-if="addAddressVisible" :visible="addAddressVisible" @onOk="handleAddress" />
|
||||
</BasicActionSheet>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import New_EditAddress from '@/views/base/address/components/New_EditAddress.vue'
|
||||
import PhysicalReceiveCartRow from '../components/PhysicalReceiveCartRow.vue'
|
||||
import PhysicalReceiveAddressPicker from '../components/PhysicalReceiveAddressPicker.vue'
|
||||
import { useNewPhysicalRequestContext } from '../composables/useNewPhysicalRequestPage'
|
||||
|
||||
const {
|
||||
items,
|
||||
selectedProduct,
|
||||
selectedProducts,
|
||||
address,
|
||||
selectedAddressID,
|
||||
showAddress,
|
||||
addAddressVisible,
|
||||
handleAdd,
|
||||
handleRemove,
|
||||
handelFirstSubmit,
|
||||
handelsubmit,
|
||||
handleAddress,
|
||||
} = useNewPhysicalRequestContext()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.physical-new-request {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
padding-bottom: var(--app-bottom-chrome-height, 80px);
|
||||
}
|
||||
|
||||
.physical-new-request__toolbar {
|
||||
flex-shrink: 0;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.physical-new-request__picker-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.physical-new-request__select {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.physical-new-request__select :deep(.ant-select) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.physical-new-request__select :deep(.ant-select-selector) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.physical-new-request__select :deep(.ant-select-selection-item),
|
||||
.physical-new-request__select :deep(.ant-select-selection-placeholder) {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.physical-new-request__add-btn {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.physical-new-request__items {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.physical-new-request__items-scroll {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overscroll-behavior-y: contain;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 0.5rem;
|
||||
background: #fff;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.physical-new-request__footer {
|
||||
flex-shrink: 0;
|
||||
padding-top: 0.75rem;
|
||||
padding-bottom: 0.75rem;
|
||||
background: #fff;
|
||||
border-top: 1px solid #f3f4f6;
|
||||
box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,15 @@
|
||||
<template>
|
||||
<MobilePageHeader :title="pageTitle" show-back />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const pageTitle = computed(() =>
|
||||
route.name === 'list' ? 'دریافت فیزیکی' : 'دریافت فیزیکی-درخواست جدید',
|
||||
)
|
||||
</script>
|
||||
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<div>
|
||||
<div
|
||||
class="flex flex-col gap-4 mpage-content px-2 pb-[calc(var(--app-bottom-chrome-height)+var(--app-add-card-height)+1rem)]"
|
||||
>
|
||||
<RequestItem v-for="item in requestItems" :key="item.id" :item="item" />
|
||||
<div
|
||||
v-if="requestItems.length === 0"
|
||||
class="flex flex-col items-center justify-center min-h-[40vh] text-gray-500"
|
||||
>
|
||||
هنوز درخواستی ثبت نشده است.
|
||||
</div>
|
||||
</div>
|
||||
<Teleport to="body">
|
||||
<div class="app-dock-add-bar" @click="openAdd()">
|
||||
<BasicIcon icon="vuesax-linear:add" />
|
||||
<div>افزودن درخواست جدید</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import RequestItem from '../components/RequestItem.vue'
|
||||
import { usePhysicalReceiveListContext } from '../composables/usePhysicalReceiveList'
|
||||
|
||||
const { requestItems, openAdd } = usePhysicalReceiveListContext()
|
||||
</script>
|
||||
@@ -1,90 +1,145 @@
|
||||
<template>
|
||||
<div @click="infoVisible = true" class="shadow mb-2 p-2 rounded-lg">
|
||||
<div v-if="variant === 'desktop'" class="dptr-card">
|
||||
<p class="dptr-card__price">{{ usePrice(item.target_price) }}</p>
|
||||
|
||||
<div class="dptr-card__meta">
|
||||
<div class="dptr-card__row">
|
||||
<span class="dptr-card__label">جهت قیمت:</span>
|
||||
<span class="dptr-card__value">{{ returnPriceCondition(item.price_condition) }}</span>
|
||||
</div>
|
||||
<div class="dptr-card__row">
|
||||
<span class="dptr-card__label">نوع هشدار:</span>
|
||||
<span class="dptr-card__value">{{ returnAction(item.action) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dptr-card__actions">
|
||||
<button
|
||||
type="button"
|
||||
class="dptr-card__icon-btn dptr-card__icon-btn--edit"
|
||||
@click.stop="emits('edit', item)"
|
||||
>
|
||||
<BasicIcon color="green" icon="vuesax-linear:edit" size="18" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="dptr-card__icon-btn dptr-card__icon-btn--danger"
|
||||
@click.stop="deleteConfirmVisible = true"
|
||||
>
|
||||
<BasicIcon color="red" icon="vuesax-linear:trash" size="18" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="dptr-card__footer">
|
||||
<span class="dptr-card__date">{{ toJalali(item.created_at) }}</span>
|
||||
<a-switch
|
||||
v-model:checked="isActive"
|
||||
checked-children="فعال"
|
||||
un-checked-children="غیر فعال"
|
||||
@change="changeActive"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<DialogVant v-model:show="deleteConfirmVisible" :closeOnClickOverlay="false" :timeOut="-1" teleport="body">
|
||||
<template #title>
|
||||
<div class="flex flex-col items-center">
|
||||
<div class="p-5 text-sm">آیا از حذف هشدار اطمینان دارید؟</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #button>
|
||||
<div class="text-center text-red flex items-center justify-center" @click="deleteItem">
|
||||
<a-spin :spinning="deleteLoading" size="small">تایید</a-spin>
|
||||
</div>
|
||||
<div class="text-center" @click="deleteConfirmVisible = false">انصراف</div>
|
||||
</template>
|
||||
</DialogVant>
|
||||
</div>
|
||||
|
||||
<div v-else @click="infoVisible = true" class="shadow mb-2 p-2 rounded-lg">
|
||||
<div class="flex justify-between">
|
||||
<div>
|
||||
<div class="font-bold text-base mb-2">{{usePrice(item.target_price) }}</div>
|
||||
<div class="font-bold text-base mb-2">{{ usePrice(item.target_price) }}</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 ">
|
||||
<BasicIcon color="red" icon="vuesax-linear:trash" @click.stop="deleteConfirmVisible = true" class="p-1"/>
|
||||
<BasicIcon color="green" icon="vuesax-linear:edit" @click.stop="emits('edit',item)" class="p-1"/>
|
||||
<div class="flex gap-2">
|
||||
<BasicIcon
|
||||
class="p-1"
|
||||
color="red"
|
||||
icon="vuesax-linear:trash"
|
||||
@click.stop="deleteConfirmVisible = true"
|
||||
/>
|
||||
<BasicIcon
|
||||
class="p-1"
|
||||
color="green"
|
||||
icon="vuesax-linear:edit"
|
||||
@click.stop="emits('edit', item)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 mt-2">
|
||||
<BasicInfoItem is-line title="جهت قیمت" :value="returnPriceCondition(item.price_condition)"/>
|
||||
|
||||
<BasicInfoItem is-line title="نوع هشدار" :value="returnAction(item.action)"/>
|
||||
<BasicInfoItem is-line title="جهت قیمت" :value="returnPriceCondition(item.price_condition)" />
|
||||
<BasicInfoItem is-line title="نوع هشدار" :value="returnAction(item.action)" />
|
||||
</div>
|
||||
<a-divider class="!my-3" />
|
||||
|
||||
<div class="flex justify-between mt-1">
|
||||
<div class="mb-2">{{toJalali(item.created_at)}}</div>
|
||||
<a-switch v-model:checked="isActive" checked-children="فعال" un-checked-children="غیر فعال" @change="changeActive"/>
|
||||
<div class="mb-2">{{ toJalali(item.created_at) }}</div>
|
||||
<a-switch
|
||||
v-model:checked="isActive"
|
||||
checked-children="فعال"
|
||||
un-checked-children="غیر فعال"
|
||||
@change="changeActive"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- <teleport to="app">-->
|
||||
<DialogVant v-model:show="deleteConfirmVisible" teleport="body" :closeOnClickOverlay="false" :timeOut="-1">
|
||||
<!-- <template v-slot:img>
|
||||
<img :src="registerDelayImage" alt="" class="opacity-80">
|
||||
</template>-->
|
||||
|
||||
<template v-slot:title>
|
||||
<DialogVant v-model:show="deleteConfirmVisible" :closeOnClickOverlay="false" :timeOut="-1" teleport="body">
|
||||
<template #title>
|
||||
<div class="flex flex-col items-center">
|
||||
<div class="p-5 text-sm">
|
||||
آیا از حذف هشدار اطمینان دارید؟
|
||||
</div>
|
||||
<div class="p-5 text-sm">آیا از حذف هشدار اطمینان دارید؟</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-slot:button>
|
||||
<template #button>
|
||||
<div class="text-center text-red flex items-center justify-center" @click="deleteItem">
|
||||
<a-spin :spinning="deleteLoading" size="small">
|
||||
تایید
|
||||
</a-spin>
|
||||
</div>
|
||||
<div class="text-center" @click="deleteConfirmVisible = false">
|
||||
انصراف
|
||||
<a-spin :spinning="deleteLoading" size="small">تایید</a-spin>
|
||||
</div>
|
||||
<div class="text-center" @click="deleteConfirmVisible = false">انصراف</div>
|
||||
</template>
|
||||
|
||||
</DialogVant>
|
||||
<!-- </teleport>-->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { usePrice, usePriceWithoutType } from '../../../../utils/usePrice'
|
||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import { toJalali, toJalaliNotime, toJalaliOutOfUTC, toTime } from '../../../../utils/useDateTime'
|
||||
import { usePrice } from '../../../../utils/usePrice'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { toJalali } from '../../../../utils/useDateTime'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import type { PriceTrigger } from '@/models/PriceTrigger'
|
||||
import BasicInfoItem from '@/components/BasicPacks/BasicInfoItem.vue'
|
||||
import DialogVant from '@/components/DialogVant.vue'
|
||||
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
|
||||
import { deletePriceTrigger, updatePriceTrigger } from '@/api/triggerPrice'
|
||||
import { loading } from '@/utils'
|
||||
|
||||
const infoVisible = ref<boolean>(false)
|
||||
|
||||
const isActive = ref<boolean>(false)
|
||||
|
||||
const infoVisible = ref(false)
|
||||
const isActive = ref(false)
|
||||
const deleteLoading = ref(false)
|
||||
const deleteConfirmVisible = ref(false)
|
||||
|
||||
interface Prop {
|
||||
item: PriceTrigger
|
||||
}
|
||||
onMounted(()=> isActive.value = props.item.is_active)
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
item: PriceTrigger
|
||||
variant?: 'mobile' | 'desktop'
|
||||
}>(),
|
||||
{ variant: 'mobile' },
|
||||
)
|
||||
|
||||
const emits = defineEmits(['edit', 'refresh'])
|
||||
|
||||
onMounted(() => {
|
||||
isActive.value = props.item.is_active
|
||||
})
|
||||
|
||||
function changeActive(val: boolean) {
|
||||
console.log(val)
|
||||
try {
|
||||
loading.value = true
|
||||
updatePriceTrigger(props?.item.id, {is_active: val})
|
||||
updatePriceTrigger(props?.item.id, { is_active: val })
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
isActive.value = !isActive.value
|
||||
@@ -95,15 +150,13 @@ function changeActive(val: boolean) {
|
||||
|
||||
function returnPriceCondition(val: string) {
|
||||
switch (val) {
|
||||
case '==': return 'مساوی'
|
||||
case '<': return 'کوچکتر'
|
||||
case '>': return 'بزرگتر'
|
||||
case '==':
|
||||
return 'مساوی'
|
||||
case '<':
|
||||
return 'کوچکتر'
|
||||
case '>':
|
||||
return 'بزرگتر'
|
||||
}
|
||||
/* if (val === '=='){
|
||||
return 'مساوی'
|
||||
} else if (val === '<'){
|
||||
return 'کوچکتر'
|
||||
}*/
|
||||
}
|
||||
|
||||
async function deleteItem() {
|
||||
@@ -121,41 +174,12 @@ async function deleteItem() {
|
||||
|
||||
function returnAction(val: string) {
|
||||
switch (val) {
|
||||
case 'sms': return 'پیامک'
|
||||
case 'email': return 'ایمیل'
|
||||
case 'notify': return 'نوتیفیکیشن'
|
||||
// case '==': return 'مساوی'
|
||||
case 'sms':
|
||||
return 'پیامک'
|
||||
case 'email':
|
||||
return 'ایمیل'
|
||||
case 'notify':
|
||||
return 'نوتیفیکیشن'
|
||||
}
|
||||
/* if (val === '=='){
|
||||
return 'مساوی'
|
||||
} else if (val === '<'){
|
||||
return 'کوچکتر'
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
const props = withDefaults(defineProps<Prop>(), {})
|
||||
const emits = defineEmits(['edit','refresh'])
|
||||
|
||||
const isUp = computed(() => props.item.type === 3 || props.item.type === 1 || props.item.type === 8)
|
||||
const isGold = computed(() => props.item.type === 1 || props.item.type === 2 || props.item.type === 10)
|
||||
/*const title = computed(() => {
|
||||
if (isUp.value) {
|
||||
if (isGold.value) {
|
||||
return 'واریز ریالی'
|
||||
} else {
|
||||
return 'خرید طلا'
|
||||
}
|
||||
} else {
|
||||
if (isGold.value) {
|
||||
return 'برداشت ریالی'
|
||||
} else {
|
||||
return 'فروش طلا'
|
||||
}
|
||||
}
|
||||
})*/
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<template>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
class="!mt-0"
|
||||
name="price-trigger-form"
|
||||
@finish="ok()"
|
||||
>
|
||||
<div class="flex flex-col gap-4 w-full">
|
||||
<a-form-item :rules="[required()]" label="جهت قیمت" name="price_condition">
|
||||
<BasicSelect
|
||||
v-model:value="form.price_condition"
|
||||
:items="typeItems"
|
||||
:show-search="false"
|
||||
key-name="key"
|
||||
placeholder="انتخاب نوع جهت قیمت"
|
||||
size="large"
|
||||
value-name="value"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item :rules="[required()]" label="قیمت" name="target_price">
|
||||
<BasicInput
|
||||
v-model:value="form.target_price"
|
||||
addon-before="ریال"
|
||||
place-holder="وارد کردن قیمت"
|
||||
size="large"
|
||||
type="price"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item :rules="[required()]" label="نوع هشدار را انتخاب کنید" name="action">
|
||||
<a-radio-group v-model:value="form.action">
|
||||
<a-radio :style="radioStyle" value="sms">ارسال پیامک</a-radio>
|
||||
<a-radio :style="radioStyle" value="email">ارسال ایمیل</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-spin :spinning="loading">
|
||||
<BasicButton class="w-full" html-type="submit" type="primary">
|
||||
{{ editId ? 'ویرایش هشدار' : 'ثبت هشدار' }}
|
||||
</BasicButton>
|
||||
</a-spin>
|
||||
</a-form-item>
|
||||
</div>
|
||||
</a-form>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
||||
import { required } from '@/utils/inputRules'
|
||||
import { usePriceTriggerPageContext } from '../composables/usePriceTriggerPage'
|
||||
|
||||
const {
|
||||
form,
|
||||
formRef,
|
||||
editId,
|
||||
loading,
|
||||
radioStyle,
|
||||
typeItems,
|
||||
ok,
|
||||
} = usePriceTriggerPageContext()
|
||||
</script>
|
||||
@@ -0,0 +1,135 @@
|
||||
import { inject, onMounted, provide, reactive, ref, type InjectionKey, type Ref } from 'vue'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { type FormInstance, message } from 'ant-design-vue'
|
||||
import { createPriceTrigger, getPriceTriggers, updatePriceTrigger } from '@/api/triggerPrice'
|
||||
import type { SelectItem } from '@/models/SelectItem'
|
||||
import type { PriceTrigger } from '@/models/PriceTrigger'
|
||||
import { loading } from '@/utils'
|
||||
|
||||
export interface PriceTriggerPageContext {
|
||||
items: Ref<PriceTrigger[]>
|
||||
addTriggerVisible: Ref<boolean>
|
||||
editId: Ref<number | undefined>
|
||||
form: Ref<PriceTrigger>
|
||||
formRef: Ref<FormInstance | undefined>
|
||||
loading: typeof loading
|
||||
radioStyle: ReturnType<typeof reactive<{ display: string; height: string; lineHeight: string }>>
|
||||
typeItems: SelectItem[]
|
||||
resetFields: () => void
|
||||
openAdd: () => void
|
||||
openEdit: (val: PriceTrigger) => void
|
||||
initItems: () => Promise<void>
|
||||
ok: () => Promise<void>
|
||||
}
|
||||
|
||||
export const PRICE_TRIGGER_PAGE_CONTEXT_KEY: InjectionKey<PriceTriggerPageContext> =
|
||||
Symbol('priceTriggerPageContext')
|
||||
|
||||
export function usePriceTriggerPage() {
|
||||
const items = ref<PriceTrigger[]>([])
|
||||
const addTriggerVisible = ref(false)
|
||||
const editId = ref<number | undefined>(undefined)
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const radioStyle = reactive({
|
||||
display: '',
|
||||
height: '30px',
|
||||
lineHeight: '30px',
|
||||
})
|
||||
|
||||
const form = ref<PriceTrigger>({
|
||||
price_condition: '',
|
||||
is_active: true,
|
||||
action: '',
|
||||
target_price: '',
|
||||
})
|
||||
|
||||
const typeItems: SelectItem[] = [
|
||||
{ value: 'بزرگتر', key: '>' },
|
||||
{ value: 'کوچکتر', key: '<' },
|
||||
{ value: 'مساوی', key: '==' },
|
||||
]
|
||||
|
||||
function resetFields() {
|
||||
form.value = {
|
||||
price_condition: '',
|
||||
is_active: true,
|
||||
action: '',
|
||||
target_price: '',
|
||||
}
|
||||
}
|
||||
|
||||
function openAdd() {
|
||||
resetFields()
|
||||
editId.value = undefined
|
||||
addTriggerVisible.value = true
|
||||
}
|
||||
|
||||
function openEdit(val: PriceTrigger) {
|
||||
form.value = cloneDeep(val)
|
||||
editId.value = form.value.id
|
||||
addTriggerVisible.value = true
|
||||
}
|
||||
|
||||
async function initItems() {
|
||||
try {
|
||||
items.value = []
|
||||
items.value = await getPriceTriggers()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function ok() {
|
||||
await formRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
if (editId.value) {
|
||||
await updatePriceTrigger(editId.value, form.value)
|
||||
} else {
|
||||
await createPriceTrigger(form.value)
|
||||
}
|
||||
message.success('هشدار با موفقیت ایجاد شد')
|
||||
await initItems()
|
||||
addTriggerVisible.value = false
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initItems()
|
||||
})
|
||||
|
||||
const context: PriceTriggerPageContext = {
|
||||
items,
|
||||
addTriggerVisible,
|
||||
editId,
|
||||
form,
|
||||
formRef,
|
||||
loading,
|
||||
radioStyle,
|
||||
typeItems,
|
||||
resetFields,
|
||||
openAdd,
|
||||
openEdit,
|
||||
initItems,
|
||||
ok,
|
||||
}
|
||||
|
||||
provide(PRICE_TRIGGER_PAGE_CONTEXT_KEY, context)
|
||||
return context
|
||||
}
|
||||
|
||||
export function usePriceTriggerPageContext() {
|
||||
const context = inject(PRICE_TRIGGER_PAGE_CONTEXT_KEY)
|
||||
if (!context) {
|
||||
throw new Error('usePriceTriggerPageContext must be used within a page that calls usePriceTriggerPage()')
|
||||
}
|
||||
return context
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div class="dptr">
|
||||
<div class="dptr__container">
|
||||
<header class="dptr-topbar">
|
||||
<p class="dptr-topbar__eyebrow">اعلانها</p>
|
||||
<h1 class="dptr-topbar__title">هشدار قیمت</h1>
|
||||
<p class="dptr-topbar__subtitle">هنگام رسیدن قیمت به مقدار تعیینشده، از طریق پیامک یا ایمیل مطلع شوید</p>
|
||||
</header>
|
||||
|
||||
<div class="dptr-grid">
|
||||
<section class="dptr-surface dptr-form">
|
||||
<div class="dptr-form__header">
|
||||
<h2 class="dptr-form__title">{{ editId ? 'ویرایش هشدار' : 'ثبت هشدار جدید' }}</h2>
|
||||
<button
|
||||
v-if="editId"
|
||||
type="button"
|
||||
class="dptr-form__reset"
|
||||
@click="openAdd()"
|
||||
>
|
||||
هشدار جدید
|
||||
</button>
|
||||
</div>
|
||||
<PriceTriggerForm />
|
||||
</section>
|
||||
|
||||
<section class="dptr-surface dptr-list">
|
||||
<div class="dptr-list__header">
|
||||
<h3 class="dptr-list__title">هشدارهای فعلی</h3>
|
||||
<span class="dptr-list__count">{{ items.length }} مورد</span>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="dptr-list__skeletons">
|
||||
<TransactionSkeleton v-for="i in 6" :key="i" class="mt-1" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="items.length" class="dptr-list__items">
|
||||
<list-anim>
|
||||
<Item
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
variant="desktop"
|
||||
@edit="openEdit"
|
||||
@refresh="initItems"
|
||||
/>
|
||||
</list-anim>
|
||||
</div>
|
||||
|
||||
<div v-else class="dptr-empty">
|
||||
<BasicIcon icon="vuesax-linear:notification-bing" size="36" />
|
||||
<p>هنوز هشداری ثبت نشده است.</p>
|
||||
<button type="button" class="dptr-empty__btn" @click="openAdd()">
|
||||
افزودن اولین هشدار
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import ListAnim from '@/components/ListAnim.vue'
|
||||
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||
import Item from '../components/Item.vue'
|
||||
import PriceTriggerForm from '../components/PriceTriggerForm.vue'
|
||||
import { usePriceTriggerPageContext } from '../composables/usePriceTriggerPage'
|
||||
|
||||
const {
|
||||
items,
|
||||
loading,
|
||||
editId,
|
||||
openAdd,
|
||||
openEdit,
|
||||
initItems,
|
||||
} = usePriceTriggerPageContext()
|
||||
</script>
|
||||
@@ -0,0 +1,273 @@
|
||||
/* Premium desktop price trigger page */
|
||||
|
||||
.dptr {
|
||||
min-height: 100%;
|
||||
background: #f6f7f9;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.dptr__container {
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
padding: 28px 36px 40px;
|
||||
}
|
||||
|
||||
.dptr-topbar {
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 24px;
|
||||
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
|
||||
|
||||
&__eyebrow {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: #9ca3af;
|
||||
margin: 0 0 4px;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 26px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.03em;
|
||||
color: #111827;
|
||||
margin: 0 0 6px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
&__subtitle {
|
||||
font-size: 14px;
|
||||
color: #6b7280;
|
||||
margin: 0;
|
||||
max-width: 520px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
|
||||
.dptr-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
|
||||
gap: 20px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.dptr-surface {
|
||||
background: #fff;
|
||||
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||
}
|
||||
|
||||
.dptr-form {
|
||||
padding: 24px;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #111827;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__reset {
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
color: #6b7280;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
padding: 6px 10px;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s ease, color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: @theme-primary;
|
||||
color: @theme-primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dptr-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 420px;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 20px 24px 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #111827;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__count {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #6b7280;
|
||||
background: #f3f4f6;
|
||||
border-radius: 999px;
|
||||
padding: 4px 10px;
|
||||
}
|
||||
|
||||
&__items {
|
||||
padding: 16px 24px 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
&__skeletons {
|
||||
padding: 16px 24px 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.dptr-card {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 12px 16px;
|
||||
padding: 16px 18px;
|
||||
border: 1px solid #eef0f3;
|
||||
border-radius: 12px;
|
||||
background: #fafbfc;
|
||||
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: #dbe0e6;
|
||||
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
|
||||
}
|
||||
|
||||
&__price {
|
||||
grid-column: 1 / -1;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
&__label {
|
||||
color: #9ca3af;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__value {
|
||||
color: #374151;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
&__icon-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s ease, background 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: #f9fafb;
|
||||
}
|
||||
|
||||
&--danger:hover {
|
||||
border-color: #fecaca;
|
||||
background: #fef2f2;
|
||||
}
|
||||
|
||||
&--edit:hover {
|
||||
border-color: #bbf7d0;
|
||||
background: #f0fdf4;
|
||||
}
|
||||
}
|
||||
|
||||
&__footer {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid #eef0f3;
|
||||
}
|
||||
|
||||
&__date {
|
||||
font-size: 12px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
}
|
||||
|
||||
.dptr-empty {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 48px 24px;
|
||||
color: #6b7280;
|
||||
text-align: center;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
&__btn {
|
||||
margin-top: 4px;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
background: @theme-primary;
|
||||
color: #fff;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
padding: 10px 16px;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
opacity: 0.92;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1023.98px) {
|
||||
.dptr-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@@ -1,197 +1,31 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="bg-white py-3 px-3 text-primary font-bold drop-shadow wrap-fix flex z-10">
|
||||
<div @click="router.back()">
|
||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||
</div>
|
||||
<div class="mr-2">هشدارهای فعلی</div>
|
||||
</div>
|
||||
<!-- <a-spin :spinning="loading">-->
|
||||
<div ref="el" :class="loading? 'h-screen': ''" class="px-3 pt-16 pb-2 overflow-y-scroll"
|
||||
style="max-height: calc(100vh - 50px)">
|
||||
<div class="price-trigger-page-root">
|
||||
<DesktopPriceTriggerView v-show="isDesktop" />
|
||||
<MobilePriceTriggerView v-show="!isDesktop" />
|
||||
|
||||
<list-anim v-if="!loading" class="pb-12vh">
|
||||
<Item v-for="item in items" :key="item.id" :item="item" @edit="openEdit" @refresh="initItems" />
|
||||
<!-- <TransactionSkeleton v-if="loadingMore" class="mt-1 mb-8" />-->
|
||||
</list-anim>
|
||||
<div v-if="loading">
|
||||
<TransactionSkeleton v-for="i in 13" :key="i" class="mt-1" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- </a-spin>-->
|
||||
<BasicActionSheet v-model:show="addTriggerVisible" teleport="body">
|
||||
<a-form ref="formRef" :model="form" class="!mt-5" name="basic"
|
||||
@finish="ok()">
|
||||
<div class="flex flex-col gap-4 pb-12 w-full">
|
||||
<div class="font-bold text-lg">هشدار قیمت</div>
|
||||
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" label="جهت قیمت" name="price_condition">
|
||||
<BasicSelect :items="typeItems" v-model:value="form.price_condition" :show-search="false" value-name="value"
|
||||
key-name="key"
|
||||
placeholder="انتخاب نوع جهت قیمت"
|
||||
size="large"></BasicSelect>
|
||||
</a-form-item>
|
||||
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" label="قیمت" name="target_price">
|
||||
<BasicInput v-model:value="form.target_price" place-holder="وارد کردن قیمت" type="price" size="large"
|
||||
addon-before="ریال" />
|
||||
</a-form-item>
|
||||
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" name="action"
|
||||
label="نوع هشدار را انتخاب کنید">
|
||||
<a-radio-group v-model:value="form.action">
|
||||
<a-radio :style="radioStyle" value="sms">ارسال پیامک</a-radio>
|
||||
<a-radio :style="radioStyle" value="email">ارسال ایمیل</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-spin :spinning="loading">
|
||||
<BasicButton class="w-full" type="primary" html-type="submit">
|
||||
{{ editId ? 'ویرایش هشدار' : 'ثبت هشدار' }}
|
||||
</BasicButton>
|
||||
</a-spin>
|
||||
</a-form-item>
|
||||
</div>
|
||||
</a-form>
|
||||
<BasicActionSheet v-if="!isDesktop" v-model:show="addTriggerVisible" teleport="body">
|
||||
<div class="font-bold text-lg mb-2">هشدار قیمت</div>
|
||||
<PriceTriggerForm />
|
||||
</BasicActionSheet>
|
||||
<!-- <div class="bg-primary w-3rem h-3rem flex items-center justify-center rounded-lg fixed bottom-12vh left-8vw"
|
||||
@click="openAdd()">
|
||||
<BasicIcon icon="vuesax-linear:add" color="white" />
|
||||
</div>-->
|
||||
<Transition mode="out-in" name="fade">
|
||||
<div
|
||||
class="wrap-fix bottom-0 h-[16vh] bg-[#FBFBFC] shadow-lg rounded-3xl flex justify-center pt-3 z-200"
|
||||
style="box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 26px 11px"
|
||||
@click="openAdd()">
|
||||
<BasicIcon icon="vuesax-linear:add" />
|
||||
<div>افزودن هشدار جدید</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createPriceTrigger, getPriceTriggers, updatePriceTrigger } from '@/api/triggerPrice'
|
||||
|
||||
const radioStyle = reactive({
|
||||
display: '',
|
||||
height: '30px',
|
||||
lineHeight: '30px'
|
||||
})
|
||||
import type { SelectItem } from '@/models/SelectItem'
|
||||
|
||||
// import Item from "./components/Item.vue";
|
||||
/*import {lengthValidation, required} from "@/utils/inputRules";
|
||||
import {loading} from "@/utils";
|
||||
import BasicButton from "@/components/BasicPacks/BasicButton.vue";
|
||||
import BasicActionSheet from "@/components/BasicPacks/BasicActionSheet.vue";
|
||||
import BasicInput from "@/components/BasicPacks/BasicInput.vue";*/
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import type { TableEngineInput, TableOutput } from '@/models/table'
|
||||
import { loading, loadingMore } from '@/utils'
|
||||
// import {getOrders} from "@/api/order";
|
||||
import { getTransactionTable } from '@/api/transaction'
|
||||
import type { Transaction } from '@/models/transaction'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BaseDatePicker from '@/components/BasicPacks/BaseDatePicker/src/BaseDatePicker.vue'
|
||||
import { useInfiniteScroll, useScroll } from '@vueuse/core'
|
||||
import ListAnim from '@/components/ListAnim.vue'
|
||||
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
|
||||
import { mobileValidation, required } from '@/utils/inputRules'
|
||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||
import type { User } from '@/models/login'
|
||||
import { type FormInstance, message } from 'ant-design-vue'
|
||||
import type { PriceTrigger } from '@/models/PriceTrigger'
|
||||
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
||||
import Item from './components/Item.vue'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import router from '@/router'
|
||||
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||
import { usePriceTriggerPage } from './composables/usePriceTriggerPage'
|
||||
import DesktopPriceTriggerView from './desktop/DesktopPriceTriggerView.vue'
|
||||
import MobilePriceTriggerView from './mobile/MobilePriceTriggerView.vue'
|
||||
import PriceTriggerForm from './components/PriceTriggerForm.vue'
|
||||
|
||||
const items = ref<PriceTrigger[]>([])
|
||||
const addTriggerVisible = ref<boolean>(false)
|
||||
const editId = ref<number | undefined>(undefined)
|
||||
const el = ref()
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
|
||||
const form = ref<PriceTrigger>({
|
||||
price_condition: '',
|
||||
is_active: true,
|
||||
action: '',
|
||||
target_price: ''
|
||||
})
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
onMounted(() => {
|
||||
initItems()
|
||||
})
|
||||
|
||||
function resetFields() {
|
||||
form.value = {
|
||||
price_condition: '',
|
||||
is_active: true,
|
||||
action: '',
|
||||
target_price: ''
|
||||
}
|
||||
}
|
||||
|
||||
function openAdd() {
|
||||
resetFields()
|
||||
editId.value = undefined
|
||||
addTriggerVisible.value = true
|
||||
}
|
||||
|
||||
async function initItems() {
|
||||
try {
|
||||
items.value = []
|
||||
items.value = await getPriceTriggers()
|
||||
// console.log(items.value)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
loadingMore.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function openEdit(val: PriceTrigger) {
|
||||
form.value = cloneDeep(val)
|
||||
editId.value = form.value.id
|
||||
addTriggerVisible.value = true
|
||||
}
|
||||
|
||||
async function ok() {
|
||||
formRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
editId.value ? await updatePriceTrigger(editId.value, form.value) : await createPriceTrigger(form.value)
|
||||
message.success('هشدار با موفقیت ایجاد شد')
|
||||
await initItems()
|
||||
addTriggerVisible.value = false
|
||||
//
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const typeItems: SelectItem[] = [
|
||||
{
|
||||
value: 'بزرگتر',
|
||||
key: '>'
|
||||
},
|
||||
{
|
||||
value: 'کوچکتر',
|
||||
key: '<'
|
||||
},
|
||||
{
|
||||
value: 'مساوی',
|
||||
key: '=='
|
||||
}
|
||||
]
|
||||
const { addTriggerVisible } = usePriceTriggerPage()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
.price-trigger-page-root {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div>
|
||||
<MobilePageHeader title="هشدارهای فعلی" show-back />
|
||||
|
||||
<div
|
||||
:class="loading ? 'h-screen' : ''"
|
||||
class="px-3 mpage-content pb-2 overflow-y-scroll mpage-scroll"
|
||||
>
|
||||
<list-anim v-if="!loading" class="pb-[calc(var(--app-bottom-chrome-height)+var(--app-add-card-height)+1rem)]">
|
||||
<Item
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
@edit="openEdit"
|
||||
@refresh="initItems"
|
||||
/>
|
||||
</list-anim>
|
||||
<div v-if="loading">
|
||||
<TransactionSkeleton v-for="i in 13" :key="i" class="mt-1" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="!addTriggerVisible"
|
||||
class="app-dock-add-bar"
|
||||
@click="openAdd()"
|
||||
>
|
||||
<BasicIcon icon="vuesax-linear:add" />
|
||||
<div>افزودن هشدار جدید</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||
import ListAnim from '@/components/ListAnim.vue'
|
||||
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||
import Item from '../components/Item.vue'
|
||||
import { usePriceTriggerPageContext } from '../composables/usePriceTriggerPage'
|
||||
|
||||
const {
|
||||
items,
|
||||
loading,
|
||||
addTriggerVisible,
|
||||
openAdd,
|
||||
openEdit,
|
||||
initItems,
|
||||
} = usePriceTriggerPageContext()
|
||||
</script>
|
||||
@@ -38,11 +38,6 @@
|
||||
<div v-else class="w-full h-[88px]">
|
||||
<GoldSkeleton class="w-full" />
|
||||
</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-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">
|
||||
@@ -552,11 +547,6 @@ const unitCashCalculator = computed(() => {
|
||||
return (walletStore?.walletInfo?.cash ?? 0) / 100
|
||||
})
|
||||
|
||||
const limitedPrice = computed(() => {
|
||||
if (walletStore.limitedPrice)
|
||||
return walletStore?.limitedPrice[0]
|
||||
})
|
||||
|
||||
function calculateCash(val: number) {
|
||||
priceErrorVisible.value = false
|
||||
console.log("val",val,props?.ProductItem)
|
||||
|
||||
@@ -1,54 +1,68 @@
|
||||
<template>
|
||||
<div :class="isDesktop ? 'dpage products-page' : ''">
|
||||
<div class="bottom-0 fixed top-0 -z-10 pointer-events-none">
|
||||
<img :src="img" alt="" class=" w-inherit "
|
||||
:style="{ backgroundRepeat: 'repeat', }"
|
||||
/>
|
||||
</div>
|
||||
<a-spin :spinning="productsPageLoading">
|
||||
<div class="relative z-0 !h-full overflow-y-scroll">
|
||||
<div class="w-full flex justify-center top-0 py-5" style="align-self: center">
|
||||
<ARadioGroup @change="changeProductsTab" v-model:value="productsActiveKey" button-style="solid">
|
||||
<ARadioButton class="cats" value="همه">همه</ARadioButton>
|
||||
<ARadioButton class="cats" v-for="item in productsTypeItems" :key="item" :value="item">{{ item }}</ARadioButton>
|
||||
</ARadioGroup>
|
||||
<div
|
||||
class="products-page-root main-with-bottom-chrome-inner--contained"
|
||||
:class="isDesktop ? 'dpage products-page' : ''"
|
||||
>
|
||||
<MobileProductsView v-if="!isDesktop" @select="clickProduct" />
|
||||
|
||||
<template v-else>
|
||||
<div class="bottom-0 fixed top-0 -z-10 pointer-events-none">
|
||||
<img :src="img" alt="" class="w-inherit" :style="{ backgroundRepeat: 'repeat' }" />
|
||||
</div>
|
||||
<div class="mx-5 flex justify-end" @click="viewVertical=!viewVertical">
|
||||
<BasicIcon v-if="viewVertical" icon="vuesax-linear:row-vertical"></BasicIcon>
|
||||
<BasicIcon v-else icon="vuesax-linear:element-3"></BasicIcon>
|
||||
<a-spin :spinning="productsPageLoading">
|
||||
<div class="relative z-0 !h-full overflow-y-scroll">
|
||||
<div class="w-full flex justify-center top-0 py-5" style="align-self: center">
|
||||
<ARadioGroup
|
||||
v-model:value="productsActiveKey"
|
||||
button-style="solid"
|
||||
@change="changeProductsTab"
|
||||
>
|
||||
<ARadioButton class="cats" value="همه">همه</ARadioButton>
|
||||
<ARadioButton
|
||||
v-for="item in productsTypeItems"
|
||||
:key="item"
|
||||
class="cats"
|
||||
:value="item"
|
||||
>
|
||||
{{ item }}
|
||||
</ARadioButton>
|
||||
</ARadioGroup>
|
||||
</div>
|
||||
<div class="mx-5 flex justify-end" @click="viewVertical = !viewVertical">
|
||||
<BasicIcon v-if="viewVertical" icon="vuesax-linear:row-vertical" />
|
||||
<BasicIcon v-else icon="vuesax-linear:element-3" />
|
||||
</div>
|
||||
|
||||
<div class="mx-5 pb-30 pt-2 grid grid-cols-2 gap-3 items-stretch">
|
||||
<template v-if="viewVertical">
|
||||
<ProductItemVertical
|
||||
v-for="item in productsItems"
|
||||
:key="item.id"
|
||||
class="h-full"
|
||||
:ProductItem="item"
|
||||
@click="clickProduct(item)"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<ProductItem
|
||||
v-for="item in productsItems"
|
||||
:key="item.id"
|
||||
class="col-span-2 h-full"
|
||||
:ProductItem="item"
|
||||
@click="clickProduct(item)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<BasicActionSheet placement="bottom" v-model:show="showFilter">
|
||||
<div>
|
||||
<indexGold v-if="selectedProduct?.group_type == 'آبشده'" :ProductItem="selectedProduct" />
|
||||
<DealProduct v-else :ProductItem="selectedProduct" @close="showFilter = false" />
|
||||
</div>
|
||||
|
||||
<div class="mx-5 pb-30 pt-2 grid grid-cols-2 gap-3 items-stretch">
|
||||
<template v-if="viewVertical">
|
||||
<ProductItemVertical
|
||||
v-for="item in productsItems"
|
||||
:key="item.id"
|
||||
class="h-full"
|
||||
:ProductItem="item"
|
||||
@click="clickProduct(item)"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<ProductItem
|
||||
v-for="item in productsItems"
|
||||
:key="item.id"
|
||||
class="col-span-2 h-full"
|
||||
:ProductItem="item"
|
||||
@click="clickProduct(item)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</a-spin>
|
||||
|
||||
<BasicActionSheet placement="bottom" v-model:show="showFilter">
|
||||
<div class="">
|
||||
<indexGold v-if="selectedProduct?.group_type=='آبشده'" :ProductItem="selectedProduct"></indexGold>
|
||||
<DealProduct v-else :ProductItem="selectedProduct" @close="showFilter = false"></DealProduct>
|
||||
</div>
|
||||
</BasicActionSheet>
|
||||
|
||||
</BasicActionSheet>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -61,9 +75,10 @@ import type { Product } from '@/models/products'
|
||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import indexGold from '@/views/base/gold/index.vue'
|
||||
import DealProduct from '@/views/base/products/components/DealProduct.vue'
|
||||
import img from "@/assets/img/user_ly1.svg";
|
||||
import BasicIcon from "@/components/BasicPacks/BasicIcon.vue";
|
||||
import ProductItemVertical from "@/views/base/products/components/ProductItemVertical.vue";
|
||||
import img from '@/assets/img/user_ly1.svg'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import ProductItemVertical from '@/views/base/products/components/ProductItemVertical.vue'
|
||||
import MobileProductsView from '@/views/base/products/mobile/MobileProductsView.vue'
|
||||
import { isProductVisible } from '@/utils/productPrice'
|
||||
import {
|
||||
productsActiveKey,
|
||||
@@ -76,7 +91,7 @@ import {
|
||||
onProductsPageProviderUnmounted,
|
||||
} from '@/views/base/products/composables/useProductsPageData'
|
||||
|
||||
const showFilter = ref()
|
||||
const showFilter = ref<boolean>()
|
||||
const selectedProduct = ref<Product>()
|
||||
const viewVertical = ref(true)
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
@@ -98,9 +113,9 @@ onMounted(async () => {
|
||||
|
||||
if (router.currentRoute.value.query.state) {
|
||||
if (router.currentRoute.value.query.product) {
|
||||
clickProduct(productsItems.value?.find((x) => x.title === 'سکه'))
|
||||
clickProduct(productsItems.value?.find((x) => x.title === 'سکه')!)
|
||||
} else {
|
||||
clickProduct(productsItems.value?.find((x) => x.title === 'آبشده نقدی'))
|
||||
clickProduct(productsItems.value?.find((x) => x.title === 'آبشده نقدی')!)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -110,13 +125,18 @@ onUnmounted(() => {
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.products-page-root {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.cats{
|
||||
font-size: x-small;
|
||||
.products-page-root.main-with-bottom-chrome-inner {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
.cats:hover span {
|
||||
--un-text-opacity: 1;
|
||||
color: rgba(206, 163, 76, var(--un-text-opacity))!important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
<template>
|
||||
<div class="products-mobile-root">
|
||||
<div class="mobile-page-bg" aria-hidden="true">
|
||||
<img :src="img" alt="" />
|
||||
</div>
|
||||
|
||||
<div class="products-mobile-root__chrome">
|
||||
<div class="products-mobile-root__tabs">
|
||||
<ARadioGroup
|
||||
v-model:value="productsActiveKey"
|
||||
button-style="solid"
|
||||
@change="changeProductsTab"
|
||||
>
|
||||
<ARadioButton class="cats" value="همه">همه</ARadioButton>
|
||||
<ARadioButton
|
||||
v-for="item in productsTypeItems"
|
||||
:key="item"
|
||||
class="cats"
|
||||
:value="item"
|
||||
>
|
||||
{{ item }}
|
||||
</ARadioButton>
|
||||
</ARadioGroup>
|
||||
</div>
|
||||
|
||||
<div class="products-mobile-root__toolbar mx-5">
|
||||
<button type="button" class="products-mobile-root__view-toggle" @click="viewVertical = !viewVertical">
|
||||
<BasicIcon v-if="viewVertical" icon="vuesax-linear:row-vertical" />
|
||||
<BasicIcon v-else icon="vuesax-linear:element-3" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="products-mobile-root__scroll">
|
||||
<a-spin :spinning="productsPageLoading">
|
||||
<div
|
||||
class="products-mobile-root__list mx-5 pt-2 pb-[calc(var(--app-bottom-chrome-height)+1rem)] grid gap-3 items-stretch"
|
||||
:class="viewVertical ? 'grid-cols-2' : 'grid-cols-1'"
|
||||
>
|
||||
<template v-if="viewVertical">
|
||||
<ProductItemVertical
|
||||
v-for="item in productsItems"
|
||||
:key="item.id"
|
||||
class="h-full"
|
||||
:ProductItem="item"
|
||||
@click="$emit('select', item)"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<ProductItem
|
||||
v-for="item in productsItems"
|
||||
:key="item.id"
|
||||
class="h-full"
|
||||
:ProductItem="item"
|
||||
@click="$emit('select', item)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</a-spin>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import type { Product } from '@/models/products'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import ProductItem from '@/views/base/products/components/ProductItem.vue'
|
||||
import ProductItemVertical from '@/views/base/products/components/ProductItemVertical.vue'
|
||||
import img from '@/assets/img/user_ly1.svg'
|
||||
import {
|
||||
productsActiveKey,
|
||||
productsTypeItems,
|
||||
productsItems,
|
||||
productsPageLoading,
|
||||
changeProductsTab,
|
||||
} from '@/views/base/products/composables/useProductsPageData'
|
||||
|
||||
defineEmits<{
|
||||
select: [item: Product]
|
||||
}>()
|
||||
|
||||
const viewVertical = ref(true)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.products-mobile-root {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.products-mobile-root__chrome {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.products-mobile-root__tabs {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
padding: 1.25rem 0.75rem 0.5rem;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.products-mobile-root__toolbar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.products-mobile-root__view-toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0.25rem;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.products-mobile-root__scroll {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overscroll-behavior-y: contain;
|
||||
}
|
||||
|
||||
.products-mobile-root__list {
|
||||
min-height: min-content;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.cats {
|
||||
font-size: x-small;
|
||||
}
|
||||
|
||||
.cats:hover span {
|
||||
--un-text-opacity: 1;
|
||||
color: rgba(206, 163, 76, var(--un-text-opacity)) !important;
|
||||
}
|
||||
</style>
|
||||
@@ -46,7 +46,7 @@
|
||||
height: 56px;
|
||||
border-radius: 14px;
|
||||
background: rgba(167, 43, 119, 0.08);
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
border: 1px solid rgba(167, 43, 119, 0.15);
|
||||
border-radius: 12px;
|
||||
background: rgba(167, 43, 119, 0.03);
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
|
||||
&__title {
|
||||
font-size: 16px;
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="wrap-fix z-1 bg-white py-3 px-3 text-primary font-bold drop-shadow flex">
|
||||
<div class="cursor-pointer" @click="router.back()">
|
||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||
</div>
|
||||
<div class="mr-2">قوانین و مقررات</div>
|
||||
</div>
|
||||
<div class="pt-20 pb-24 px-5">
|
||||
<MobilePageHeader title="قوانین و مقررات" show-back />
|
||||
<div class="mpage-content pb-[calc(var(--app-bottom-chrome-height)+1rem)] px-5">
|
||||
<RulesContentPanel variant="mobile" />
|
||||
<RulesSupportActions variant="mobile" />
|
||||
</div>
|
||||
@@ -14,8 +9,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import router from '@/router'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||
import RulesContentPanel from '../components/RulesContentPanel.vue'
|
||||
import RulesSupportActions from '../components/RulesSupportActions.vue'
|
||||
</script>
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
}
|
||||
|
||||
&--active {
|
||||
background: @App-primary-color;
|
||||
border-color: @App-primary-color;
|
||||
background: @theme-primary;
|
||||
border-color: @theme-primary;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
<template>
|
||||
<div>
|
||||
<div :style="{ backgroundImage: `url(${img})` }" class="fixed top-0 right-0 left-0 bottom-0"></div>
|
||||
<div class="absolute inset-0 bg-cover bg-center opacity-60"></div>
|
||||
<div
|
||||
class="bg-white w-full transaction-list py-3 px-3 font-bold drop-shadow flex justify-between z-10"
|
||||
>
|
||||
<div>لیست تراکنش ها</div>
|
||||
<BasicIcon icon="vuesax-linear:filter" @click="showFilter = true" />
|
||||
<div class="mobile-transactions-view">
|
||||
<div class="mobile-page-bg" aria-hidden="true">
|
||||
<img :src="img" alt="" />
|
||||
</div>
|
||||
|
||||
<MobilePageHeader title="لیست تراکنش ها">
|
||||
<template #trailing>
|
||||
<button type="button" class="mobile-transactions-view__filter" @click="showFilter = true">
|
||||
<BasicIcon icon="vuesax-linear:filter" />
|
||||
</button>
|
||||
</template>
|
||||
</MobilePageHeader>
|
||||
|
||||
<div
|
||||
ref="el"
|
||||
:class="loading ? 'h-screen' : ''"
|
||||
class="px-3 pt-16 pb-4"
|
||||
style="max-height: calc(100vh - 50px)"
|
||||
class="mobile-transactions-view__content mpage-content px-3 pb-[calc(var(--app-bottom-chrome-height)+1rem)]"
|
||||
>
|
||||
<list-anim v-if="!loading">
|
||||
<Item v-for="item in items" :key="item.id" :item="item" />
|
||||
@@ -22,7 +24,7 @@
|
||||
<TransactionSkeleton v-if="loadingMore" class="mt-1 mb-8" />
|
||||
</list-anim>
|
||||
<TransactionSkeleton v-for="i in 13" v-else :key="i" class="mt-1" />
|
||||
<div v-if="items.length <= 0 && !loading" class="flex flex-col items-center justify-center h-80vh">
|
||||
<div v-if="items.length <= 0 && !loading" class="flex flex-col items-center justify-center min-h-[50vh]">
|
||||
<DotLottieVue
|
||||
class="w-11rem h-11rem"
|
||||
autoplay
|
||||
@@ -31,9 +33,10 @@
|
||||
<div class="font-bold">{{ emptyText }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BasicActionSheet v-model:show="showFilter">
|
||||
<div class="font-bold text-lg">فیلتر</div>
|
||||
<div class="pb-20 mt-5">
|
||||
<div class="pb-10 mt-5">
|
||||
<a-form-item class="w-full gap-2 !flex-col" label="تاریخ" name="password">
|
||||
<BaseDatePicker v-model:value="dateFilter" class="w-full" size="large" />
|
||||
</a-form-item>
|
||||
@@ -54,6 +57,7 @@ import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BaseDatePicker from '@/components/BasicPacks/BaseDatePicker/src/BaseDatePicker.vue'
|
||||
import ListAnim from '@/components/ListAnim.vue'
|
||||
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
|
||||
import img from '@/assets/img/user_ly1.svg'
|
||||
import { useTransactionsPageContext } from '../composables/useTransactionsPage'
|
||||
@@ -71,14 +75,27 @@ const {
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.transaction-list {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 0;
|
||||
@media screen and (min-width: 426px) {
|
||||
width: 426px;
|
||||
left: auto;
|
||||
right: auto;
|
||||
}
|
||||
.mobile-transactions-view {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.mobile-transactions-view__content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
padding-inline: 0.75rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.mobile-transactions-view__filter {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -87,6 +87,12 @@ export function useUserPage() {
|
||||
icon: 'vuesax-linear:lock',
|
||||
onClick: () => { editPasswordVisible.value = true },
|
||||
},
|
||||
{
|
||||
id: 'notify',
|
||||
label: 'هشدار قیمت',
|
||||
icon: 'vuesax-linear:bill',
|
||||
onClick: () => router.push({ name: 'notifyTrigger' }),
|
||||
},
|
||||
{
|
||||
id: 'about',
|
||||
label: 'درباره ما',
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
height: 64px;
|
||||
border-radius: 16px;
|
||||
background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -174,8 +174,8 @@
|
||||
|
||||
&--primary {
|
||||
width: 100%;
|
||||
background: @App-primary-color;
|
||||
border-color: @App-primary-color;
|
||||
background: @theme-primary;
|
||||
border-color: @theme-primary;
|
||||
color: #fff;
|
||||
|
||||
&:hover {
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
<template>
|
||||
<div class="relative">
|
||||
<div>
|
||||
<!-- <img :src="gr_bottom" alt="" class="absolute bottom-20">-->
|
||||
<img :src="img" alt="" class="mt-2 w-full absolute bottom-0" />
|
||||
<div class="relative mobile-user-view">
|
||||
<div class="mobile-page-bg" aria-hidden="true">
|
||||
<img :src="img" alt="" />
|
||||
</div>
|
||||
<div class="bg-white w-full py-3 px-3 font-bold drop-shadow flex">
|
||||
<div @click="router.back()" class="cursor-pointer">
|
||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||
</div>
|
||||
<div class="mr-2 items-center">اطلاعات حساب کاربری</div>
|
||||
</div>
|
||||
<div class="pt-16 pb-8 z-30 relative">
|
||||
<MobilePageHeader title="اطلاعات حساب کاربری" show-back />
|
||||
<div class="mpage-content pb-[calc(var(--app-bottom-chrome-height)+1rem)] z-30 relative">
|
||||
<div
|
||||
class="border-gray-200 border-1 rounded-xl p-5 trans flex flex-col items-center mx-5 z-1000 relative bg-white shadow-lg"
|
||||
>
|
||||
@@ -92,16 +86,16 @@
|
||||
<div>آدرس ها</div>
|
||||
</div>
|
||||
</BasicButton>-->
|
||||
<!-- <BasicButton-->
|
||||
<!-- class="w-full mt-2"-->
|
||||
<!-- size="large"-->
|
||||
<!-- @click="$router.push({ name: 'notifyTrigger' })"-->
|
||||
<!-- >-->
|
||||
<!-- <div class="flex">-->
|
||||
<!-- <BasicIcon icon="vuesax-linear:bill" class="absolute right-8" />-->
|
||||
<!-- <div>هشدار قیمت</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </BasicButton>-->
|
||||
<BasicButton
|
||||
class="w-full mt-2"
|
||||
size="large"
|
||||
@click="$router.push({ name: 'notifyTrigger' })"
|
||||
>
|
||||
<div class="flex">
|
||||
<BasicIcon icon="vuesax-linear:bill" class="absolute right-8" />
|
||||
<div>هشدار قیمت</div>
|
||||
</div>
|
||||
</BasicButton>
|
||||
<BasicButton
|
||||
class="mt-2 w-full"
|
||||
icon=""
|
||||
@@ -222,6 +216,7 @@ import { useWindowScroll } from '@vueuse/core/index'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { useUserPageContext } from '../composables/useUserPage'
|
||||
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const walletStore = useWalletStore()
|
||||
@@ -282,17 +277,7 @@ async function logout() {
|
||||
z-index: 40;
|
||||
}
|
||||
|
||||
.relative {
|
||||
overflow-y: auto;
|
||||
max-height: 100vh;
|
||||
//scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
.fixed {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 50; /* بالاتر از همه */
|
||||
.mobile-user-view {
|
||||
min-height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
&--active {
|
||||
background: #fff;
|
||||
color: @App-primary-color;
|
||||
color: @theme-primary;
|
||||
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
|
||||
}
|
||||
}
|
||||
@@ -182,8 +182,8 @@
|
||||
transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: @App-primary-color;
|
||||
color: @App-primary-color;
|
||||
border-color: @theme-primary;
|
||||
color: @theme-primary;
|
||||
background: #fff;
|
||||
}
|
||||
}
|
||||
@@ -255,13 +255,13 @@
|
||||
transition: border-color 0.15s ease, color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: @App-primary-color;
|
||||
color: @App-primary-color;
|
||||
border-color: @theme-primary;
|
||||
color: @theme-primary;
|
||||
}
|
||||
|
||||
&--primary {
|
||||
background: @App-primary-color;
|
||||
border-color: @App-primary-color;
|
||||
background: @theme-primary;
|
||||
border-color: @theme-primary;
|
||||
color: #fff;
|
||||
padding: 10px 16px;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="absolute inset-0 bg-cover bg-center opacity-60" :style="{ backgroundImage: `url(${img})` }"></div>
|
||||
<div class="bg-white py-3 px-3 font-bold drop-shadow z-[1999] wrap-fix">کیف پول</div>
|
||||
<div class="mpage-header wrap-fix z-[1999]">کیف پول</div>
|
||||
<div
|
||||
class="bg-white wrap-fix py-3 top-11 px-3 text-primary font-bold flex justify-evenly z-[1999]"
|
||||
class="mpage-subheader wrap-fix fixed left-0 right-0 px-3 text-primary font-bold flex justify-evenly z-[1999]"
|
||||
>
|
||||
<div class="flex justify-evenly w-full px-2 h-11 items-center bg-gray-50 relative rounded">
|
||||
<div
|
||||
@@ -29,7 +29,7 @@
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-5 pt-26 pb-2">
|
||||
<div class="px-5 mpage-content--with-subheader pb-[calc(var(--app-bottom-chrome-height)+1rem)]">
|
||||
<a-form :model="form" class="!mt-5" name="basic" @finish="ok()">
|
||||
<div class="border-gray-200 border-1 rounded-xl p-5 trans h-40 relative">
|
||||
<bg_main />
|
||||
@@ -99,8 +99,7 @@
|
||||
v-if="isDeposit"
|
||||
:ref="(node) => { mobileDepositScrollEl = node as HTMLElement | null }"
|
||||
:class="loading ? 'h-screen' : ''"
|
||||
class="px-3 overflow-y-scroll w-full h-[49vh] pb-16"
|
||||
style="max-height: calc(100vh - 50px)"
|
||||
class="px-3 overflow-y-scroll w-full h-[49vh] pb-[calc(var(--app-bottom-chrome-height)+1rem)] mpage-scroll"
|
||||
>
|
||||
<list-anim v-if="!loading" :numberItemsAnim="4">
|
||||
<Item
|
||||
@@ -122,7 +121,7 @@
|
||||
:items="cardItems"
|
||||
v-model:id="form.card_id"
|
||||
@refresh="getCards"
|
||||
class="card-slider-wrap mt-[2vh] px-3 fixed bottom-10 right-0 left-0"
|
||||
class="card-slider-wrap mt-[2vh] px-3 wallet-dock-width fixed bottom-[calc(var(--app-bottom-chrome-height)+var(--app-add-card-height)-var(--wallet-card-dock-overlap))] z-[var(--app-z-wallet-dock)]"
|
||||
style="touch-action: none"
|
||||
/>
|
||||
<div
|
||||
@@ -137,8 +136,7 @@
|
||||
<Transition mode="out-in" name="fade">
|
||||
<div
|
||||
v-if="!isDeposit"
|
||||
class="add-card fixed bottom-0 h-[18vh] bg-[#FBFBFC] w-full shadow-lg rounded-3xl flex justify-center pt-3 z-200"
|
||||
style="box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 26px 11px"
|
||||
class="app-dock-add-bar"
|
||||
@click="showAddCard = true"
|
||||
>
|
||||
<div>افزودن کارت جدید</div>
|
||||
|
||||
@@ -190,13 +190,6 @@ function setIsSMS(val: boolean) {
|
||||
if (!val) stepTwoVerify.value = false
|
||||
userFormState.token = ''
|
||||
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() {
|
||||
|
||||
+3
-2
@@ -6,11 +6,12 @@ import {
|
||||
|
||||
export default defineConfig({
|
||||
shortcuts: [
|
||||
// ...
|
||||
['wallet-dock-width', 'fixed inset-x-0 w-full max-w-[426px] left-0 right-0'],
|
||||
['app-dock-add-bar', 'wallet-dock-width !fixed bottom-[var(--app-bottom-chrome-height)] z-[var(--app-z-wallet-add-bar)] h-[var(--app-add-card-height)] flex items-center justify-center gap-1 rounded-t-3xl bg-[#FBFBFC] shadow-[0_1px_26px_11px_rgba(0,0,0,0.1)] cursor-pointer box-border'],
|
||||
],
|
||||
theme: {
|
||||
colors: {
|
||||
"primary": "#a72b77",
|
||||
"primary": "var(--app-primary-color, #a72b77)",
|
||||
"secondary": "#ffffff",
|
||||
"tertiary": "#e0be7f"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user