feat: dynamic assets banner price stats alignment intrinsic value labels and closed store text

This commit is contained in:
2026-11-18 18:26:18 +03:30
parent 21472823b4
commit 1aceafd02d
18 changed files with 384 additions and 73 deletions
+21 -2
View File
@@ -25,9 +25,12 @@
:placeHolder="props.placeHolder"
:size="props.size"
:type="props.type === 'price'? 'tel':props.type"
:inputmode="props.inputmode"
:inputmode="props.onlyPersian ? 'text' : props.inputmode"
:pattern="props.pattern"
:dir="props.onlyPersian ? 'rtl' : undefined"
:lang="props.onlyPersian ? 'fa' : undefined"
class=""
@keypress="handleKeyPress"
@input="handlerChange"
@change="handlerChange"
/>
@@ -59,6 +62,7 @@ interface Prop {
addonBgColor?: String
addonTextColor?: String
placeHolder?: String
onlyPersian?: boolean
}
//emits
@@ -74,7 +78,8 @@ const localValue = computed({
})
const props = withDefaults(defineProps<Prop>(), {
isPassword: false
isPassword: false,
onlyPersian: false
})
const emits = defineEmits(['update:value', 'onchange'])
@@ -83,6 +88,12 @@ function normalizeValue(value: unknown) {
return value
}
if (props.onlyPersian) {
return String(value)
.replace(/[a-zA-Z0-9]/g, '')
.replace(/[^\u0600-\u06FF\s\u200C]/g, '')
}
if (shouldNormalizeDecimalSeparators(props)) {
const isPrice = String(props.type ?? '').trim().toLowerCase() === 'price'
return normalizeDecimalInput(value as string | number, {
@@ -93,6 +104,14 @@ function normalizeValue(value: unknown) {
return persianToEnglishDigits(String(value))
}
function handleKeyPress(e: KeyboardEvent) {
if (props.onlyPersian) {
if (/[a-zA-Z0-9]/.test(e.key)) {
e.preventDefault()
}
}
}
const handlerChange = (e: Event | string) => {
const target = typeof e === 'string' ? null : (e.target as HTMLInputElement | null)
const raw = typeof e === 'string' ? e : target?.value
+22 -3
View File
@@ -133,10 +133,29 @@ export const persianValidation = computed(() => {
}
})
export const isValidPersian = () => {
export const isValidPersian = (title?: string) => {
return {
pattern: /^[\u0600-\u06FF\s]+$/,
message: 'فقط حروف فارسی مجاز است'
pattern: /^[\u0600-\u06FF\s\u200C]+$/,
message: title ? `${title} باید فقط با حروف فارسی وارد شود` : 'فقط حروف فارسی مجاز است'
}
};
export const persianNameValidation = (title = 'نام'): Rule => {
return {
validator: (_rule, value) => {
const text = String(value ?? '').trim()
if (!text) {
return Promise.resolve()
}
if (/[a-zA-Z]/.test(text)) {
return Promise.reject(`${title} باید فقط با حروف فارسی وارد شود`)
}
if (!/^[\u0600-\u06FF\s\u200C]+$/.test(text)) {
return Promise.reject(`${title} باید فقط شامل حروف فارسی باشد`)
}
return Promise.resolve()
},
trigger: ['change', 'blur'],
}
};
+5 -9
View File
@@ -257,21 +257,17 @@ export function stripHtmlMessage(message: string): string {
return replaceMazanehTerminology(message.replace(/<[^>]*>/g, '').trim())
}
export function getStoreClosedHint(customMessage?: unknown): string {
/** متن واحد بسته بودن فروشگاه — مستقیماً از تنظیمات ادمین (closed_message) یا پیش‌فرض */
export function resolveStoreClosedNotice(customMessage?: unknown): string {
const custom = typeof customMessage === 'string' ? customMessage.trim() : ''
if (custom) {
return stripHtmlMessage(custom)
}
return ''
return STORE_CLOSED_TITLE
}
export function getStoreClosedMessage(): string {
return ''
}
/** برای toast/اعلان: پیام ادمین یا عنوان پیش‌فرض */
export function resolveStoreClosedNotice(customMessage?: unknown): string {
return getStoreClosedHint(customMessage) || STORE_CLOSED_TITLE
export function getStoreClosedHint(customMessage?: unknown): string {
return resolveStoreClosedNotice(customMessage)
}
export function isMarketClosedForDisplay(): boolean {
@@ -0,0 +1,153 @@
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'
import { getConstByKey } from '@/api/const'
import { normalizePublicFileUrl } from '@/utils/file'
import assetsCopperBanner from '@/assets/img/assets-copper-banner.webp'
export interface AssetBannerItem {
icon?: string | null
show?: boolean
link?: string | null
typeClick?: 'link' | 'modal' | 'share' | null
modalText?: string | null
caption?: string | null
}
const loaded = ref(false)
const rawBanners = ref<AssetBannerItem[]>([])
const hasCustomConfig = ref(false)
const bannerLoading = ref(false)
export function useAssetsBanner() {
const router = useRouter()
const showModal = ref(false)
const modalContent = ref('')
async function loadBanner(force = false) {
if (!force && loaded.value) return
bannerLoading.value = true
try {
// 1. Try 'assets_banner' key first
const res = await getConstByKey('assets_banner')
let list: unknown[] = []
if (res) {
hasCustomConfig.value = true
if (typeof res === 'string') {
try {
list = JSON.parse(res)
} catch {
list = []
}
} else if (typeof res === 'object' && !Array.isArray(res) && 'value' in res) {
const val = (res as { value?: unknown }).value
if (typeof val === 'string') {
try {
list = JSON.parse(val)
} catch {
list = []
}
} else if (Array.isArray(val)) {
list = val
}
} else if (Array.isArray(res)) {
list = res
}
} else {
// Fallback: check 'app_banners'
const appBannersRes = await getConstByKey('app_banners')
if (appBannersRes) {
let parsed: unknown = appBannersRes
if (typeof appBannersRes === 'string') {
try {
parsed = JSON.parse(appBannersRes)
} catch {
parsed = null
}
} else if (typeof appBannersRes === 'object' && !Array.isArray(appBannersRes) && 'value' in appBannersRes) {
const val = (appBannersRes as { value?: unknown }).value
parsed = typeof val === 'string' ? JSON.parse(val) : val
}
if (parsed && typeof parsed === 'object' && Array.isArray((parsed as Record<string, unknown>).assetsBanner)) {
list = (parsed as Record<string, unknown>).assetsBanner as unknown[]
hasCustomConfig.value = true
}
}
}
if (Array.isArray(list)) {
rawBanners.value = list.map((item) => {
if (!item || typeof item !== 'object') return item as AssetBannerItem
const obj = item as AssetBannerItem
return {
...obj,
icon: obj.icon ? (normalizePublicFileUrl(obj.icon) ?? obj.icon) : null,
}
})
}
loaded.value = true
} catch (e) {
console.error('Error loading assets banner:', e)
} finally {
bannerLoading.value = false
}
}
const displayBanner = computed<AssetBannerItem | null>(() => {
// If admin has configured banners in DB
if (hasCustomConfig.value && rawBanners.value.length > 0) {
const active = rawBanners.value.find((b) => b.show !== false)
if (active) {
return active
}
// If admin configured banners but all are show: false, hide the banner completely
return null
}
// Default copper banner if not configured yet by admin
return {
icon: assetsCopperBanner,
show: true,
link: 'buyProduct',
typeClick: 'link',
caption: 'مس، قدم بعدی سبد دارایی شما — خرید و فروش شمش مس، ساده و آنلاین',
}
})
function handleBannerClick(banner: AssetBannerItem | null) {
if (!banner) return
const type = banner.typeClick
if (type === 'modal') {
if (banner.modalText) {
modalContent.value = banner.modalText
showModal.value = true
}
return
}
const targetLink = banner.link || (banner.typeClick === 'link' ? 'buyProduct' : null)
if (targetLink) {
if (targetLink.startsWith('http://') || targetLink.startsWith('https://')) {
window.open(targetLink, '_blank')
} else if (targetLink.startsWith('/')) {
router.push(targetLink)
} else {
try {
router.push({ name: targetLink })
} catch {
router.push(targetLink)
}
}
}
}
return {
bannerLoading,
displayBanner,
showModal,
modalContent,
loadBanner,
handleBannerClick,
}
}
+23 -3
View File
@@ -125,15 +125,24 @@
</article>
</section>
<button type="button" class="assets-banner-slot" @click="go('buyProduct')">
<button
v-if="displayBanner"
type="button"
class="assets-banner-slot"
@click="handleBannerClick(displayBanner)"
>
<img
:src="assetsCopperBanner"
alt="مس، قدم بعدی سبد دارایی شما — خرید و فروش شمش مس، ساده و آنلاین"
:src="displayBanner.icon || assetsCopperBanner"
:alt="displayBanner.caption || 'مس، قدم بعدی سبد دارایی شما — خرید و فروش شمش مس، ساده و آنلاین'"
loading="lazy"
decoding="async"
/>
</button>
<BasicModal v-model:visible="showModal" :custom-footer="true" destroy-on-close>
<div class="max-h-[54vh] ql-editor p-4" v-html="modalContent" />
</BasicModal>
<section class="assets-card assets-table-wrap">
<div class="assets-table-wrap__head">
<h2>دارایی‌ها</h2>
@@ -163,6 +172,7 @@
<script setup lang="ts">
import { computed, onMounted } from 'vue'
import router from '@/router'
import BasicModal from '@/components/BasicPacks/BasicModal.vue'
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
import { useDesktopBreakpoint } from '@/layouts/composables/useResponsiveLayout'
@@ -181,6 +191,7 @@ import {
import { formatWeightAmount } from '@/utils/usePrice'
import type { WalletMetalTotal } from '@/models/walletAssets'
import { useAssetsPortfolioChart } from './composables/useAssetsPortfolioChart'
import { useAssetsBanner } from './composables/useAssetsBanner'
import assetsCopperBanner from '@/assets/img/assets-copper-banner.webp'
import { getBoursecuActionIconSrc } from '@/utils/config'
@@ -334,7 +345,16 @@ function go(name: string, query?: Record<string, string>) {
router.push(query ? { name, query } : { name })
}
const {
displayBanner,
showModal,
modalContent,
loadBanner,
handleBannerClick,
} = useAssetsBanner()
onMounted(async () => {
void loadBanner()
await loadWalletAssets(true)
await initAssetsPortfolioChart()
})
@@ -23,8 +23,7 @@
color="#ffffff"
/>
</div>
<div class="status-box__title">{{ statusTitle }}</div>
<div v-if="statusHint" class="status-box__hint">{{ statusHint }}</div>
<div class="status-box__title whitespace-pre-line text-center px-3">{{ statusText }}</div>
</div>
</template>
@@ -49,10 +48,9 @@ import { useUserStore } from '@/store/userStore'
import { useHomeQuoteRows } from '@/views/base/home/composables/useHomeQuoteRows'
import {
NO_QUOTE_MESSAGE,
STORE_CLOSED_TITLE,
getPriceDisplayState,
getStoreClosedHint,
isHomeQuotePending,
resolveStoreClosedNotice,
} from '@/utils/storeHours'
const userStore = useUserStore()
@@ -60,15 +58,11 @@ const userStore = useUserStore()
const displayState = computed(() => getPriceDisplayState())
const quotePending = computed(() => isHomeQuotePending())
const statusTitle = computed(() =>
displayState.value === 'closed' ? STORE_CLOSED_TITLE : NO_QUOTE_MESSAGE
)
const statusHint = computed(() => {
const statusText = computed(() => {
if (displayState.value === 'closed') {
return getStoreClosedHint(userStore.getValueByKey('closed_message'))
return resolveStoreClosedNotice(userStore.getValueByKey('closed_message'))
}
return 'در حال حاضر قیمتی برای نمایش وجود ندارد.'
return NO_QUOTE_MESSAGE
})
const containerClass = computed(() => {
+22 -5
View File
@@ -8,7 +8,7 @@
>
<div class="text-center w-full">
<div>بالاترین قیمت امروز</div>
<div v-if="price" class="flex flex-col items-center mt-3">
<div v-if="hasPrice" class="flex flex-col items-center mt-3">
<div class="text-green-600 flex gap-1 text-xs items-center">
<div class="text-base">{{ usePriceWithoutType(highPrice) }}</div>
ریال
@@ -19,7 +19,7 @@
<div class="text-center w-full">
<div>پایین ترین قیمت امروز</div>
<div class="flex w-full mt-3 justify-evenly">
<div v-if="price" class="flex flex-col items-center">
<div v-if="hasPrice" class="flex flex-col items-center">
<div class="text-red-600 flex gap-1 text-xs items-center">
<div class="text-base">{{ usePriceWithoutType(lowPrice) }}</div>
ریال
@@ -35,6 +35,7 @@ import { computed } from 'vue'
import { usePriceWithoutType } from '../../../../utils/usePrice'
import { price } from '@/utils/price'
import { resolveMetalDayRangePrices, usePriceChart } from '../composables/usePriceChart'
import { useLandingLiveChart } from '../composables/useLandingLiveChart'
withDefaults(
defineProps<{
@@ -46,8 +47,9 @@ withDefaults(
)
const { selectedChartMetal, selectedMetalChartRatio } = usePriceChart()
const { dayHighPrice, dayLowPrice, liveUnitPrice } = useLandingLiveChart()
const rangePrices = computed(() =>
const fallbackRange = computed(() =>
resolveMetalDayRangePrices({
price: price.value,
metal: selectedChartMetal.value,
@@ -55,6 +57,21 @@ const rangePrices = computed(() =>
})
)
const highPrice = computed(() => rangePrices.value.high)
const lowPrice = computed(() => rangePrices.value.low)
const highPrice = computed(() => {
if (dayHighPrice.value && dayHighPrice.value > 0) {
return dayHighPrice.value
}
return fallbackRange.value.high
})
const lowPrice = computed(() => {
if (dayLowPrice.value && dayLowPrice.value > 0) {
return dayLowPrice.value
}
return fallbackRange.value.low
})
const hasPrice = computed(() =>
Boolean((highPrice.value && highPrice.value > 0) || price.value || (liveUnitPrice.value && liveUnitPrice.value > 0))
)
</script>
@@ -110,8 +110,8 @@ export function useHomeQuoteRows() {
return [
{ label: 'قیمت مس جهانی', value: text(copper), unit: copper > 0 ? 'دلار' : '' },
{ label: 'قیمت دلار بازار آزاد', value: text(dollar), unit: dollar > 0 ? 'ریال' : '' },
{ label: 'قیمت تن', value: text(ton), unit: ton > 0 ? 'ریال' : '' },
{ label: 'قیمت کیلوگرم', value: text(kilo), unit: kilo > 0 ? 'ریال' : '' },
{ label: 'ارزش ذاتی هر تن', value: text(ton), unit: ton > 0 ? 'ریال' : '' },
{ label: 'ارزش ذاتی هر کیلوگرم', value: text(kilo), unit: kilo > 0 ? 'ریال' : '' },
]
})
@@ -340,6 +340,46 @@ const dayChangeAmountLabel = computed(() => {
return `${delta > 0 ? '+' : '−'}${abs} ریال`
})
function isPointRecordedToday(timeMs: number): boolean {
try {
const tehranFormatter = new Intl.DateTimeFormat('en-CA', {
timeZone: 'Asia/Tehran',
year: 'numeric',
month: '2-digit',
day: '2-digit',
})
return tehranFormatter.format(new Date(timeMs)) === tehranFormatter.format(new Date())
} catch {
return Date.now() - timeMs < 24 * 60 * 60 * 1000
}
}
const todayChartPoints = computed(() => {
const points = chartPoints.value
const todayOnly = points.filter((p) => isPointRecordedToday(p.timeMs))
return todayOnly.length >= 2 ? todayOnly : points
})
const todayChartValues = computed(() =>
todayChartPoints.value.map((p) => p.price).filter((p) => Number.isFinite(p) && p > 0),
)
const dayRange = computed(() => {
const values = todayChartValues.value
const current = Number.isFinite(liveUnitPrice.value) && liveUnitPrice.value > 0 ? liveUnitPrice.value : 0
const allValues = current > 0 ? [...values, current] : values
if (!allValues.length) {
return { high: current, low: current }
}
return {
high: Math.max(...allValues),
low: Math.min(...allValues),
}
})
const dayHighPrice = computed(() => dayRange.value.high)
const dayLowPrice = computed(() => dayRange.value.low)
function resolveHoverFromEvent(
event: PointerEvent,
chart: { samples: ChartPlotSample[]; hasData: boolean },
@@ -439,14 +479,24 @@ function setupLiveChartDraw() {
observer.observe(liveChartPlotEl.value)
}
watch(
selectedChartProduct,
(product) => {
if (product) {
const { setChartMetal } = usePriceChart()
setChartMetal(metalFromProductTitle(product.title))
}
},
{ immediate: true },
)
function setLiveProduct(productId: number) {
if (!chartProductTabs.value.some((product) => product.id === productId)) return
const targetProduct = chartProductTabs.value.find((product) => product.id === productId)
if (!targetProduct) return
activeProductId.value = productId
liveChartHover.value = null
const product = selectedChartProduct.value
if (!product) return
const { setChartMetal } = usePriceChart()
setChartMetal(metalFromProductTitle(product.title))
setChartMetal(metalFromProductTitle(targetProduct.title))
}
async function setLiveChartRange(range: LandingHistoryRange) {
@@ -536,6 +586,9 @@ export function useLandingLiveChart() {
liveChartPlotEl,
liveSectionChart,
formattedLivePrice,
liveUnitPrice,
dayHighPrice,
dayLowPrice,
liveProductLabel,
liveChartRangeLabel,
liveMarketState,
@@ -57,8 +57,28 @@ export function resolveMetalDayRangePrices(options: {
metal: ChartMetalType
metalRatio: number
}) {
const baseHigh = options.price?.up?.buy ?? getTradeBuyPrice(options.price as Parameters<typeof getTradeBuyPrice>[0])
const baseLow = options.price?.up?.sell ?? getTradeSellPrice(options.price as Parameters<typeof getTradeSellPrice>[0])
let baseHigh = options.price?.up?.buy ?? getTradeBuyPrice(options.price as Parameters<typeof getTradeBuyPrice>[0])
let baseLow = options.price?.up?.sell ?? getTradeSellPrice(options.price as Parameters<typeof getTradeSellPrice>[0])
const tradePrice = getTradeBuyPrice(options.price as Parameters<typeof getTradeBuyPrice>[0])
// اگر سقف و کف بر اساس تن (بیش از ۱۰۰ میلیون ریال) آمده باشند، به مقیاس کیلوگرم تبدیل کن
if (baseHigh > 100_000_000) {
baseHigh = Math.round(baseHigh / 1000)
}
if (baseLow > 100_000_000) {
baseLow = Math.round(baseLow / 1000)
}
// اگر مقادیر نامعتبر باشند یا به دلیل مغایرت منبع فاصله غیرمنطقی داشته باشند
if (tradePrice > 0) {
if (baseHigh <= 0 || (baseHigh / tradePrice > 2.5) || (tradePrice / baseHigh > 2.5)) {
baseHigh = tradePrice
}
if (baseLow <= 0 || (baseLow / tradePrice > 2.5) || (tradePrice / baseLow > 2.5)) {
baseLow = tradePrice
}
}
const ratio = options.metalRatio || CHART_METAL_MARKUP_RATIO[options.metal]
return {
@@ -26,8 +26,7 @@
color="#ffffff"
/>
</div>
<p class="dhome-hero-price__closed-title">{{ statusTitle }}</p>
<p v-if="statusHint" class="dhome-hero-price__closed-hint">{{ statusHint }}</p>
<p class="dhome-hero-price__closed-title whitespace-pre-line text-center px-3">{{ statusText }}</p>
</div>
</template>
@@ -52,10 +51,9 @@ import { useUserStore } from '@/store/userStore'
import { useHomeQuoteRows } from '@/views/base/home/composables/useHomeQuoteRows'
import {
NO_QUOTE_MESSAGE,
STORE_CLOSED_TITLE,
getPriceDisplayState,
getStoreClosedHint,
isHomeQuotePending,
resolveStoreClosedNotice,
} from '@/utils/storeHours'
const userStore = useUserStore()
@@ -63,15 +61,11 @@ const userStore = useUserStore()
const displayState = computed(() => getPriceDisplayState())
const quotePending = computed(() => isHomeQuotePending())
const statusTitle = computed(() =>
displayState.value === 'closed' ? STORE_CLOSED_TITLE : NO_QUOTE_MESSAGE
)
const statusHint = computed(() => {
const statusText = computed(() => {
if (displayState.value === 'closed') {
return getStoreClosedHint(userStore.getValueByKey('closed_message'))
return resolveStoreClosedNotice(userStore.getValueByKey('closed_message'))
}
return 'در حال حاضر قیمتی برای نمایش وجود ندارد.'
return NO_QUOTE_MESSAGE
})
const { quoteRows } = useHomeQuoteRows()
@@ -3,10 +3,12 @@ import { computed } from 'vue'
import { price } from '@/utils/price'
import { usePriceWithoutType } from '@/utils/usePrice'
import { resolveMetalDayRangePrices, usePriceChart } from '../../composables/usePriceChart'
import { useLandingLiveChart } from '../../composables/useLandingLiveChart'
const { selectedChartMetal, selectedMetalChartRatio } = usePriceChart()
const { dayHighPrice, dayLowPrice } = useLandingLiveChart()
const rangePrices = computed(() =>
const fallbackRange = computed(() =>
resolveMetalDayRangePrices({
price: price.value,
metal: selectedChartMetal.value,
@@ -14,8 +16,19 @@ const rangePrices = computed(() =>
})
)
const highPrice = computed(() => rangePrices.value.high)
const lowPrice = computed(() => rangePrices.value.low)
const highPrice = computed(() => {
if (dayHighPrice.value && dayHighPrice.value > 0) {
return dayHighPrice.value
}
return fallbackRange.value.high
})
const lowPrice = computed(() => {
if (dayLowPrice.value && dayLowPrice.value > 0) {
return dayLowPrice.value
}
return fallbackRange.value.low
})
</script>
<template>
@@ -60,7 +60,7 @@ export function useProductsPageProvider() {
const isAfterCloseTime = ref(false)
const isProductInactive = ref(false)
const storeClosedMessage = computed(() =>
getStoreClosedHint(userStore.getValueByKey('closed_message')),
resolveStoreClosedNotice(userStore.getValueByKey('closed_message')),
)
function openStoreClosedModal() {
@@ -10,8 +10,7 @@
<!-- بنر بسته بودن فروشگاه -->
<div v-if="storeClosed" class="dproducts-closed-banner">
<span>🔒</span>
<span class="dproducts-closed-banner__title">{{ STORE_CLOSED_TITLE }}</span>
<span v-if="storeClosedMessage" class="dproducts-closed-banner__hint">— {{ storeClosedMessage }}</span>
<span class="dproducts-closed-banner__title">{{ storeClosedMessage || STORE_CLOSED_TITLE }}</span>
</div>
<div class="dproducts-tabs">
@@ -9,8 +9,7 @@
<div v-if="storeClosed" class="mx-4 mt-4 closed-banner">
<div class="closed-banner__icon">🔒</div>
<div class="closed-banner__body">
<div class="closed-banner__title">{{ STORE_CLOSED_TITLE }}</div>
<div v-if="storeClosedMessage" class="closed-banner__hint">{{ storeClosedMessage }}</div>
<div class="closed-banner__title">{{ storeClosedMessage || STORE_CLOSED_TITLE }}</div>
</div>
</div>
+16 -9
View File
@@ -34,19 +34,19 @@
@finish="registerAccount"
>
<template v-if="variant === 'desktop'">
<a-form-item :rules="[required()]" label="نام" name="fname">
<BasicInput v-model:value="userFormState.fname" place-holder="نام" size="large" />
<a-form-item :rules="[required('نام'), persianNameValidation('نام')]" label="نام" name="fname">
<BasicInput v-model:value="userFormState.fname" only-persian place-holder="نام" size="large" />
</a-form-item>
<a-form-item :rules="[required()]" label="نام خانوادگی" name="lname">
<BasicInput v-model:value="userFormState.lname" place-holder="نام خانوادگی" size="large" />
<a-form-item :rules="[required('نام خانوادگی'), persianNameValidation('نام خانوادگی')]" label="نام خانوادگی" name="lname">
<BasicInput v-model:value="userFormState.lname" only-persian place-holder="نام خانوادگی" size="large" />
</a-form-item>
</template>
<template v-else>
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" label="نام" name="fname">
<BasicInput v-model:value="userFormState.fname" place-holder="نام" />
<a-form-item :rules="[required('نام'), persianNameValidation('نام')]" class="home_appear_fade_in_down" label="نام" name="fname">
<BasicInput v-model:value="userFormState.fname" only-persian place-holder="نام" />
</a-form-item>
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" label="نام خانوادگی" name="lname">
<BasicInput v-model:value="userFormState.lname" place-holder="نام خانوادگی" />
<a-form-item :rules="[required('نام خانوادگی'), persianNameValidation('نام خانوادگی')]" class="home_appear_fade_in_down" label="نام خانوادگی" name="lname">
<BasicInput v-model:value="userFormState.lname" only-persian place-holder="نام خانوادگی" />
</a-form-item>
</template>
<a-form-item
@@ -218,7 +218,7 @@
<script lang="ts" setup>
import {mobileValidation, required} from '@/utils/inputRules'
import {mobileValidation, required, persianNameValidation} from '@/utils/inputRules'
import type { User } from '@/models/login'
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
@@ -284,6 +284,13 @@ function registerAccount() {
// console.log('test')
formRef.value?.validateFields().then(async () => {
try {
const fname = String(userFormState.fname ?? '').trim()
const lname = String(userFormState.lname ?? '').trim()
if (/[a-zA-Z]/.test(fname) || /[a-zA-Z]/.test(lname)) {
message.error('نام و نام خانوادگی باید فقط به زبان فارسی باشد')
return
}
// console.log('test',stepTwoVerify.value)
loading.value = true
// if (!stepTwoVerify.value) {
@@ -32,6 +32,13 @@ export function useRegisterForm() {
function registerAccount() {
formRef.value?.validateFields().then(async () => {
try {
const fname = String(userFormState.fname ?? '').trim()
const lname = String(userFormState.lname ?? '').trim()
if (/[a-zA-Z]/.test(fname) || /[a-zA-Z]/.test(lname)) {
message.error('نام و نام خانوادگی باید فقط به زبان فارسی باشد')
return
}
loading.value = true
URLUserType() === 'single' ? (userFormState.type = 2) : (userFormState.type = 1)
// فیلد مخفی + بدون لینک دعوت → کد را نفرست
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed } from 'vue'
import { mobileValidation, required } from '@/utils/inputRules'
import { mobileValidation, required, persianNameValidation } from '@/utils/inputRules'
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
import DialogVantOneButton from '@/components/DialogVantOneButton.vue'
@@ -65,12 +65,13 @@ function handleSuccessDismiss() {
name="desktop-register"
@finish="registerAccount"
>
<a-form-item :rules="[required()]" label="نام" name="fname">
<BasicInput v-model:value="userFormState.fname" place-holder="نام" size="large" />
<a-form-item :rules="[required('نام'), persianNameValidation('نام')]" label="نام" name="fname">
<BasicInput v-model:value="userFormState.fname" only-persian place-holder="نام" size="large" />
</a-form-item>
<a-form-item :rules="[required()]" label="نام خانوادگی" name="lname">
<a-form-item :rules="[required('نام خانوادگی'), persianNameValidation('نام خانوادگی')]" label="نام خانوادگی" name="lname">
<BasicInput
v-model:value="userFormState.lname"
only-persian
place-holder="نام خانوادگی"
size="large"
/>