Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be17631109 | ||
|
|
2e159dde20 | ||
|
|
548866160c | ||
|
|
f7ba6963ef | ||
|
|
68be4fd5a1 | ||
|
|
511564be64 | ||
|
|
bf34d0fba0 | ||
|
|
53a3e2f61a | ||
|
|
518a5316cb | ||
|
|
400178591e | ||
|
|
80e573ecad |
@@ -7,6 +7,7 @@ export {}
|
||||
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
ABadge: typeof import('ant-design-vue/es')['Badge']
|
||||
AButton: typeof import('ant-design-vue/es')['Button']
|
||||
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
|
||||
ADivider: typeof import('ant-design-vue/es')['Divider']
|
||||
@@ -55,6 +56,7 @@ declare module 'vue' {
|
||||
ListAnim: typeof import('./src/components/ListAnim.vue')['default']
|
||||
Mode: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/mode.vue')['default']
|
||||
PresettedRanges: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/presetted-ranges.vue')['default']
|
||||
ProductImage: typeof import('./src/components/ProductImage.vue')['default']
|
||||
RangePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/range-picker.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
|
||||
@@ -1,16 +1,129 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="fa" dir="rtl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.png">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
<title>Ghatreh</title>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.png" />
|
||||
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, viewport-fit=cover, interactive-widget=resizes-content"
|
||||
/>
|
||||
|
||||
<title>در حال بارگذاری...</title>
|
||||
<!---->
|
||||
<style>
|
||||
:root {
|
||||
--boot-bg: #ffffff;
|
||||
--boot-bg-soft: #f8fafc;
|
||||
--boot-card: rgba(255, 255, 255, 0.88);
|
||||
--boot-border: rgba(15, 23, 42, 0.08);
|
||||
--boot-text: #111827;
|
||||
--boot-muted: rgba(15, 23, 42, 0.62);
|
||||
--boot-accent: #2563eb;
|
||||
--boot-orb: rgba(37, 99, 235, 0.10);
|
||||
--boot-spinner-track: rgba(15, 23, 42, 0.10);
|
||||
--boot-shadow: rgba(15, 23, 42, 0.10);
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100%;
|
||||
background: var(--boot-bg);
|
||||
}
|
||||
|
||||
#app {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.boot-loader {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
direction: rtl;
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
sans-serif;
|
||||
background:
|
||||
radial-gradient(circle at top, var(--boot-orb), transparent 38%),
|
||||
linear-gradient(
|
||||
135deg,
|
||||
var(--boot-bg) 0%,
|
||||
var(--boot-bg-soft) 100%
|
||||
);
|
||||
color: var(--boot-text);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.boot-loader__card {
|
||||
position: relative;
|
||||
width: min(340px, calc(100vw - 48px));
|
||||
padding: 30px 22px 28px;
|
||||
border-radius: 24px;
|
||||
text-align: center;
|
||||
background: var(--boot-card);
|
||||
border: 1px solid var(--boot-border);
|
||||
box-shadow: 0 18px 48px var(--boot-shadow);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.boot-loader__orb {
|
||||
position: absolute;
|
||||
top: -72px;
|
||||
left: 50%;
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
transform: translateX(-50%);
|
||||
border-radius: 999px;
|
||||
background: var(--boot-orb);
|
||||
filter: blur(8px);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.boot-loader__spinner {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
margin: 0 auto 20px;
|
||||
border-radius: 999px;
|
||||
border: 4px solid var(--boot-spinner-track);
|
||||
border-top-color: var(--boot-accent);
|
||||
animation: boot-spin 0.9s linear infinite;
|
||||
}
|
||||
|
||||
.boot-loader__title {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
margin: 0;
|
||||
font-size: 19px;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.boot-loader__text {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
margin: 10px 0 0;
|
||||
color: var(--boot-muted);
|
||||
font-size: 14px;
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
@keyframes boot-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
#whatsapp-button {
|
||||
position: fixed;
|
||||
bottom: 90px;
|
||||
@@ -23,27 +136,597 @@
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
|
||||
cursor: pointer;
|
||||
cursor: grab;
|
||||
user-select: none;
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#whatsapp-button:hover {
|
||||
#whatsapp-button:hover:not(.is-dragging) {
|
||||
transform: scale(1.1);
|
||||
box-shadow: 0 6px 14px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
#whatsapp-button:hover + #whatsapp-tooltip {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
#whatsapp-button.is-dragging {
|
||||
cursor: grabbing;
|
||||
transform: none;
|
||||
box-shadow: 0 8px 18px rgba(0,0,0,0.22);
|
||||
}
|
||||
|
||||
#whatsapp-button img {
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
;(function () {
|
||||
var CONFIG_COOKIE_NAME = 'APP_CONFIG_CACHE'
|
||||
|
||||
function getCookie(name) {
|
||||
var cookie = document.cookie.split('; ').find(function (row) {
|
||||
return row.indexOf(name + '=') === 0
|
||||
})
|
||||
|
||||
if (!cookie) return null
|
||||
|
||||
return cookie.substring(name.length + 1)
|
||||
}
|
||||
|
||||
function readCachedConfig() {
|
||||
try {
|
||||
var rawCookie = getCookie(CONFIG_COOKIE_NAME)
|
||||
|
||||
if (!rawCookie) return null
|
||||
|
||||
var decoded = decodeURIComponent(rawCookie)
|
||||
var payload = JSON.parse(decoded)
|
||||
|
||||
return payload && payload.config ? payload.config : null
|
||||
} catch (error) {
|
||||
console.warn('Boot theme: failed to read cached config', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeHex(hex) {
|
||||
if (!hex || typeof hex !== 'string') return null
|
||||
|
||||
var value = hex.trim()
|
||||
|
||||
if (!value) return null
|
||||
|
||||
if (value[0] !== '#') {
|
||||
value = '#' + value
|
||||
}
|
||||
|
||||
if (/^#[0-9a-fA-F]{3}$/.test(value)) {
|
||||
value =
|
||||
'#' +
|
||||
value[1] +
|
||||
value[1] +
|
||||
value[2] +
|
||||
value[2] +
|
||||
value[3] +
|
||||
value[3]
|
||||
}
|
||||
|
||||
if (!/^#[0-9a-fA-F]{6}$/.test(value)) return null
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
function hexToRgb(hex) {
|
||||
var normalized = normalizeHex(hex)
|
||||
|
||||
if (!normalized) return null
|
||||
|
||||
var num = parseInt(normalized.slice(1), 16)
|
||||
|
||||
return {
|
||||
r: (num >> 16) & 255,
|
||||
g: (num >> 8) & 255,
|
||||
b: num & 255
|
||||
}
|
||||
}
|
||||
|
||||
function rgbToHex(r, g, b) {
|
||||
function toHex(value) {
|
||||
var hex = Math.max(0, Math.min(255, Math.round(value))).toString(16)
|
||||
return hex.length === 1 ? '0' + hex : hex
|
||||
}
|
||||
|
||||
return '#' + toHex(r) + toHex(g) + toHex(b)
|
||||
}
|
||||
|
||||
function mix(hexA, hexB, weight) {
|
||||
var a = hexToRgb(hexA)
|
||||
var b = hexToRgb(hexB)
|
||||
|
||||
if (!a || !b) return hexA
|
||||
|
||||
return rgbToHex(
|
||||
a.r * (1 - weight) + b.r * weight,
|
||||
a.g * (1 - weight) + b.g * weight,
|
||||
a.b * (1 - weight) + b.b * weight
|
||||
)
|
||||
}
|
||||
|
||||
function brightness(hex) {
|
||||
var rgb = hexToRgb(hex)
|
||||
|
||||
if (!rgb) return 0
|
||||
|
||||
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000
|
||||
}
|
||||
|
||||
function hexToRgba(hex, alpha) {
|
||||
var rgb = hexToRgb(hex)
|
||||
|
||||
if (!rgb) return 'rgba(96, 165, 250, ' + alpha + ')'
|
||||
|
||||
return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + alpha + ')'
|
||||
}
|
||||
|
||||
function setVar(name, value) {
|
||||
document.documentElement.style.setProperty(name, value)
|
||||
}
|
||||
|
||||
function applyBootTheme() {
|
||||
var config = readCachedConfig()
|
||||
var user = config && config.user ? config.user : null
|
||||
|
||||
if (!user) return
|
||||
|
||||
var tenantColor = normalizeHex(user.color)
|
||||
var tenantSecondary = normalizeHex(user.secondary_color)
|
||||
var tenantBackground = normalizeHex(user.background_color)
|
||||
|
||||
/**
|
||||
* مهم:
|
||||
* background_color بکگراند اپ است.
|
||||
* اگر نبود، لودینگ باید روشن بماند، نه اینکه color را بکگراند کنیم.
|
||||
*/
|
||||
var bg = tenantBackground || '#ffffff'
|
||||
|
||||
/**
|
||||
* color و secondary_color فقط برای accent استفاده میشوند.
|
||||
*/
|
||||
var accent = tenantSecondary || tenantColor || '#2563eb'
|
||||
|
||||
var isLight = brightness(bg) > 155
|
||||
|
||||
var bgSoft = isLight ? mix(bg, accent, 0.045) : mix(bg, '#ffffff', 0.055)
|
||||
|
||||
var text = isLight ? '#111827' : '#ffffff'
|
||||
var muted = isLight ? 'rgba(15, 23, 42, 0.62)' : 'rgba(255, 255, 255, 0.70)'
|
||||
|
||||
var card = isLight ? 'rgba(255, 255, 255, 0.88)' : 'rgba(255, 255, 255, 0.07)'
|
||||
var border = isLight ? 'rgba(15, 23, 42, 0.08)' : 'rgba(255, 255, 255, 0.12)'
|
||||
|
||||
var orb = hexToRgba(accent, isLight ? 0.10 : 0.18)
|
||||
var spinnerTrack = isLight ? 'rgba(15, 23, 42, 0.10)' : 'rgba(255, 255, 255, 0.14)'
|
||||
var shadow = isLight ? 'rgba(15, 23, 42, 0.10)' : 'rgba(0, 0, 0, 0.24)'
|
||||
|
||||
setVar('--boot-bg', bg)
|
||||
setVar('--boot-bg-soft', bgSoft)
|
||||
setVar('--boot-accent', accent)
|
||||
setVar('--boot-text', text)
|
||||
setVar('--boot-muted', muted)
|
||||
setVar('--boot-card', card)
|
||||
setVar('--boot-border', border)
|
||||
setVar('--boot-orb', orb)
|
||||
setVar('--boot-spinner-track', spinnerTrack)
|
||||
setVar('--boot-shadow', shadow)
|
||||
|
||||
document.title = user.name_fa || user.name || 'در حال بارگذاری...'
|
||||
}
|
||||
|
||||
applyBootTheme()
|
||||
})()
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<div id="app">
|
||||
<div class="boot-loader">
|
||||
<div class="boot-loader__card">
|
||||
<div class="boot-loader__orb"></div>
|
||||
<div class="boot-loader__spinner"></div>
|
||||
|
||||
<h1 class="boot-loader__title">در حال هدایت به سامانه</h1>
|
||||
<p class="boot-loader__text">لطفاً چند لحظه صبر کنید...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
;(function () {
|
||||
var BOOT_TIMEOUT_MS = 90000
|
||||
|
||||
var RETRY_KEY = '__APP_BOOT_RETRY_CLICKED__'
|
||||
var RECOVERY_KEY = '__APP_BOOT_RECOVERY_DONE__'
|
||||
|
||||
var CONFIG_COOKIE_NAME = 'APP_CONFIG_CACHE'
|
||||
var CONFIG_COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 7
|
||||
|
||||
var TOKEN_STORAGE_KEY = 'liman_user_token'
|
||||
var VERSION_SUCCESS_URL_KEY = 'VERSION_Success_URL'
|
||||
var VERSION_STORAGE_KEY = 'version'
|
||||
var CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
|
||||
|
||||
function getProtocol() {
|
||||
return window.location.protocol === 'https:' ? 'https:' : 'http:'
|
||||
}
|
||||
|
||||
function getVersionUrls() {
|
||||
return ['https://nerkh.gold/get_version', 'https://tablo.talasevin.ir/get_version', 'https://abshode-service.montgit.ir/server/get_version']
|
||||
}
|
||||
|
||||
function getConfigUrls() {
|
||||
var protocol = getProtocol()
|
||||
|
||||
return [
|
||||
protocol + '//nerkh.gold/get_user',
|
||||
protocol + '//tablo.talasevin.ir/get_user',
|
||||
protocol + '//abshode-service.montgit.ir/server/get_user',
|
||||
protocol + '//212.23.201.173:8381/get_user',
|
||||
protocol + '//91.212.174.137:4040/server/get_user'
|
||||
]
|
||||
}
|
||||
|
||||
function sortVersionUrls(urls) {
|
||||
var lastSuccessUrl = localStorage.getItem(VERSION_SUCCESS_URL_KEY)
|
||||
|
||||
if (!lastSuccessUrl) {
|
||||
return urls.slice()
|
||||
}
|
||||
|
||||
return [lastSuccessUrl].concat(urls.filter(function (url) {
|
||||
return url !== lastSuccessUrl
|
||||
}))
|
||||
}
|
||||
|
||||
function sortByLastSuccess(urls) {
|
||||
var lastSuccessUrl = localStorage.getItem(CONFIG_SUCCESS_URL_KEY)
|
||||
|
||||
return urls.slice().sort(function (a, b) {
|
||||
if (a === lastSuccessUrl) return -1
|
||||
if (b === lastSuccessUrl) return 1
|
||||
return 0
|
||||
})
|
||||
}
|
||||
|
||||
function normalizeVersionResponse(data) {
|
||||
if (typeof data === 'string' || typeof data === 'number') {
|
||||
return String(data).trim()
|
||||
}
|
||||
|
||||
if (!data) return ''
|
||||
|
||||
if (typeof data.data === 'string' || typeof data.data === 'number') {
|
||||
return String(data.data).trim()
|
||||
}
|
||||
|
||||
var version =
|
||||
data.version ||
|
||||
data.value ||
|
||||
(data.data && typeof data.data === 'object' ? data.data.version : '')
|
||||
|
||||
return version ? String(version).trim() : ''
|
||||
}
|
||||
|
||||
async function fetchJsonOrText(url, timeout) {
|
||||
var controller = new AbortController()
|
||||
|
||||
var timeoutId = window.setTimeout(function () {
|
||||
controller.abort()
|
||||
}, timeout)
|
||||
|
||||
try {
|
||||
var response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
cache: 'no-store',
|
||||
signal: controller.signal
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Request failed: ' + response.status)
|
||||
}
|
||||
|
||||
var contentType = response.headers.get('content-type') || ''
|
||||
|
||||
if (contentType.indexOf('application/json') !== -1) {
|
||||
return await response.json()
|
||||
}
|
||||
|
||||
return await response.text()
|
||||
} finally {
|
||||
window.clearTimeout(timeoutId)
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchVersionFromUrl(url, timeout) {
|
||||
var controller = new AbortController()
|
||||
var timeoutId = window.setTimeout(function () {
|
||||
controller.abort()
|
||||
}, timeout)
|
||||
|
||||
try {
|
||||
var response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
cache: 'no-store',
|
||||
signal: controller.signal
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Version request failed: ' + response.status)
|
||||
}
|
||||
|
||||
var contentType = response.headers.get('content-type') || ''
|
||||
var data
|
||||
|
||||
if (contentType.indexOf('application/json') !== -1) {
|
||||
data = await response.json()
|
||||
} else {
|
||||
data = await response.text()
|
||||
}
|
||||
|
||||
var version = normalizeVersionResponse(data)
|
||||
|
||||
if (!version) {
|
||||
throw new Error('Version response is empty')
|
||||
}
|
||||
|
||||
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
|
||||
return version
|
||||
} catch (error) {
|
||||
console.warn('Version failed:', url, error)
|
||||
return undefined
|
||||
} finally {
|
||||
window.clearTimeout(timeoutId)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRemoteVersion(rounds) {
|
||||
var urls = sortVersionUrls(getVersionUrls())
|
||||
|
||||
for (var round = 1; round <= rounds; round++) {
|
||||
for (var i = 0; i < urls.length; i++) {
|
||||
var timeout = i === urls.length - 1 ? 6000 : 3500
|
||||
var result = await fetchVersionFromUrl(urls[i], timeout)
|
||||
|
||||
if (result) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
async function fetchFreshConfig(rounds) {
|
||||
var urls = sortByLastSuccess(getConfigUrls())
|
||||
|
||||
for (var round = 1; round <= rounds; round++) {
|
||||
for (var i = 0; i < urls.length; i++) {
|
||||
var url = urls[i]
|
||||
|
||||
try {
|
||||
var config = await fetchJsonOrText(url, i === urls.length - 1 ? 7000 : 4000)
|
||||
|
||||
if (!config || typeof config !== 'object') {
|
||||
throw new Error('Config response is invalid')
|
||||
}
|
||||
|
||||
return {
|
||||
config: config,
|
||||
url: url
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Config failed:', url, 'round:', round, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Cannot fetch fresh config')
|
||||
}
|
||||
|
||||
function writeConfigCookie(config) {
|
||||
try {
|
||||
var payload = {
|
||||
cached_at: Date.now(),
|
||||
config: config
|
||||
}
|
||||
|
||||
var encoded = encodeURIComponent(JSON.stringify(payload))
|
||||
var secure = window.location.protocol === 'https:' ? '; Secure' : ''
|
||||
|
||||
document.cookie =
|
||||
CONFIG_COOKIE_NAME +
|
||||
'=' +
|
||||
encoded +
|
||||
'; Path=/; Max-Age=' +
|
||||
CONFIG_COOKIE_MAX_AGE_SECONDS +
|
||||
'; SameSite=Lax' +
|
||||
secure
|
||||
} catch (error) {
|
||||
console.warn('Failed to write config cookie:', error)
|
||||
}
|
||||
}
|
||||
|
||||
function clearReadableCookies() {
|
||||
document.cookie.split(';').forEach(function (cookie) {
|
||||
var name = cookie.split('=')[0] && cookie.split('=')[0].trim()
|
||||
|
||||
if (!name) return
|
||||
|
||||
document.cookie = name + '=; Path=/; Max-Age=0; SameSite=Lax'
|
||||
})
|
||||
}
|
||||
|
||||
function clearLocalStorageExceptToken() {
|
||||
var token = localStorage.getItem(TOKEN_STORAGE_KEY)
|
||||
|
||||
localStorage.clear()
|
||||
|
||||
if (token) {
|
||||
localStorage.setItem(TOKEN_STORAGE_KEY, token)
|
||||
}
|
||||
}
|
||||
|
||||
async function clearServiceWorkersAndCaches() {
|
||||
try {
|
||||
if ('serviceWorker' in navigator) {
|
||||
var registrations = await navigator.serviceWorker.getRegistrations()
|
||||
|
||||
await Promise.all(
|
||||
registrations.map(function (registration) {
|
||||
return registration.unregister()
|
||||
})
|
||||
)
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to unregister service workers:', error)
|
||||
}
|
||||
|
||||
try {
|
||||
if ('caches' in window) {
|
||||
var keys = await caches.keys()
|
||||
|
||||
await Promise.all(
|
||||
keys.map(function (key) {
|
||||
return caches.delete(key)
|
||||
})
|
||||
)
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to clear caches:', error)
|
||||
}
|
||||
}
|
||||
|
||||
function reloadWithCacheBust() {
|
||||
var url = new URL(window.location.href)
|
||||
url.searchParams.set('__boot_recover', String(Date.now()))
|
||||
window.location.replace(url.toString())
|
||||
}
|
||||
|
||||
function renderRecovering(text) {
|
||||
var app = document.getElementById('app')
|
||||
if (!app) return
|
||||
|
||||
app.innerHTML =
|
||||
'<div style="min-height: 100vh; display: flex; align-items: center; justify-content: center; direction: rtl; font-family: sans-serif; padding: 24px; background: var(--boot-bg); color: var(--boot-text);">' +
|
||||
'<div style="width: min(420px, 100%); text-align: center; background: var(--boot-card); border: 1px solid var(--boot-border); border-radius: 24px; padding: 28px 22px;">' +
|
||||
'<div style="width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 999px; border: 4px solid rgba(255,255,255,0.18); border-top-color: var(--boot-accent); animation: bootSpin 0.9s linear infinite;"></div>' +
|
||||
'<style>@keyframes bootSpin { to { transform: rotate(360deg); } }</style>' +
|
||||
'<h2 style="margin: 0 0 12px; font-size: 20px;">در حال بازیابی برنامه</h2>' +
|
||||
'<p style="margin: 0; color: var(--boot-muted); line-height: 2; font-size: 14px;">' +
|
||||
(text || 'لطفاً چند لحظه صبر کنید.') +
|
||||
'</p>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
}
|
||||
|
||||
function renderBootError() {
|
||||
var app = document.getElementById('app')
|
||||
if (!app) return
|
||||
|
||||
app.innerHTML =
|
||||
'<div style="min-height: 100vh; display: flex; align-items: center; justify-content: center; direction: rtl; font-family: sans-serif; padding: 24px; background: var(--boot-bg); color: var(--boot-text);">' +
|
||||
'<div style="width: min(420px, 100%); text-align: center; background: var(--boot-card); border: 1px solid var(--boot-border); border-radius: 24px; padding: 28px 22px;">' +
|
||||
'<div style="font-size: 42px; margin-bottom: 12px;">⚠️</div>' +
|
||||
'<h2 style="margin: 0 0 12px; font-size: 20px;">خطا در بارگذاری برنامه</h2>' +
|
||||
'<p style="margin: 0 0 20px; color: var(--boot-muted); line-height: 2; font-size: 14px;">' +
|
||||
'ارتباط با سرور برقرار نشد یا فایلهای برنامه بهدرستی دریافت نشدند.' +
|
||||
'</p>' +
|
||||
'<button onclick="window.__APP_BOOT_SIMPLE_RETRY__()" style="padding: 11px 22px; border: 0; border-radius: 12px; background: var(--boot-accent); color: white; cursor: pointer; font-weight: 700;">' +
|
||||
'تلاش مجدد' +
|
||||
'</button>' +
|
||||
'<button onclick="window.__APP_BOOT_CLEAN_RELOAD__()" style="margin-right: 8px; padding: 11px 18px; border: 1px solid var(--boot-border); border-radius: 12px; background: transparent; color: var(--boot-text); cursor: pointer; font-weight: 700;">' +
|
||||
'پاکسازی و تلاش مجدد' +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
}
|
||||
|
||||
async function cleanFetchAndReload() {
|
||||
renderRecovering('در حال دریافت تنظیمات جدید برنامه...')
|
||||
|
||||
var version = await loadRemoteVersion(5)
|
||||
var freshConfigResult = await fetchFreshConfig(2)
|
||||
|
||||
clearReadableCookies()
|
||||
// clearLocalStorageExceptToken()
|
||||
await clearServiceWorkersAndCaches()
|
||||
|
||||
writeConfigCookie(freshConfigResult.config)
|
||||
localStorage.setItem(CONFIG_SUCCESS_URL_KEY, freshConfigResult.url)
|
||||
|
||||
if (version) {
|
||||
localStorage.setItem(VERSION_STORAGE_KEY, version)
|
||||
}
|
||||
|
||||
sessionStorage.removeItem(RETRY_KEY)
|
||||
sessionStorage.removeItem(RECOVERY_KEY)
|
||||
|
||||
reloadWithCacheBust()
|
||||
}
|
||||
|
||||
window.__APP_BOOT_SIMPLE_RETRY__ = function () {
|
||||
sessionStorage.setItem(RETRY_KEY, '1')
|
||||
reloadWithCacheBust()
|
||||
}
|
||||
|
||||
window.__APP_BOOT_CLEAN_RELOAD__ = async function () {
|
||||
try {
|
||||
sessionStorage.setItem(RECOVERY_KEY, '1')
|
||||
await cleanFetchAndReload()
|
||||
} catch (error) {
|
||||
console.error('Manual boot recovery failed:', error)
|
||||
renderBootError()
|
||||
}
|
||||
}
|
||||
|
||||
window.__BOOT_TIMEOUT__ = window.setTimeout(async function () {
|
||||
if (window.__APP_BOOTSTRAPPED__) return
|
||||
|
||||
var app = document.getElementById('app')
|
||||
var stillBooting = app && app.querySelector('.boot-loader')
|
||||
|
||||
if (!stillBooting) return
|
||||
|
||||
if (!sessionStorage.getItem(RETRY_KEY)) {
|
||||
renderBootError()
|
||||
return
|
||||
}
|
||||
|
||||
if (!sessionStorage.getItem(RECOVERY_KEY)) {
|
||||
sessionStorage.setItem(RECOVERY_KEY, '1')
|
||||
|
||||
try {
|
||||
await cleanFetchAndReload()
|
||||
} catch (error) {
|
||||
console.error('Auto boot recovery after retry failed:', error)
|
||||
renderBootError()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
renderBootError()
|
||||
}, BOOT_TIMEOUT_MS)
|
||||
})()
|
||||
</script>
|
||||
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
<a href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c" target="_blank" id="whatsapp-button">
|
||||
<a href="#" target="_blank" id="whatsapp-button">
|
||||
<img class="p-2" src="/src/assets/img/rubika.webp" alt="" />
|
||||
</a>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -19,6 +19,7 @@
|
||||
"axios": "^1.6.2",
|
||||
"dayjalali": "^1.0.1",
|
||||
"echarts": "^5.4.3",
|
||||
"express": "^5.2.1",
|
||||
"jalaliday": "^2.3.0",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.29.4",
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
[
|
||||
{
|
||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||
"target": {
|
||||
"namespace": "android_app",
|
||||
"package_name": "ir.ghatreh.app",
|
||||
"sha256_cert_fingerprints": ["60:54:C6:C1:22:6C:2E:EA:A1:05:02:B1:17:F5:7D:49:1A:C0:84:FF:4C:ED:FD:42:D9:7F:DF:B2:70:37:8E:03"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 450 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 583 KiB |
@@ -55,42 +55,25 @@
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
<van-dialog
|
||||
v-model:show="versionDialog"
|
||||
class="updateButton"
|
||||
confirm-button-text="به روزرسانی کنید"
|
||||
show-confirm-button
|
||||
@confirm="update()"
|
||||
>
|
||||
<div class="flex flex-col items-center p-2">
|
||||
<DotLottieVue
|
||||
class="w-full aspect-square"
|
||||
autoplay
|
||||
loop
|
||||
src="https://lottie.host/cb620e8e-c64a-42e8-a6b5-8844146e5999/nmft7oBO8q.json"
|
||||
/>
|
||||
<div class="home_appear_fade_in_up mt-2">نسخه جدید قطره منتشر شد!</div>
|
||||
</div>
|
||||
</van-dialog>
|
||||
<VersionUpdateModal />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { colors } from './themeConfig'
|
||||
import pkg from '../package.json'
|
||||
import { useRegisterSW } from 'virtual:pwa-register/vue'
|
||||
import { h, onMounted, ref } from 'vue'
|
||||
import { update } from 'lodash'
|
||||
import { defineAsyncComponent, h, onMounted, ref } from 'vue'
|
||||
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'
|
||||
|
||||
import img_bottomGradiant from '@/views/login/assets/img/gr_bottom_white.svg'
|
||||
import logoFull from '@/assets/img/logo_full_.png'
|
||||
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
|
||||
const { offlineReady, needRefresh, updateServiceWorker } = useRegisterSW()
|
||||
const VersionUpdateModal = defineAsyncComponent(
|
||||
() => import('@/modules/version/VersionUpdateModal.vue')
|
||||
)
|
||||
|
||||
const indicator = h(LoadingOutlined, {
|
||||
style: {
|
||||
@@ -100,33 +83,12 @@ const indicator = h(LoadingOutlined, {
|
||||
})
|
||||
const showSplash = ref(true)
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
checkVersion()
|
||||
setTimeout(() => {
|
||||
showSplash.value = false
|
||||
}, 2000)
|
||||
})
|
||||
|
||||
const versionDialog = ref<boolean>(false)
|
||||
|
||||
function checkVersion() {
|
||||
const version = localStorage.getItem('version')
|
||||
// if (true) {
|
||||
if (!version){
|
||||
update()
|
||||
}
|
||||
if (version != pkg.version) {
|
||||
versionDialog.value = true
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
localStorage.setItem('version', pkg.version)
|
||||
updateServiceWorker()
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import useAxios from '@/utils/useAxios'
|
||||
|
||||
export interface StoreCategory {
|
||||
id: number
|
||||
name: string
|
||||
sort_order?: number
|
||||
}
|
||||
|
||||
export const getStoreCategories = async (): Promise<StoreCategory[]> =>
|
||||
await useAxios.get<StoreCategory[]>('/customer/categories')
|
||||
@@ -0,0 +1,5 @@
|
||||
import useAxios from '@/utils/useAxios'
|
||||
|
||||
export async function getSettings() {
|
||||
return await useAxios.get(`api/get_settings`)
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import type { RouteLocationNormalized } from 'vue-router'
|
||||
import router from '@/router'
|
||||
import { message } from 'ant-design-vue'
|
||||
|
||||
let fingerPosition = false
|
||||
let fingerTimeoutId: ReturnType<typeof setTimeout> | null = null
|
||||
let hasFingerPrint = false
|
||||
|
||||
export function setTruth() {
|
||||
fingerPosition = true
|
||||
}
|
||||
|
||||
export function setEnableAuthenticate() {
|
||||
fingerPosition = false
|
||||
}
|
||||
|
||||
export function setFingerPosition(value: boolean) {
|
||||
fingerPosition = value
|
||||
}
|
||||
|
||||
export function getFingerPosition() {
|
||||
return fingerPosition
|
||||
}
|
||||
|
||||
export function setHasFingerPrint(value: boolean) {
|
||||
hasFingerPrint = value
|
||||
}
|
||||
|
||||
export function getHasFingerPrint() {
|
||||
return hasFingerPrint
|
||||
}
|
||||
|
||||
export function clearFingerTimeout() {
|
||||
if (fingerTimeoutId) {
|
||||
clearTimeout(fingerTimeoutId)
|
||||
fingerTimeoutId = null
|
||||
}
|
||||
}
|
||||
|
||||
export function setFingerTimeOut(to: RouteLocationNormalized) {
|
||||
clearFingerTimeout()
|
||||
|
||||
fingerTimeoutId = setTimeout(async () => {
|
||||
if (!hasFingerPrint) return
|
||||
|
||||
fingerPosition = false
|
||||
await router.push({ name: 'login' })
|
||||
|
||||
if (to.name !== 'login') {
|
||||
message.warn('شما مدت زیادی با کشکول گلد کار نکردید، لطفا دوباره وارد شوید.')
|
||||
}
|
||||
}, 180000)
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { loadAppConfig } from '@/config/load-config'
|
||||
import { setAppConfig } from '@/config/app-config'
|
||||
import { applyAppConfig } from '@/config/apply-config'
|
||||
import { startPwaManifest } from '@/modules/pwa/manifest'
|
||||
import { createVueApp } from '@/app/createApp'
|
||||
import { setupRouterGuards } from '@/app/setupRouter'
|
||||
import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { initPriceRealtimeChannel } from '@/utils/priceSocket'
|
||||
|
||||
type BootWindow = Window & {
|
||||
__BOOT_TIMEOUT__?: number
|
||||
__APP_BOOTSTRAPPED__?: boolean
|
||||
}
|
||||
|
||||
function clearBootTimeout() {
|
||||
const bootWindow = window as BootWindow
|
||||
|
||||
if (bootWindow.__BOOT_TIMEOUT__) {
|
||||
window.clearTimeout(bootWindow.__BOOT_TIMEOUT__)
|
||||
bootWindow.__BOOT_TIMEOUT__ = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function withTimeout<T>(promise: Promise<T>, ms: number, message: string): Promise<T> {
|
||||
return Promise.race([
|
||||
promise,
|
||||
new Promise<T>((_, reject) => {
|
||||
window.setTimeout(() => {
|
||||
reject(new Error(message))
|
||||
}, ms)
|
||||
})
|
||||
])
|
||||
}
|
||||
|
||||
function showBootstrapError(error: unknown) {
|
||||
clearBootTimeout()
|
||||
|
||||
console.error('Bootstrap failed:', error)
|
||||
|
||||
const appRoot = document.querySelector('#app')
|
||||
|
||||
if (!appRoot) return
|
||||
|
||||
appRoot.innerHTML = `
|
||||
<div style="min-height: 100vh; display: flex; align-items: center; justify-content: center; direction: rtl; font-family: sans-serif; padding: 24px; background: var(--boot-bg, #ffffff); color: var(--boot-text, #111827);">
|
||||
<div style="width: min(420px, 100%); text-align: center; background: var(--boot-card, #fff); border: 1px solid var(--boot-border, rgba(15,23,42,0.08)); border-radius: 24px; padding: 28px 22px;">
|
||||
<div style="font-size: 42px; margin-bottom: 12px;">⚠️</div>
|
||||
<h2 style="margin: 0 0 12px; font-size: 20px;">خطا در راهاندازی برنامه</h2>
|
||||
<p style="margin: 0 0 20px; color: var(--boot-muted, rgba(15,23,42,0.62)); line-height: 2; font-size: 14px;">
|
||||
لطفاً اتصال اینترنت خود را بررسی کنید و دوباره تلاش کنید.
|
||||
</p>
|
||||
<button
|
||||
onclick="location.reload()"
|
||||
style="padding: 11px 22px; border: 0; border-radius: 12px; background: var(--boot-accent, #2563eb); color: white; cursor: pointer; font-weight: 700;"
|
||||
>
|
||||
تلاش مجدد
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
export async function bootstrapApp() {
|
||||
try {
|
||||
const config = await withTimeout(loadAppConfig(), 20000, 'Config loading timeout')
|
||||
|
||||
setAppConfig(config)
|
||||
startPwaManifest(config)
|
||||
applyAppConfig()
|
||||
|
||||
const { app } = createVueApp()
|
||||
const settingsStore = useSettingsStore()
|
||||
|
||||
await withTimeout(settingsStore.fetchSettings(), 45000, 'Settings loading timeout')
|
||||
initPriceRealtimeChannel((key) => settingsStore.getSettingByKey(key))
|
||||
|
||||
setupRouterGuards()
|
||||
|
||||
app.mount('#app')
|
||||
|
||||
;(window as BootWindow).__APP_BOOTSTRAPPED__ = true
|
||||
clearBootTimeout()
|
||||
sessionStorage.removeItem('__APP_BOOT_RECOVERY_DONE__')
|
||||
sessionStorage.removeItem('__APP_BOOT_RETRY_CLICKED__')
|
||||
} catch (error) {
|
||||
showBootstrapError(error)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import VueLazyLoad from 'vue3-lazyload'
|
||||
import VueApexCharts from 'vue3-apexcharts'
|
||||
import App from '@/App.vue'
|
||||
import router from '@/router'
|
||||
|
||||
export function createVueApp() {
|
||||
const app = createApp(App)
|
||||
const pinia = createPinia()
|
||||
|
||||
app.use(pinia)
|
||||
app.use(VueLazyLoad, {})
|
||||
app.use(router)
|
||||
app.use(VueApexCharts)
|
||||
|
||||
return { app, pinia }
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
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 { useFundUserStore } from '@/store/fundStore'
|
||||
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
|
||||
import { useAuthStore } from '@/store/useAuthStore'
|
||||
import {
|
||||
clearFingerTimeout,
|
||||
getFingerPosition,
|
||||
getHasFingerPrint,
|
||||
setFingerPosition,
|
||||
setFingerTimeOut,
|
||||
setHasFingerPrint
|
||||
} from '@/app/authBoot'
|
||||
|
||||
export function setupRouterGuards() {
|
||||
const userStore = useUserStore()
|
||||
const walletStore = useWalletStore()
|
||||
const fundStore = useFundUserStore()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const isApple: boolean = isIphone()
|
||||
let isFirst = true
|
||||
|
||||
const currentRoute = computed(() => router.currentRoute.value.fullPath)
|
||||
|
||||
async function start() {
|
||||
if (getToken()) {
|
||||
await walletStore.getLimitedPrice()
|
||||
await walletStore.getLimitedBuyGold()
|
||||
await fundStore.getMyFund()
|
||||
}
|
||||
}
|
||||
|
||||
function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||
if (to.name === 'buyProduct' || to.name === 'productDetail' || to.name === 'about' || to.name === 'cart') {
|
||||
return next()
|
||||
}
|
||||
if (to.name !== 'login') {
|
||||
return next({ name: 'login' })
|
||||
}
|
||||
return next()
|
||||
}
|
||||
|
||||
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||
if (to.name !== 'buyProduct') {
|
||||
return next({ name: 'buyProduct' })
|
||||
}
|
||||
return next()
|
||||
}
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
authStore.setLoading(true)
|
||||
clearFingerTimeout()
|
||||
setFingerTimeOut(to)
|
||||
|
||||
if (isFirst) {
|
||||
isFirst = false
|
||||
|
||||
if (getToken()) {
|
||||
await userStore.getMyInfo()
|
||||
const finger_print = userStore.userInfo.finger_print
|
||||
setHasFingerPrint(finger_print)
|
||||
|
||||
if (isApple && finger_print) {
|
||||
removeToken()
|
||||
goToLogin(to, next)
|
||||
} else if (!isApple && finger_print) {
|
||||
setFingerPosition(await authenticateWithFingerprint())
|
||||
|
||||
if (!getFingerPosition()) {
|
||||
goToLogin(to, next)
|
||||
}
|
||||
} else {
|
||||
if (to.name == 'login') {
|
||||
goToHome(to, next)
|
||||
}
|
||||
return next()
|
||||
}
|
||||
} else {
|
||||
if (['login', '404', 'buyProduct', 'productDetail', 'about', 'cart'].includes(to.name as string)) {
|
||||
return next()
|
||||
}
|
||||
goToLogin(to, next)
|
||||
}
|
||||
} else {
|
||||
if (getFingerPosition()) {
|
||||
if (getToken()) {
|
||||
if (to.name === 'login') {
|
||||
return next({ name: from.name || 'buyProduct' })
|
||||
}
|
||||
return next()
|
||||
}
|
||||
|
||||
if (['login', '404', 'buyProduct', 'productDetail', 'about', 'cart'].includes(to.name as string)) {
|
||||
return next()
|
||||
}
|
||||
return next({ name: 'login' })
|
||||
}
|
||||
|
||||
if (getToken() && !getHasFingerPrint()) {
|
||||
next()
|
||||
} else {
|
||||
goToLogin(to, next)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
watch(currentRoute, async () => (userStore.userInfo ? '' : await start()))
|
||||
}
|
||||
@@ -133,7 +133,7 @@ body {
|
||||
background-color: #fff;
|
||||
//display: none;
|
||||
outline: none;
|
||||
border: 1px solid #521620 !important;
|
||||
border: 1px solid #a72b77 !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,18 +331,18 @@ body {
|
||||
}
|
||||
.ant-radio-group-solid
|
||||
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover{
|
||||
color: #521620 !important;
|
||||
color: #a72b77 !important;
|
||||
}
|
||||
.ant-input-group-addon{
|
||||
background-color: #521620 !important;
|
||||
background-color: #a72b77 !important;
|
||||
color: #e0be7f !important;
|
||||
}
|
||||
.ant-slider-track{
|
||||
background-color: #521620 !important;
|
||||
background-color: #a72b77 !important;
|
||||
|
||||
}
|
||||
.ant-slider-handle {
|
||||
background-color: #521620 !important;
|
||||
background-color: #a72b77 !important;
|
||||
|
||||
}
|
||||
|
||||
@@ -351,20 +351,4 @@ body {
|
||||
}
|
||||
.ant-radio-group-solid .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover{
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.ant-spin-dot-item,
|
||||
.ant-spin-dot i {
|
||||
background-color: @primary-color !important;
|
||||
}
|
||||
|
||||
/* لودینگ محتوای صفحه — وسط ناحیه محتوا (موبایل و دسکتاپ یکسان) */
|
||||
.app-page-content-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-height: min(52vh, 22rem);
|
||||
padding: 2rem 1rem;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
@prefixCls: 'noname';
|
||||
|
||||
@primary-color: #521620;
|
||||
@secondary-color: #521620;
|
||||
@primary-color: #a72b77;
|
||||
@secondary-color: #a72b77;
|
||||
@prefixCls-font-family: 'iran-sans';
|
||||
@prefixCls-background-color: #fff;
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 450 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 583 KiB |
@@ -41,11 +41,6 @@ const _class = computed(() => {
|
||||
return ''
|
||||
})
|
||||
|
||||
const _loading = computed(() => {
|
||||
if (props.loading){
|
||||
return 'flex'
|
||||
} else return 'unset'
|
||||
})
|
||||
const { prefixCls } = usePrefix('base-button')
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
@@ -58,9 +53,6 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
<style lang="less">
|
||||
@prefix:~'@{prefixCls}-base-button';
|
||||
.@{prefix}{
|
||||
//width: fit-content;
|
||||
height: auto;
|
||||
/*padding: 8px;*/
|
||||
display: v-bind(_loading);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<template>
|
||||
<img
|
||||
:src="currentSrc"
|
||||
:class="[imgClass, dimmed && 'product-image--dimmed']"
|
||||
:alt="alt"
|
||||
@error="handleError"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import {
|
||||
getProductFallbackImage,
|
||||
resolveProductImageSrc,
|
||||
type ProductImageSource
|
||||
} from '@/utils/productImage'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
product?: ProductImageSource
|
||||
imgClass?: string
|
||||
alt?: string
|
||||
dimmed?: boolean
|
||||
}>(),
|
||||
{
|
||||
imgClass: 'max-h-full max-w-full object-contain',
|
||||
alt: '',
|
||||
dimmed: false
|
||||
}
|
||||
)
|
||||
|
||||
const currentSrc = ref(resolveProductImageSrc(props.product))
|
||||
const usingFallback = ref(false)
|
||||
|
||||
watch(
|
||||
() => props.product,
|
||||
(product) => {
|
||||
usingFallback.value = false
|
||||
currentSrc.value = resolveProductImageSrc(product)
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
function handleError() {
|
||||
if (usingFallback.value) return
|
||||
usingFallback.value = true
|
||||
currentSrc.value = getProductFallbackImage(props.product)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.product-image--dimmed {
|
||||
opacity: 0.45;
|
||||
filter: grayscale(1);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { AppConfig } from './types'
|
||||
|
||||
type RawAppConfig = AppConfig & {
|
||||
user?: Record<string, any>
|
||||
}
|
||||
|
||||
let appConfig: RawAppConfig | null = null
|
||||
|
||||
export function setAppConfig(config: RawAppConfig) {
|
||||
appConfig = config || {}
|
||||
window.__APP_CONFIG__ = appConfig
|
||||
}
|
||||
|
||||
export function getRawAppConfig() {
|
||||
return appConfig ?? window.__APP_CONFIG__ ?? null
|
||||
}
|
||||
|
||||
export function getTenantConfig() {
|
||||
const rawConfig = getRawAppConfig()
|
||||
|
||||
if (rawConfig?.user && typeof rawConfig.user === 'object') {
|
||||
return rawConfig.user
|
||||
}
|
||||
|
||||
if (rawConfig && Object.keys(rawConfig).length > 0) {
|
||||
return rawConfig
|
||||
}
|
||||
|
||||
return {}
|
||||
}
|
||||
|
||||
export function getConfig<T = any>(key: string, fallback?: T): T {
|
||||
const config = getTenantConfig()
|
||||
const value = config?.[key]
|
||||
|
||||
return (value ?? fallback ?? null) as T
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { getConfig } from '@/config/app-config'
|
||||
import { isPwaManifestReady } from '@/modules/pwa/manifest'
|
||||
|
||||
export function applyAppConfig() {
|
||||
if (isPwaManifestReady()) return
|
||||
|
||||
setTitle()
|
||||
setFavicon()
|
||||
setAppleTouchIconFallback()
|
||||
}
|
||||
|
||||
function setTitle() {
|
||||
document.title = getConfig('name_fa', 'در حال بارگذاری...')
|
||||
}
|
||||
|
||||
function getLogoUrl() {
|
||||
return getConfig<string>('avatar') || '/favicon.png'
|
||||
}
|
||||
|
||||
function setFavicon() {
|
||||
let faviconLink =
|
||||
document.querySelector<HTMLLinkElement>("link[rel='icon']") ||
|
||||
document.querySelector<HTMLLinkElement>("link[rel~='icon']")
|
||||
|
||||
if (!faviconLink) {
|
||||
faviconLink = document.createElement('link')
|
||||
faviconLink.rel = 'icon'
|
||||
document.head.appendChild(faviconLink)
|
||||
}
|
||||
|
||||
const logoUrl = getLogoUrl()
|
||||
|
||||
faviconLink.type = 'image/png'
|
||||
faviconLink.href = logoUrl.startsWith('http') ? logoUrl : resolveRemoteLogo(logoUrl)
|
||||
}
|
||||
|
||||
function setAppleTouchIconFallback() {
|
||||
const logoUrl = getLogoUrl()
|
||||
|
||||
if (!logoUrl) return
|
||||
|
||||
if (document.querySelector("link[rel='apple-touch-icon'][data-dynamic-pwa='true']")) {
|
||||
return
|
||||
}
|
||||
|
||||
const sizes = ['180x180', '152x152', '120x120']
|
||||
|
||||
sizes.forEach((size) => {
|
||||
let link = document.querySelector<HTMLLinkElement>(
|
||||
`link[rel='apple-touch-icon'][sizes='${size}']`
|
||||
)
|
||||
|
||||
if (!link) {
|
||||
link = document.createElement('link')
|
||||
link.rel = 'apple-touch-icon'
|
||||
link.sizes = size
|
||||
document.head.appendChild(link)
|
||||
}
|
||||
|
||||
link.href = logoUrl.startsWith('http') ? logoUrl : resolveRemoteLogo(logoUrl)
|
||||
})
|
||||
|
||||
let appleTitle = document.querySelector<HTMLMetaElement>("meta[name='apple-mobile-web-app-title']")
|
||||
|
||||
if (!appleTitle) {
|
||||
appleTitle = document.createElement('meta')
|
||||
appleTitle.name = 'apple-mobile-web-app-title'
|
||||
document.head.appendChild(appleTitle)
|
||||
}
|
||||
|
||||
appleTitle.content = getConfig('name_fa', 'اپ مشتری')
|
||||
}
|
||||
|
||||
function resolveRemoteLogo(path: string) {
|
||||
if (/^(https?:\/\/|data:|blob:)/i.test(path)) return path
|
||||
|
||||
const lastSuccess = localStorage.getItem('CONFIG_Success_URL')
|
||||
const base = lastSuccess
|
||||
? lastSuccess.replace(/\/get_user\/?$/i, '').replace(/\/+$/, '')
|
||||
: 'https://nerkh.gold'
|
||||
|
||||
return `${base}/${path.replace(/^\/+/, '')}`
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
import type { AppConfig } from '@/config/types'
|
||||
import { resetVersionCheckCache } from '@/config/load-version'
|
||||
import { clearCachedPwaManifest } from '@/modules/pwa/manifest-cache'
|
||||
import { tokenName } from '@/themeConfig'
|
||||
|
||||
const CONFIG_COOKIE_NAME = 'APP_CONFIG_CACHE'
|
||||
const CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
|
||||
const VERSION_SUCCESS_URL_KEY = 'VERSION_Success_URL'
|
||||
const CONFIG_COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 7
|
||||
const MAX_COOKIE_VALUE_LENGTH = 3500
|
||||
|
||||
const VERSION_STORAGE_KEY = 'version'
|
||||
const VERSION_UPDATE_LOCK_KEY = 'version_update_lock'
|
||||
const VERSION_LAST_RELOAD_KEY = 'version_last_reload'
|
||||
|
||||
type CachedConfigPayload = {
|
||||
cached_at: number
|
||||
config: AppConfig
|
||||
}
|
||||
|
||||
type VersionUpdateLock = {
|
||||
version: string
|
||||
started_at: number
|
||||
}
|
||||
|
||||
function getCookie(name: string) {
|
||||
const cookie = document.cookie.split('; ').find((row) => row.startsWith(`${name}=`))
|
||||
|
||||
if (!cookie) return null
|
||||
|
||||
return cookie.substring(name.length + 1)
|
||||
}
|
||||
|
||||
function setCookie(name: string, value: string, maxAgeSeconds: number) {
|
||||
const secure = window.location.protocol === 'https:' ? '; Secure' : ''
|
||||
|
||||
document.cookie = [
|
||||
`${name}=${value}`,
|
||||
'Path=/',
|
||||
`Max-Age=${maxAgeSeconds}`,
|
||||
'SameSite=Lax',
|
||||
secure
|
||||
].join('; ')
|
||||
}
|
||||
|
||||
export function readCachedAppConfig(): AppConfig | null {
|
||||
try {
|
||||
const rawCookie = getCookie(CONFIG_COOKIE_NAME)
|
||||
|
||||
if (!rawCookie) return null
|
||||
|
||||
const decoded = decodeURIComponent(rawCookie)
|
||||
const payload = JSON.parse(decoded) as CachedConfigPayload
|
||||
|
||||
if (!payload?.config) return null
|
||||
|
||||
return payload.config
|
||||
} catch (error) {
|
||||
console.warn('Failed to read cached app config:', error)
|
||||
clearCachedAppConfig()
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function writeCachedAppConfig(config: AppConfig) {
|
||||
try {
|
||||
const payload: CachedConfigPayload = {
|
||||
cached_at: Date.now(),
|
||||
config
|
||||
}
|
||||
|
||||
const encoded = encodeURIComponent(JSON.stringify(payload))
|
||||
|
||||
if (encoded.length > MAX_COOKIE_VALUE_LENGTH) {
|
||||
console.warn(`App config is too large for cookie cache. Size: ${encoded.length}`)
|
||||
return
|
||||
}
|
||||
|
||||
setCookie(CONFIG_COOKIE_NAME, encoded, CONFIG_COOKIE_MAX_AGE_SECONDS)
|
||||
} catch (error) {
|
||||
console.warn('Failed to write app config cache:', error)
|
||||
}
|
||||
}
|
||||
|
||||
export function clearCachedAppConfig() {
|
||||
document.cookie = `${CONFIG_COOKIE_NAME}=; Path=/; Max-Age=0; SameSite=Lax`
|
||||
clearCachedPwaManifest()
|
||||
}
|
||||
|
||||
export function getStoredAppVersion() {
|
||||
return localStorage.getItem(VERSION_STORAGE_KEY)
|
||||
}
|
||||
|
||||
export function writeStoredAppVersion(version: string) {
|
||||
localStorage.setItem(VERSION_STORAGE_KEY, String(version).trim())
|
||||
}
|
||||
|
||||
export function getNormalizedVersion(version: unknown) {
|
||||
if (version === null || version === undefined) return ''
|
||||
return String(version).trim()
|
||||
}
|
||||
|
||||
export function shouldUpdateForVersion(serverVersion: unknown) {
|
||||
const normalizedServerVersion = getNormalizedVersion(serverVersion)
|
||||
|
||||
if (!normalizedServerVersion) return false
|
||||
|
||||
const storedVersion = getStoredAppVersion()
|
||||
|
||||
if (!storedVersion) {
|
||||
writeStoredAppVersion(normalizedServerVersion)
|
||||
return false
|
||||
}
|
||||
|
||||
return storedVersion !== normalizedServerVersion
|
||||
}
|
||||
|
||||
export function canStartVersionUpdate(serverVersion: string) {
|
||||
const version = getNormalizedVersion(serverVersion)
|
||||
|
||||
if (!version) return false
|
||||
|
||||
const lastReloadVersion = sessionStorage.getItem(VERSION_LAST_RELOAD_KEY)
|
||||
|
||||
if (lastReloadVersion === version) {
|
||||
return false
|
||||
}
|
||||
|
||||
const rawLock = sessionStorage.getItem(VERSION_UPDATE_LOCK_KEY)
|
||||
|
||||
if (rawLock) {
|
||||
try {
|
||||
const lock = JSON.parse(rawLock) as VersionUpdateLock
|
||||
const isSameVersion = lock.version === version
|
||||
const isFreshLock = Date.now() - lock.started_at < 60_000
|
||||
|
||||
if (isSameVersion && isFreshLock) {
|
||||
return false
|
||||
}
|
||||
} catch {
|
||||
sessionStorage.removeItem(VERSION_UPDATE_LOCK_KEY)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
export function startVersionUpdateLock(serverVersion: string) {
|
||||
const version = getNormalizedVersion(serverVersion)
|
||||
|
||||
const lock: VersionUpdateLock = {
|
||||
version,
|
||||
started_at: Date.now()
|
||||
}
|
||||
|
||||
sessionStorage.setItem(VERSION_UPDATE_LOCK_KEY, JSON.stringify(lock))
|
||||
}
|
||||
|
||||
export function finishVersionUpdateBeforeReload(serverVersion: string) {
|
||||
const version = getNormalizedVersion(serverVersion)
|
||||
|
||||
writeStoredAppVersion(version)
|
||||
|
||||
sessionStorage.setItem(VERSION_LAST_RELOAD_KEY, version)
|
||||
sessionStorage.removeItem(VERSION_UPDATE_LOCK_KEY)
|
||||
}
|
||||
|
||||
export function cancelVersionUpdateLock() {
|
||||
sessionStorage.removeItem(VERSION_UPDATE_LOCK_KEY)
|
||||
}
|
||||
|
||||
function clearReadableCookiesExceptConfigAlreadyHandled() {
|
||||
document.cookie.split(';').forEach((cookie) => {
|
||||
const name = cookie.split('=')[0]?.trim()
|
||||
|
||||
if (!name) return
|
||||
|
||||
document.cookie = `${name}=; Path=/; Max-Age=0; SameSite=Lax`
|
||||
})
|
||||
}
|
||||
|
||||
export async function clearBrowserRuntimeCaches() {
|
||||
try {
|
||||
if ('serviceWorker' in navigator) {
|
||||
const registrations = await navigator.serviceWorker.getRegistrations()
|
||||
|
||||
await Promise.all(registrations.map((registration) => registration.unregister()))
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Could not unregister service workers:', error)
|
||||
}
|
||||
|
||||
try {
|
||||
if (!('caches' in window)) return
|
||||
|
||||
const cacheKeys = await caches.keys()
|
||||
await Promise.all(cacheKeys.map((key) => caches.delete(key)))
|
||||
} catch (error) {
|
||||
console.warn('Could not clear browser caches:', error)
|
||||
}
|
||||
}
|
||||
|
||||
function clearLocalStorageExceptToken() {
|
||||
const token = localStorage.getItem(tokenName)
|
||||
|
||||
localStorage.clear()
|
||||
|
||||
if (token) {
|
||||
localStorage.setItem(tokenName, token)
|
||||
}
|
||||
}
|
||||
|
||||
export function clearAppStorageExceptToken() {
|
||||
clearReadableCookiesExceptConfigAlreadyHandled()
|
||||
clearLocalStorageExceptToken()
|
||||
sessionStorage.clear()
|
||||
}
|
||||
|
||||
export function clearAllBootstrapFetchCaches() {
|
||||
localStorage.removeItem(CONFIG_SUCCESS_URL_KEY)
|
||||
localStorage.removeItem(VERSION_SUCCESS_URL_KEY)
|
||||
clearCachedPwaManifest()
|
||||
resetVersionCheckCache()
|
||||
window.__APP_CONFIG__ = undefined
|
||||
}
|
||||
|
||||
export function hardReloadApp() {
|
||||
const refreshUrl = `${window.location.origin}${window.location.pathname}?__app_refresh=${Date.now()}`
|
||||
window.location.href = refreshUrl
|
||||
}
|
||||
|
||||
export async function refreshConfigCacheForVersion(
|
||||
newVersion: string,
|
||||
fetchConfig: () => Promise<AppConfig>
|
||||
) {
|
||||
const normalizedVersion = getNormalizedVersion(newVersion)
|
||||
|
||||
if (!normalizedVersion) {
|
||||
throw new Error('Version is empty')
|
||||
}
|
||||
|
||||
startVersionUpdateLock(normalizedVersion)
|
||||
|
||||
clearCachedAppConfig()
|
||||
clearAppStorageExceptToken()
|
||||
clearAllBootstrapFetchCaches()
|
||||
await clearBrowserRuntimeCaches()
|
||||
|
||||
const freshConfig = await fetchConfig()
|
||||
|
||||
writeCachedAppConfig(freshConfig)
|
||||
finishVersionUpdateBeforeReload(normalizedVersion)
|
||||
|
||||
return freshConfig
|
||||
}
|
||||
|
||||
export async function resetAppAndRefreshConfig(
|
||||
fetchConfig: () => Promise<AppConfig>,
|
||||
version?: string | null
|
||||
) {
|
||||
const normalizedVersion = getNormalizedVersion(version)
|
||||
|
||||
clearCachedAppConfig()
|
||||
clearAppStorageExceptToken()
|
||||
clearAllBootstrapFetchCaches()
|
||||
await clearBrowserRuntimeCaches()
|
||||
|
||||
const freshConfig = await fetchConfig()
|
||||
|
||||
writeCachedAppConfig(freshConfig)
|
||||
|
||||
if (normalizedVersion) {
|
||||
writeStoredAppVersion(normalizedVersion)
|
||||
}
|
||||
|
||||
return freshConfig
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import type { AppConfig } from '@/config/types'
|
||||
import { readCachedAppConfig, writeCachedAppConfig } from '@/config/config-cache'
|
||||
|
||||
const CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
|
||||
|
||||
function getProtocol() {
|
||||
return window.location.protocol === 'https:' ? 'https:' : 'http:'
|
||||
}
|
||||
|
||||
export function getConfigUrls() {
|
||||
const protocol = getProtocol()
|
||||
|
||||
return [
|
||||
`${protocol}//nerkh.gold/get_user`,
|
||||
`${protocol}//tablo.talasevin.ir/get_user`,
|
||||
`${protocol}//abshode-service.montgit.ir/server/get_user`,
|
||||
`${protocol}//212.23.201.173:8381/get_user`,
|
||||
`${protocol}//91.212.174.137:4040/server/get_user`
|
||||
]
|
||||
}
|
||||
|
||||
export function sortConfigUrls(urls: string[]) {
|
||||
const lastSuccessUrl = localStorage.getItem(CONFIG_SUCCESS_URL_KEY)
|
||||
|
||||
return [...urls].sort((a, b) => {
|
||||
if (a === lastSuccessUrl) return -1
|
||||
if (b === lastSuccessUrl) return 1
|
||||
return 0
|
||||
})
|
||||
}
|
||||
|
||||
async function fetchConfig(url: string, timeout = 3000): Promise<AppConfig> {
|
||||
const controller = new AbortController()
|
||||
const timeoutId = window.setTimeout(() => controller.abort(), timeout)
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
cache: 'no-store',
|
||||
signal: controller.signal
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Config request failed with status ${response.status}`)
|
||||
}
|
||||
|
||||
const contentType = response.headers.get('content-type') ?? ''
|
||||
|
||||
if (!contentType.includes('application/json')) {
|
||||
throw new Error('Config response is not JSON')
|
||||
}
|
||||
|
||||
return await response.json()
|
||||
} finally {
|
||||
clearTimeout(timeoutId)
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchFreshAppConfig(): Promise<AppConfig> {
|
||||
const urls = sortConfigUrls(getConfigUrls())
|
||||
|
||||
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)
|
||||
|
||||
localStorage.setItem(CONFIG_SUCCESS_URL_KEY, url)
|
||||
writeCachedAppConfig(config)
|
||||
|
||||
return config
|
||||
} catch (error) {
|
||||
console.warn(`Config failed from ${url}`, error)
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Cannot load app config from any server')
|
||||
}
|
||||
|
||||
export async function loadAppConfig(): Promise<AppConfig> {
|
||||
const cachedConfig = readCachedAppConfig()
|
||||
|
||||
if (cachedConfig) {
|
||||
return cachedConfig
|
||||
}
|
||||
|
||||
return await fetchFreshAppConfig()
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
type VersionResponse =
|
||||
| string
|
||||
| number
|
||||
| {
|
||||
version?: string | number
|
||||
data?: string | number | { version?: string | number; value?: string | number }
|
||||
value?: string | number
|
||||
user?: unknown
|
||||
}
|
||||
|
||||
const VERSION_SUCCESS_URL_KEY = 'VERSION_Success_URL'
|
||||
const VERSION_RETRY_ROUNDS = 5
|
||||
|
||||
let versionFetchPromise: Promise<string | null> | null = null
|
||||
let cachedVersionResult: string | null | undefined
|
||||
|
||||
function getVersionUrls() {
|
||||
return [
|
||||
'https://nerkh.gold/get_version',
|
||||
'https://tablo.talasevin.ir/get_version',
|
||||
'https://abshode-service.montgit.ir/server/get_version'
|
||||
]
|
||||
}
|
||||
|
||||
function sortVersionUrls(urls: string[]) {
|
||||
const lastSuccessUrl = localStorage.getItem(VERSION_SUCCESS_URL_KEY)
|
||||
|
||||
if (!lastSuccessUrl) {
|
||||
return urls
|
||||
}
|
||||
|
||||
const others = urls.filter((url) => url !== lastSuccessUrl)
|
||||
return [lastSuccessUrl, ...others]
|
||||
}
|
||||
|
||||
function readUserVersion(user: unknown) {
|
||||
if (!user || typeof user !== 'object' || Array.isArray(user)) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const record = user as { version?: string | number; value?: string | number }
|
||||
const version = record.version ?? record.value
|
||||
|
||||
return version === undefined || version === null ? '' : String(version).trim()
|
||||
}
|
||||
|
||||
function normalizeVersionResponse(response: VersionResponse) {
|
||||
if (typeof response === 'string' || typeof response === 'number') {
|
||||
return String(response).trim()
|
||||
}
|
||||
|
||||
if (!response) return ''
|
||||
|
||||
if (typeof response.data === 'string' || typeof response.data === 'number') {
|
||||
return String(response.data).trim()
|
||||
}
|
||||
|
||||
const directVersion =
|
||||
response.version ??
|
||||
response.value ??
|
||||
(typeof response.data === 'object' ? response.data?.version ?? response.data?.value : undefined)
|
||||
|
||||
if (directVersion !== undefined && directVersion !== null) {
|
||||
return String(directVersion).trim()
|
||||
}
|
||||
|
||||
return readUserVersion(response.user)
|
||||
}
|
||||
|
||||
async function fetchVersion(url: string, timeout = 3500): Promise<string | null> {
|
||||
const controller = new AbortController()
|
||||
const timeoutId = window.setTimeout(() => controller.abort(), timeout)
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
cache: 'no-store',
|
||||
signal: controller.signal
|
||||
})
|
||||
|
||||
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}`)
|
||||
}
|
||||
|
||||
const contentType = response.headers.get('content-type') ?? ''
|
||||
|
||||
const data = contentType.includes('application/json')
|
||||
? ((await response.json()) as VersionResponse)
|
||||
: ((await response.text()) as VersionResponse)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
|
||||
|
||||
return version
|
||||
} finally {
|
||||
window.clearTimeout(timeoutId)
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchVersionWithRetry(rounds = VERSION_RETRY_ROUNDS): Promise<string | null> {
|
||||
const urls = sortVersionUrls(getVersionUrls())
|
||||
|
||||
for (let round = 1; round <= rounds; round++) {
|
||||
for (let index = 0; index < urls.length; index++) {
|
||||
const url = urls[index]
|
||||
const timeout = index === urls.length - 1 ? 6000 : 3500
|
||||
|
||||
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
|
||||
} catch (error) {
|
||||
console.warn(`Version failed from ${url}. Round: ${round}`, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export function resetVersionCheckCache() {
|
||||
cachedVersionResult = undefined
|
||||
versionFetchPromise = null
|
||||
}
|
||||
|
||||
export async function loadRemoteAppVersion(options?: {
|
||||
rounds?: number
|
||||
force?: boolean
|
||||
}): Promise<string | null> {
|
||||
const rounds = options?.rounds ?? VERSION_RETRY_ROUNDS
|
||||
const force = options?.force ?? false
|
||||
|
||||
if (force) {
|
||||
resetVersionCheckCache()
|
||||
}
|
||||
|
||||
if (cachedVersionResult !== undefined) {
|
||||
return cachedVersionResult
|
||||
}
|
||||
|
||||
if (versionFetchPromise) {
|
||||
return versionFetchPromise
|
||||
}
|
||||
|
||||
versionFetchPromise = fetchVersionWithRetry(rounds)
|
||||
.then((version) => {
|
||||
cachedVersionResult = version
|
||||
return version
|
||||
})
|
||||
.finally(() => {
|
||||
versionFetchPromise = null
|
||||
})
|
||||
|
||||
return versionFetchPromise
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
export interface AppConfig {
|
||||
mode?: string
|
||||
theme?: string
|
||||
name?: string
|
||||
name_fa?: string
|
||||
|
||||
avatar?: string
|
||||
color?: string
|
||||
background_color?: string
|
||||
secondary_color?: string
|
||||
|
||||
node_server?: string
|
||||
node_ws?: string
|
||||
|
||||
manifest_url?: string
|
||||
|
||||
user?: Record<string, any>
|
||||
|
||||
[key: string]: any
|
||||
}
|
||||
@@ -1,189 +1,21 @@
|
||||
import 'ant-design-vue/dist/antd.less'
|
||||
import './assets/css/main.less'
|
||||
import 'virtual:uno.css'
|
||||
import { computed, createApp, ref, watch } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
|
||||
import { initPwaInstallCapture } from '@/modules/pwa/manifest'
|
||||
import { bootstrapApp } from '@/app/bootstrap'
|
||||
import { initWhatsappButtonDrag } from '@/utils/initWhatsappButtonDrag'
|
||||
|
||||
export {
|
||||
setTruth,
|
||||
setEnableAuthenticate,
|
||||
setFingerPosition,
|
||||
setFingerTimeOut
|
||||
} from '@/app/authBoot'
|
||||
|
||||
import '@unocss/reset/tailwind-compat.css'
|
||||
import VueApexCharts from 'vue3-apexcharts'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import { authenticateWithFingerprint, getToken, isIphone, removeToken } from '@/utils'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { useWalletStore } from '@/store/walletStore'
|
||||
import { useFundUserStore } from '@/store/fundStore'
|
||||
import VueLazyLoad from 'vue3-lazyload'
|
||||
import { getMe } from '@/api/me'
|
||||
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
|
||||
import { useAuthStore } from '@/store/useAuthStore'
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(createPinia())
|
||||
app.use(VueLazyLoad, {
|
||||
// options...
|
||||
initPwaInstallCapture()
|
||||
bootstrapApp().then(() => {
|
||||
initWhatsappButtonDrag()
|
||||
})
|
||||
app.use(router)
|
||||
app.use(VueApexCharts)
|
||||
|
||||
const userStore = useUserStore()
|
||||
const walletStore = useWalletStore()
|
||||
const fundStore = useFundUserStore()
|
||||
const authStore = useAuthStore()
|
||||
const isApple: boolean = isIphone()
|
||||
let isFirst: boolean = true
|
||||
let fingerPosition: boolean = false
|
||||
let timeoutId: ReturnType<typeof setTimeout> | null = null
|
||||
let hasFingerPrint: boolean = false
|
||||
const userInfo = ref()
|
||||
// userInfo.value = await getMe()
|
||||
// const token = getToken()
|
||||
|
||||
const currentRoute = computed(() => {
|
||||
return router.currentRoute.value.fullPath
|
||||
})
|
||||
|
||||
async function start() {
|
||||
// console.log('ffffffffffffffffffffffffffffffffffffffffff')
|
||||
if (getToken()) {
|
||||
// await userStore.getMyInfo()
|
||||
await walletStore.getLimitedPrice()
|
||||
await walletStore.getLimitedBuyGold()
|
||||
await fundStore.getMyFund()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export function setTruth() {
|
||||
fingerPosition = true
|
||||
}
|
||||
|
||||
export function setEnableAuthenticate() {
|
||||
fingerPosition = false
|
||||
}
|
||||
|
||||
|
||||
function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||
if (to.name === 'buyProduct'||to.name === 'productDetail'||to.name==='about'||to.name==='cart') {
|
||||
return next() // Allow access to buyProduct without login
|
||||
}
|
||||
if (to.name !== 'login') {
|
||||
return next({ name: 'login' }) // Redirect to login
|
||||
} else {
|
||||
return next() // If already on the login page, don't redirect
|
||||
}
|
||||
}
|
||||
|
||||
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||
if (to.name !== 'buyProduct') {
|
||||
return next({ name: 'buyProduct' }) // Redirect to login
|
||||
} else {
|
||||
return next() // If already on the login page, don't redirect
|
||||
}
|
||||
}
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
authStore.setLoading(true)
|
||||
// console.log(authStore)
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId)
|
||||
}
|
||||
// Start a new timeout to reset fingerprint after 5 seconds of inactivity
|
||||
if (from.name !== 'login' || from.name !== undefined) {
|
||||
// console.log(from.name)
|
||||
timeoutId = setTimeout(async () => {
|
||||
if (hasFingerPrint) {
|
||||
fingerPosition = false
|
||||
/* fingerPosition = await authenticateWithFingerprint()
|
||||
if (!fingerPosition) {
|
||||
goToLogin(to, next)
|
||||
}*/
|
||||
// isFirst = true;
|
||||
console.log('Fingerprint authentication reset after 5 seconds of inactivity')
|
||||
}
|
||||
}, 180000) // 5 seconds
|
||||
}
|
||||
// If it's the first time the navigation guard runs
|
||||
if (isFirst) {
|
||||
isFirst = false // Set isFirst to false after the first check
|
||||
|
||||
// If the user has a token
|
||||
if (getToken()) {
|
||||
await userStore.getMyInfo()
|
||||
const finger_print =userStore.userInfo.finger_print
|
||||
// console.log(finger_print)
|
||||
// const { finger_print } = await getMe()
|
||||
hasFingerPrint = finger_print
|
||||
// If on an Apple device and fingerprint exists
|
||||
if (isApple && finger_print) {
|
||||
removeToken() // Remove token if fingerprint is found
|
||||
goToLogin(to, next) // Redirect to login
|
||||
}
|
||||
// If not an Apple device and fingerprint exists
|
||||
else if (!isApple && finger_print) {
|
||||
// goToLogin(to, next)
|
||||
fingerPosition = await authenticateWithFingerprint()
|
||||
|
||||
if (fingerPosition) {
|
||||
// goToHome(to, next) // Redirect to home if fingerprint is authenticated
|
||||
} else {
|
||||
goToLogin(to, next) // Redirect to login if authentication fails
|
||||
}
|
||||
} else {
|
||||
// console.log('salam')
|
||||
if (from.path === '/') {
|
||||
// goToHome(to, next)
|
||||
}
|
||||
if(to.name=="login"){
|
||||
goToHome(to, next)
|
||||
}
|
||||
return next()
|
||||
}
|
||||
} else {
|
||||
// If no token, handle redirect to login or allow access to login, 404, or buyProduct
|
||||
if (['login', '404', 'buyProduct','productDetail','about','cart'].includes(to.name as string)) {
|
||||
return next() // Allow access to login, 404, or buyProduct
|
||||
}
|
||||
goToLogin(to, next) // Redirect to login if no token
|
||||
}
|
||||
}
|
||||
// For subsequent navigations after the first check
|
||||
else {
|
||||
// If the user has passed fingerprint authentication
|
||||
if (fingerPosition) {
|
||||
if (getToken()) {
|
||||
if (to.name === 'login') {
|
||||
return next({ name: from.name || 'buyProduct' }) // Redirect to home if trying to access login after authentication
|
||||
}
|
||||
return next() // Proceed to the intended route
|
||||
} else {
|
||||
// If no token, ensure proper redirection to login or 404
|
||||
if (['login', '404', 'buyProduct','productDetail','about','cart'].includes(to.name as string)) {
|
||||
return next() // Allow access to login, 404, or buyProduct
|
||||
}
|
||||
return next({ name: 'login' })
|
||||
}
|
||||
}
|
||||
// If fingerprint authentication failed or was not done
|
||||
else {
|
||||
if (getToken() && !hasFingerPrint) {
|
||||
next()
|
||||
} else {
|
||||
goToLogin(to, next)
|
||||
}
|
||||
/* if (to.name !== 'login') {
|
||||
return next({ name: 'login' }) // Redirect to login
|
||||
} else {
|
||||
return next() // If already on the login page, don't redirect
|
||||
}*/
|
||||
/* console.log('sssssssssssssssssssssssss')
|
||||
return next({ name: 'login' })*/
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
app.mount('#app')
|
||||
// if (currentRoute.value !== '/') {
|
||||
// await start()
|
||||
// }
|
||||
watch(currentRoute, async () => userStore.userInfo ? '' : await start())
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ export function setFingerTimeOut(to: RouteLocationNormalized){
|
||||
// console.log('Fingerprint authentication reset after 5 seconds of inactivity');
|
||||
await router.push({ name: 'login' })
|
||||
if (to.name !== 'login') {
|
||||
message.warn('شما مدت زیادی با قطره کار نکردید، لطفا دوباره وارد شوید.')
|
||||
message.warn('شما مدت زیادی با کشکول گلد کار نکردید، لطفا دوباره وارد شوید.')
|
||||
}
|
||||
}
|
||||
}, 10000) // 3 minutess
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
export type PwaManifestIcon = {
|
||||
src: string
|
||||
sizes?: string
|
||||
type?: string
|
||||
purpose?: string
|
||||
}
|
||||
|
||||
export type PwaManifest = {
|
||||
id?: string
|
||||
name?: string
|
||||
short_name?: string
|
||||
lang?: string
|
||||
dir?: string
|
||||
start_url?: string
|
||||
scope?: string
|
||||
display?: string
|
||||
background_color?: string
|
||||
theme_color?: string
|
||||
description?: string
|
||||
icons?: PwaManifestIcon[]
|
||||
}
|
||||
|
||||
const MANIFEST_CACHE_KEY = 'PWA_MANIFEST_CACHE_V5'
|
||||
const MANIFEST_CACHE_MAX_AGE_MS = 60 * 60 * 24 * 7
|
||||
|
||||
export type CachedPwaManifest = {
|
||||
cached_at: number
|
||||
user_id: string | number
|
||||
config_base: string
|
||||
manifest_url: string
|
||||
manifest: PwaManifest
|
||||
}
|
||||
|
||||
export function readCachedPwaManifest(
|
||||
userId: string | number | null | undefined,
|
||||
configBase: string
|
||||
): CachedPwaManifest | null {
|
||||
if (userId == null || userId === '' || !configBase) return null
|
||||
|
||||
try {
|
||||
const raw = localStorage.getItem(MANIFEST_CACHE_KEY)
|
||||
if (!raw) return null
|
||||
|
||||
const payload = JSON.parse(raw) as CachedPwaManifest
|
||||
|
||||
if (!payload?.manifest || !payload.manifest_url) return null
|
||||
if (String(payload.user_id) !== String(userId)) return null
|
||||
if (payload.config_base !== configBase) return null
|
||||
|
||||
if (Date.now() - Number(payload.cached_at || 0) > MANIFEST_CACHE_MAX_AGE_MS) {
|
||||
localStorage.removeItem(MANIFEST_CACHE_KEY)
|
||||
return null
|
||||
}
|
||||
|
||||
return payload
|
||||
} catch {
|
||||
localStorage.removeItem(MANIFEST_CACHE_KEY)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function writeCachedPwaManifest(entry: CachedPwaManifest) {
|
||||
try {
|
||||
localStorage.setItem(MANIFEST_CACHE_KEY, JSON.stringify(entry))
|
||||
} catch (error) {
|
||||
console.warn('Failed to cache PWA manifest:', error)
|
||||
}
|
||||
}
|
||||
|
||||
export function clearCachedPwaManifest() {
|
||||
localStorage.removeItem(MANIFEST_CACHE_KEY)
|
||||
}
|
||||
@@ -0,0 +1,558 @@
|
||||
import type { AppConfig } from '@/config/types'
|
||||
import { getConfig, getRawAppConfig } from '@/config/app-config'
|
||||
import { getConfigUrls, sortConfigUrls } from '@/config/load-config'
|
||||
import {
|
||||
clearCachedPwaManifest,
|
||||
readCachedPwaManifest,
|
||||
writeCachedPwaManifest,
|
||||
type PwaManifest
|
||||
} from '@/modules/pwa/manifest-cache'
|
||||
|
||||
export { clearCachedPwaManifest, type PwaManifest, type PwaManifestIcon } from '@/modules/pwa/manifest-cache'
|
||||
|
||||
export const PWA_MANIFEST_READY_KEY = 'pwa_manifest_ready'
|
||||
export const PWA_MANIFEST_READY_EVENT = 'pwa-manifest-ready'
|
||||
|
||||
const CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
|
||||
let pendingBeforeInstallPrompt: Event | null = null
|
||||
let installCaptureInitialized = false
|
||||
const MANIFEST_RETRY_DELAY_MS = 500
|
||||
|
||||
function sleep(ms: number) {
|
||||
return new Promise((resolve) => window.setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
function normalizeBaseUrl(url: string) {
|
||||
return url.replace(/\/get_user\/?$/i, '').replace(/\/+$/, '')
|
||||
}
|
||||
|
||||
/** همان baseای که get_user از آن لود شده (کش شده در localStorage) */
|
||||
export function getConfigBaseFromStorage() {
|
||||
const lastSuccess = localStorage.getItem(CONFIG_SUCCESS_URL_KEY)
|
||||
if (!lastSuccess) return ''
|
||||
return normalizeBaseUrl(lastSuccess)
|
||||
}
|
||||
|
||||
function configUrlToManifestUrl(configUrl: string) {
|
||||
return `${configUrl.replace(/\/+$/, '')}/manifest.json`
|
||||
}
|
||||
|
||||
/** همان ۵ URL پایهٔ get_user — اولویت با CONFIG_Success_URL */
|
||||
export function resolveManifestUrls(config?: AppConfig | null): string[] {
|
||||
const explicit = getConfig<string>('manifest_url')
|
||||
if (explicit) return [explicit]
|
||||
|
||||
return sortConfigUrls(getConfigUrls()).map(configUrlToManifestUrl)
|
||||
}
|
||||
|
||||
/** اولین کاندید — برای سازگاری */
|
||||
export function resolveManifestUrl(config?: AppConfig | null) {
|
||||
return resolveManifestUrls(config)[0] ?? ''
|
||||
}
|
||||
|
||||
function isValidManifest(payload: unknown): payload is PwaManifest {
|
||||
if (!payload || typeof payload !== 'object') return false
|
||||
|
||||
const manifest = payload as PwaManifest
|
||||
const icons = manifest.icons
|
||||
|
||||
if (!Array.isArray(icons) || icons.length === 0) return false
|
||||
|
||||
return icons.some((icon) => typeof icon?.src === 'string' && icon.src.trim().length > 0)
|
||||
}
|
||||
|
||||
async function fetchManifestOnce(url: string, timeout = 6000): Promise<PwaManifest> {
|
||||
const controller = new AbortController()
|
||||
const timeoutId = window.setTimeout(() => controller.abort(), timeout)
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: { Accept: 'application/manifest+json, application/json' },
|
||||
cache: 'default',
|
||||
signal: controller.signal,
|
||||
priority: 'high'
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Manifest request failed: ${response.status}`)
|
||||
}
|
||||
|
||||
const payload = await response.json()
|
||||
|
||||
if (!isValidManifest(payload)) {
|
||||
throw new Error('Manifest response is missing valid icons')
|
||||
}
|
||||
|
||||
return payload
|
||||
} finally {
|
||||
clearTimeout(timeoutId)
|
||||
}
|
||||
}
|
||||
|
||||
/** هر URL یک بار — مثل لوپ get_user */
|
||||
async function fetchManifestTryingUrls(
|
||||
urls: string[]
|
||||
): Promise<{ manifest: PwaManifest; manifestUrl: string }> {
|
||||
if (!urls.length) {
|
||||
throw new Error('No manifest URL candidates')
|
||||
}
|
||||
|
||||
let lastError: unknown = null
|
||||
|
||||
for (let index = 0; index < urls.length; index++) {
|
||||
const url = urls[index]
|
||||
|
||||
try {
|
||||
const manifest = await fetchManifestOnce(url)
|
||||
return { manifest, manifestUrl: url }
|
||||
} catch (error) {
|
||||
lastError = error
|
||||
console.warn(`PWA manifest failed (${url}), candidate ${index + 1}/${urls.length}`, error)
|
||||
}
|
||||
|
||||
if (index < urls.length - 1) {
|
||||
await sleep(MANIFEST_RETRY_DELAY_MS)
|
||||
}
|
||||
}
|
||||
|
||||
throw lastError ?? new Error('PWA manifest could not be loaded from any server')
|
||||
}
|
||||
|
||||
let manifestBlobUrl: string | null = null
|
||||
|
||||
function revokeManifestBlobUrl() {
|
||||
if (manifestBlobUrl) {
|
||||
URL.revokeObjectURL(manifestBlobUrl)
|
||||
manifestBlobUrl = null
|
||||
}
|
||||
}
|
||||
|
||||
function isAbsoluteWebUrl(src: string) {
|
||||
return /^https?:\/\//i.test(src) || src.startsWith('//')
|
||||
}
|
||||
|
||||
function toAbsoluteAssetUrl(src: string, base: string) {
|
||||
const value = String(src || '').trim()
|
||||
if (!value) return ''
|
||||
|
||||
if (value.startsWith('//')) {
|
||||
const protocol = window.location.protocol === 'https:' ? 'https:' : 'http:'
|
||||
return `${protocol}${value}`
|
||||
}
|
||||
|
||||
if (/^(https?:\/\/|data:|blob:)/i.test(value)) return value
|
||||
if (!base) return value
|
||||
|
||||
return `${base.replace(/\/+$/, '')}/${value.replace(/^\/+/, '')}`
|
||||
}
|
||||
|
||||
/** path داخل همین اپ — دامنهٔ سرور (montpar.ir) نادیده گرفته میشود */
|
||||
function toManifestPath(url: string | undefined, fallback = '/') {
|
||||
const defaultPath = fallback.startsWith('/') ? fallback : `/${fallback}`
|
||||
|
||||
if (!url?.trim()) return defaultPath
|
||||
|
||||
try {
|
||||
const trimmed = url.trim()
|
||||
|
||||
if (trimmed.startsWith('/') && !trimmed.startsWith('//')) {
|
||||
return trimmed
|
||||
}
|
||||
|
||||
const parsed = new URL(trimmed)
|
||||
const path = `${parsed.pathname || '/'}${parsed.search}${parsed.hash}`
|
||||
|
||||
if (parsed.origin !== window.location.origin) {
|
||||
return path || '/'
|
||||
}
|
||||
|
||||
return path || '/'
|
||||
} catch {
|
||||
return defaultPath
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* blob manifest فقط URL مطلق همorigin را میپذیرد (مثلاً http://192.168.x.x:3100/).
|
||||
* مسیر نسبی مثل "/" → "property ignored, URL is invalid".
|
||||
*/
|
||||
function toSameOriginManifestUrl(url: string | undefined, fallbackPath = '/') {
|
||||
const path = toManifestPath(url, fallbackPath)
|
||||
return new URL(path, window.location.origin).href
|
||||
}
|
||||
|
||||
function normalizeManifestId(id: string | undefined, startUrl: string) {
|
||||
const value = String(id || '').trim()
|
||||
if (!value || value === '/') return startUrl
|
||||
|
||||
try {
|
||||
const parsed = new URL(value, window.location.origin)
|
||||
if (parsed.origin === window.location.origin) return parsed.href
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
return startUrl
|
||||
}
|
||||
|
||||
function guessMimeType(src: string) {
|
||||
const lower = src.split('?')[0].toLowerCase()
|
||||
|
||||
if (lower.endsWith('.png')) return 'image/png'
|
||||
if (lower.endsWith('.jpg') || lower.endsWith('.jpeg')) return 'image/jpeg'
|
||||
if (lower.endsWith('.webp')) return 'image/webp'
|
||||
|
||||
return 'image/png'
|
||||
}
|
||||
|
||||
function mapManifestIcons(manifest: PwaManifest, base: string) {
|
||||
return (manifest.icons || [])
|
||||
.map((icon) => {
|
||||
const src = toAbsoluteAssetUrl(icon.src, base)
|
||||
|
||||
return {
|
||||
src,
|
||||
sizes: icon.sizes || '512x512',
|
||||
type: guessMimeType(src),
|
||||
purpose: icon.purpose || 'any'
|
||||
}
|
||||
})
|
||||
.filter((icon) => isAbsoluteWebUrl(icon.src))
|
||||
}
|
||||
|
||||
/** فقط آیکونهای داخل monifist.json — بدون آواتار / pwa-icons / env */
|
||||
function resolveInstallIcons(manifest: PwaManifest) {
|
||||
const base = getConfigBaseFromStorage()
|
||||
const mapped = mapManifestIcons(manifest, base)
|
||||
|
||||
if (!mapped.length) {
|
||||
throw new Error('Manifest icons could not be resolved to absolute URLs')
|
||||
}
|
||||
|
||||
return mapped
|
||||
}
|
||||
|
||||
function prepareManifestForInstall(manifest: PwaManifest) {
|
||||
const scopeUrl = toSameOriginManifestUrl(manifest.scope ?? manifest.start_url, '/')
|
||||
const startUrl = toSameOriginManifestUrl(manifest.start_url, '/')
|
||||
const icons = resolveInstallIcons(manifest)
|
||||
const name = manifest.short_name || manifest.name
|
||||
|
||||
if (!name) {
|
||||
throw new Error('Manifest is missing name/short_name')
|
||||
}
|
||||
|
||||
if (!manifest.theme_color) {
|
||||
throw new Error('Manifest is missing theme_color')
|
||||
}
|
||||
|
||||
// start_url باید داخل scope باشد
|
||||
const scopeBase = scopeUrl.endsWith('/') ? scopeUrl : `${scopeUrl}/`
|
||||
const effectiveScope = startUrl.startsWith(scopeBase) ? scopeUrl : toSameOriginManifestUrl('/', '/')
|
||||
|
||||
return {
|
||||
id: normalizeManifestId(manifest.id, startUrl),
|
||||
name,
|
||||
short_name: manifest.short_name || manifest.name || name,
|
||||
lang: manifest.lang || 'fa',
|
||||
dir: manifest.dir || 'rtl',
|
||||
start_url: startUrl,
|
||||
scope: effectiveScope,
|
||||
display: manifest.display || 'standalone',
|
||||
background_color: manifest.background_color || '#ffffff',
|
||||
theme_color: manifest.theme_color,
|
||||
description: manifest.description || name,
|
||||
icons
|
||||
}
|
||||
}
|
||||
|
||||
function pickManifestIconUrl(manifest: PwaManifest, preferredSizes: number[]) {
|
||||
const icons = manifest.icons ?? []
|
||||
|
||||
for (const size of preferredSizes) {
|
||||
const target = `${size}x${size}`
|
||||
const match = icons.find((icon) => String(icon.sizes || '').includes(target))
|
||||
|
||||
if (match?.src) return match.src
|
||||
}
|
||||
|
||||
const sorted = [...icons].sort((a, b) => {
|
||||
const aSize = Number.parseInt(String(a.sizes || '0'), 10) || 0
|
||||
const bSize = Number.parseInt(String(b.sizes || '0'), 10) || 0
|
||||
return bSize - aSize
|
||||
})
|
||||
|
||||
return sorted[0]?.src || ''
|
||||
}
|
||||
|
||||
function upsertLink(rel: string, attrs: Record<string, string>) {
|
||||
const selectorParts = Object.entries(attrs)
|
||||
.filter(([key]) => key !== 'href')
|
||||
.map(([key, value]) => `[${key}="${value}"]`)
|
||||
.join('')
|
||||
|
||||
let link = document.querySelector<HTMLLinkElement>(`link[rel="${rel}"]${selectorParts}`)
|
||||
|
||||
if (!link) {
|
||||
link = document.createElement('link')
|
||||
link.rel = rel
|
||||
document.head.appendChild(link)
|
||||
}
|
||||
|
||||
Object.entries(attrs).forEach(([key, value]) => {
|
||||
link!.setAttribute(key, value)
|
||||
})
|
||||
|
||||
return link
|
||||
}
|
||||
|
||||
function upsertMeta(name: string, content: string) {
|
||||
let meta = document.querySelector<HTMLMetaElement>(`meta[name="${name}"]`)
|
||||
|
||||
if (!meta) {
|
||||
meta = document.createElement('meta')
|
||||
meta.name = name
|
||||
document.head.appendChild(meta)
|
||||
}
|
||||
|
||||
meta.content = content
|
||||
}
|
||||
|
||||
function removeAllManifestLinks() {
|
||||
document.querySelectorAll<HTMLLinkElement>("link[rel='manifest']").forEach((node) => node.remove())
|
||||
}
|
||||
|
||||
function removeDynamicManifestLinks() {
|
||||
removeAllManifestLinks()
|
||||
revokeManifestBlobUrl()
|
||||
|
||||
document
|
||||
.querySelectorAll<HTMLLinkElement>("link[rel='apple-touch-icon'][data-dynamic-pwa='true']")
|
||||
.forEach((node) => node.remove())
|
||||
}
|
||||
|
||||
function applyAppleTouchIconsFromManifest(manifest: PwaManifest) {
|
||||
document
|
||||
.querySelectorAll<HTMLLinkElement>("link[rel='apple-touch-icon'][data-dynamic-pwa='true']")
|
||||
.forEach((node) => node.remove())
|
||||
|
||||
const appleSizes = [180, 167, 152, 120]
|
||||
const used = new Set<string>()
|
||||
|
||||
appleSizes.forEach((size) => {
|
||||
const href = pickManifestIconUrl(manifest, [size, 192, 512])
|
||||
|
||||
if (!href || used.has(href)) return
|
||||
|
||||
used.add(href)
|
||||
|
||||
upsertLink('apple-touch-icon', {
|
||||
'data-dynamic-pwa': 'true',
|
||||
sizes: `${size}x${size}`,
|
||||
href
|
||||
})
|
||||
})
|
||||
|
||||
const primary = pickManifestIconUrl(manifest, [180, 192, 512, 384])
|
||||
|
||||
if (primary) {
|
||||
upsertLink('apple-touch-icon', {
|
||||
'data-dynamic-pwa': 'true',
|
||||
href: primary
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export async function applyPreparedManifestToDocument(
|
||||
normalized: PwaManifest,
|
||||
manifestUrl: string
|
||||
) {
|
||||
removeDynamicManifestLinks()
|
||||
|
||||
if (!normalized.icons?.length) {
|
||||
throw new Error('Manifest has no valid absolute icon URLs')
|
||||
}
|
||||
|
||||
const title = normalized.short_name || normalized.name
|
||||
|
||||
if (!title) {
|
||||
throw new Error('Prepared manifest is missing title')
|
||||
}
|
||||
|
||||
document.title = title
|
||||
|
||||
const blob = new Blob([JSON.stringify(normalized)], {
|
||||
type: 'application/manifest+json'
|
||||
})
|
||||
manifestBlobUrl = URL.createObjectURL(blob)
|
||||
|
||||
upsertLink('manifest', {
|
||||
'data-dynamic-pwa': 'true',
|
||||
href: manifestBlobUrl
|
||||
})
|
||||
|
||||
if (normalized.theme_color) {
|
||||
upsertMeta('theme-color', normalized.theme_color)
|
||||
}
|
||||
|
||||
upsertMeta('apple-mobile-web-app-title', title)
|
||||
upsertMeta('mobile-web-app-capable', 'yes')
|
||||
upsertMeta('apple-mobile-web-app-capable', 'yes')
|
||||
|
||||
applyAppleTouchIconsFromManifest(normalized)
|
||||
|
||||
const favicon = pickManifestIconUrl(normalized, [192, 180, 128, 96, 72])
|
||||
|
||||
console.info('PWA manifest applied:', manifestUrl, `icons: ${normalized.icons.length}`)
|
||||
|
||||
if (favicon) {
|
||||
upsertLink('icon', { type: 'image/png', href: favicon })
|
||||
}
|
||||
}
|
||||
|
||||
export async function applyManifestToDocument(manifest: PwaManifest, manifestUrl: string) {
|
||||
const prepared = prepareManifestForInstall(manifest)
|
||||
await applyPreparedManifestToDocument(prepared, manifestUrl)
|
||||
}
|
||||
|
||||
export function setPwaManifestReady(enabled: boolean) {
|
||||
if (enabled) {
|
||||
sessionStorage.setItem(PWA_MANIFEST_READY_KEY, '1')
|
||||
} else {
|
||||
sessionStorage.removeItem(PWA_MANIFEST_READY_KEY)
|
||||
}
|
||||
}
|
||||
|
||||
export function isPwaManifestReady() {
|
||||
return sessionStorage.getItem(PWA_MANIFEST_READY_KEY) === '1'
|
||||
}
|
||||
|
||||
/** هرچه زودتر در main.ts — قبل از bootstrap */
|
||||
export function initPwaInstallCapture() {
|
||||
if (installCaptureInitialized || typeof window === 'undefined') return
|
||||
installCaptureInitialized = true
|
||||
|
||||
window.addEventListener('beforeinstallprompt', (e) => {
|
||||
e.preventDefault()
|
||||
|
||||
if (isPwaManifestReady()) {
|
||||
notifyPwaManifestReady(e)
|
||||
return
|
||||
}
|
||||
|
||||
pendingBeforeInstallPrompt = e
|
||||
console.info('PWA install prompt captured, waiting for manifest + service worker')
|
||||
})
|
||||
}
|
||||
|
||||
export function notifyPwaManifestReady(installEvent?: Event | null) {
|
||||
if (!isPwaManifestReady()) return
|
||||
|
||||
const event = installEvent ?? pendingBeforeInstallPrompt
|
||||
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(PWA_MANIFEST_READY_EVENT, {
|
||||
detail: { installEvent: event }
|
||||
})
|
||||
)
|
||||
|
||||
if (!event) {
|
||||
console.info('PWA ready (manifest + SW). Waiting for beforeinstallprompt…', {
|
||||
secureContext: window.isSecureContext,
|
||||
origin: window.location.origin
|
||||
})
|
||||
}
|
||||
|
||||
pendingBeforeInstallPrompt = null
|
||||
}
|
||||
|
||||
async function applyCachedManifestEntry(
|
||||
cached: ReturnType<typeof readCachedPwaManifest>
|
||||
): Promise<boolean> {
|
||||
if (!cached) return false
|
||||
|
||||
try {
|
||||
const prepared = prepareManifestForInstall(cached.manifest)
|
||||
await applyPreparedManifestToDocument(prepared, cached.manifest_url)
|
||||
setPwaManifestReady(true)
|
||||
return true
|
||||
} catch (error) {
|
||||
console.warn('Cached PWA manifest invalid, refetching:', error)
|
||||
clearCachedPwaManifest()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* بعد از loadAppConfig / setAppConfig صدا بزن.
|
||||
* get_user دوباره fetch نمیشود — manifest از همان ۵ URL پایهٔ get_user امتحان میشود.
|
||||
*/
|
||||
export async function setupPwaManifest(config?: AppConfig | null): Promise<boolean> {
|
||||
const raw = config ?? getRawAppConfig()
|
||||
const userId = raw?.user?.id
|
||||
const configBase = getConfigBaseFromStorage()
|
||||
const manifestUrls = resolveManifestUrls(raw)
|
||||
|
||||
if (!manifestUrls.length) {
|
||||
console.warn('PWA manifest skipped: no manifest URL candidates')
|
||||
removeDynamicManifestLinks()
|
||||
setPwaManifestReady(false)
|
||||
return false
|
||||
}
|
||||
|
||||
const cached = configBase ? readCachedPwaManifest(userId, configBase) : null
|
||||
|
||||
if (cached && (await applyCachedManifestEntry(cached))) {
|
||||
console.info('PWA manifest applied from cache:', cached.manifest_url)
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
const { manifest, manifestUrl } = await fetchManifestTryingUrls(manifestUrls)
|
||||
|
||||
const prepared = prepareManifestForInstall(manifest)
|
||||
|
||||
await applyPreparedManifestToDocument(prepared, manifestUrl)
|
||||
setPwaManifestReady(true)
|
||||
|
||||
if (userId != null && userId !== '') {
|
||||
const effectiveConfigBase =
|
||||
configBase || normalizeBaseUrl(manifestUrl.replace(/\/manifest\.json$/i, ''))
|
||||
|
||||
writeCachedPwaManifest({
|
||||
cached_at: Date.now(),
|
||||
user_id: userId,
|
||||
config_base: effectiveConfigBase,
|
||||
manifest_url: manifestUrl,
|
||||
manifest: prepared
|
||||
})
|
||||
}
|
||||
|
||||
console.info('PWA manifest loaded once:', manifestUrl)
|
||||
return true
|
||||
} catch (error) {
|
||||
console.warn('PWA manifest unavailable, PWA disabled this session:', error)
|
||||
|
||||
removeDynamicManifestLinks()
|
||||
setPwaManifestReady(false)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
let manifestBootstrapStarted = false
|
||||
|
||||
/**
|
||||
* بلافاصله بعد از setAppConfig — بدون await در bootstrap.
|
||||
* اپ منتظر مانیفست نمیماند؛ SW بعد از موفقیت در پسزمینه ثبت میشود.
|
||||
*/
|
||||
export function startPwaManifest(config?: AppConfig | null) {
|
||||
if (manifestBootstrapStarted) return
|
||||
manifestBootstrapStarted = true
|
||||
|
||||
void setupPwaManifest(config).then((ready) => {
|
||||
if (!ready) return
|
||||
|
||||
void import('@/modules/pwa/register-pwa').then(({ registerAppPwa }) => registerAppPwa())
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { registerSW } from 'virtual:pwa-register'
|
||||
import { isPwaManifestReady, notifyPwaManifestReady } from '@/modules/pwa/manifest'
|
||||
|
||||
let swRegistrationStarted = false
|
||||
|
||||
export function registerAppPwa() {
|
||||
if (!isPwaManifestReady()) {
|
||||
console.info('Skipping service worker registration: manifest not ready')
|
||||
return
|
||||
}
|
||||
|
||||
if (swRegistrationStarted) return
|
||||
swRegistrationStarted = true
|
||||
|
||||
registerSW({
|
||||
immediate: true,
|
||||
onRegistered() {
|
||||
console.info('PWA service worker registered')
|
||||
notifyPwaManifestReady()
|
||||
},
|
||||
onRegisterError(error: unknown) {
|
||||
console.warn('PWA service worker registration failed:', error)
|
||||
notifyPwaManifestReady()
|
||||
},
|
||||
onNeedRefresh() {
|
||||
console.log('New content available, please refresh.')
|
||||
},
|
||||
onOfflineReady() {
|
||||
console.log('App ready to work offline.')
|
||||
notifyPwaManifestReady()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="version-update-fade">
|
||||
<div v-if="isUpdating || hasError" class="version-update-overlay" dir="rtl">
|
||||
<div class="version-update-card">
|
||||
<div v-if="!hasError" class="version-update-spinner" />
|
||||
|
||||
<div v-else class="version-update-error-icon">!</div>
|
||||
|
||||
<h2 class="version-update-title">
|
||||
{{ hasError ? 'خطا در بهروزرسانی' : 'در حال بهروزرسانی برنامه' }}
|
||||
</h2>
|
||||
|
||||
<p class="version-update-text">
|
||||
{{ statusText || 'لطفاً چند لحظه صبر کنید...' }}
|
||||
</p>
|
||||
|
||||
<button v-if="hasError" type="button" class="version-update-button" @click="retry">
|
||||
تلاش مجدد
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { setAppConfig } from '@/config/app-config'
|
||||
import { fetchFreshAppConfig } from '@/config/load-config'
|
||||
import { loadRemoteAppVersion, resetVersionCheckCache } from '@/config/load-version'
|
||||
import {
|
||||
shouldUpdateForVersion,
|
||||
canStartVersionUpdate,
|
||||
refreshConfigCacheForVersion,
|
||||
cancelVersionUpdateLock,
|
||||
hardReloadApp
|
||||
} from '@/config/config-cache'
|
||||
|
||||
const isUpdating = ref(false)
|
||||
const hasError = ref(false)
|
||||
const statusText = ref('')
|
||||
const pendingVersion = ref('')
|
||||
|
||||
onMounted(async () => {
|
||||
await checkRemoteVersion()
|
||||
})
|
||||
|
||||
async function checkRemoteVersion() {
|
||||
try {
|
||||
const version = await loadRemoteAppVersion()
|
||||
|
||||
/**
|
||||
* خیلی مهم:
|
||||
* اگر get_version جواب نداد، هیچ کاری نکن.
|
||||
* نه cache پاک کن، نه reload بزن.
|
||||
* چون ممکنه کاربر فقط اینترنت ضعیف داشته باشه یا endpoint موقتاً 404/timeout بده.
|
||||
*/
|
||||
if (!version) {
|
||||
console.warn('Remote version is empty. Version check skipped.')
|
||||
return
|
||||
}
|
||||
|
||||
if (!shouldUpdateForVersion(version)) return
|
||||
if (!canStartVersionUpdate(version)) return
|
||||
|
||||
pendingVersion.value = version
|
||||
|
||||
await startUpdate(version)
|
||||
} catch (error) {
|
||||
console.warn('Version check failed. Version update skipped:', error)
|
||||
}
|
||||
}
|
||||
|
||||
async function startUpdate(version: string) {
|
||||
try {
|
||||
isUpdating.value = true
|
||||
hasError.value = false
|
||||
|
||||
statusText.value = 'در حال آمادهسازی نسخه جدید...'
|
||||
await wait(500)
|
||||
|
||||
statusText.value = 'دریافت تنظیمات جدید برنامه...'
|
||||
|
||||
const freshConfig = await refreshConfigCacheForVersion(version, fetchFreshAppConfig)
|
||||
|
||||
setAppConfig(freshConfig)
|
||||
|
||||
await wait(500)
|
||||
|
||||
statusText.value = 'بارگذاری مجدد برنامه...'
|
||||
await wait(300)
|
||||
|
||||
hardReloadApp()
|
||||
} catch (error) {
|
||||
console.error('Version update failed:', error)
|
||||
|
||||
cancelVersionUpdateLock()
|
||||
|
||||
isUpdating.value = false
|
||||
hasError.value = true
|
||||
statusText.value = 'بهروزرسانی انجام نشد. لطفاً دوباره تلاش کنید.'
|
||||
}
|
||||
}
|
||||
|
||||
function retry() {
|
||||
hasError.value = false
|
||||
|
||||
if (pendingVersion.value) {
|
||||
startUpdate(pendingVersion.value)
|
||||
return
|
||||
}
|
||||
|
||||
resetVersionCheckCache()
|
||||
void checkRemoteVersion()
|
||||
}
|
||||
|
||||
function wait(ms: number) {
|
||||
return new Promise((resolve) => window.setTimeout(resolve, ms))
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.version-update-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 999999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
background: radial-gradient(
|
||||
circle at top,
|
||||
rgba(var(--colorPrimaryRGB, 37 99 235) / 0.16),
|
||||
transparent 38%
|
||||
),
|
||||
rgba(15, 23, 42, 0.38);
|
||||
backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
.version-update-card {
|
||||
width: min(390px, 100%);
|
||||
padding: 30px 22px 26px;
|
||||
border-radius: 24px;
|
||||
text-align: center;
|
||||
color: var(--colorText, #111827);
|
||||
background: var(--bg, #ffffff);
|
||||
border: 1px solid rgba(var(--colorPrimaryRGB, 37 99 235) / 0.18);
|
||||
box-shadow: 0 22px 70px rgba(15, 23, 42, 0.22);
|
||||
}
|
||||
|
||||
.version-update-spinner {
|
||||
width: 58px;
|
||||
height: 58px;
|
||||
margin: 0 auto 20px;
|
||||
border-radius: 999px;
|
||||
border: 4px solid rgba(var(--colorPrimaryRGB, 37 99 235) / 0.14);
|
||||
border-top-color: var(--colorPrimary, #2563eb);
|
||||
animation: version-update-spin 0.9s linear infinite;
|
||||
}
|
||||
|
||||
.version-update-error-icon {
|
||||
width: 58px;
|
||||
height: 58px;
|
||||
margin: 0 auto 20px;
|
||||
border-radius: 999px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--color6, #ffffff);
|
||||
background: var(--color5, #f44336);
|
||||
font-size: 34px;
|
||||
font-weight: 900;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.version-update-title {
|
||||
margin: 0;
|
||||
color: var(--colorText, #111827);
|
||||
font-size: 19px;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.version-update-text {
|
||||
margin: 12px 0 0;
|
||||
color: var(--colorText, #111827);
|
||||
opacity: 0.72;
|
||||
font-size: 14px;
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
.version-update-button {
|
||||
width: 100%;
|
||||
margin-top: 22px;
|
||||
padding: 12px 18px;
|
||||
border: 0;
|
||||
border-radius: 14px;
|
||||
color: var(--color6, #ffffff);
|
||||
background: var(--colorPrimary, #2563eb);
|
||||
font-weight: 800;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.version-update-button:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.version-update-fade-enter-active,
|
||||
.version-update-fade-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.version-update-fade-enter-from,
|
||||
.version-update-fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
@keyframes version-update-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -85,21 +85,21 @@ 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: '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'),
|
||||
// component: () => import('@/views/base/physicalReceive/index.vue'),
|
||||
children:[
|
||||
{
|
||||
path: '',
|
||||
@@ -112,7 +112,7 @@ const router = createRouter({
|
||||
component: () => import('@/views/base/physicalReceive/components/NewRequest.vue')
|
||||
},
|
||||
]
|
||||
},*/
|
||||
},
|
||||
{
|
||||
path: 'rules',
|
||||
name: 'rules',
|
||||
|
||||
@@ -2,6 +2,8 @@ import { computed, ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import type { CartItem } from '@/models/cart'
|
||||
import type { Product } from '@/models/products'
|
||||
import type { Price } from '@/models/home'
|
||||
import { getProducts } from '@/api/products'
|
||||
|
||||
const CART_STORAGE_KEY = 'ghatre_cart'
|
||||
|
||||
@@ -93,6 +95,58 @@ export const useCartStore = defineStore('cart', () => {
|
||||
return cartItems.value.length
|
||||
})
|
||||
|
||||
function syncProductsFromServer(serverProducts: Product[]): number {
|
||||
const productMap = new Map(serverProducts.map(p => [p.id, p]))
|
||||
const beforeCount = cartItems.value.length
|
||||
|
||||
cartItems.value = cartItems.value
|
||||
.filter(item => productMap.has(item.product.id))
|
||||
.map(item => ({
|
||||
...item,
|
||||
product: { ...productMap.get(item.product.id)! }
|
||||
}))
|
||||
|
||||
if (cartItems.value.length > 0 || beforeCount > 0) {
|
||||
saveCartToStorage()
|
||||
}
|
||||
|
||||
return beforeCount - cartItems.value.length
|
||||
}
|
||||
|
||||
function recalculateCartPrices(lastPrice: Price) {
|
||||
if (!lastPrice || cartItems.value.length === 0) return
|
||||
|
||||
cartItems.value.forEach((item) => {
|
||||
const product = item.product
|
||||
let newPrice = 0
|
||||
|
||||
if (product.group_type == 'آبشده') {
|
||||
newPrice = lastPrice.price_last ?? 0
|
||||
} else {
|
||||
newPrice = product.amount * (lastPrice.price_last ?? 0)
|
||||
}
|
||||
|
||||
product.price = newPrice
|
||||
product.sellPrice = product.amount * (lastPrice.sell ?? 0)
|
||||
item.price = newPrice + (product.cash_fee_buy ?? 0)
|
||||
item.totalPrice = parseInt(String(item.price * item.quantity))
|
||||
})
|
||||
|
||||
saveCartToStorage()
|
||||
}
|
||||
|
||||
async function refreshCartFromServer(): Promise<number> {
|
||||
if (cartItems.value.length === 0) return 0
|
||||
|
||||
try {
|
||||
const serverProducts: Product[] = await getProducts()
|
||||
return syncProductsFromServer(serverProducts)
|
||||
} catch (e) {
|
||||
console.error('Error refreshing cart from server:', e)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
cartItems,
|
||||
addToCart,
|
||||
@@ -102,7 +156,10 @@ export const useCartStore = defineStore('cart', () => {
|
||||
totalPrice,
|
||||
itemCount,
|
||||
loadCartFromStorage,
|
||||
saveCartToStorage
|
||||
saveCartToStorage,
|
||||
syncProductsFromServer,
|
||||
recalculateCartPrices,
|
||||
refreshCartFromServer
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { getSettings } from '@/api/configuration'
|
||||
|
||||
export interface AppSetting {
|
||||
id?: number
|
||||
key?: string | number
|
||||
title_fa?: string
|
||||
value?: string | number
|
||||
description?: string
|
||||
is_active?: boolean
|
||||
type?: string
|
||||
}
|
||||
|
||||
export const useSettingsStore = defineStore('settings', () => {
|
||||
const settings = ref<AppSetting[]>([])
|
||||
const loaded = ref(false)
|
||||
let fetchPromise: Promise<AppSetting[]> | null = null
|
||||
|
||||
function getSettingByKey(key: string) {
|
||||
const item = settings.value.find((setting) => setting?.key === key)
|
||||
return item?.value ?? null
|
||||
}
|
||||
|
||||
async function fetchSettings(force = false) {
|
||||
if (!force && fetchPromise) {
|
||||
return fetchPromise
|
||||
}
|
||||
|
||||
fetchPromise = (async () => {
|
||||
try {
|
||||
const data = await getSettings()
|
||||
if (Array.isArray(data)) {
|
||||
settings.value = data
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
} finally {
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
return settings.value
|
||||
})()
|
||||
|
||||
return fetchPromise
|
||||
}
|
||||
|
||||
return {
|
||||
settings,
|
||||
loaded,
|
||||
fetchSettings,
|
||||
getSettingByKey,
|
||||
}
|
||||
})
|
||||
@@ -1,14 +1,14 @@
|
||||
import colors from './baseColor.json'
|
||||
/** base config **/
|
||||
/** api document **/
|
||||
export const baseURL: string = 'https://ghatreh.gold/server/'
|
||||
export const baseURL: string = 'https://kh.kashkolgold.ir/server/'
|
||||
// const baseUploadURL: string = '/site/file'
|
||||
// const uploadURL: string = baseURL + baseUploadURL
|
||||
// const baseURLStorage: string = baseURL + '/v1'
|
||||
const prefixCls: string = 'noname'
|
||||
// const version: string = pkg.version
|
||||
// const tokenName: string = 'gholaktala_app_token'
|
||||
const tokenName: string = 'ghatreh_app_token'
|
||||
const tokenName: string = 'kashkolgold_app_token'
|
||||
|
||||
const baseButtonIconSize = '24'
|
||||
// const appName = { fa: 'بدون نام', en: 'noname' }
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { getStoreCategories } from '@/api/categories'
|
||||
|
||||
/** تبهای فیلتر محصول — فقط از API دستهبندی (هماهنگ با پنل ادمین) */
|
||||
export async function loadProductCategoryTabNames(): Promise<string[]> {
|
||||
const categories = await getStoreCategories()
|
||||
return categories.map((item) => item.name)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export function getConfigApp(key: string) {
|
||||
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user : {}
|
||||
|
||||
if (config) {
|
||||
return config[key]
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -30,11 +30,11 @@ export async function authenticateWithFingerprint() {
|
||||
|
||||
const createOptions = {
|
||||
challenge,
|
||||
rp: { name: 'ghatreh' },
|
||||
rp: { name: 'kashkol' },
|
||||
user: {
|
||||
id: Uint8Array.from('user-id', c => c.charCodeAt(0)),
|
||||
name: 'Ghatreh',
|
||||
displayName: 'Ghatreh'
|
||||
name: 'Kashkol',
|
||||
displayName: 'Kashkol'
|
||||
},
|
||||
pubKeyCredParams: [{ type: 'public-key', alg: -7 }],
|
||||
authenticatorSelection: {
|
||||
@@ -52,7 +52,7 @@ export async function authenticateWithFingerprint() {
|
||||
const credentialId = btoa(String.fromCharCode(...new Uint8Array(credential.rawId)))
|
||||
|
||||
// بازیابی توکن از localStorage
|
||||
const token = localStorage.getItem('ghatreh_app_token')
|
||||
const token = localStorage.getItem('kashkol_app_token')
|
||||
|
||||
if (!token) {
|
||||
console.warn('توکن پیدا نشد، عملیات متوقف شد.')
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
import {
|
||||
buildSupportMessengerUrl,
|
||||
loadSupportMessengerFromSettings,
|
||||
supportMessengerSettings,
|
||||
} from '@/utils/supportMessenger'
|
||||
|
||||
const STORAGE_KEY = 'ghatreh_whatsapp_button_position'
|
||||
const DRAG_THRESHOLD = 6
|
||||
const WIDTH = 60
|
||||
const HEIGHT = 60
|
||||
const DEFAULT_BOTTOM_OFFSET = 90
|
||||
const DEFAULT_RIGHT_OFFSET = 20
|
||||
|
||||
type FabPosition = { x: number; y: number }
|
||||
|
||||
function getViewportWidth() {
|
||||
return Math.min(window.innerWidth, 426)
|
||||
}
|
||||
|
||||
function getHorizontalOffset() {
|
||||
const vw = window.innerWidth
|
||||
const contentWidth = getViewportWidth()
|
||||
return Math.max(0, (vw - contentWidth) / 2)
|
||||
}
|
||||
|
||||
function getDefaultPosition(): FabPosition {
|
||||
const vh = window.innerHeight
|
||||
const offsetX = getHorizontalOffset()
|
||||
const contentWidth = getViewportWidth()
|
||||
|
||||
return {
|
||||
x: offsetX + contentWidth - WIDTH - DEFAULT_RIGHT_OFFSET,
|
||||
y: vh - DEFAULT_BOTTOM_OFFSET - HEIGHT,
|
||||
}
|
||||
}
|
||||
|
||||
function loadPosition(): FabPosition | null {
|
||||
try {
|
||||
const raw = localStorage.getItem(STORAGE_KEY)
|
||||
if (!raw) return null
|
||||
const parsed = JSON.parse(raw) as FabPosition
|
||||
if (typeof parsed?.x === 'number' && typeof parsed?.y === 'number') {
|
||||
return parsed
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function savePosition(pos: FabPosition) {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(pos))
|
||||
}
|
||||
|
||||
function clampPosition(pos: FabPosition): FabPosition {
|
||||
const vw = window.innerWidth
|
||||
const vh = window.innerHeight
|
||||
|
||||
return {
|
||||
x: Math.max(0, Math.min(vw - WIDTH, pos.x)),
|
||||
y: Math.max(0, Math.min(vh - HEIGHT, pos.y)),
|
||||
}
|
||||
}
|
||||
|
||||
function applyPosition(button: HTMLElement, pos: FabPosition) {
|
||||
button.style.position = 'fixed'
|
||||
button.style.bottom = 'auto'
|
||||
button.style.right = 'auto'
|
||||
button.style.left = `${pos.x}px`
|
||||
button.style.top = `${pos.y}px`
|
||||
button.style.touchAction = 'none'
|
||||
}
|
||||
|
||||
function updateWhatsappHref(button: HTMLAnchorElement) {
|
||||
const link = buildSupportMessengerUrl(
|
||||
supportMessengerSettings.value.messenger,
|
||||
supportMessengerSettings.value.messengerId
|
||||
)
|
||||
|
||||
button.href = link || '#'
|
||||
button.style.display = 'flex'
|
||||
}
|
||||
|
||||
export function initWhatsappButtonDrag() {
|
||||
const button = document.getElementById('whatsapp-button') as HTMLAnchorElement | null
|
||||
if (!button) return
|
||||
|
||||
let pos = clampPosition(loadPosition() ?? getDefaultPosition())
|
||||
applyPosition(button, pos)
|
||||
|
||||
let pointerId: number | null = null
|
||||
let startX = 0
|
||||
let startY = 0
|
||||
let originX = 0
|
||||
let originY = 0
|
||||
let hasMoved = false
|
||||
let dragging = false
|
||||
|
||||
function onResize() {
|
||||
pos = clampPosition(pos)
|
||||
applyPosition(button!, pos)
|
||||
savePosition(pos)
|
||||
}
|
||||
|
||||
function onPointerDown(event: PointerEvent) {
|
||||
dragging = true
|
||||
hasMoved = false
|
||||
pointerId = event.pointerId
|
||||
startX = event.clientX
|
||||
startY = event.clientY
|
||||
originX = pos.x
|
||||
originY = pos.y
|
||||
button!.classList.add('is-dragging')
|
||||
button!.setPointerCapture(event.pointerId)
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
function onPointerMove(event: PointerEvent) {
|
||||
if (!dragging || pointerId !== event.pointerId) return
|
||||
|
||||
const dx = event.clientX - startX
|
||||
const dy = event.clientY - startY
|
||||
|
||||
if (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD) {
|
||||
hasMoved = true
|
||||
}
|
||||
|
||||
pos = clampPosition({ x: originX + dx, y: originY + dy })
|
||||
applyPosition(button!, pos)
|
||||
}
|
||||
|
||||
function finishPointer(event: PointerEvent) {
|
||||
if (!dragging || pointerId !== event.pointerId) return
|
||||
|
||||
dragging = false
|
||||
pointerId = null
|
||||
button!.classList.remove('is-dragging')
|
||||
savePosition(pos)
|
||||
|
||||
const clicked = !hasMoved
|
||||
hasMoved = false
|
||||
|
||||
if (clicked && button!.href && button!.href !== '#') {
|
||||
window.open(button!.href, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
}
|
||||
|
||||
button.addEventListener('pointerdown', onPointerDown)
|
||||
button.addEventListener('pointermove', onPointerMove)
|
||||
button.addEventListener('pointerup', finishPointer)
|
||||
button.addEventListener('pointercancel', finishPointer)
|
||||
button.addEventListener('click', (event) => event.preventDefault())
|
||||
window.addEventListener('resize', onResize)
|
||||
|
||||
void loadSupportMessengerFromSettings().then(() => {
|
||||
updateWhatsappHref(button)
|
||||
})
|
||||
}
|
||||
@@ -1,86 +1,166 @@
|
||||
import {loading} from '@/utils/index'
|
||||
import {getLastPrice, getPrice} from '@/api/home'
|
||||
import {ref} from 'vue'
|
||||
import type {Price} from '@/models/home'
|
||||
import { getLastPrice, getPrice } from '@/api/home'
|
||||
import type { Price, PriceUp } from '@/models/home'
|
||||
import { ref, watch } from 'vue'
|
||||
import {
|
||||
priceSocketConnected,
|
||||
priceStreamLifecycle,
|
||||
priceWssEnabled,
|
||||
shouldUsePricePolling,
|
||||
} from '@/utils/priceSocketState'
|
||||
|
||||
const LAST_INTERVAL_MS = 10000
|
||||
|
||||
let lastInterval: ReturnType<typeof setInterval> | undefined
|
||||
let lastSubscribers = 0
|
||||
|
||||
let interval: any
|
||||
export const price = ref<Price>()
|
||||
export const lastPrice = ref<Price>()
|
||||
export const olderPrice = ref<number| undefined>(0)
|
||||
export const olderPrice = ref<number | undefined>(0)
|
||||
|
||||
let lastPriceSourceAt = 0
|
||||
let consecutivePriceFetchFailures = 0
|
||||
|
||||
function hasValidPricePayload(data?: Price | null): boolean {
|
||||
if (!data) {
|
||||
return false
|
||||
}
|
||||
|
||||
return (
|
||||
Number(data.buy ?? data.up?.buy ?? 0) > 0
|
||||
|| Number(data.sell ?? data.up?.sell ?? 0) > 0
|
||||
|| Number(data.price_last ?? data.price ?? 0) > 0
|
||||
)
|
||||
}
|
||||
|
||||
export function markPriceSourceReceived() {
|
||||
lastPriceSourceAt = Date.now()
|
||||
consecutivePriceFetchFailures = 0
|
||||
}
|
||||
|
||||
export function markPriceSourceFetchFailed() {
|
||||
consecutivePriceFetchFailures += 1
|
||||
}
|
||||
|
||||
export function hasRecentPriceFromSource(maxAgeMs = 45000): boolean {
|
||||
return lastPriceSourceAt > 0 && Date.now() - lastPriceSourceAt < maxAgeMs
|
||||
}
|
||||
|
||||
export function consecutivePriceSourceFailures(): number {
|
||||
return consecutivePriceFetchFailures
|
||||
}
|
||||
|
||||
function startPollingInterval() {
|
||||
if (lastInterval || !shouldUsePricePolling()) {
|
||||
return
|
||||
}
|
||||
|
||||
lastInterval = setInterval(() => {
|
||||
if (shouldUsePricePolling()) {
|
||||
void getLastPrices()
|
||||
}
|
||||
}, LAST_INTERVAL_MS)
|
||||
}
|
||||
|
||||
function stopPollingInterval() {
|
||||
if (lastInterval) {
|
||||
clearInterval(lastInterval)
|
||||
lastInterval = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function syncLastPricePolling() {
|
||||
const usePolling = shouldUsePricePolling()
|
||||
if (usePolling) {
|
||||
if (lastSubscribers > 0) {
|
||||
startPollingInterval()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
stopPollingInterval()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [priceWssEnabled.value, priceSocketConnected.value, priceStreamLifecycle.value] as const,
|
||||
() => {
|
||||
syncLastPricePolling()
|
||||
},
|
||||
)
|
||||
|
||||
export function startLastPricePolling() {
|
||||
lastSubscribers++
|
||||
syncLastPricePolling()
|
||||
}
|
||||
|
||||
export async function setIntervalGetAllPrice() {
|
||||
// console.log('salam')
|
||||
try {
|
||||
interval = setInterval(async () => {
|
||||
await getLastPrices()
|
||||
await getUpPrice()
|
||||
}, 10000)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
startLastPricePolling()
|
||||
}
|
||||
|
||||
export async function setIntervalGetLastPrice() {
|
||||
// console.log('salam')
|
||||
try {
|
||||
interval = setInterval(async () => {
|
||||
await getLastPrices()
|
||||
// await getUpPrice()
|
||||
}, 10000)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
startLastPricePolling()
|
||||
}
|
||||
|
||||
export async function getUpPrice() {
|
||||
try {
|
||||
// loading.value = true
|
||||
const data = await getPrice()
|
||||
// const dataLast = await getLastPrice()
|
||||
// if (lastPrice.value?.price_last != dataLast.price_last) {
|
||||
// olderPrice.value = lastPrice.value?.price_last
|
||||
// }
|
||||
price.value = data
|
||||
// lastPrice.value = dataLast
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
// loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function getLastPrices() {
|
||||
try {
|
||||
// loading.value = true
|
||||
// const data = await getPrice()
|
||||
const dataLast = await getLastPrice()
|
||||
if (lastPrice.value?.price_last != dataLast.price_last) {
|
||||
olderPrice.value = lastPrice.value?.price_last
|
||||
}
|
||||
// price.value = data
|
||||
lastPrice.value = dataLast
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
// loading.value = false
|
||||
}
|
||||
export function stopLastPricePolling() {
|
||||
lastSubscribers = Math.max(0, lastSubscribers - 1)
|
||||
if (lastSubscribers === 0) {
|
||||
stopPollingInterval()
|
||||
}
|
||||
}
|
||||
|
||||
export function stopPriceInterval() {
|
||||
// console.log('stop')
|
||||
clearInterval(interval)
|
||||
stopLastPricePolling()
|
||||
}
|
||||
|
||||
async function fetchUpPrices(): Promise<PriceUp | undefined> {
|
||||
try {
|
||||
const up = await getPrice()
|
||||
if (up?.buy != null && up?.sell != null) {
|
||||
return { buy: up.buy, sell: up.sell }
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
export async function getUpPrice() {
|
||||
await getLastPrices()
|
||||
}
|
||||
|
||||
export async function getLastPrices(): Promise<boolean> {
|
||||
try {
|
||||
let dataLast = await getLastPrice()
|
||||
|
||||
if (!dataLast?.up) {
|
||||
const up = await fetchUpPrices()
|
||||
if (up) {
|
||||
dataLast = { ...dataLast, up }
|
||||
}
|
||||
}
|
||||
|
||||
applyLastPricePayload(dataLast)
|
||||
return hasValidPricePayload(dataLast)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
markPriceSourceFetchFailed()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function applyLastPricePayload(dataLast: Price) {
|
||||
if (lastPrice.value?.price_last != dataLast.price_last) {
|
||||
olderPrice.value = lastPrice.value?.price_last
|
||||
}
|
||||
lastPrice.value = dataLast
|
||||
price.value = dataLast
|
||||
|
||||
if (hasValidPricePayload(dataLast)) {
|
||||
markPriceSourceReceived()
|
||||
}
|
||||
}
|
||||
|
||||
export function percentPriceChanged() {
|
||||
// console.log(olderPrice.value)
|
||||
// console.log(lastPrice.value?.price_last)
|
||||
if (!olderPrice.value)
|
||||
return 0
|
||||
return ((lastPrice.value?.price_last-olderPrice.value) *100)/olderPrice.value
|
||||
}
|
||||
if (!olderPrice.value) {
|
||||
return 0
|
||||
}
|
||||
return ((lastPrice.value?.price_last! - olderPrice.value) * 100) / olderPrice.value
|
||||
}
|
||||
|
||||
@@ -0,0 +1,630 @@
|
||||
import type { Price } from '@/models/home'
|
||||
import type { Product } from '@/models/products'
|
||||
import { Modal } from 'ant-design-vue'
|
||||
import { getConfigApp } from '@/utils/config'
|
||||
import { applyProductsListFromStream } from '@/utils/productStreamBridge'
|
||||
import {
|
||||
priceSocketConnected,
|
||||
priceStreamConnectingSince,
|
||||
priceStreamLifecycle,
|
||||
priceWssEnabled,
|
||||
} from '@/utils/priceSocketState'
|
||||
|
||||
export {
|
||||
priceSocketConnected,
|
||||
priceStreamConnectingSince,
|
||||
priceStreamLifecycle,
|
||||
priceWssEnabled,
|
||||
shouldUsePricePolling,
|
||||
} from '@/utils/priceSocketState'
|
||||
|
||||
const RECONNECT_BASE_MS = 3000
|
||||
const RECONNECT_MAX_MS = 30000
|
||||
const FAILURES_BEFORE_ALERT = 4
|
||||
const ALERT_COOLDOWN_MS = 5 * 60 * 1000
|
||||
const FALLBACK_POLL_INTERVAL_MS = 10000
|
||||
const PRICE_SOURCE_STALE_MS_MOBILE = 50000
|
||||
const PRICE_SOURCE_STALE_MS_DESKTOP = 35000
|
||||
const STALE_STREAM_MS = 120000
|
||||
const FALLBACK_POLL_DELAY_MS = 2500
|
||||
|
||||
let eventSource: EventSource | null = null
|
||||
let subscribers = 0
|
||||
let stopped = false
|
||||
let getSetting: ((key: string) => unknown) | null = null
|
||||
let reconnectTimer: ReturnType<typeof setTimeout> | undefined
|
||||
let staleCheckTimer: ReturnType<typeof setInterval> | undefined
|
||||
let reconnectAttempt = 0
|
||||
let lastStreamEventAt = 0
|
||||
let networkAlertOpen = false
|
||||
let lastNetworkAlertAt = 0
|
||||
let listenersBound = false
|
||||
let fallbackPollTimer: ReturnType<typeof setTimeout> | undefined
|
||||
let fallbackPollInterval: ReturnType<typeof setInterval> | undefined
|
||||
let pendingPriceAlert = false
|
||||
|
||||
function isMobileDevice(): boolean {
|
||||
if (typeof navigator === 'undefined') {
|
||||
return false
|
||||
}
|
||||
|
||||
return /iPhone|iPad|iPod|Android|Mobile/i.test(navigator.userAgent)
|
||||
}
|
||||
|
||||
function isPageVisible(): boolean {
|
||||
return typeof document === 'undefined' || document.visibilityState === 'visible'
|
||||
}
|
||||
|
||||
function markConnectingLifecycle() {
|
||||
priceStreamLifecycle.value = 'connecting'
|
||||
if (priceStreamConnectingSince.value <= 0) {
|
||||
priceStreamConnectingSince.value = Date.now()
|
||||
}
|
||||
}
|
||||
|
||||
function clearConnectingLifecycle() {
|
||||
priceStreamConnectingSince.value = 0
|
||||
}
|
||||
|
||||
function isTruthySetting(value: unknown, defaultValue = true): boolean {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
return ['true', '1', 'yes', 'on'].includes(String(value).toLowerCase())
|
||||
}
|
||||
|
||||
function resolveStreamPath(): string {
|
||||
const ssePath = String(getSetting?.('sse_path') ?? '').trim()
|
||||
if (ssePath && !ssePath.includes('/prc/')) {
|
||||
return ssePath.startsWith('/') ? ssePath : `/${ssePath}`
|
||||
}
|
||||
|
||||
const legacyPath = String(getSetting?.('wss_path') ?? '').trim()
|
||||
if (legacyPath && !legacyPath.includes('/prc/')) {
|
||||
return legacyPath.startsWith('/') ? legacyPath : `/${legacyPath}`
|
||||
}
|
||||
|
||||
return '/api/price/stream'
|
||||
}
|
||||
|
||||
function resolveStreamUrl(): string | null {
|
||||
if (!getSetting) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (!isTruthySetting(getSetting('wss_enabled'), true)) {
|
||||
return null
|
||||
}
|
||||
|
||||
const base = String(getConfigApp('node_server') || window.location.origin).replace(/\/$/, '')
|
||||
return `${base}${resolveStreamPath()}`
|
||||
}
|
||||
|
||||
function clearReconnectTimer() {
|
||||
if (reconnectTimer) {
|
||||
clearTimeout(reconnectTimer)
|
||||
reconnectTimer = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function stopStaleCheck() {
|
||||
if (staleCheckTimer) {
|
||||
clearInterval(staleCheckTimer)
|
||||
staleCheckTimer = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function touchStreamActivity() {
|
||||
lastStreamEventAt = Date.now()
|
||||
}
|
||||
|
||||
function startStaleCheck() {
|
||||
stopStaleCheck()
|
||||
touchStreamActivity()
|
||||
staleCheckTimer = setInterval(() => {
|
||||
if (
|
||||
stopped
|
||||
|| subscribers <= 0
|
||||
|| !eventSource
|
||||
|| eventSource.readyState !== EventSource.OPEN
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Date.now() - lastStreamEventAt > STALE_STREAM_MS) {
|
||||
console.warn('Price SSE stale — reconnecting')
|
||||
handleStreamLost(true)
|
||||
}
|
||||
}, 15000)
|
||||
}
|
||||
|
||||
function clearFallbackPollTimer() {
|
||||
if (fallbackPollTimer) {
|
||||
clearTimeout(fallbackPollTimer)
|
||||
fallbackPollTimer = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function stopFallbackPolling() {
|
||||
clearFallbackPollTimer()
|
||||
if (fallbackPollInterval) {
|
||||
clearInterval(fallbackPollInterval)
|
||||
fallbackPollInterval = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function startFallbackPolling() {
|
||||
if (fallbackPollInterval) {
|
||||
return
|
||||
}
|
||||
|
||||
scheduleFallbackPoll()
|
||||
fallbackPollInterval = setInterval(() => {
|
||||
if (stopped || subscribers <= 0 || priceSocketConnected.value) {
|
||||
stopFallbackPolling()
|
||||
return
|
||||
}
|
||||
|
||||
void runFallbackPoll()
|
||||
}, FALLBACK_POLL_INTERVAL_MS)
|
||||
}
|
||||
|
||||
function scheduleFallbackPoll() {
|
||||
clearFallbackPollTimer()
|
||||
fallbackPollTimer = setTimeout(() => {
|
||||
fallbackPollTimer = undefined
|
||||
if (!stopped && subscribers > 0 && !priceSocketConnected.value) {
|
||||
void runFallbackPoll()
|
||||
}
|
||||
}, FALLBACK_POLL_DELAY_MS)
|
||||
}
|
||||
|
||||
async function runFallbackPoll() {
|
||||
if (!priceWssEnabled.value || priceSocketConnected.value) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const { getLastPrices, hasRecentPriceFromSource, markPriceSourceFetchFailed } = await import(
|
||||
'@/utils/price'
|
||||
)
|
||||
const { getProducts } = await import('@/api/products')
|
||||
const { applyProductsListFromStream: applyList } = await import('@/utils/productStreamBridge')
|
||||
const [lastResult, products] = await Promise.allSettled([
|
||||
getLastPrices(),
|
||||
getProducts(),
|
||||
])
|
||||
|
||||
if (products.status === 'fulfilled' && Array.isArray(products.value) && products.value.length) {
|
||||
applyList(products.value)
|
||||
}
|
||||
|
||||
const priceOk =
|
||||
lastResult.status === 'fulfilled'
|
||||
&& lastResult.value === true
|
||||
&& hasRecentPriceFromSource(getPriceSourceStaleMs())
|
||||
|
||||
if (!priceOk) {
|
||||
markPriceSourceFetchFailed()
|
||||
}
|
||||
|
||||
void maybeShowNetworkAlert()
|
||||
} catch (error) {
|
||||
console.warn('Price fallback poll failed', error)
|
||||
const { markPriceSourceFetchFailed } = await import('@/utils/price')
|
||||
markPriceSourceFetchFailed()
|
||||
void maybeShowNetworkAlert()
|
||||
}
|
||||
}
|
||||
|
||||
function getPriceSourceStaleMs(): number {
|
||||
return isMobileDevice() ? PRICE_SOURCE_STALE_MS_MOBILE : PRICE_SOURCE_STALE_MS_DESKTOP
|
||||
}
|
||||
|
||||
async function isRealPriceOutage(): Promise<boolean> {
|
||||
const {
|
||||
hasRecentPriceFromSource,
|
||||
consecutivePriceSourceFailures,
|
||||
} = await import('@/utils/price')
|
||||
|
||||
const staleMs = getPriceSourceStaleMs()
|
||||
|
||||
if (hasRecentPriceFromSource(staleMs)) {
|
||||
pendingPriceAlert = false
|
||||
return false
|
||||
}
|
||||
|
||||
const fetchFailures = consecutivePriceSourceFailures()
|
||||
|
||||
if (fetchFailures >= 2) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (!priceSocketConnected.value && fetchFailures >= 1 && reconnectAttempt >= 2) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (!isMobileDevice() && !navigator.onLine && fetchFailures >= 1) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (!isMobileDevice() && reconnectAttempt >= FAILURES_BEFORE_ALERT) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
function showNetworkAlert() {
|
||||
if (networkAlertOpen || stopped || !priceWssEnabled.value) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!isPageVisible()) {
|
||||
pendingPriceAlert = true
|
||||
return
|
||||
}
|
||||
|
||||
const now = Date.now()
|
||||
if (now - lastNetworkAlertAt < ALERT_COOLDOWN_MS) {
|
||||
return
|
||||
}
|
||||
|
||||
lastNetworkAlertAt = now
|
||||
pendingPriceAlert = false
|
||||
networkAlertOpen = true
|
||||
Modal.confirm({
|
||||
title: 'اتصال قیمت برقرار نیست',
|
||||
content:
|
||||
'بهروزرسانی لحظهای قیمت قطع شده است. اتصال اینترنت را بررسی کنید یا دوباره تلاش کنید. تا زمان اتصال مجدد، قیمت با تأخیر بهروز میشود.',
|
||||
okText: 'تلاش مجدد',
|
||||
cancelText: 'بستن',
|
||||
centered: true,
|
||||
onOk: () => {
|
||||
networkAlertOpen = false
|
||||
reconnectAttempt = 0
|
||||
forceReconnect()
|
||||
},
|
||||
onCancel: () => {
|
||||
networkAlertOpen = false
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function maybeShowNetworkAlert() {
|
||||
if (!(await isRealPriceOutage())) {
|
||||
return
|
||||
}
|
||||
|
||||
showNetworkAlert()
|
||||
}
|
||||
|
||||
function scheduleReconnect() {
|
||||
if (stopped || subscribers <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
clearReconnectTimer()
|
||||
const delay = Math.min(
|
||||
RECONNECT_BASE_MS * Math.pow(2, reconnectAttempt),
|
||||
RECONNECT_MAX_MS,
|
||||
)
|
||||
|
||||
reconnectTimer = setTimeout(() => {
|
||||
reconnectAttempt += 1
|
||||
connect()
|
||||
maybeShowNetworkAlert()
|
||||
}, delay)
|
||||
}
|
||||
|
||||
async function applyLastFromStream(last: Price) {
|
||||
const { applyLastPricePayload } = await import('@/utils/price')
|
||||
applyLastPricePayload(last)
|
||||
}
|
||||
|
||||
function handleLastPayload(payload: unknown) {
|
||||
if (!payload || typeof payload !== 'object') {
|
||||
return
|
||||
}
|
||||
|
||||
const last = payload as Price
|
||||
if (last.price_last == null && last.price == null && last.buy == null) {
|
||||
return
|
||||
}
|
||||
|
||||
touchStreamActivity()
|
||||
void applyLastFromStream(last)
|
||||
}
|
||||
|
||||
function handleListPayload(payload: unknown) {
|
||||
if (!Array.isArray(payload) || !payload.length) {
|
||||
return
|
||||
}
|
||||
|
||||
touchStreamActivity()
|
||||
applyProductsListFromStream(payload as Product[])
|
||||
}
|
||||
|
||||
function bindStreamEvents(source: EventSource) {
|
||||
source.addEventListener('last', (event) => {
|
||||
try {
|
||||
handleLastPayload(JSON.parse(event.data))
|
||||
} catch (error) {
|
||||
console.warn('Price SSE last parse failed', error)
|
||||
}
|
||||
})
|
||||
|
||||
source.addEventListener('list', (event) => {
|
||||
try {
|
||||
handleListPayload(JSON.parse(event.data))
|
||||
} catch (error) {
|
||||
console.warn('Price SSE list parse failed', error)
|
||||
}
|
||||
})
|
||||
|
||||
source.addEventListener('ping', () => {
|
||||
touchStreamActivity()
|
||||
})
|
||||
|
||||
source.onmessage = () => {
|
||||
touchStreamActivity()
|
||||
}
|
||||
}
|
||||
|
||||
function handleStreamLost(scheduleRetry = true) {
|
||||
const wasConnected = priceSocketConnected.value
|
||||
disconnectSourceOnly()
|
||||
priceSocketConnected.value = false
|
||||
priceStreamLifecycle.value = scheduleRetry ? 'connecting' : 'closed'
|
||||
|
||||
if ((wasConnected || scheduleRetry) && scheduleRetry) {
|
||||
startFallbackPolling()
|
||||
}
|
||||
|
||||
if (scheduleRetry && !stopped && subscribers > 0) {
|
||||
scheduleReconnect()
|
||||
}
|
||||
}
|
||||
|
||||
function disconnectSourceOnly() {
|
||||
stopStaleCheck()
|
||||
if (eventSource) {
|
||||
eventSource.onopen = null
|
||||
eventSource.onerror = null
|
||||
eventSource.onmessage = null
|
||||
eventSource.close()
|
||||
eventSource = null
|
||||
}
|
||||
}
|
||||
|
||||
function connect() {
|
||||
if (stopped || subscribers <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const url = resolveStreamUrl()
|
||||
if (!url) {
|
||||
priceSocketConnected.value = false
|
||||
priceStreamLifecycle.value = 'closed'
|
||||
clearConnectingLifecycle()
|
||||
return
|
||||
}
|
||||
|
||||
if (eventSource) {
|
||||
const state = eventSource.readyState
|
||||
if (state === EventSource.OPEN || state === EventSource.CONNECTING) {
|
||||
return
|
||||
}
|
||||
disconnectSourceOnly()
|
||||
}
|
||||
|
||||
markConnectingLifecycle()
|
||||
|
||||
try {
|
||||
eventSource = new EventSource(url)
|
||||
} catch (error) {
|
||||
console.warn('Price SSE connect failed', error)
|
||||
handleStreamLost()
|
||||
return
|
||||
}
|
||||
|
||||
bindStreamEvents(eventSource)
|
||||
|
||||
eventSource.onopen = () => {
|
||||
reconnectAttempt = 0
|
||||
clearReconnectTimer()
|
||||
stopFallbackPolling()
|
||||
networkAlertOpen = false
|
||||
priceStreamLifecycle.value = 'open'
|
||||
clearConnectingLifecycle()
|
||||
priceSocketConnected.value = true
|
||||
touchStreamActivity()
|
||||
startStaleCheck()
|
||||
}
|
||||
|
||||
eventSource.onerror = () => {
|
||||
const state = eventSource?.readyState
|
||||
if (state === EventSource.OPEN || state === EventSource.CONNECTING) {
|
||||
return
|
||||
}
|
||||
|
||||
handleStreamLost()
|
||||
}
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
clearReconnectTimer()
|
||||
stopFallbackPolling()
|
||||
disconnectSourceOnly()
|
||||
priceSocketConnected.value = false
|
||||
priceStreamLifecycle.value = 'idle'
|
||||
clearConnectingLifecycle()
|
||||
}
|
||||
|
||||
export function forceReconnect() {
|
||||
if (stopped || subscribers <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
clearReconnectTimer()
|
||||
disconnect()
|
||||
connect()
|
||||
}
|
||||
|
||||
function onBrowserOnline() {
|
||||
if (stopped || subscribers <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
reconnectAttempt = 0
|
||||
networkAlertOpen = false
|
||||
forceReconnect()
|
||||
}
|
||||
|
||||
function onBrowserOffline() {
|
||||
handleStreamLost(true)
|
||||
void maybeShowNetworkAlert()
|
||||
}
|
||||
|
||||
function bindBrowserNetworkListeners() {
|
||||
if (listenersBound || typeof window === 'undefined') {
|
||||
return
|
||||
}
|
||||
|
||||
listenersBound = true
|
||||
window.addEventListener('online', onBrowserOnline)
|
||||
window.addEventListener('offline', onBrowserOffline)
|
||||
}
|
||||
|
||||
function unbindBrowserNetworkListeners() {
|
||||
if (!listenersBound || typeof window === 'undefined') {
|
||||
return
|
||||
}
|
||||
|
||||
listenersBound = false
|
||||
window.removeEventListener('online', onBrowserOnline)
|
||||
window.removeEventListener('offline', onBrowserOffline)
|
||||
}
|
||||
|
||||
export function startPriceSocket(settingGetter: (key: string) => unknown) {
|
||||
getSetting = settingGetter
|
||||
subscribers += 1
|
||||
stopped = false
|
||||
connect()
|
||||
bindBrowserNetworkListeners()
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
document.addEventListener('visibilitychange', onVisibilityChange)
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('pageshow', onPageShow)
|
||||
}
|
||||
}
|
||||
|
||||
export function stopPriceSocket() {
|
||||
subscribers = Math.max(0, subscribers - 1)
|
||||
if (subscribers > 0) {
|
||||
return
|
||||
}
|
||||
|
||||
stopped = true
|
||||
disconnect()
|
||||
unbindBrowserNetworkListeners()
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange)
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.removeEventListener('pageshow', onPageShow)
|
||||
}
|
||||
}
|
||||
|
||||
function onVisibilityChange() {
|
||||
if (stopped || subscribers <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
if (document.visibilityState === 'hidden') {
|
||||
reconnectAttempt = 0
|
||||
return
|
||||
}
|
||||
|
||||
reconnectAttempt = 0
|
||||
networkAlertOpen = false
|
||||
|
||||
if (pendingPriceAlert) {
|
||||
void maybeShowNetworkAlert()
|
||||
}
|
||||
|
||||
if (!eventSource || eventSource.readyState !== EventSource.OPEN) {
|
||||
forceReconnect()
|
||||
}
|
||||
}
|
||||
|
||||
function onPageShow(event: PageTransitionEvent) {
|
||||
if (stopped || subscribers <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
if (event.persisted || !eventSource || eventSource.readyState !== EventSource.OPEN) {
|
||||
reconnectAttempt = 0
|
||||
networkAlertOpen = false
|
||||
forceReconnect()
|
||||
if (pendingPriceAlert) {
|
||||
void maybeShowNetworkAlert()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function isPriceWebSocketEnabled(settingGetter: (key: string) => unknown): boolean {
|
||||
getSetting = settingGetter
|
||||
if (!isTruthySetting(settingGetter('wss_enabled'), true)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return resolveStreamUrl() !== null
|
||||
}
|
||||
|
||||
let channelStarted = false
|
||||
|
||||
function shutdownPriceRealtimeChannel() {
|
||||
if (!channelStarted && subscribers <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
channelStarted = false
|
||||
stopped = true
|
||||
subscribers = 0
|
||||
disconnect()
|
||||
unbindBrowserNetworkListeners()
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange)
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.removeEventListener('pageshow', onPageShow)
|
||||
}
|
||||
}
|
||||
|
||||
export function initPriceRealtimeChannel(settingGetter: (key: string) => unknown) {
|
||||
getSetting = settingGetter
|
||||
priceWssEnabled.value = isTruthySetting(settingGetter('wss_enabled'), true)
|
||||
|
||||
if (!priceWssEnabled.value || !isPriceWebSocketEnabled(settingGetter)) {
|
||||
shutdownPriceRealtimeChannel()
|
||||
return
|
||||
}
|
||||
|
||||
if (channelStarted && subscribers > 0) {
|
||||
forceReconnect()
|
||||
return
|
||||
}
|
||||
|
||||
channelStarted = true
|
||||
stopped = false
|
||||
startPriceSocket(settingGetter)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const priceSocketConnected = ref(false)
|
||||
export const priceWssEnabled = ref(false)
|
||||
|
||||
export type PriceStreamLifecycle = 'idle' | 'connecting' | 'open' | 'closed'
|
||||
|
||||
export const priceStreamLifecycle = ref<PriceStreamLifecycle>('idle')
|
||||
|
||||
export const priceStreamConnectingSince = ref(0)
|
||||
|
||||
const CONNECTING_POLL_AFTER_MS = 8000
|
||||
|
||||
export function shouldUsePricePolling(): boolean {
|
||||
if (!priceWssEnabled.value) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (priceStreamLifecycle.value === 'open') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (priceStreamLifecycle.value === 'connecting') {
|
||||
const since = priceStreamConnectingSince.value
|
||||
if (since > 0 && Date.now() - since >= CONNECTING_POLL_AFTER_MS) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import defaultImg from '@/assets/img/defaultAbshodeh.svg'
|
||||
import goyImg from '@/assets/img/goyImg.svg'
|
||||
import mokaabImg from '@/assets/img/mokaabImg.svg'
|
||||
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
||||
import parsianImg from '@/assets/img/parsianImg.svg'
|
||||
import venusImg from '@/assets/img/venousImg.svg'
|
||||
|
||||
export type ProductImageSource = {
|
||||
file?: { src?: string | null } | null
|
||||
group_type?: string | null
|
||||
} | null | undefined
|
||||
|
||||
function isUsableImageSrc(src?: string | null): boolean {
|
||||
if (!src) return false
|
||||
const value = src.trim()
|
||||
return value !== '' && value !== 'null' && value !== 'undefined'
|
||||
}
|
||||
|
||||
export function getProductFallbackImage(product?: ProductImageSource): string {
|
||||
const type = (product?.group_type ?? '').trim()
|
||||
if (!type) return defaultImg
|
||||
|
||||
const exactMap: Record<string, string> = {
|
||||
گوی: goyImg,
|
||||
مکعب: mokaabImg,
|
||||
سکه: sekkeImg,
|
||||
'شمش ونوس': venusImg,
|
||||
'سکه پارسیان': parsianImg,
|
||||
شمش: defaultImg,
|
||||
آبشده: defaultImg,
|
||||
}
|
||||
|
||||
if (exactMap[type]) return exactMap[type]
|
||||
|
||||
if (type.includes('پارسیان')) return parsianImg
|
||||
if (type.includes('ونوس')) return venusImg
|
||||
if (type.includes('گوی')) return goyImg
|
||||
if (type.includes('مکعب')) return mokaabImg
|
||||
if (type.includes('سکه')) return sekkeImg
|
||||
if (type.includes('شمش')) return defaultImg
|
||||
|
||||
return defaultImg
|
||||
}
|
||||
|
||||
export function resolveProductImageSrc(product?: ProductImageSource): string {
|
||||
const remoteSrc = product?.file?.src
|
||||
if (isUsableImageSrc(remoteSrc)) {
|
||||
return remoteSrc!.trim()
|
||||
}
|
||||
return getProductFallbackImage(product)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { Product } from '@/models/products'
|
||||
|
||||
type ProductListHandler = (products: Product[]) => void
|
||||
|
||||
const handlers = new Set<ProductListHandler>()
|
||||
|
||||
export function subscribeProductListStream(handler: ProductListHandler) {
|
||||
handlers.add(handler)
|
||||
|
||||
return () => {
|
||||
handlers.delete(handler)
|
||||
}
|
||||
}
|
||||
|
||||
export function applyProductsListFromStream(products: Product[]) {
|
||||
if (!Array.isArray(products) || !products.length) {
|
||||
return
|
||||
}
|
||||
|
||||
handlers.forEach((handler) => handler(products))
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
import { ref } from 'vue'
|
||||
import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { lastPrice } from '@/utils/price'
|
||||
|
||||
export interface StoreTradingHours {
|
||||
start: string
|
||||
end: string
|
||||
closePriceEnabled: boolean
|
||||
}
|
||||
|
||||
export interface EffectiveTradingHours {
|
||||
start: string
|
||||
end: string
|
||||
enforced: boolean
|
||||
}
|
||||
|
||||
const productTradingHours = ref<{ start: string; end: string } | null>(null)
|
||||
const productTradingHoursVersion = ref(0)
|
||||
|
||||
function normalizeTradingTimeSetting(value: unknown, fallback: string): string {
|
||||
const raw = String(value ?? '').trim()
|
||||
return raw || fallback
|
||||
}
|
||||
|
||||
function parseTimeToSeconds(time: string): number {
|
||||
const parts = time.trim().split(':').map(Number)
|
||||
const [hours = 0, minutes = 0, seconds = 0] = parts
|
||||
return hours * 3600 + minutes * 60 + seconds
|
||||
}
|
||||
|
||||
export function formatTradingTimeDisplay(time: string): string {
|
||||
const normalized = normalizeTradingTimeSetting(time, '')
|
||||
if (!normalized) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const parts = normalized.split(':')
|
||||
if (parts.length >= 3) {
|
||||
return `${parts[0]}:${parts[1]}:${parts[2]}`
|
||||
}
|
||||
if (parts.length >= 2) {
|
||||
return `${parts[0]}:${parts[1]}:00`
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
|
||||
function hasProductTradingWindow(start?: string | null, end?: string | null): boolean {
|
||||
const open = formatTradingTimeDisplay(normalizeTradingTimeSetting(start, '00:00:00'))
|
||||
const close = formatTradingTimeDisplay(normalizeTradingTimeSetting(end, '00:00:00'))
|
||||
if (!open || !close) {
|
||||
return false
|
||||
}
|
||||
|
||||
return open !== close
|
||||
}
|
||||
|
||||
export function setProductTradingHours(start?: string | null, end?: string | null) {
|
||||
if (!hasProductTradingWindow(start, end)) {
|
||||
productTradingHours.value = null
|
||||
productTradingHoursVersion.value += 1
|
||||
return
|
||||
}
|
||||
|
||||
productTradingHours.value = {
|
||||
start: normalizeTradingTimeSetting(start, '00:00'),
|
||||
end: normalizeTradingTimeSetting(end, '23:59'),
|
||||
}
|
||||
productTradingHoursVersion.value += 1
|
||||
}
|
||||
|
||||
export function syncProductTradingHoursFromProducts(
|
||||
products: Array<{ auto_open_at?: string | null; auto_close_at?: string | null }>,
|
||||
) {
|
||||
for (const product of products) {
|
||||
if (hasProductTradingWindow(product.auto_open_at, product.auto_close_at)) {
|
||||
setProductTradingHours(product.auto_open_at, product.auto_close_at)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
setProductTradingHours(null, null)
|
||||
}
|
||||
|
||||
export function getStoreTradingHours(): StoreTradingHours {
|
||||
const settings = useSettingsStore()
|
||||
const closeRaw = settings.getSettingByKey('close_price')
|
||||
const closePriceEnabled =
|
||||
closeRaw === true ||
|
||||
closeRaw === 1 ||
|
||||
String(closeRaw ?? 'false').trim().toLowerCase() === 'true'
|
||||
|
||||
return {
|
||||
start: normalizeTradingTimeSetting(settings.getSettingByKey('startDay'), '00:00'),
|
||||
end: normalizeTradingTimeSetting(settings.getSettingByKey('endDay'), '23:59'),
|
||||
closePriceEnabled,
|
||||
}
|
||||
}
|
||||
|
||||
export function getEffectiveTradingHours(): EffectiveTradingHours {
|
||||
void productTradingHoursVersion.value
|
||||
const settings = getStoreTradingHours()
|
||||
if (settings.closePriceEnabled) {
|
||||
return {
|
||||
start: settings.start,
|
||||
end: settings.end,
|
||||
enforced: true,
|
||||
}
|
||||
}
|
||||
|
||||
if (productTradingHours.value?.start && productTradingHours.value?.end) {
|
||||
return {
|
||||
start: productTradingHours.value.start,
|
||||
end: productTradingHours.value.end,
|
||||
enforced: true,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
start: settings.start,
|
||||
end: settings.end,
|
||||
enforced: false,
|
||||
}
|
||||
}
|
||||
|
||||
export function isStoreClosedBySchedule(now = new Date()): boolean {
|
||||
const { start, end, enforced } = getEffectiveTradingHours()
|
||||
if (!enforced) {
|
||||
return false
|
||||
}
|
||||
|
||||
const currentSeconds = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()
|
||||
const openSeconds = parseTimeToSeconds(start)
|
||||
const closeSeconds = parseTimeToSeconds(end)
|
||||
|
||||
return currentSeconds < openSeconds || currentSeconds > closeSeconds
|
||||
}
|
||||
|
||||
export function isStoreClosed(): boolean {
|
||||
void productTradingHoursVersion.value
|
||||
const { closePriceEnabled } = getStoreTradingHours()
|
||||
|
||||
if (closePriceEnabled) {
|
||||
if (lastPrice.value?.closed === true) {
|
||||
return true
|
||||
}
|
||||
|
||||
return isStoreClosedBySchedule()
|
||||
}
|
||||
|
||||
// وقتی close_price خاموش است، صفر بودن قیمت مرجع به معنی بسته بودن فروشگاه نیست.
|
||||
return isStoreClosedBySchedule()
|
||||
}
|
||||
|
||||
export function getStoreClosedMessage(): string {
|
||||
const { start, end } = getEffectiveTradingHours()
|
||||
const open = formatTradingTimeDisplay(start)
|
||||
const close = formatTradingTimeDisplay(end)
|
||||
|
||||
if (!open || !close) {
|
||||
return 'فروشگاه در حال حاضر بسته است.'
|
||||
}
|
||||
|
||||
return `فروشگاه در حال حاضر بسته است. ساعت کاری از ${open} تا ${close} میباشد.`
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import { ref } from 'vue'
|
||||
import { getSettings } from '@/api/configuration'
|
||||
|
||||
export type SupportMessengerType =
|
||||
| 'bale'
|
||||
| 'telegram'
|
||||
| 'whatsapp'
|
||||
| 'rubika'
|
||||
| 'eitaa'
|
||||
| 'soroush'
|
||||
|
||||
export interface SupportMessengerSettings {
|
||||
messenger?: SupportMessengerType | string
|
||||
messengerId?: string
|
||||
messengerText?: string
|
||||
}
|
||||
|
||||
export const supportMessengerSettings = ref<SupportMessengerSettings>({})
|
||||
|
||||
function getSupportSettingValue(
|
||||
settings: Array<{ key?: string; is_active?: boolean | number; value?: unknown }>,
|
||||
key: string
|
||||
) {
|
||||
const setting = settings.find((item) => item?.key === key)
|
||||
if (!setting) return ''
|
||||
|
||||
const value = setting.value
|
||||
if (value === undefined || value === null) return ''
|
||||
|
||||
return String(value).trim()
|
||||
}
|
||||
|
||||
export function buildSupportMessengerUrl(messenger?: string, messengerId?: string) {
|
||||
const id = (messengerId ?? '').trim()
|
||||
if (!id) return ''
|
||||
|
||||
if (/^https?:\/\//i.test(id)) return id
|
||||
|
||||
const type = (messenger ?? '').trim().toLowerCase()
|
||||
const username = id.replace(/^@/, '')
|
||||
|
||||
if (!type) return ''
|
||||
|
||||
switch (type) {
|
||||
case 'bale':
|
||||
if (id.includes('ble.ir')) {
|
||||
return id.startsWith('http') ? id : `https://${id.replace(/^\/\//, '')}`
|
||||
}
|
||||
return `https://ble.ir/${username}`
|
||||
case 'telegram':
|
||||
return `https://t.me/${username}`
|
||||
case 'whatsapp':
|
||||
return `https://wa.me/${username.replace(/\D/g, '')}`
|
||||
case 'rubika':
|
||||
return `https://rubika.ir/${username}`
|
||||
case 'eitaa':
|
||||
return `https://eitaa.com/${username}`
|
||||
case 'soroush':
|
||||
return `https://splus.ir/splus/${username}`
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadSupportMessengerFromSettings() {
|
||||
try {
|
||||
const settings = await getSettings()
|
||||
if (!settings || !Array.isArray(settings)) return
|
||||
|
||||
supportMessengerSettings.value = {
|
||||
messenger: getSupportSettingValue(settings, 'support_messenger'),
|
||||
messengerId: getSupportSettingValue(settings, 'support_messenger_id'),
|
||||
messengerText: getSupportSettingValue(settings, 'support_messenger_text'),
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import {baseURL} from '@/themeConfig'
|
||||
import { getConfigApp } from '@/utils/config'
|
||||
import { baseURL as fallbackBaseURL } from '@/themeConfig'
|
||||
import type {AxiosRequestConfig, AxiosResponse} from 'axios'
|
||||
import axios from 'axios'
|
||||
import {getToken, removeToken} from "@/utils";
|
||||
@@ -20,12 +21,16 @@ const headers = {
|
||||
}
|
||||
|
||||
const _axios = axios.create({
|
||||
baseURL,
|
||||
headers,
|
||||
baseURL: fallbackBaseURL,
|
||||
headers,
|
||||
})
|
||||
|
||||
_axios.interceptors.request.use(
|
||||
(config) => {
|
||||
const runtimeBaseURL = getConfigApp('node_server')
|
||||
if (runtimeBaseURL) {
|
||||
config.baseURL = runtimeBaseURL
|
||||
}
|
||||
//console.log('request config', config)
|
||||
if (config.headers) {
|
||||
const token = getToken()
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
|
||||
const DRAG_THRESHOLD = 6
|
||||
|
||||
type FabPosition = { x: number; y: number }
|
||||
|
||||
type DraggableFloatingOptions = {
|
||||
width?: number
|
||||
height?: number
|
||||
defaultBottomOffset?: number
|
||||
defaultRightOffset?: number
|
||||
}
|
||||
|
||||
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 pos = ref<FabPosition>({ x: 0, y: 0 })
|
||||
const dragging = ref(false)
|
||||
|
||||
let pointerId: number | null = null
|
||||
let startX = 0
|
||||
let startY = 0
|
||||
let originX = 0
|
||||
let originY = 0
|
||||
let hasMoved = false
|
||||
|
||||
const fabStyle = computed(() => ({
|
||||
left: `${pos.value.x}px`,
|
||||
top: `${pos.value.y}px`,
|
||||
width: `${width}px`,
|
||||
touchAction: 'none'
|
||||
}))
|
||||
|
||||
function getViewportWidth() {
|
||||
return Math.min(window.innerWidth, 426)
|
||||
}
|
||||
|
||||
function getHorizontalOffset() {
|
||||
const vw = window.innerWidth
|
||||
const contentWidth = getViewportWidth()
|
||||
return Math.max(0, (vw - contentWidth) / 2)
|
||||
}
|
||||
|
||||
function resetToDefault() {
|
||||
const vh = window.innerHeight
|
||||
const offsetX = getHorizontalOffset()
|
||||
const contentWidth = getViewportWidth()
|
||||
|
||||
pos.value = {
|
||||
x: offsetX + contentWidth - width - defaultRightOffset,
|
||||
y: vh - defaultBottomOffset - height
|
||||
}
|
||||
}
|
||||
|
||||
function clampToViewport() {
|
||||
const vw = window.innerWidth
|
||||
const vh = window.innerHeight
|
||||
|
||||
pos.value = {
|
||||
x: Math.max(0, Math.min(vw - width, pos.value.x)),
|
||||
y: Math.max(0, Math.min(vh - height, pos.value.y))
|
||||
}
|
||||
}
|
||||
|
||||
function loadPosition() {
|
||||
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()
|
||||
return true
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function savePosition() {
|
||||
localStorage.setItem(storageKey, JSON.stringify(pos.value))
|
||||
}
|
||||
|
||||
function handleResize() {
|
||||
clampToViewport()
|
||||
savePosition()
|
||||
}
|
||||
|
||||
function handlePointerDown(event: PointerEvent) {
|
||||
dragging.value = true
|
||||
hasMoved = false
|
||||
pointerId = event.pointerId
|
||||
startX = event.clientX
|
||||
startY = event.clientY
|
||||
originX = pos.value.x
|
||||
originY = pos.value.y
|
||||
;(event.currentTarget as HTMLElement)?.setPointerCapture?.(event.pointerId)
|
||||
}
|
||||
|
||||
function handlePointerMove(event: PointerEvent) {
|
||||
if (!dragging.value || pointerId !== event.pointerId) return
|
||||
|
||||
const dx = event.clientX - startX
|
||||
const dy = event.clientY - startY
|
||||
|
||||
if (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD) {
|
||||
hasMoved = true
|
||||
}
|
||||
|
||||
pos.value = {
|
||||
x: originX + dx,
|
||||
y: originY + dy
|
||||
}
|
||||
clampToViewport()
|
||||
}
|
||||
|
||||
function finishPointer(event: PointerEvent) {
|
||||
if (!dragging.value || pointerId !== event.pointerId) return false
|
||||
|
||||
dragging.value = false
|
||||
pointerId = null
|
||||
savePosition()
|
||||
|
||||
const clicked = !hasMoved
|
||||
hasMoved = false
|
||||
return clicked
|
||||
}
|
||||
|
||||
function handlePointerUp(event: PointerEvent) {
|
||||
return finishPointer(event)
|
||||
}
|
||||
|
||||
function handlePointerCancel(event: PointerEvent) {
|
||||
finishPointer(event)
|
||||
return false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!loadPosition()) {
|
||||
resetToDefault()
|
||||
}
|
||||
window.addEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
return {
|
||||
dragging,
|
||||
fabStyle,
|
||||
handlePointerDown,
|
||||
handlePointerMove,
|
||||
handlePointerUp,
|
||||
handlePointerCancel,
|
||||
resetToDefault
|
||||
}
|
||||
}
|
||||
@@ -24,3 +24,58 @@ export function useTowDecimal(num: string | number): string | number {
|
||||
export function useFormat(num: string | number, unit = '') {
|
||||
return usePrice(Math.abs(+useTowDecimal(num)), true, unit)
|
||||
}
|
||||
|
||||
type TransactionPriceSource = {
|
||||
cash?: number | null
|
||||
gold?: number | null
|
||||
order?: {
|
||||
price?: number | null
|
||||
total_price?: number | null
|
||||
amount?: number | null
|
||||
} | null
|
||||
}
|
||||
|
||||
export function getTransactionTradePrice(item: TransactionPriceSource): number {
|
||||
const orderPrice = Number(item.order?.price)
|
||||
if (Number.isFinite(orderPrice) && orderPrice > 0) {
|
||||
return Math.round(orderPrice)
|
||||
}
|
||||
|
||||
const cashAmount = Math.abs(Number(item.cash) || 0)
|
||||
const goldAmount =
|
||||
Math.abs(Number(item.gold) || 0) || Math.abs(Number(item.order?.amount) || 0)
|
||||
|
||||
if (goldAmount > 0 && cashAmount > 0) {
|
||||
return Math.round(cashAmount / goldAmount)
|
||||
}
|
||||
|
||||
const totalPrice = Number(item.order?.total_price)
|
||||
if (Number.isFinite(totalPrice) && totalPrice > 0) {
|
||||
return Math.round(totalPrice)
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
export function getTransactionGoldAmount(item: TransactionPriceSource): number {
|
||||
const gold = Number(item.gold) || 0
|
||||
if (Math.abs(gold) > 0) {
|
||||
return gold
|
||||
}
|
||||
|
||||
const orderAmount = Number(item.order?.amount) || 0
|
||||
if (orderAmount > 0) {
|
||||
const cash = Number(item.cash) || 0
|
||||
if (cash < 0) return orderAmount
|
||||
if (cash > 0) return -orderAmount
|
||||
return orderAmount
|
||||
}
|
||||
|
||||
return gold
|
||||
}
|
||||
|
||||
export function formatGoldAmount(amount?: number | null): string {
|
||||
const num = Number(amount)
|
||||
if (!Number.isFinite(num)) return '0'
|
||||
return String(Number(num.toFixed(3)))
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ export function useProduct(product: Ref<Product> | Product) {
|
||||
if (temp && temp.file) {
|
||||
return temp.file.src
|
||||
}
|
||||
return 'Ghatreh'
|
||||
return 'kashkol'
|
||||
}
|
||||
|
||||
const collection = computed(() => {
|
||||
|
||||
@@ -17,60 +17,60 @@
|
||||
<div class="bg-primary text-white rounded-[12px] p-4 text-xs leading-5">
|
||||
<div class="w-full h-1px my-3 bg-tertiary"></div>
|
||||
<div>
|
||||
قطره وبسایت رسمی خانواده نور هشتم برای خرید شمش طلا است؛ بستری امن، شفاف و قابل اعتماد که با هدف سادهسازی سرمایهگذاری در طلا طراحی شده است.
|
||||
کشکول گلد وبسایت رسمی تست.
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
این وبسایت با پشتوانه سه مجموعه معتبر نور هشتم فعالیت میکند و امکان خرید شمش طلا را از وزنهای خرد تا معاملات عمده، با قیمت شفاف و امنیت کامل فراهم میسازد.
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
تمامی فرآیندهای خرید در قطره بر اساس استانداردهای حرفهای بازار طلا و با اتکا به اعتبار مجموعههای نور هشتم مشهد، نورهشتم فردوس و نورهشتم (داماس) بجستان انجام میشود تا کاربران با آرامش و اطمینان کامل اقدام به خرید کنند.
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
قطرهقطره، بانکی از طلا بساز...
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
برای ارتباط حضوری، دریافت مشاوره و اطمینان بیشتر، کاربران میتوانند از طریق آدرسهای سه شعبه رسمی نور هشتم با مجموعه در ارتباط باشند و از پشتیبانی مستقیم مجموعه بهرهمند شوند.
|
||||
</div>
|
||||
<div class="w-full h-1px my-3 bg-tertiary"></div>
|
||||
<!-- <div class="mt-3 text-xl font-bold">چرا قطره؟</div>
|
||||
<!-- <div class="mt-3">-->
|
||||
<!-- این وبسایت با پشتوانه سه مجموعه معتبر نور هشتم فعالیت میکند و امکان خرید شمش طلا را از وزنهای خرد تا معاملات عمده، با قیمت شفاف و امنیت کامل فراهم میسازد.-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="mt-3">-->
|
||||
<!-- تمامی فرآیندهای خرید در کشکول گلد بر اساس استانداردهای حرفهای بازار طلا و با اتکا به اعتبار مجموعههای نور هشتم مشهد، نورهشتم فردوس و نورهشتم (داماس) بجستان انجام میشود تا کاربران با آرامش و اطمینان کامل اقدام به خرید کنند.-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="mt-3">-->
|
||||
<!-- کشکول گلدکشکول گلد، بانکی از طلا بساز...-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="mt-3">-->
|
||||
<!-- برای ارتباط حضوری، دریافت مشاوره و اطمینان بیشتر، کاربران میتوانند از طریق آدرسهای سه شعبه رسمی نور هشتم با مجموعه در ارتباط باشند و از پشتیبانی مستقیم مجموعه بهرهمند شوند.-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="w-full h-1px my-3 bg-tertiary"></div>-->
|
||||
<!-- <div class="mt-3 text-xl font-bold">چرا کشکول گلد؟</div>
|
||||
<div class="mt-3">
|
||||
۱. خرید بدون اجرت و مالیات
|
||||
طلایی که از اپلیکیشن قطره خریداری میکنید، بدون اجرت ساخت و مالیات محاسبه میشود و تنها ۰.۵٪ کارمزد از شما دریافت خواهد شد.
|
||||
طلایی که از اپلیکیشن کشکول گلد خریداری میکنید، بدون اجرت ساخت و مالیات محاسبه میشود و تنها ۰.۵٪ کارمزد از شما دریافت خواهد شد.
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
۲. خرید بدون محدودیت
|
||||
در قطره میتوانید از ۵۰ سوت تا چند کیلوگرم طلا را بهصورت آنلاین و بدون هیچگونه محدودیت مکانی خریداری کنید
|
||||
در کشکول گلد میتوانید از ۵۰ سوت تا چند کیلوگرم طلا را بهصورت آنلاین و بدون هیچگونه محدودیت مکانی خریداری کنید
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
۳. فعالیت در ساعات رسمی معاملات طلا
|
||||
برای رعایت قوانین صنف طلا و جلوگیری از خالیفروشی، فعالیت اپلیکیشن قطره منطبق با ساعات رسمی معاملات اتحادیه طلافروشان کشور است.
|
||||
برای رعایت قوانین صنف طلا و جلوگیری از خالیفروشی، فعالیت اپلیکیشن کشکول گلد منطبق با ساعات رسمی معاملات اتحادیه طلافروشان کشور است.
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
۴. امکان تحویل فیزیکی طلا
|
||||
قطره دارای شعب حضوری معتبر با مجوز خردهفروشی طلاست تا کاربران بتوانند در صورت تمایل، طلای خریداریشده خود را بهصورت فیزیکی تحویل بگیرند و از نزدیک از اصالت آن اطمینان حاصل کنند.
|
||||
کشکول گلد دارای شعب حضوری معتبر با مجوز خردهفروشی طلاست تا کاربران بتوانند در صورت تمایل، طلای خریداریشده خود را بهصورت فیزیکی تحویل بگیرند و از نزدیک از اصالت آن اطمینان حاصل کنند.
|
||||
</div>
|
||||
<div class="w-full h-1px my-3 bg-tertiary"></div>-->
|
||||
<div class="mt-3">
|
||||
آدرس شعب ما:
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
مشهد : خیابان امام خمینی / برج طلا و جواهر مرمر / طبقه همکف / واحد 16 / طلا و سکه نورهشتم
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
فردوس : خیابان امام خمینی / بعد از امام خمینی 11 / طلا و سکه نورهشتم
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
بجستان : خیابان امام خمینی / چهارراه وحدت / طلا و جواهر داماس [طلا و سکه نورهشتم]
|
||||
</div>
|
||||
<div class="w-full h-1px my-3 bg-tertiary"></div>
|
||||
<!-- <div class="mt-3">-->
|
||||
<!-- آدرس شعب ما:-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="mt-3">-->
|
||||
<!-- مشهد : خیابان امام خمینی / برج طلا و جواهر مرمر / طبقه همکف / واحد 16 / طلا و سکه نورهشتم-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="mt-3">-->
|
||||
<!-- فردوس : خیابان امام خمینی / بعد از امام خمینی 11 / طلا و سکه نورهشتم-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="mt-3">-->
|
||||
<!-- بجستان : خیابان امام خمینی / چهارراه وحدت / طلا و جواهر داماس [طلا و سکه نورهشتم]-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="w-full h-1px my-3 bg-tertiary"></div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wrap-fix bottom-0 px-10 py-6 flex gap-2 bg-white items-center">
|
||||
<a class="w-full" href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
|
||||
<a class="w-full" href="https://web.rubika.ir/#">
|
||||
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
|
||||
</a>
|
||||
<a href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c">
|
||||
<a href="https://web.rubika.ir/#">
|
||||
<img src="@/assets/img/rubika.webp" alt="" class=" w-12"/>
|
||||
</a>
|
||||
</div>
|
||||
@@ -132,12 +132,12 @@ function shareCode() {
|
||||
const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر!
|
||||
با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر!
|
||||
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای قطره جا نمونید.
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای کشکول گلد جا نمونید.
|
||||
روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید.
|
||||
|
||||
ghatreh.gold/login?id=${userStore.userInfo?.referral_id}`
|
||||
kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}`
|
||||
navigator.share({
|
||||
title: 'قطره',
|
||||
title: 'کشکول گلد',
|
||||
text: val
|
||||
})
|
||||
// message.info('کد رونوشت شد')
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div>سبد خرید</div>
|
||||
<!-- Price Display in Header -->
|
||||
<div v-if="price" class="flex gap-1 items-center text-xs flex-1 justify-end">
|
||||
<span class="text-gray-600 text-xs">قیمت خرید از قطره:</span>
|
||||
<span class="text-gray-600 text-xs">قیمت خرید از کشکول گلد:</span>
|
||||
<div class="font-bold text-base" style="font-family: iran-sans; direction: ltr">
|
||||
{{ usePriceWithoutType(price?.price_last ?? 0) }}
|
||||
</div>
|
||||
@@ -15,7 +15,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<GoldLoading v-model:show="infoVisible" title=""/>
|
||||
<div class="px-5 pt-26 pb-30">
|
||||
<div class="px-5 pt-26 pb-30" :class="loading ? 'h-[60vh]' : ''">
|
||||
<template v-if="loading">
|
||||
<TransactionSkeleton v-for="i in 3" :key="i" class="mt-4" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<!-- Empty Cart Message -->
|
||||
<div v-if="cartStore.itemCount === 0" class="flex flex-col items-center justify-center h-[60vh]">
|
||||
<div class="text-gray-500 text-lg font-semibold mb-4">سبد خرید شما خالی است</div>
|
||||
@@ -35,10 +39,9 @@
|
||||
<div class="flex gap-4">
|
||||
<!-- Product Image -->
|
||||
<div class="bg-gray-100 rounded-lg flex justify-center items-center p-1 min-w-[80px] h-[80px]">
|
||||
<img
|
||||
:src="getProductImage(item.product)"
|
||||
class="max-w-full max-h-full object-contain"
|
||||
alt=""
|
||||
<ProductImage
|
||||
:product="item.product"
|
||||
img-class="max-w-full max-h-full object-contain"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -75,38 +78,71 @@
|
||||
</div>
|
||||
|
||||
<!-- Total and Checkout -->
|
||||
<div class="fixed bottom-20 left-0 right-0 bg-white border-t border-gray-200 p-4 shadow-lg z-1">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<div class="text-lg font-semibold">مجموع:</div>
|
||||
<div class="flex flex-col gap-2 ">
|
||||
<div class="text-primary font-bold text-xl">
|
||||
{{ usePrice(displaytotalPrice) }}
|
||||
<div class=" flex justify-center fixed bottom-20 left-0 right-0 z-1">
|
||||
<div class="md:w-[426px] w-full bg-white border-t border-gray-200 p-4 shadow-lg">
|
||||
<div
|
||||
v-if="discountInfo?.amount > 0"
|
||||
class="mb-3 flex items-center justify-between rounded-lg bg-purple-50 px-3 py-2"
|
||||
>
|
||||
<div class="flex flex-col gap-0.5 text-sm">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-gray-600">کد تخفیف:</span>
|
||||
<span class="font-semibold">{{ discountInfo.code }}</span>
|
||||
</div>
|
||||
<div class="text-xs text-green-600">
|
||||
{{ discountPercentLabel }} تخفیف اعمال شد
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-1 text-xs text-red-500"
|
||||
@click="removeDiscount"
|
||||
>
|
||||
<BasicIcon icon="vuesax-linear:close-circle" size="18" />
|
||||
<span>حذف</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="!text-primary font-bold text-xs line-through cursor-pointer "
|
||||
v-if="discountInfo?.amount>0"
|
||||
@click="showDiscountModal=true">
|
||||
{{ usePrice(totalPrice) }}
|
||||
</div>
|
||||
<div v-else
|
||||
class="!text-primary font-bold text-xs underline-solid underline cursor-pointer"
|
||||
@click="showDiscountModal=true">
|
||||
کد تخفیف دارم
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<div class="text-lg font-semibold">مجموع:</div>
|
||||
<div class="flex flex-col items-end gap-1">
|
||||
<div class="text-primary font-bold text-xl">
|
||||
{{ usePrice(displaytotalPrice) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="discountInfo?.amount > 0"
|
||||
class="text-xs text-gray-400 line-through"
|
||||
>
|
||||
{{ usePrice(totalPrice) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="!discountInfo?.amount"
|
||||
class="mb-3 text-center"
|
||||
>
|
||||
<span
|
||||
class="text-xs text-primary underline cursor-pointer"
|
||||
@click="showDiscountModal = true"
|
||||
>
|
||||
کد تخفیف دارم
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<BasicButton
|
||||
class="w-full py-3"
|
||||
type="primary"
|
||||
size="large"
|
||||
@click="handleCheckout"
|
||||
>
|
||||
تسویه حساب
|
||||
</BasicButton>
|
||||
</div>
|
||||
<BasicButton
|
||||
class="w-full py-3"
|
||||
type="primary"
|
||||
size="large"
|
||||
@click="handleCheckout"
|
||||
>
|
||||
تسویه حساب
|
||||
</BasicButton>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<AModal v-model:visible="showDiscountModal" ok-text="اعمال کد تخفیف" cancel-text="انصراف" @ok="submitDiscount"
|
||||
@@ -143,15 +179,10 @@ import {useFundUserStore} from '@/store/fundStore'
|
||||
import type {Price} from '@/models/home'
|
||||
import type {Order} from '@/models/order'
|
||||
|
||||
// Image imports
|
||||
import defaultImg from '@/assets/img/defaultAbshodeh.svg'
|
||||
import goyImg from '@/assets/img/goyImg.svg'
|
||||
import mokaabImg from '@/assets/img/mokaabImg.svg'
|
||||
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
||||
import parsianImg from '@/assets/img/parsianImg.svg'
|
||||
import venusImg from '@/assets/img/venousImg.svg'
|
||||
import {loading, getToken} from '@/utils'
|
||||
import GoldLoading from '@/components/GoldLoading.vue'
|
||||
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||
import ProductImage from '@/components/ProductImage.vue'
|
||||
import {registerCodeDiscount} from "@/api/giftCard";
|
||||
|
||||
const cartStore = useCartStore()
|
||||
@@ -167,28 +198,8 @@ const price = computed((): Price => <Price>lastPrice.value ?? 0)
|
||||
|
||||
// Watch for price updates and update cart items
|
||||
watch(lastPrice, () => {
|
||||
if (lastPrice.value && cartStore.cartItems.length > 0) {
|
||||
cartStore.cartItems.forEach((item) => {
|
||||
const product = item.product
|
||||
let newPrice = 0
|
||||
|
||||
if (product.group_type == 'آبشده') {
|
||||
newPrice = lastPrice.value?.price_last ?? 0
|
||||
} else {
|
||||
newPrice = product.amount * (lastPrice.value?.price_last ?? 0)
|
||||
}
|
||||
|
||||
// Update product price
|
||||
product.price = newPrice
|
||||
product.sellPrice = product.amount * (lastPrice.value?.sell ?? 0)
|
||||
|
||||
// Update item price and total price
|
||||
item.price = newPrice + (product.cash_fee_buy ?? 0)
|
||||
item.totalPrice = parseInt(item.price * item.quantity)
|
||||
})
|
||||
|
||||
// Save updated prices to storage
|
||||
cartStore.saveCartToStorage()
|
||||
if (lastPrice.value) {
|
||||
cartStore.recalculateCartPrices(lastPrice.value)
|
||||
}
|
||||
}, {deep: true, immediate: false})
|
||||
|
||||
@@ -204,6 +215,18 @@ const displaytotalPrice = computed(() => {
|
||||
return totalPrice.value
|
||||
})
|
||||
|
||||
const discountPercentLabel = computed(() => {
|
||||
const amount = Number(discountInfo.value?.amount ?? 0)
|
||||
if (amount <= 0) return ''
|
||||
return `${Math.round(amount * 100)}٪`
|
||||
})
|
||||
|
||||
function removeDiscount() {
|
||||
discountInfo.value = undefined
|
||||
discountCode.value = ''
|
||||
message.success('کد تخفیف حذف شد')
|
||||
}
|
||||
|
||||
async function submitDiscount() {
|
||||
try {
|
||||
loading.value = true
|
||||
@@ -219,30 +242,6 @@ async function submitDiscount() {
|
||||
}
|
||||
}
|
||||
|
||||
function getProductImage(product: any) {
|
||||
// Check if product has file field from server with src property
|
||||
if (product?.file?.src) {
|
||||
return product.file.src
|
||||
}
|
||||
|
||||
// Fallback to local images based on group_type if file is empty or doesn't exist
|
||||
const type = product?.group_type
|
||||
switch (type) {
|
||||
case 'گوی':
|
||||
return goyImg
|
||||
case 'مکعب':
|
||||
return mokaabImg
|
||||
case 'سکه':
|
||||
return sekkeImg
|
||||
case 'شمش ونوس':
|
||||
return venusImg
|
||||
case 'سکه پارسیان':
|
||||
return parsianImg
|
||||
default:
|
||||
return defaultImg
|
||||
}
|
||||
}
|
||||
|
||||
function getProductAmount(amount?: number) {
|
||||
if (!amount) return ''
|
||||
if (amount < 1) {
|
||||
@@ -313,8 +312,8 @@ async function handleCheckout() {
|
||||
|
||||
if (cashItemsTotal > 0) {
|
||||
// Ensure wallet info is loaded
|
||||
if (discountInfo.value.amount>0){
|
||||
cashItemsTotal=cashItemsTotal-cashItemsTotal*discountInfo.value.amount
|
||||
if (discountInfo.value?.amount && discountInfo.value?.amount>0){
|
||||
cashItemsTotal=cashItemsTotal-cashItemsTotal*discountInfo.value?.amount
|
||||
}
|
||||
if (!walletStore.walletInfo) {
|
||||
await walletStore.getMyWallet()
|
||||
@@ -348,11 +347,11 @@ async function handleCheckout() {
|
||||
}
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
infoVisible.value = true
|
||||
|
||||
// Prepare orders array with same structure as createOrder for each product
|
||||
const orders: Order[] = cartStore.cartItems.map(item => {
|
||||
console.log(item)
|
||||
const product = item.product
|
||||
// Calculate price similar to createOrder (buy price)
|
||||
let productPrice = 0
|
||||
@@ -370,7 +369,7 @@ async function handleCheckout() {
|
||||
product_id: product.id,
|
||||
method: item.method,
|
||||
number: item.quantity,
|
||||
discount_code:discountInfo.value.code
|
||||
discount_code:discountInfo.value?.code
|
||||
}
|
||||
})
|
||||
|
||||
@@ -413,40 +412,37 @@ async function initPrice() {
|
||||
try {
|
||||
await getLastPrices()
|
||||
await setIntervalGetLastPrice()
|
||||
|
||||
// Update prices for all cart items
|
||||
if (lastPrice.value && cartStore.cartItems.length > 0) {
|
||||
cartStore.cartItems.forEach((item) => {
|
||||
const product = item.product
|
||||
let newPrice = 0
|
||||
|
||||
if (product.group_type == 'آبشده') {
|
||||
newPrice = lastPrice.value?.price_last ?? 0
|
||||
} else {
|
||||
newPrice = product.amount * (lastPrice.value?.price_last ?? 0)
|
||||
}
|
||||
|
||||
// Update product price
|
||||
product.price = newPrice
|
||||
product.sellPrice = product.amount * (lastPrice.value?.sell ?? 0)
|
||||
|
||||
// Update item price and total price
|
||||
item.price = newPrice + (product.cash_fee_buy ?? 0)
|
||||
item.totalPrice = parseInt(item.price * item.quantity)
|
||||
})
|
||||
|
||||
// Save updated prices to storage
|
||||
cartStore.saveCartToStorage()
|
||||
if (lastPrice.value) {
|
||||
cartStore.recalculateCartPrices(lastPrice.value)
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshCart() {
|
||||
const removedCount = await cartStore.refreshCartFromServer()
|
||||
if (removedCount > 0) {
|
||||
message.warning(`${removedCount} محصول از سبد خرید حذف شد (دیگر در دسترس نیست)`)
|
||||
}
|
||||
if (lastPrice.value) {
|
||||
cartStore.recalculateCartPrices(lastPrice.value)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// Load cart from storage if needed
|
||||
cartStore.loadCartFromStorage()
|
||||
await initPrice()
|
||||
loading.value = true
|
||||
try {
|
||||
await initPrice()
|
||||
await refreshCart()
|
||||
const refreshCartInfo=setInterval(async () => {
|
||||
await refreshCart()
|
||||
// await getUpPrice()
|
||||
}, 10000)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4">
|
||||
<div class=" p-3 border-solid border-1 rounded-[8px] border-[#521620] ">
|
||||
<div class=" p-3 border-solid border-1 rounded-[8px] border-[#a72b77] ">
|
||||
<div class="flex items-center">
|
||||
<div class=" bg-[#DBEAFE] h-10 w-10 rounded-100% flex justify-center items-center">
|
||||
<img :src="coin" />
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="font-bold">دعوت دوستان</div>
|
||||
<!-- <div class="text-xs ">راهنمای کسب درآمد</div>-->
|
||||
</div>
|
||||
<div class=" mt-2 text-xs">با دعوت دوستانتان به اپلیکیشن قطره،
|
||||
<div class=" mt-2 text-xs">با دعوت دوستانتان به اپلیکیشن کشکول گلد،
|
||||
دوست شما اولین خرید خود را بدون کارمزد انجام میدهد
|
||||
و شما نیز ۱۰٪ از کارمزد ۱۰ معاملهی اول او را بهعنوان پاداش دریافت میکنید. 💰</div>
|
||||
</div>
|
||||
@@ -62,10 +62,10 @@
|
||||
</div>
|
||||
<!-- //**************************************-->
|
||||
<!-- <div class="flex mt-6">-->
|
||||
<!-- <div class="bg-[#521620] p-2 rounded-[8px] w-full">-->
|
||||
<!-- <div class="bg-[#a72b77] p-2 rounded-[8px] w-full">-->
|
||||
<!-- <div class="text-white text-center">فهرست زیرمجموعه</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="bg-[#521620] p-2 rounded-[8px] w-full mr-2">-->
|
||||
<!-- <div class="bg-[#a72b77] p-2 rounded-[8px] w-full mr-2">-->
|
||||
<!-- <div class="text-white text-center">پاداش ها</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
@@ -119,12 +119,12 @@ function shareCode() {
|
||||
const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر!
|
||||
با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر!
|
||||
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای قطره جا نمونید.
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای کشکول گلد جا نمونید.
|
||||
روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید.
|
||||
|
||||
ghatreh.gold/login?id=${userStore.userInfo?.referral_id}`
|
||||
kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}`
|
||||
navigator.share({
|
||||
title: 'قطره',
|
||||
title: 'کشکول گلد',
|
||||
text: val
|
||||
})
|
||||
// message.info('کد رونوشت شد')
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
<div class="ml-1 text-base text-black">{{ info?.wallet[0]?.gold }}</div>
|
||||
گرم
|
||||
</div>
|
||||
<div v-if="rialEquivalent !== null" class="mt-1 text-xs text-gray-400">
|
||||
{{ usePriceWithoutType(rialEquivalent) }} ریال
|
||||
</div>
|
||||
<div class="text-gray-400">موجودی قلک {{ info?.title }}</div>
|
||||
<div class="w-full p-5">
|
||||
<div class="w-full flex gap-3">
|
||||
@@ -148,8 +145,6 @@ import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
||||
import DialogVant from '@/components/DialogVant.vue'
|
||||
import { useFundUserStore } from '@/store/fundStore'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import { getLastPrices, lastPrice } from '@/utils/price'
|
||||
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||
|
||||
const info = ref<Fund>()
|
||||
const items = ref<Transaction[]>([])
|
||||
@@ -164,16 +159,8 @@ let fundStore = useFundUserStore()
|
||||
let walletStore = useWalletStore()
|
||||
|
||||
|
||||
const rialEquivalent = computed(() => {
|
||||
const unit = Number(lastPrice.value?.price_last ?? 0)
|
||||
if (!unit) return null
|
||||
const gold = Number(info.value?.wallet?.[0]?.gold ?? 0)
|
||||
return Math.round(gold * unit)
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
initInfo()
|
||||
if (!lastPrice.value) getLastPrices()
|
||||
// initTable()
|
||||
})
|
||||
|
||||
|
||||
@@ -48,14 +48,14 @@
|
||||
<bg_main/>
|
||||
<div class="z-100 relative">
|
||||
<a-form-item>
|
||||
<BasicInput v-model:value="form.goldCash" addon-before="ریال" addon-bg-color="#521620"
|
||||
<BasicInput v-model:value="form.goldCash" addon-before="ریال" addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
place-holder="ارزش کل"
|
||||
size="large"
|
||||
type="price" @onchange="calculateGold" />
|
||||
</a-form-item>
|
||||
<a-form-item :rules="[justNumber()]">
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="گرم" addon-bg-color="#521620"
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="گرم" addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
place-holder="مقدار طلا"
|
||||
size="large" type="text" inputmode="decimal" @onchange="calculateCash" />
|
||||
@@ -650,7 +650,7 @@ async function ok() {
|
||||
|
||||
<style lang="less">
|
||||
.completeButtonStyle .van-dialog__confirm .van-button__content {
|
||||
background-color: #521620;
|
||||
background-color: #a72b77;
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
<div class="flex flex-col gap-7 rounded-lg p-4 w-56 bg-white ">
|
||||
<div class="flex justify-between items-center font-medium text-sm">
|
||||
<div class="text-primary">موجودی {{ props.ProductItem.title }}</div>
|
||||
<BasicIcon v-if="props.ProductItem.group_type=='گوی'" stroke-width="1" size="50" color="#521620" class="rotate-310" icon="vuesax-linear:grammerly"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='سکه'" stroke-width="1" size="50" color="#521620" class="rotate-310" icon="vuesax-linear:coin"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='شمش'" stroke-width="1" size="50" color="#521620" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='مکعب'" stroke-width="1" size="50" color="#521620" class="rotate-310" icon="vuesax-linear:keyboard"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='آبشده'" stroke-width="1" size="50" color="#521620" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
|
||||
<BasicIcon v-else stroke-width="1" size="50" color="#521620" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
|
||||
<BasicIcon v-if="props.ProductItem.group_type=='گوی'" stroke-width="1" size="50" color="#a72b77" class="rotate-310" icon="vuesax-linear:grammerly"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='سکه'" stroke-width="1" size="50" color="#a72b77" class="rotate-310" icon="vuesax-linear:coin"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='شمش'" stroke-width="1" size="50" color="#a72b77" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='مکعب'" stroke-width="1" size="50" color="#a72b77" class="rotate-310" icon="vuesax-linear:keyboard"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='آبشده'" stroke-width="1" size="50" color="#a72b77" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
|
||||
<BasicIcon v-else stroke-width="1" size="50" color="#a72b77" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
|
||||
</div>
|
||||
<div class="flex justify-between px-2 items-center ">
|
||||
<BasicIcon v-if="props.ProductItem.group_type=='گوی'" stroke-width="1" size="26" color="#521620" class="rotate-310" icon="vuesax-linear:grammerly"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='سکه'" stroke-width="1" size="26" color="#521620" class="rotate-310" icon="vuesax-linear:coin"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='شمش'" stroke-width="1" size="26" color="#521620" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='مکعب'" stroke-width="1" size="26" color="#521620" class="rotate-310" icon="vuesax-linear:keyboard"/>
|
||||
<BasicIcon v-else stroke-width="1" size="26" color="#521620" class="rotate-310" icon="vuesax-linear:slider-vertical"/> <div class="flex justify-between gap-2 items-center">
|
||||
<BasicIcon v-if="props.ProductItem.group_type=='گوی'" stroke-width="1" size="26" color="#a72b77" class="rotate-310" icon="vuesax-linear:grammerly"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='سکه'" stroke-width="1" size="26" color="#a72b77" class="rotate-310" icon="vuesax-linear:coin"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='شمش'" stroke-width="1" size="26" color="#a72b77" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
|
||||
<BasicIcon v-else-if="props.ProductItem.group_type=='مکعب'" stroke-width="1" size="26" color="#a72b77" class="rotate-310" icon="vuesax-linear:keyboard"/>
|
||||
<BasicIcon v-else stroke-width="1" size="26" color="#a72b77" class="rotate-310" icon="vuesax-linear:slider-vertical"/> <div class="flex justify-between gap-2 items-center">
|
||||
<span v-if="props.ProductItem.group_type=='آبشده'" class="font-bold text-secondary">{{userWallet.walletInfo?.gold??0}}</span>
|
||||
<span v-else class="font-bold text-secondary">{{props?.ProductItem.wallet?.gold??0}}</span>
|
||||
<span class="text-gray-400">{{props?.ProductItem?.unit}}</span>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
<div class="bg-gray-50 w-full flex justify-evenly rounded-lg py-2">
|
||||
<div class="text-center w-full">
|
||||
<div>قیمت خرید از قطره</div>
|
||||
<div>قیمت خرید از کشکول گلد</div>
|
||||
<div class="text-[10px] text-gray-500">(هر گرم طلای 18 عیار)</div>
|
||||
<div class="flex w-full mt-3 justify-evenly">
|
||||
<!-- <div class="text-[10px] gap-1 flex bg-green-100 rounded-xl px-1 text-green-600 items-center">
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<div
|
||||
class="px-5 py-5 shadow-lg rounded-2xl text-white relative overflow-hidden shadow-lg"
|
||||
style=" background: linear-gradient(145deg, #521620 0%, #7a2a1e 40%, #521620 100%); "
|
||||
style=" background: linear-gradient(145deg, #a72b77 0%, #711d4d 40%, #a72b77 100%); "
|
||||
>
|
||||
<div
|
||||
class="absolute inset-0 opacity-20"
|
||||
@@ -30,13 +30,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">کشکول گلد </div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-between items-end mb-3">
|
||||
<div class="text-sm "></div>
|
||||
<div>
|
||||
<div class="text-xs opacity-75" style="justify-self: end;">شناسه شما در قطره</div>
|
||||
<div class="text-xs opacity-75" style="justify-self: end;">شناسه شما در کشکول گلد</div>
|
||||
<div class="flex">
|
||||
<div v-if="userStore?.userInfo?.virtual_card_number" class="ml-2 " @click.stop="copyCode()">
|
||||
<BasicIcon
|
||||
@@ -72,8 +72,8 @@
|
||||
style="touch-action: none" />
|
||||
</div>-->
|
||||
<!-- <div class="bg-gradient-to-l mt-3 p-1 shadow-lg from-primary rounded-lg p-px to-transparent ">-->
|
||||
<div class="mt-3 p-1 shadow-lg from-primary rounded-lg p-px to-transparent">
|
||||
<div class=" p-1 py-6 rounded-lg bg-tertiary">
|
||||
<div class="mt-3 p-1 shadow-lg from-primary rounded-lg p-px to-transparent border-solid border border-primary">
|
||||
<div class=" p-1 py-6 rounded-lg bg-white">
|
||||
<div class="flex justify-between ">
|
||||
<!-- <div
|
||||
class="text-center w-full flex-flex-col items-center home_appear_fade_in_up"
|
||||
@@ -82,7 +82,7 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[42px] h-[42px] bg-primary flex items-center justify-center"
|
||||
style="border: solid 1px #521620"
|
||||
style="border: solid 1px #a72b77"
|
||||
|
||||
>
|
||||
<Icon class="text-tertiary" icon="vuesax-linear:money-send" />
|
||||
@@ -96,10 +96,10 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
|
||||
style="border: solid 1px #521620"
|
||||
style="border: solid 1px #a72b77"
|
||||
|
||||
>
|
||||
<Icon class="text-tertiary" icon="vuesax-linear:money-receive" />
|
||||
<Icon class="text-white" icon="vuesax-linear:money-receive" />
|
||||
</div>
|
||||
<div class="text-primary">خرید و فروش</div>
|
||||
</div>
|
||||
@@ -110,10 +110,10 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
|
||||
style="border: solid 1px #521620"
|
||||
style="border: solid 1px #a72b77"
|
||||
|
||||
>
|
||||
<Icon class="text-tertiary" icon="vuesax-linear:card-add" />
|
||||
<Icon class="text-white" icon="vuesax-linear:card-add" />
|
||||
</div>
|
||||
<div class="text-primary">واریز نقدی</div>
|
||||
</div>
|
||||
@@ -124,9 +124,9 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center "
|
||||
style="border: solid 1px #521620"
|
||||
style="border: solid 1px #a72b77"
|
||||
>
|
||||
<Icon class="text-tertiary" icon="vuesax-linear:receipt-item" />
|
||||
<Icon class="text-white" icon="vuesax-linear:receipt-item" />
|
||||
</div>
|
||||
<div class="text-primary">موجودی</div>
|
||||
</div>
|
||||
@@ -137,9 +137,9 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
|
||||
style=" border: solid 1px #521620"
|
||||
style=" border: solid 1px #a72b77"
|
||||
>
|
||||
<Icon class="text-tertiary font-bold" icon="vuesax-linear:archive-1" />
|
||||
<Icon class="text-white font-bold" icon="vuesax-linear:archive-1" />
|
||||
</div>
|
||||
<div class="text-primary">قلک</div>
|
||||
</div>
|
||||
@@ -150,10 +150,10 @@
|
||||
>
|
||||
<div
|
||||
class="rounded-full w-[50px] h-[50px] bg-primary flex items-center justify-center"
|
||||
style=" border: solid 1px #521620"
|
||||
style=" border: solid 1px #a72b77"
|
||||
|
||||
>
|
||||
<Icon class="text-tertiary font-bold" icon="vuesax-linear:dollar-circle" />
|
||||
<Icon class="text-white font-bold" icon="vuesax-linear:dollar-circle" />
|
||||
</div>
|
||||
<div class="text-primary">کسب درآمد</div>
|
||||
</div>
|
||||
@@ -200,7 +200,7 @@
|
||||
<span class="text-xs text-base">ریال</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 ml-4">
|
||||
<span class="text-base font-bold">{{ walletStore.walletInfo?.gold_sum.toFixed(3) }}</span>
|
||||
<span class="text-base font-bold">{{ walletStore.walletInfo?.gold_sum?.toFixed(3) ?? '0.000' }}</span>
|
||||
<span class="text-xs text-base">گرم</span>
|
||||
</div>
|
||||
</div>-->
|
||||
@@ -252,7 +252,7 @@
|
||||
>
|
||||
|
||||
<div class="w-full items-center flex flex-col">
|
||||
<div class="text-gray-600">قیمت خرید از قطره</div>
|
||||
<div class="text-gray-600">قیمت خرید از کشکول گلد</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) }}–>
|
||||
@@ -287,7 +287,7 @@
|
||||
</swiper>
|
||||
|
||||
|
||||
<div class="flex mt-5 gap-1 bg-primary text-[#CEA34C] font-bold justify-center cursor-pointer rounded-lg py-5"
|
||||
<div class="flex mt-5 gap-1 bg-primary text-white font-bold justify-center cursor-pointer rounded-lg py-5"
|
||||
@click="router.push({ name: 'gold' })">
|
||||
<div>خرید و فروش</div>
|
||||
</div>
|
||||
@@ -360,9 +360,9 @@
|
||||
<!-- <img :src="image">-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="bg-primary pb-30"-->
|
||||
<!-- style="background: linear-gradient(to bottom, #fff,#fff, #521620, #521620);"-->
|
||||
<!-- style="background: linear-gradient(to bottom, #fff,#fff, #a72b77, #a72b77);"-->
|
||||
<!-- >-->
|
||||
<!-- <div class=" text-tertiary text-2xl pt-6 pr-5 pl-50" style="font-size: 26px;font-weight: 600; color: #521620" >ارسال کالا بعد از ثبت سفارش</div>-->
|
||||
<!-- <div class=" text-tertiary text-2xl pt-6 pr-5 pl-50" style="font-size: 26px;font-weight: 600; color: #a72b77" >ارسال کالا بعد از ثبت سفارش</div>-->
|
||||
<!-- <div class="pr-5 pl-8 pt-10 text-tertiary ">میتوانید با خرید محصولات بعد از ثبت سفارش درخواست ارسال را-->
|
||||
<!-- ثبت کرده و زیر 24 ساعت خرید خود را دریافت کنید-->
|
||||
<!-- </div>-->
|
||||
@@ -490,7 +490,7 @@
|
||||
<div class="text-center">
|
||||
<div class="mt-2">
|
||||
<div>🔥یه فرصت طلایی واقعی جلوتِ !🔥</div>
|
||||
<div>دوستاتو همین الان به قطره دعوت کن!</div>
|
||||
<div>دوستاتو همین الان به کشکول گلد دعوت کن!</div>
|
||||
<div>اونا اولین خریدشونو کاملاً بدون کارمزد انجام میدن،۱۰٪ از کارمزد ۱۰ معاملهی اولشون هم، مستقیم میاد تو حساب تو!</div>
|
||||
<div>زود باش، این فرصت همیشه باز نیست! ⏳✨</div>
|
||||
</div>
|
||||
@@ -751,7 +751,7 @@ const priceChartOptions = ref({
|
||||
show: false
|
||||
}
|
||||
},
|
||||
colors: ['#521620'],
|
||||
colors: ['#a72b77'],
|
||||
fill: {
|
||||
type: 'gradient',
|
||||
gradient: {
|
||||
@@ -769,8 +769,8 @@ const toPersianNumber = (num) => {
|
||||
const fetchPrices = async () => {
|
||||
try {
|
||||
const response = await getAllPrices()
|
||||
const data = response.data?.prices
|
||||
const selectedData = data[selection.value] || []
|
||||
const data = response?.data?.prices ?? {}
|
||||
const selectedData = data[selection.value] ?? []
|
||||
priceChartSeries.value[0].data = selectedData.map((item) => [item.timestamp, item.value - 1])
|
||||
// console.log(priceChartSeries.value[0].data)
|
||||
chartRef.value?.updateOptions({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="">
|
||||
<!-- <div class="bg-primary h-30 mt-[-3rem] z-100000000000"></div>-->
|
||||
<div class="fixed h-[60vh] bg-[#521620] w-screen">
|
||||
<div class="fixed h-[60vh] bg-[#a72b77] w-screen">
|
||||
<div class="flex w-full justify-around mt-18">
|
||||
<div class="text-center">
|
||||
<div class="text-[#E5D7CE] text-xs ">موجودی کیف طلا</div>
|
||||
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
<div class="bg-gray-50 w-full flex justify-evenly rounded-lg py-2">
|
||||
<div class="text-center w-full">
|
||||
<div>قیمت خرید از قطره</div>
|
||||
<div>قیمت خرید از کشکول گلد</div>
|
||||
<div class="text-[10px] text-gray-500">(هر گرم طلای 18 عیار)</div>
|
||||
<div class="flex w-full mt-3 justify-evenly">
|
||||
<!-- <div class="text-[10px] gap-1 flex bg-green-100 rounded-xl px-1 text-green-600 items-center">
|
||||
@@ -56,7 +56,7 @@
|
||||
</div>
|
||||
<a-divider class="bg-gray-200 !h-auto !my-2" type="vertical"/>
|
||||
<div class="text-center w-full">
|
||||
<div>قیمت فروش به قطره</div>
|
||||
<div>قیمت فروش به کشکول گلد</div>
|
||||
<div class="text-[10px] text-gray-500">(هر گرم طلای 18 عیار)</div>
|
||||
<div class="flex w-full mt-3 justify-evenly">
|
||||
<!-- <div class="text-[10px] gap-1 flex bg-red-100 rounded-xl px-1 text-red-600 items-center">
|
||||
|
||||
@@ -241,7 +241,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="text-center w-full">
|
||||
<div>قیمت خرید از قطره</div>
|
||||
<div>قیمت خرید از کشکول گلد</div>
|
||||
<div class="text-[10px] text-gray-500">(هر گرم طلای 18 عیار)</div>
|
||||
<div class="flex w-full mt-3 justify-evenly">
|
||||
<!– <div class="text-[10px] gap-1 flex bg-green-100 rounded-xl px-1 text-green-600 items-center">
|
||||
@@ -258,7 +258,7 @@
|
||||
</div>
|
||||
<a-divider class="bg-gray-200 !h-auto !my-2" type="vertical" />
|
||||
<div class="text-center w-full">
|
||||
<div>قیمت فروش به قطره</div>
|
||||
<div>قیمت فروش به کشکول گلد</div>
|
||||
<div class="text-[10px] text-gray-500">(هر گرم طلای 18 عیار)</div>
|
||||
<div class="flex w-full mt-3 justify-evenly">
|
||||
<!– <div class="text-[10px] gap-1 flex bg-red-100 rounded-xl px-1 text-red-600 items-center">
|
||||
@@ -620,7 +620,7 @@ const priceChartOptions = ref({
|
||||
show: false
|
||||
}
|
||||
},
|
||||
colors: ['#521620'],
|
||||
colors: ['#a72b77'],
|
||||
fill: {
|
||||
type: 'gradient',
|
||||
gradient: {
|
||||
@@ -638,8 +638,8 @@ const toPersianNumber = (num) => {
|
||||
const fetchPrices = async () => {
|
||||
try {
|
||||
const response = await getAllPrices()
|
||||
const data = response.data.prices
|
||||
const selectedData = data[selection.value] || []
|
||||
const data = response?.data?.prices ?? {}
|
||||
const selectedData = data[selection.value] ?? []
|
||||
priceChartSeries.value[0].data = selectedData.map((item) => [item.timestamp, item.value - 1])
|
||||
// console.log(priceChartSeries.value[0].data)
|
||||
chartRef.value?.updateOptions({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div >
|
||||
<Transition>
|
||||
<div v-if="popVisible" class="top-0 bottom-0 bg-primary wrap-fix z-2000 opacity-60"
|
||||
<div v-if="popVisible" class="top-0 bottom-0 bg-black wrap-fix z-2000 opacity-60"
|
||||
@click="popVisible = false">
|
||||
</div>
|
||||
</Transition>
|
||||
@@ -33,16 +33,16 @@
|
||||
<!-- @click="$router.push({name: 'transfer'}); popVisible = false">-->
|
||||
<!-- <div class="flex gap-2 items-center">-->
|
||||
<!-- <BasicIcon icon="vuesax-linear:card-send" size="16" class="absolute right-2" />-->
|
||||
<!-- <div>انتقال قطره</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </BasicButton>-->
|
||||
<!-- <BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"-->
|
||||
<!-- @click="$router.push({name: 'physicalReceive'}); popVisible = false">-->
|
||||
<!-- <div class="flex gap-2 items-center">-->
|
||||
<!-- <BasicIcon icon="vuesax-linear:direct-inbox" size="16" class="absolute right-2" />-->
|
||||
<!-- <div>دریافت طلای فیزیکی</div>-->
|
||||
<!-- <div>انتقال کشکول گلد</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </BasicButton>-->
|
||||
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
|
||||
@click="$router.push({name: 'physicalReceive'}); popVisible = false">
|
||||
<div class="flex gap-2 items-center">
|
||||
<BasicIcon icon="vuesax-linear:direct-inbox" size="16" class="absolute right-2" />
|
||||
<div>دریافت طلای فیزیکی</div>
|
||||
</div>
|
||||
</BasicButton>
|
||||
<BasicButton v-if="isToken()" icon-size="16" class="!font-bold w-15rem"
|
||||
@click="$router.push({name: 'buyProduct'}); popVisible = false">
|
||||
<div class="flex gap-2 items-center">
|
||||
@@ -107,14 +107,14 @@
|
||||
<!-- <canvas ref="canvas" id="canvas1" width="400" height="80" class="w-full"></canvas>-->
|
||||
<div v-if="isToken()" class="bottom-appbar w-auto mx-auto">
|
||||
<div class="tabs">
|
||||
<!-- <div :class="setNavColor('home')" class="tab" @click="setRoute('home')">-->
|
||||
<!-- <Icon icon="vuesax-linear:home" />-->
|
||||
<!-- <div class="text-xs mt-1 font-bold">صفحه اصلی</div>-->
|
||||
<!-- </div>-->
|
||||
<div :class="setNavColor('buyProduct')" class="tab" @click="setRoute('buyProduct')">
|
||||
<Icon icon="vuesax-linear:coin" />
|
||||
<div class="text-xs mt-1 font-bold">فروشگاه</div>
|
||||
<div :class="setNavColor('home')" class="tab" @click="setRoute('home')">
|
||||
<Icon icon="vuesax-linear:home" />
|
||||
<div class="text-xs mt-1 font-bold">صفحه اصلی</div>
|
||||
</div>
|
||||
<!-- <div :class="setNavColor('buyProduct')" class="tab" @click="setRoute('buyProduct')">-->
|
||||
<!-- <Icon icon="vuesax-linear:coin" />-->
|
||||
<!-- <div class="text-xs mt-1 font-bold">فروشگاه</div>-->
|
||||
<!-- </div>-->
|
||||
<div :class="setNavColor('transactions')" class="tab" @click="setRoute('transactions')">
|
||||
<Icon icon="vuesax-linear:receipt-item" />
|
||||
<div class="text-xs mt-1 font-bold">گزارش</div>
|
||||
@@ -127,8 +127,6 @@
|
||||
src="@/assets/img/logo.png"
|
||||
/>
|
||||
</div>
|
||||
<!-- <div class="flex justify-center">خرید </div>
|
||||
<div class="flex justify-center">محصول </div>-->
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div :class="setNavColor('buyProduct')" class="tab" @click="setRoute('buyProduct')">
|
||||
@@ -144,7 +142,9 @@
|
||||
<!-- <div class="text-xs mt-1 font-bold">دریافت فیزیکی</div>-->
|
||||
<!-- </div>-->
|
||||
<div :class="setNavColor('cart')" class="tab" @click="setRoute('cart')">
|
||||
<Icon icon="vuesax-linear:shopping-cart" />
|
||||
<a-badge :count="cartStore.itemCount">
|
||||
<Icon icon="vuesax-linear:shopping-cart" />
|
||||
</a-badge>
|
||||
<div class="text-xs mt-1 font-bold">سبد خرید</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -164,23 +164,23 @@
|
||||
<div class="text-xs mt-1 font-bold">درباره ما</div>
|
||||
</div>
|
||||
<div class="main_in">
|
||||
<div class="text-white circle_in">
|
||||
<div class="circle_into " @click="popVisible = !popVisible">
|
||||
<img
|
||||
class="p-2"
|
||||
src="@/assets/img/logo.png"
|
||||
/>
|
||||
</div>
|
||||
<!-- <div class="flex justify-center">خرید </div>
|
||||
<div class="flex justify-center">محصول </div>-->
|
||||
</div>
|
||||
<div class="text-white circle_in">
|
||||
<div class="circle_into " @click="popVisible = !popVisible">
|
||||
<img
|
||||
class="p-2"
|
||||
src="@/assets/img/logo.png"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div :class="setNavColor('buyProduct')" class="tab" @click="setRoute('buyProduct')">
|
||||
<Icon icon="vuesax-linear:coin" />
|
||||
<div class="text-xs mt-1 font-bold">خرید محصول</div>
|
||||
</div>-->
|
||||
<div :class="setNavColor('cart')" class="tab" @click="setRoute('cart')">
|
||||
<Icon icon="vuesax-linear:shopping-cart" />
|
||||
<a-badge :count="cartStore.itemCount">
|
||||
<Icon icon="vuesax-linear:shopping-cart" />
|
||||
</a-badge>
|
||||
<div class="text-xs mt-1 font-bold">سبد خرید</div>
|
||||
</div>
|
||||
<div :class="setNavColor('login')" class="tab" @click="setRoute('login')">
|
||||
@@ -205,11 +205,14 @@ import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import type { Transaction } from '@/models/transaction'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import {isToken} from "@/utils";
|
||||
import { useCartStore } from '@/store/cartStore'
|
||||
|
||||
const currentRoute = computed(() => router.currentRoute.value.name)
|
||||
const cartStore = useCartStore()
|
||||
|
||||
const popVisible = ref(false)
|
||||
|
||||
const currentRoute = computed(() => router.currentRoute.value.name)
|
||||
|
||||
function setNavColor(val: string) {
|
||||
if (currentRoute.value === val) {
|
||||
return 'text-primary'
|
||||
@@ -286,7 +289,7 @@ onMounted(()=>{
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
flex-wrap: wrap;
|
||||
background-color: #521620;
|
||||
background-color: #a72b77;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
value-name="title"
|
||||
size="large"
|
||||
placeholder="لطفا محصول را انتخاب کنید"
|
||||
:has-tooltip="false"/>
|
||||
: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">
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
<a-form-item v-if="isBuy" name="goldValue"
|
||||
:rules="[justNumber2(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true)]">
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#521620"
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
place-holder="تعداد"
|
||||
size="large" type="number" inputmode="number" @onchange="calculateCash" />
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
<a-form-item v-else name="goldValue"
|
||||
:rules="[justNumber3(props?.ProductItem?.sellPrice, productNum ,false)]">
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#521620"
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
place-holder="تعداد"
|
||||
size="large" type="number" inputmode="number" @onchange="calculateCash" />
|
||||
@@ -694,7 +694,7 @@ watch(form.value.goldValue, () => {
|
||||
background: blue;
|
||||
}*/
|
||||
.completeButtonStyle .van-dialog__confirm .van-button__content {
|
||||
background: #521620;
|
||||
background: #a72b77;
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<div class="flex flex-col gap-4 pt-13 pb-35 px-2">
|
||||
<RequestItem v-for="item in requestItems" :item="item"></RequestItem>
|
||||
</div>
|
||||
<!-- <Transition mode="out-in" name="fade">
|
||||
<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"
|
||||
@@ -17,7 +17,7 @@
|
||||
<BasicIcon icon="vuesax-linear:add" />
|
||||
<div class="cursor-pointer">افزودن درخواست جدید</div>
|
||||
</div>
|
||||
</Transition>-->
|
||||
</Transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -4,195 +4,193 @@
|
||||
</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">
|
||||
<!--<template>-->
|
||||
<!-- <div class="bottom-0 fixed top-0">-->
|
||||
<!-- <img :src="img" alt="" class=" w-inherit "-->
|
||||
<!-- :style="{ backgroundRepeat: 'repeat', }"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
<!-- <a-spin :spinning="loading">-->
|
||||
|
||||
<div class=" !h-full overflow-y-scroll">
|
||||
<!-- <div class=" !h-full overflow-y-scroll">-->
|
||||
|
||||
<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>
|
||||
<!-- <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>-->
|
||||
|
||||
<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>–>
|
||||
<!-- <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>–>-->
|
||||
|
||||
<BasicActionSheet placement="bottom" v-model:show="showFilter">
|
||||
<div class="">
|
||||
<!– <indexGold v-if="selectedProduct?.group_type=='آبشده'" :ProductItem="selectedProduct"></indexGold>–>
|
||||
<ReceiveDealProduct :ProductItem="selectedProduct"></ReceiveDealProduct>
|
||||
</div>
|
||||
</BasicActionSheet>
|
||||
<!-- <BasicActionSheet placement="bottom" v-model:show="showFilter">-->
|
||||
<!-- <div class="">-->
|
||||
<!--<!– <indexGold v-if="selectedProduct?.group_type=='آبشده'" :ProductItem="selectedProduct"></indexGold>–>-->
|
||||
<!-- <ReceiveDealProduct :ProductItem="selectedProduct"></ReceiveDealProduct>-->
|
||||
<!-- </div>-->
|
||||
<!-- </BasicActionSheet>-->
|
||||
|
||||
</template>
|
||||
<!--</template>-->
|
||||
|
||||
<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'
|
||||
<!--<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'-->
|
||||
|
||||
const activekey = ref('آبشده')
|
||||
const showFilter = ref()
|
||||
const selectedProduct = ref<Product>()
|
||||
<!--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 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
|
||||
<!--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')
|
||||
<!--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()
|
||||
}
|
||||
<!-- } 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')
|
||||
})
|
||||
<!-- 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>
|
||||
<!--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 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>
|
||||
<!--</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>
|
||||
<!--<!–-->
|
||||
<!--<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";
|
||||
<!--<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>
|
||||
<!--const activekey=ref(1)-->
|
||||
<!--const route=useRoute()-->
|
||||
<!--</script>-->
|
||||
|
||||
<style scoped>
|
||||
/*.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
<!--<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>
|
||||
–>
|
||||
-->
|
||||
<!--.fade-enter-from,-->
|
||||
<!--.fade-leave-to {-->
|
||||
<!-- opacity: 0;-->
|
||||
<!--}*/-->
|
||||
<!--/*.trans{-->
|
||||
<!-- transition: height 1s;-->
|
||||
<!--}*/-->
|
||||
<!--</style>-->
|
||||
<!--–>-->
|
||||
|
||||
@@ -61,14 +61,14 @@
|
||||
|
||||
<a-form-item v-if="isBuy" name="goldValue"
|
||||
:rules="[justNumber4(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true, form.gateway)]">
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#521620"
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
place-holder="تعداد"
|
||||
size="large" type="number" inputmode="number" @onchange="calculateCash" />
|
||||
</a-form-item>
|
||||
<a-form-item v-else name="goldValue"
|
||||
:rules="[justNumber3(props?.ProductItem?.sellPrice, productNum ,false)]">
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#521620"
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
place-holder="تعداد"
|
||||
size="large" type="number" inputmode="number" @onchange="calculateCash" />
|
||||
@@ -779,7 +779,7 @@ async function ok() {
|
||||
background: blue;
|
||||
}*/
|
||||
.completeButtonStyle .van-dialog__confirm .van-button__content {
|
||||
background: #521620;
|
||||
background: #a72b77;
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,14 +61,14 @@
|
||||
|
||||
<a-form-item v-if="isBuy" name="goldValue"
|
||||
:rules="[justNumber2(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true, form.gateway)]">
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#521620"
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
place-holder="تعداد"
|
||||
size="large" type="number" inputmode="number" @onchange="calculateCash" />
|
||||
</a-form-item>
|
||||
<a-form-item v-else name="goldValue"
|
||||
:rules="[justNumber3(props?.ProductItem?.sellPrice, productNum ,false)]">
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#521620"
|
||||
<BasicInput v-model:value="form.goldValue" addon-before="تعداد" addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
place-holder="تعداد"
|
||||
size="large" type="number" inputmode="number" @onchange="calculateCash" />
|
||||
@@ -749,7 +749,7 @@ async function ok() {
|
||||
background: blue;
|
||||
}*/
|
||||
.completeButtonStyle .van-dialog__confirm .van-button__content {
|
||||
background: #521620;
|
||||
background: #a72b77;
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,23 +64,27 @@
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex bg-white border border-gray-200 rounded-xl p-3 transition-all duration-300
|
||||
hover:shadow-lg hover:-translate-y-0.5 cursor-pointer"
|
||||
:class="!props.ProductItem.show && 'opacity-50 grayscale'"
|
||||
class="product-card relative flex cursor-pointer rounded-xl border border-gray-200 bg-white p-3 transition-all duration-300 hover:-translate-y-0.5 hover:shadow-lg"
|
||||
:class="!props.ProductItem.show && 'opacity-50 grayscale'"
|
||||
>
|
||||
<!-- Image -->
|
||||
<div class="bg-gray-100 rounded-lg w-24 h-24 flex items-center justify-center shrink-0">
|
||||
<img
|
||||
:src="productImage"
|
||||
class="max-h-30 object-contain"
|
||||
alt=""
|
||||
<span
|
||||
v-if="isOutOfStock"
|
||||
class="product-card__badge absolute top-2 right-2 z-10 rounded-md bg-gray-700/90 px-2 py-0.5 text-xs font-medium text-white shadow-sm"
|
||||
>
|
||||
ناموجود
|
||||
</span>
|
||||
|
||||
<div class="flex h-24 w-24 shrink-0 items-center justify-center rounded-lg bg-gray-100">
|
||||
<ProductImage
|
||||
:product="props.ProductItem"
|
||||
:dimmed="isOutOfStock"
|
||||
img-class="max-h-20 object-contain"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="mr-4 flex flex-col justify-between flex-1">
|
||||
<div class="mr-4 flex flex-1 flex-col justify-between">
|
||||
<div>
|
||||
<div class="text-sm font-semibold line-clamp-2 mb-1">
|
||||
<div class="mb-1 line-clamp-2 text-sm font-semibold">
|
||||
{{ props.ProductItem.title }}
|
||||
</div>
|
||||
|
||||
@@ -89,17 +93,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between mt-2">
|
||||
<div class="!text-primary font-bold text-sm">
|
||||
{{ usePrice((props.ProductItem.price ?? 0) + (props.ProductItem.cash_fee_buy ?? 0)) }}
|
||||
</div>
|
||||
|
||||
<span
|
||||
v-if="!props.ProductItem?.inventory || props.ProductItem?.inventory==0"
|
||||
class="text-xs bg-gray-300 text-gray-600 px-2 py-0.5 rounded-md"
|
||||
>
|
||||
ناموجود
|
||||
</span>
|
||||
<div class="mt-2 !text-primary text-sm font-bold">
|
||||
{{ usePrice((props.ProductItem.price ?? 0) + (props.ProductItem.cash_fee_buy ?? 0)) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -109,13 +104,7 @@
|
||||
import { computed } from 'vue'
|
||||
import type { Product } from '@/models/products'
|
||||
import { usePrice } from '@/utils/usePrice'
|
||||
|
||||
import defaultImg from '@/assets/img/defaultAbshodeh.svg'
|
||||
import goyImg from '@/assets/img/goyImg.svg'
|
||||
import mokaabImg from '@/assets/img/mokaabImg.svg'
|
||||
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
||||
import parsianImg from '@/assets/img/parsianImg.svg'
|
||||
import venusImg from '@/assets/img/venousImg.svg'
|
||||
import ProductImage from '@/components/ProductImage.vue'
|
||||
|
||||
interface Props {
|
||||
ProductItem: Product
|
||||
@@ -123,6 +112,10 @@ interface Props {
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const isOutOfStock = computed(
|
||||
() => !props.ProductItem?.inventory || props.ProductItem.inventory === 0
|
||||
)
|
||||
|
||||
const amountProduct = computed(() => {
|
||||
if (!props.ProductItem.amount) return ''
|
||||
if (props.ProductItem.amount < 1) {
|
||||
@@ -131,28 +124,6 @@ const amountProduct = computed(() => {
|
||||
return `${props.ProductItem.amount} گرم`
|
||||
})
|
||||
|
||||
const productImage = computed(() => {
|
||||
// Check if product has file field from server with src property
|
||||
if (props.ProductItem?.file?.src) {
|
||||
return props.ProductItem.file.src
|
||||
}
|
||||
|
||||
// Fallback to local images based on group_type if file is empty or doesn't exist
|
||||
switch (props.ProductItem.group_type) {
|
||||
case 'گوی':
|
||||
return goyImg
|
||||
case 'مکعب':
|
||||
return mokaabImg
|
||||
case 'سکه':
|
||||
return sekkeImg
|
||||
case 'شمش ونوس':
|
||||
return venusImg
|
||||
case 'سکه پارسیان':
|
||||
return parsianImg
|
||||
default:
|
||||
return defaultImg
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -1,40 +1,33 @@
|
||||
<template>
|
||||
<div
|
||||
class="bg-white border border-gray-200 rounded-xl p-3 transition-all duration-300
|
||||
hover:shadow-lg hover:-translate-y-1 cursor-pointer"
|
||||
:class="!props.ProductItem.show && 'opacity-50 grayscale'"
|
||||
class="product-card relative flex h-full flex-col rounded-xl border border-gray-200 bg-white p-3 transition-all duration-300 hover:-translate-y-1 hover:shadow-lg cursor-pointer"
|
||||
:class="!props.ProductItem.show && 'opacity-50 grayscale'"
|
||||
>
|
||||
<!-- Image -->
|
||||
<div class="bg-gray-100 rounded-lg h-32 flex items-center justify-center mb-3">
|
||||
<img
|
||||
:src="productImage"
|
||||
class="max-h-35 object-contain"
|
||||
alt=""
|
||||
<span
|
||||
v-if="isOutOfStock"
|
||||
class="product-card__badge absolute top-2 right-2 z-10 rounded-md bg-gray-700/90 px-2 py-0.5 text-xs font-medium text-white shadow-sm"
|
||||
>
|
||||
ناموجود
|
||||
</span>
|
||||
|
||||
<div class="mb-3 flex h-32 items-center justify-center rounded-lg bg-gray-100">
|
||||
<ProductImage
|
||||
:product="props.ProductItem"
|
||||
:dimmed="isOutOfStock"
|
||||
img-class="max-h-28 w-full object-contain"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Title -->
|
||||
<div class="text-sm font-semibold line-clamp-2 mb-2 min-h-[40px]">
|
||||
<div class="mb-2 min-h-[40px] line-clamp-2 text-sm font-semibold">
|
||||
{{ props.ProductItem.title }}
|
||||
</div>
|
||||
|
||||
<!-- Amount -->
|
||||
<div class="text-xs text-gray-500 mb-2">
|
||||
<div class="mb-2 text-xs text-gray-500">
|
||||
{{ amountProduct }}
|
||||
</div>
|
||||
|
||||
<!-- Price & Status -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="!text-primary font-bold text-sm">
|
||||
{{ usePrice((props.ProductItem.price ?? 0) + (props.ProductItem.cash_fee_buy ?? 0)) }}
|
||||
</div>
|
||||
|
||||
<span
|
||||
v-if="!props.ProductItem?.inventory || props.ProductItem?.inventory==0"
|
||||
class="text-xs bg-gray-300 text-gray-600 px-2 py-0.5 rounded-md"
|
||||
>
|
||||
ناموجود
|
||||
</span>
|
||||
<div class="mt-auto !text-primary text-sm font-bold">
|
||||
{{ usePrice((props.ProductItem.price ?? 0) + (props.ProductItem.cash_fee_buy ?? 0)) }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -43,13 +36,7 @@
|
||||
import { computed } from 'vue'
|
||||
import type { Product } from '@/models/products'
|
||||
import { usePrice } from '@/utils/usePrice'
|
||||
|
||||
import defaultImg from '@/assets/img/defaultAbshodeh.svg'
|
||||
import goyImg from '@/assets/img/goyImg.svg'
|
||||
import mokaabImg from '@/assets/img/mokaabImg.svg'
|
||||
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
||||
import parsianImg from '@/assets/img/parsianImg.svg'
|
||||
import venusImg from '@/assets/img/venousImg.svg'
|
||||
import ProductImage from '@/components/ProductImage.vue'
|
||||
|
||||
interface Props {
|
||||
ProductItem: Product
|
||||
@@ -57,6 +44,10 @@ interface Props {
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const isOutOfStock = computed(
|
||||
() => !props.ProductItem?.inventory || props.ProductItem.inventory === 0
|
||||
)
|
||||
|
||||
const amountProduct = computed(() => {
|
||||
if (!props.ProductItem.amount) return ''
|
||||
if (props.ProductItem.amount < 1) {
|
||||
@@ -64,29 +55,6 @@ const amountProduct = computed(() => {
|
||||
}
|
||||
return `${props.ProductItem.amount} گرم`
|
||||
})
|
||||
|
||||
const productImage = computed(() => {
|
||||
// Check if product has file field from server with src property
|
||||
if (props.ProductItem?.file?.src) {
|
||||
return props.ProductItem.file.src
|
||||
}
|
||||
|
||||
// Fallback to local images based on group_type if file is empty or doesn't exist
|
||||
switch (props.ProductItem.group_type) {
|
||||
case 'گوی':
|
||||
return goyImg
|
||||
case 'مکعب':
|
||||
return mokaabImg
|
||||
case 'سکه':
|
||||
return sekkeImg
|
||||
case 'شمش ونوس':
|
||||
return venusImg
|
||||
case 'سکه پارسیان':
|
||||
return parsianImg
|
||||
default:
|
||||
return defaultImg
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="bottom-0 fixed top-0">
|
||||
<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="loading">
|
||||
<div class=" !h-full overflow-y-scroll">
|
||||
<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="changeTab" v-model:value="activekey" button-style="solid">
|
||||
<ARadioButton class="cats" value="همه">همه</ARadioButton>
|
||||
@@ -17,11 +17,25 @@
|
||||
<BasicIcon v-else icon="vuesax-linear:element-3"></BasicIcon>
|
||||
</div>
|
||||
|
||||
<div class="mx-5 pb-30 pt-2 grid grid-cols-2 gap-2" style="color: #1b2b07">
|
||||
<div class="mt-3 gap-2 " :class="!viewVertical?'col-span-2':''" v-for="item in items?.filter(i => i.show)">
|
||||
<ProductItemVertical v-if="viewVertical" :ProductItem="item" @click="clickProduct(item)"></ProductItemVertical>
|
||||
<ProductItem v-else class="col-span-2" :ProductItem="item" @click="clickProduct(item)"></ProductItem>
|
||||
</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 items"
|
||||
:key="item.id"
|
||||
class="h-full"
|
||||
:ProductItem="item"
|
||||
@click="clickProduct(item)"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<ProductItem
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
class="col-span-2 h-full"
|
||||
:ProductItem="item"
|
||||
@click="clickProduct(item)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -62,11 +76,13 @@ import { message } from 'ant-design-vue'
|
||||
import BasicButton from "@/App.vue";
|
||||
import BasicIcon from "@/components/BasicPacks/BasicIcon.vue";
|
||||
import ProductItemVertical from "@/views/base/products/components/ProductItemVertical.vue";
|
||||
import { loadProductCategoryTabNames } from '@/utils/categoryTabs'
|
||||
import { subscribeProductListStream } from '@/utils/productStreamBridge'
|
||||
|
||||
const activekey = ref('آبشده')
|
||||
const activekey = ref('همه')
|
||||
const showFilter = ref()
|
||||
const selectedProduct = ref<Product>()
|
||||
const viewVertical=ref<boolean>('true')
|
||||
const viewVertical = ref(true)
|
||||
|
||||
function clickProduct(item: Product) {
|
||||
if(item?.show){
|
||||
@@ -81,24 +97,51 @@ function changeTab() {
|
||||
val.group_type == activekey.value
|
||||
)
|
||||
} else items.value = firstItems.value
|
||||
}
|
||||
|
||||
function sortProductsByInventory(products: Product[] | undefined) {
|
||||
if (!products?.length) return products ?? []
|
||||
|
||||
return [...products].sort((a, b) => {
|
||||
const aInStock = Number(a.inventory ?? 0) > 0 ? 0 : 1
|
||||
const bInStock = Number(b.inventory ?? 0) > 0 ? 0 : 1
|
||||
if (aInStock !== bInStock) return aInStock - bInStock
|
||||
return Number(b.inventory ?? 0) - Number(a.inventory ?? 0)
|
||||
})
|
||||
}
|
||||
|
||||
async function loadCategoryTabs() {
|
||||
try {
|
||||
typeItems.value = await loadProductCategoryTabNames()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
typeItems.value = []
|
||||
}
|
||||
}
|
||||
|
||||
const firstItems = ref<Product[]>()
|
||||
const price = ref<Price>()
|
||||
const items = ref<Product[]>()
|
||||
const typeItems = ref([])
|
||||
let unsubscribeProductStream: (() => void) | undefined
|
||||
|
||||
function applyStreamProducts(products: Product[]) {
|
||||
const sorted = sortProductsByInventory(products)
|
||||
firstItems.value = sorted
|
||||
changeTab()
|
||||
applyLivePricesToProducts(items.value)
|
||||
applyLivePricesToProducts(firstItems.value)
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
unsubscribeProductStream = subscribeProductListStream(applyStreamProducts)
|
||||
|
||||
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
|
||||
const products = sortProductsByInventory(await getProducts())
|
||||
items.value = products
|
||||
firstItems.value = products
|
||||
await loadCategoryTabs()
|
||||
await initPrice()
|
||||
// await setIntervalGetLastPrice()
|
||||
// console.log('run product')
|
||||
@@ -128,40 +171,47 @@ onMounted(async () => {
|
||||
}
|
||||
})
|
||||
onUnmounted(() => {
|
||||
unsubscribeProductStream?.()
|
||||
stopPriceInterval()
|
||||
// console.log('stop product')
|
||||
|
||||
// console.log('okgold')
|
||||
})
|
||||
|
||||
watch(lastPrice, async () => {
|
||||
// console.log(items);
|
||||
if (lastPrice.value && items.value) {
|
||||
items.value.forEach((val) => {
|
||||
// console.log(lastPrice.value)
|
||||
if (val.group_type == 'آبشده') {
|
||||
val.price = lastPrice.value?.price_last
|
||||
val.sellPrice = lastPrice.value?.sell
|
||||
} else {
|
||||
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||
|
||||
// console.log(lastPrice.value?.price_last + "*" + val.amount + ' ' + val.price)
|
||||
}
|
||||
})
|
||||
// Update firstItems as well
|
||||
if (firstItems.value) {
|
||||
firstItems.value.forEach((val) => {
|
||||
if (val.group_type == 'آبشده') {
|
||||
val.price = parseInt(lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(lastPrice.value?.sell)
|
||||
} else {
|
||||
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||
}
|
||||
})
|
||||
}
|
||||
function applyLivePricesToProducts(products: Product[] | undefined) {
|
||||
if (!lastPrice.value || !products?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
products.forEach((val) => {
|
||||
if (val.group_type == 'آبشده') {
|
||||
val.price = parseInt(String(lastPrice.value?.price_last ?? 0))
|
||||
val.sellPrice = parseInt(String(lastPrice.value?.sell ?? 0))
|
||||
} else {
|
||||
val.price = parseInt(String(val.amount * lastPrice.value?.price_last))
|
||||
val.sellPrice = parseInt(String(val.amount * lastPrice.value?.sell))
|
||||
}
|
||||
|
||||
syncProductShow(val)
|
||||
})
|
||||
}
|
||||
|
||||
/** show از API سرور — بعد از محاسبه قیمت زنده فقط اگر غیرفعال یا قیمت صفر باشد خاموش میشود */
|
||||
function syncProductShow(product: Product) {
|
||||
if (!product.active) {
|
||||
product.show = false
|
||||
return
|
||||
}
|
||||
|
||||
const displayPrice = Number(product.price ?? 0) + Number(product.cash_fee_buy ?? 0)
|
||||
if (displayPrice > 0) {
|
||||
product.show = true
|
||||
return
|
||||
}
|
||||
|
||||
product.show = Number(lastPrice.value?.price_last ?? 0) > 0
|
||||
}
|
||||
|
||||
watch(lastPrice, () => {
|
||||
applyLivePricesToProducts(items.value)
|
||||
applyLivePricesToProducts(firstItems.value)
|
||||
}, { deep: true })
|
||||
|
||||
async function initPrice() {
|
||||
@@ -172,30 +222,8 @@ async function initPrice() {
|
||||
loading.value = true
|
||||
price.value = lastPrice.value
|
||||
|
||||
// Update prices for all items
|
||||
if (lastPrice.value && items.value) {
|
||||
items.value.forEach((val) => {
|
||||
if (val.group_type == 'آبشده') {
|
||||
val.price = parseInt(lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(lastPrice.value?.sell)
|
||||
} else {
|
||||
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||
}
|
||||
})
|
||||
// Update firstItems as well
|
||||
if (firstItems.value) {
|
||||
firstItems.value.forEach((val) => {
|
||||
if (val.group_type == 'آبشده') {
|
||||
val.price = parseInt(lastPrice.value?.price_last)
|
||||
val.sellPrice =parseInt( lastPrice.value?.sell)
|
||||
} else {
|
||||
val.price = parseInt(val.amount * lastPrice.value?.price_last)
|
||||
val.sellPrice = parseInt(val.amount * lastPrice.value?.sell)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
applyLivePricesToProducts(items.value)
|
||||
applyLivePricesToProducts(firstItems.value)
|
||||
} catch (e: any) {
|
||||
console.log(e)
|
||||
// If 401 error, just skip price initialization
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
<div class="!h-full overflow-y-scroll">
|
||||
<div class="mx-5 pb-30 pt-5" style="color: #1b2b07">
|
||||
<!-- Product Image -->
|
||||
<div class="bg-gray-100 rounded-lg w-full flex justify-center mb-4">
|
||||
<img :src="getProductImage(product)" class="max-w-full h-auto"/>
|
||||
<div class="bg-gray-100 rounded-lg w-full flex justify-center mb-4">
|
||||
<ProductImage
|
||||
:product="product"
|
||||
:dimmed="isOutOfStock"
|
||||
img-class="max-w-full h-auto"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Product Title -->
|
||||
@@ -68,9 +72,10 @@
|
||||
>
|
||||
<!-- Image -->
|
||||
<div class="bg-gray-100 rounded-md flex justify-center p-4 mb-2">
|
||||
<img
|
||||
:src="getProductImage(item)"
|
||||
class="h-20 object-contain"
|
||||
<ProductImage
|
||||
:product="item"
|
||||
:dimmed="!item.inventory || item.inventory === 0"
|
||||
img-class="h-20 object-contain"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -129,14 +134,7 @@ import {
|
||||
} from '@/utils/price'
|
||||
import {Swiper, SwiperSlide} from 'swiper/vue'
|
||||
import 'swiper/swiper-bundle.css'
|
||||
|
||||
// Image imports
|
||||
import defaultImg from '@/assets/img/defaultAbshodeh.svg'
|
||||
import goyImg from '@/assets/img/goyImg.svg'
|
||||
import mokaabImg from '@/assets/img/mokaabImg.svg'
|
||||
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
||||
import parsianImg from '@/assets/img/parsianImg.svg'
|
||||
import venusImg from '@/assets/img/venousImg.svg'
|
||||
import ProductImage from '@/components/ProductImage.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -147,6 +145,11 @@ const productId = computed(() => {
|
||||
const id = route.params.id
|
||||
return typeof id === 'string' ? parseInt(id) : id
|
||||
})
|
||||
|
||||
const isOutOfStock = computed(
|
||||
() => !product.value?.inventory || product.value.inventory === 0
|
||||
)
|
||||
|
||||
watch(
|
||||
() => productId.value,
|
||||
(newId, oldId) => {
|
||||
@@ -250,30 +253,6 @@ function goToProduct(id: number) {
|
||||
router.push({name: 'productDetail', params: {id}})
|
||||
}
|
||||
|
||||
function getProductImage(product: any) {
|
||||
// Check if product has file field from server with src property
|
||||
if (product?.file?.src) {
|
||||
return product.file.src
|
||||
}
|
||||
|
||||
// Fallback to local images based on group_type if file is empty or doesn't exist
|
||||
const type = product?.group_type
|
||||
switch (type) {
|
||||
case 'گوی':
|
||||
return goyImg
|
||||
case 'مکعب':
|
||||
return mokaabImg
|
||||
case 'سکه':
|
||||
return sekkeImg
|
||||
case 'شمش ونوس':
|
||||
return venusImg
|
||||
case 'سکه پارسیان':
|
||||
return parsianImg
|
||||
default:
|
||||
return defaultImg
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
class="mt-5 text-5 border-solid border-2 border-primary text-primary rounded-[12px] p-4"
|
||||
>
|
||||
<div class="font-bold text-sm text-primary">
|
||||
قوانین و مقررات معاملات طلا در بستر قطره
|
||||
قوانین و مقررات معاملات طلا در بستر کشکول گلد
|
||||
</div>
|
||||
<div class="w-full h-1px my-3 bg-secondary"></div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
@@ -28,23 +28,23 @@
|
||||
صورت پذیرش آن اقدام به ثبتنام نمایند.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• کاربران قطره میپذیرند که کلیهی فعالیتهای آنها در قطره، در چارچوب قوانین
|
||||
• کاربران کشکول گلد میپذیرند که کلیهی فعالیتهای آنها در کشکول گلد، در چارچوب قوانین
|
||||
جمهوری اسلامی ایران بوده و هیچ گونه فعالیتی خارج از این چارچوب انجام نخواهد شد.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• احراز هویت برای استفاده از خدمات قطره ضروری بوده و کاربران موظفند اطلاعات صحیح
|
||||
• احراز هویت برای استفاده از خدمات کشکول گلد ضروری بوده و کاربران موظفند اطلاعات صحیح
|
||||
خود را بارگذاری نمایند؛ بدیهی است در صورت وجود هرگونه تخلف در احراز هویت، مسئولیت به
|
||||
عهدهی فرد متخلف بوده و قطره حق توقف ارائه خدمات به کاربر مذکور و ارجاع موارد
|
||||
عهدهی فرد متخلف بوده و کشکول گلد حق توقف ارائه خدمات به کاربر مذکور و ارجاع موارد
|
||||
تخلف به مراجع ذیصلاح را خواهد داشت.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• قطره خود را ملزم به حفظ اطلاعات شخصی کاربران در چارچوب قوانین قضایی کشور
|
||||
• کشکول گلد خود را ملزم به حفظ اطلاعات شخصی کاربران در چارچوب قوانین قضایی کشور
|
||||
میداند.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• کاربران قطره تعهد میدهند که از قرار دادن حساب خود در اختیار دیگران خودداری
|
||||
• کاربران کشکول گلد تعهد میدهند که از قرار دادن حساب خود در اختیار دیگران خودداری
|
||||
نمایند. از خدمات سایت، تنها برای حساب شخصی خود استفاده نموده و مسئولیت استفاده از
|
||||
خدمات قطره برای فردی دیگر، به عهده کاربر خواهد بود. شماره حساب اعلام شده به سایت
|
||||
خدمات کشکول گلد برای فردی دیگر، به عهده کاربر خواهد بود. شماره حساب اعلام شده به سایت
|
||||
باید متعلق به کاربر بوده و کاربران مجاز به دادن شماره حساب متعلق به اشخاص دیگر
|
||||
نیستند.
|
||||
</div>
|
||||
@@ -55,7 +55,7 @@
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• هرگونه سهلانگاری کاربران در حفظ اطلاعات شخصی و امنیتی از جمله: رمز عبور کاربر،
|
||||
سرقت گوشی کاربر، سرقت کارت ملی و مدارک شناسایی کاربر، سپردن مدارک شخصی و موبایل به
|
||||
فرد ثالث و ... به عهدهی شخص کاربر بوده و قطره هیچ گونه مسئولیتی در این موارد
|
||||
فرد ثالث و ... به عهدهی شخص کاربر بوده و کشکول گلد هیچ گونه مسئولیتی در این موارد
|
||||
نخواهد داشت.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
@@ -63,45 +63,45 @@
|
||||
شود.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• قطره این اطمینان را میدهد که داراییهای کاربران را نزد خود به امانت و به
|
||||
• کشکول گلد این اطمینان را میدهد که داراییهای کاربران را نزد خود به امانت و به
|
||||
بهترین شکل و با بالاترین استانداردهای امنیتی ممکن حفظ نماید؛ در صورت بروز هرگونه
|
||||
مشکل امنیتی، قطره متعهد به جبران خسارت خواهد بود.
|
||||
مشکل امنیتی، کشکول گلد متعهد به جبران خسارت خواهد بود.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• به عنوان پلتفرم معاملات برخط فلزات گرانبها، هیچگونه مسئولیتی در قبال تصمیمات
|
||||
اقتصادی فی مابین کاربران و سود و زیان حاصل از آن بر عهده قطره نمیباشد.
|
||||
اقتصادی فی مابین کاربران و سود و زیان حاصل از آن بر عهده کشکول گلد نمیباشد.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• قطره حق اصلاح و تغییر قوانین و مقررات ذکر شده در این صفحه را چه به صورت کلی و
|
||||
• کشکول گلد حق اصلاح و تغییر قوانین و مقررات ذکر شده در این صفحه را چه به صورت کلی و
|
||||
چه به صورت جزئی دارد و نسخه نهایی را در این صفحه در معرض دید قرار میدهد. استفاده از
|
||||
خدمات قطره پس از اعمال تغییرات، به معنای پذیرش همه تغییرات میباشد.
|
||||
خدمات کشکول گلد پس از اعمال تغییرات، به معنای پذیرش همه تغییرات میباشد.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• از لحظه خرید کاربران تا زمان تحویل طلای خریداری شده، مسئولیت حفظ و نگهداری اصل طلا
|
||||
بر عهده قطره میباشد.
|
||||
بر عهده کشکول گلد میباشد.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• کاربران قطره اذعان میدارند که از ریسکهای اقتصادی مربوط به سرمایهگذاری در
|
||||
• کاربران کشکول گلد اذعان میدارند که از ریسکهای اقتصادی مربوط به سرمایهگذاری در
|
||||
حوزه طلا مطلع بوده و با علم بر این موضوع اقدام به تبادل و سرمایهگذاری میکنند.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• قطره متعهد میشود در حد توان از حریم شخصی شما محافظت کند و در این راستا،
|
||||
• کشکول گلد متعهد میشود در حد توان از حریم شخصی شما محافظت کند و در این راستا،
|
||||
تکنولوژی مورد نیاز در سایت و پلتفرم را برای هر چه مطمئنتر و امنتر شدن استفاده شما،
|
||||
توسعه دهد.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• در صورت بروز نوسان شدید در قیمت طلا و هرگونه رویداد برهمزننده نظم حاکم بر بازار
|
||||
طلا، قطره میتواند برای خرید و فروش طلا توسط کاربر سقف تعیین کند تا دو طرف متضرر
|
||||
طلا، کشکول گلد میتواند برای خرید و فروش طلا توسط کاربر سقف تعیین کند تا دو طرف متضرر
|
||||
نشوند.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• قطره مجاز است بدون اطلاع قبلی و به صلاحدید شخصی نسبت به توقف سفارشگیری جدید،
|
||||
• کشکول گلد مجاز است بدون اطلاع قبلی و به صلاحدید شخصی نسبت به توقف سفارشگیری جدید،
|
||||
معاملات (از جمله سفارشهای باز) را متوقف کند؛ بدیهی است که کلیه سفارشهای تکمیلشده
|
||||
قبل از توقف سفارشگیری، پردازش و تحویل داده خواهد شد.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• در صورت بروز هرگونه اختلال در اینترنت و خدمات زیرساخت به دلایل حاکمیتی، هیچگونه
|
||||
مسئولیتی به عهده قطره نمیباشد.
|
||||
مسئولیتی به عهده کشکول گلد نمیباشد.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• درخواست برداشت ریال از حساب کاربری در سریعترین زمان ممکن پس از ثبت، بررسی خواهد
|
||||
@@ -115,35 +115,35 @@
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• اگر کاربر تحت هر عنوان اشتباهاً یا من غیر حق، وجوهی را به حساب کاربر منظور یا در
|
||||
محاسبات خود هر نوع اشتباهی نماید، قطره هر زمان مجاز و مختار است راساً و مستقلاً و
|
||||
محاسبات خود هر نوع اشتباهی نماید، کشکول گلد هر زمان مجاز و مختار است راساً و مستقلاً و
|
||||
بدون انجام هیچگونه تشریفات اداری و قضایی و دریافت اجازه کتبی از متعهد (صاحب حساب)
|
||||
در رفع اشتباه و برداشت از حسابهای وی اقدام نماید و تشخیص نسبت به وقوع اشتباه یا
|
||||
پرداخت بدون حق و لزوم برداشت از حساب معتبر خواهد بود و کاربر حق هرگونه اعتراض و
|
||||
ادعایی را در خصوص نحوه عملکرد قطره از هر جهت از خود ساقط مینماید.
|
||||
ادعایی را در خصوص نحوه عملکرد کشکول گلد از هر جهت از خود ساقط مینماید.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• در صورت بروز هرگونه مشکل یا ابهام در هر یک از معاملات (مانند دستکاری قیمت، اختلال
|
||||
در وبسرویسها، انجام معامله خارج از دامنه نوسان و ...)، قطره حق دارد مستقلاً آن
|
||||
در وبسرویسها، انجام معامله خارج از دامنه نوسان و ...)، کشکول گلد حق دارد مستقلاً آن
|
||||
معامله را ابطال کرده و داراییهای هر یک از طرفین را به حساب خودشان عودت دهد. بدیهی
|
||||
است در صورتی که اشکال از سمت قطره باشد، شرکت موظف خواهد بود که جبران خسارت نماید
|
||||
است در صورتی که اشکال از سمت کشکول گلد باشد، شرکت موظف خواهد بود که جبران خسارت نماید
|
||||
و در غیر این صورت، کاربر حق هرگونه اعتراض و ادعایی در خصوص نحوه عملکرد از هر جهت را
|
||||
از خود ساقط مینماید.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• در صورت فوت یا حجر کاربر، قطره پیرو قوانین جمهوری اسلامی ایران میباشد. کاربر
|
||||
با علم و اطلاع از مقررات این بند نسبت به افتتاح حساب کاربری در قطره اقدام نموده و
|
||||
• در صورت فوت یا حجر کاربر، کشکول گلد پیرو قوانین جمهوری اسلامی ایران میباشد. کاربر
|
||||
با علم و اطلاع از مقررات این بند نسبت به افتتاح حساب کاربری در کشکول گلد اقدام نموده و
|
||||
کاربر، اشخاص ثالث، ورثه یا قائممقام قانونی ایشان حق اعتراض و یا ادعایی در آینده در
|
||||
این خصوص نخواهند داشت.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• هزینه خدمات و کارمزد تراکنشهای مالی انجام شده در مطابق با توضیحات ارائه شده در
|
||||
صفحه راهنمای استفاده از قطره میباشد.
|
||||
صفحه راهنمای استفاده از کشکول گلد میباشد.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• تمامی علائم تجاری، طرحهای گرافیکی، رابط کاربری، رابط بصری، عکس، لوگو، کدهای
|
||||
نرمافزار، ساختار، نحوه بیان، تنظیم مطالب و محتوای موجود در قطره و شبکههای متعلق
|
||||
به قطره و بهطور کلی، سایر حقوق و امتیازات مربوطه منحصراً در مالکیت قطره
|
||||
میباشد و هیچ شخصی حق استفاده از آن را بدون رضایت قطره ندارد.
|
||||
نرمافزار، ساختار، نحوه بیان، تنظیم مطالب و محتوای موجود در کشکول گلد و شبکههای متعلق
|
||||
به کشکول گلد و بهطور کلی، سایر حقوق و امتیازات مربوطه منحصراً در مالکیت کشکول گلد
|
||||
میباشد و هیچ شخصی حق استفاده از آن را بدون رضایت کشکول گلد ندارد.
|
||||
</div>
|
||||
<div class="mt-5 text-xs leading-5">
|
||||
• اگر هر یک از مفاد این موافقتنامه بر اساس هر قانون لازمالاجرا، نامعتبر یا غیرقابل
|
||||
@@ -222,12 +222,12 @@ function shareCode() {
|
||||
const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر!
|
||||
با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر!
|
||||
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای قطره جا نمونید.
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای کشکول گلد جا نمونید.
|
||||
روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید.
|
||||
|
||||
ghatreh.gold/login?id=${userStore.userInfo?.referral_id}`
|
||||
kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}`
|
||||
navigator.share({
|
||||
title: 'قطره',
|
||||
title: 'کشکول گلد',
|
||||
text: val
|
||||
})
|
||||
// message.info('کد رونوشت شد')
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<a class="w-full" href="tel:09128081392">
|
||||
<BasicButton class="w-full" type="primary">تماس با پشتیبانی</BasicButton>
|
||||
</a>
|
||||
<a href="https://t.me/ghatreh">
|
||||
<a href="https://t.me/kashkol">
|
||||
<img src="@/assets/img/telegram.png" alt="" class="h-10 w-10"/>
|
||||
</a>
|
||||
</div>
|
||||
@@ -85,12 +85,12 @@ function shareCode() {
|
||||
const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر!
|
||||
با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر!
|
||||
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای قطره جا نمونید.
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای کشکول گلد جا نمونید.
|
||||
روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید.
|
||||
|
||||
ghatreh.gold/login?id=${userStore.userInfo?.referral_id}`
|
||||
kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}`
|
||||
navigator.share({
|
||||
title: 'قطره',
|
||||
title: 'کشکول گلد',
|
||||
text: val
|
||||
})
|
||||
// message.info('کد رونوشت شد')
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
<div>{{ toJalaliOutOfUTC(item.expire_at) }}</div>
|
||||
</div>
|
||||
<div class="flex justify-between mt-2">
|
||||
<div :class="item.gold >= 0? 'text-green-600':'text-red-600'"
|
||||
class="text-gray-500 text-xs number-ltr">{{ item.gold }}
|
||||
<div :class="getTransactionGoldAmount(item) >= 0? 'text-green-600':'text-red-600'"
|
||||
class="text-gray-500 text-xs number-ltr">{{ formatGoldAmount(getTransactionGoldAmount(item)) }}
|
||||
<div>{{item.unit}}</div>
|
||||
</div>
|
||||
<div class="text-gray-500 flex gap-1 text-xs items-center number-ltr">
|
||||
<div v-if="!isShopProduct" class="text-gray-500 flex gap-1 text-xs items-center number-ltr">
|
||||
<div :class="item.cash > 0 ? 'text-green-600':'text-red-600'" class="text-base">
|
||||
{{ usePriceWithoutType(item.cash?? 0) }}
|
||||
</div>
|
||||
@@ -25,11 +25,31 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="isGold" class="flex w-full justify-between mt-2">
|
||||
<template v-if="isShopProduct">
|
||||
<div class="flex w-full justify-between mt-2">
|
||||
<div class="text-gray-500">تعداد:</div>
|
||||
<div class="text-gray-500 text-xs number-ltr">{{ item?.gold ?? 0 }}</div>
|
||||
</div>
|
||||
<div class="flex w-full justify-between mt-2">
|
||||
<div class="text-gray-500">قیمت کل:</div>
|
||||
<div class="text-gray-500 flex gap-1 text-xs items-center number-ltr">
|
||||
<div class="text-base">{{ usePriceWithoutType(item.order?.total_price ?? 0) }}</div>
|
||||
ریال
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex w-full justify-between mt-2">
|
||||
<div class="text-gray-500">قیمت واحد:</div>
|
||||
<div class="text-gray-500 flex gap-1 text-xs items-center number-ltr">
|
||||
<div class="text-base">{{ usePriceWithoutType(item.order?.price ?? 0) }}</div>
|
||||
ریال
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else-if="isGold" class="flex w-full justify-between mt-2">
|
||||
<div class="text-gray-500">قیمت معامله:</div>
|
||||
<div class="text-gray-500 flex gap-1 text-xs items-center">
|
||||
<!-- <div class="text-base">{{ typeof parseInt((Math.abs(item.cash) / Math.abs(item.gold)).toFixed(0)) }}</div>-->
|
||||
<div class="text-base">{{ usePriceWithoutType(parseInt((Math.abs(item.cash) / Math.abs(item.gold)).toFixed(0))) }}</div>
|
||||
<div class="text-base">{{ usePriceWithoutType(getTransactionTradePrice(item)) }}</div>
|
||||
ریال
|
||||
</div>
|
||||
</div>
|
||||
@@ -37,7 +57,7 @@
|
||||
<div class="text-gray-500">وضعیت :</div>
|
||||
<div class="text-gray-500 flex gap-1 text-xs items-center">
|
||||
<ATag class="!py-1 !px-6 !ml-0" color="blue">
|
||||
{{ (item.order?.sts_str ?? item.withdraw?.sts_str )?? item?.title}}
|
||||
{{ (item.order?.sts_str ?? item.withdraw?.sts_str) ?? item?.title }}
|
||||
</ATag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -60,20 +80,44 @@
|
||||
ریال
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.order" class="flex justify-between mb-3">
|
||||
<div class="text-primary">قیمت هر گرم طلا حین معامله:</div>
|
||||
<div class="flex text-xs items-center number-ltr">
|
||||
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.price?? 0) }}</div>
|
||||
ریال
|
||||
<template v-if="isShopProduct">
|
||||
<div class="flex justify-between mb-3">
|
||||
<div class="text-primary">تعداد:</div>
|
||||
<div class="flex text-xs items-center number-ltr">
|
||||
<div class="text-base ml-1">{{ item.order?.number ?? 0 }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between mb-3">
|
||||
<div class="text-primary">مقدار {{item.wallet?.product? item.wallet.product.title: 'آبشده' }} مبادله شده:</div>
|
||||
<div :class="item.gold >= 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center number-ltr">
|
||||
<div class="text-base ml-1">{{ item.gold }}</div>
|
||||
{{item.unit}}
|
||||
<div class="flex justify-between mb-3">
|
||||
<div class="text-primary">قیمت کل:</div>
|
||||
<div class="flex text-xs items-center number-ltr">
|
||||
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.total_price ?? 0) }}</div>
|
||||
ریال
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between mb-3">
|
||||
<div class="text-primary">قیمت واحد:</div>
|
||||
<div class="flex text-xs items-center number-ltr">
|
||||
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.price ?? 0) }}</div>
|
||||
ریال
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div v-if="item.order" class="flex justify-between mb-3">
|
||||
<div class="text-primary">قیمت هر گرم طلا حین معامله:</div>
|
||||
<div class="flex text-xs items-center number-ltr">
|
||||
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.price?? 0) }}</div>
|
||||
ریال
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between mb-3">
|
||||
<div class="text-primary">مقدار {{item.wallet?.product? item.wallet.product.title: 'آبشده' }} مبادله شده:</div>
|
||||
<div :class="getTransactionGoldAmount(item) >= 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center number-ltr">
|
||||
<div class="text-base ml-1">{{ formatGoldAmount(getTransactionGoldAmount(item)) }}</div>
|
||||
{{item.unit}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="flex justify-between mb-3">
|
||||
<div class="text-primary">موجودی کیف پول:</div>
|
||||
<div :class="item.cash > 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center number-ltr">
|
||||
@@ -140,7 +184,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import Icon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import { usePriceWithoutType } from '../../../../utils/usePrice'
|
||||
import { formatGoldAmount, getTransactionGoldAmount, getTransactionTradePrice, usePriceWithoutType } from '../../../../utils/usePrice'
|
||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
@@ -156,6 +200,7 @@ interface Prop {
|
||||
const props = withDefaults(defineProps<Prop>(), {})
|
||||
const isUp = computed(() => props.item.type === 3 || props.item.type === 1 || props.item.type === 8 || props.item.type === 9)
|
||||
const isGold = computed(() => props.item.type === 1 || props.item.type === 2 || props.item.type === 10)
|
||||
const isShopProduct = computed(() => !!props.item?.product_id)
|
||||
/*const title = computed(() => {
|
||||
if (isUp.value) {
|
||||
if (isGold.value) {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<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>
|
||||
<div class="font-bold text-lg">انتقال کشکول گلد</div>
|
||||
<a-form-item
|
||||
:rules="required()"
|
||||
class="w-full gap-2 !flex-col"
|
||||
@@ -45,7 +45,7 @@
|
||||
<a-form ref="formRef" :model="transferForm" class="!mt-5" name="basic"
|
||||
@finish="submitTransfer()">
|
||||
<div class="flex flex-col gap-4 pb-12 w-full">
|
||||
<div class="font-bold text-lg">انتقال قطره</div>
|
||||
<div class="font-bold text-lg">انتقال کشکول گلد</div>
|
||||
<a-form-item
|
||||
:rules="required()"
|
||||
class="w-full mb-4rem gap-2 !flex-col"
|
||||
@@ -68,7 +68,7 @@
|
||||
<a-form ref="formRef" :model="transferForm" class="!mt-5" name="basic"
|
||||
@finish="finalRegister()">
|
||||
<div class="flex flex-col gap-4 pb-12 w-full">
|
||||
<!-- <div class="font-bold text-lg">انتقال قطره</div>-->
|
||||
<!-- <div class="font-bold text-lg">انتقال کشکول گلد</div>-->
|
||||
|
||||
|
||||
<div class="flex items-center justify-center gap-4">
|
||||
|
||||
@@ -402,12 +402,12 @@ function shareCode() {
|
||||
const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر!
|
||||
با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر!
|
||||
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای قطره جا نمونید.
|
||||
این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای کشکول گلد جا نمونید.
|
||||
روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید.
|
||||
|
||||
ghatreh.gold/login?id=${userStore.userInfo?.referral_id}`
|
||||
kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}`
|
||||
navigator.share({
|
||||
title: 'قطره',
|
||||
title: 'کشکول گلد',
|
||||
text: val
|
||||
})
|
||||
// message.info('کد رونوشت شد')
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<div v-if="isGold" class="flex w-full justify-between mt-2">
|
||||
<div class="text-gray-500">قیمت معامله:</div>
|
||||
<div class="text-gray-500 flex gap-1 text-xs items-center">
|
||||
<div class="text-base">{{ usePriceWithoutType((Math.abs(item.cash) / Math.abs(item.gold)).toFixed(0)) }}</div>
|
||||
<div class="text-base">{{ usePriceWithoutType(getTransactionTradePrice(item)) }}</div>
|
||||
ریال
|
||||
</div>
|
||||
</div>
|
||||
@@ -138,7 +138,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import Icon from "@/components/BasicPacks/BasicIcon.vue";
|
||||
import {usePriceWithoutType} from "../../../../utils/usePrice";
|
||||
import {getTransactionTradePrice, usePriceWithoutType} from "../../../../utils/usePrice";
|
||||
import BasicActionSheet from "@/components/BasicPacks/BasicActionSheet.vue";
|
||||
import {computed, ref} from "vue";
|
||||
import BasicButton from "@/components/BasicPacks/BasicButton.vue";
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<BasicInput
|
||||
v-model:value="form.value"
|
||||
addon-before="ریال"
|
||||
addon-bg-color="#521620"
|
||||
addon-bg-color="#a72b77"
|
||||
addon-text-color="white"
|
||||
place-holder="مبلغ"
|
||||
size="large"
|
||||
|
||||
@@ -435,7 +435,7 @@ const getcode=()=>{
|
||||
</div>
|
||||
</BasicButton>
|
||||
<div class="flex gap-1 justify-center mt-5 text-xs" @click="$emit('register',true)">اگر حساب کاربری ندارید
|
||||
<div class="font-bold text-[#521620]">از این قسمت</div>
|
||||
<div class="font-bold text-[#a72b77]">از این قسمت</div>
|
||||
ثبت نام کنید.
|
||||
</div>
|
||||
</a-form-item>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__APP_CONFIG__?: Record<string, any>;
|
||||
__BOOT_TIMEOUT__?: number;
|
||||
__APP_BOOTSTRAPPED__?: boolean;
|
||||
__APP_BOOT_SIMPLE_RETRY__?: () => void;
|
||||
__APP_BOOT_CLEAN_RELOAD__?: () => Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -10,7 +10,7 @@ export default defineConfig({
|
||||
],
|
||||
theme: {
|
||||
colors: {
|
||||
"primary": "#521620",
|
||||
"primary": "#a72b77",
|
||||
"secondary": "#ffffff",
|
||||
"tertiary": "#e0be7f"
|
||||
}
|
||||
|
||||