From 036184c68be198545f94e904a7281d84b67d6da5 Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Sun, 8 Nov 2026 13:26:54 +0330 Subject: [PATCH] feat: add deposit identifier, tip note, and receipt upload in deposit guide modal --- src/api/wallet.ts | 4 + src/utils/depositGuideText.ts | 75 ++- .../components/WalletDepositGuideModal.vue | 501 +++++++++++++++++- src/views/base/wallet/index.vue | 11 +- 4 files changed, 559 insertions(+), 32 deletions(-) diff --git a/src/api/wallet.ts b/src/api/wallet.ts index 559cb8e..309c0a7 100644 --- a/src/api/wallet.ts +++ b/src/api/wallet.ts @@ -16,6 +16,10 @@ export const deposit = async (obj: Transaction): Promise => { return await useAxios.post(`/customer/charge_account`, obj) } +export const submitDepositRequest = async (formData: FormData): Promise => { + return await useAxios.postForm(`/customer/wallet/deposit_request`, formData) +} + export const createCard = async (obj: Card): Promise => { return await useAxios.post(`/customer/account`, obj) } diff --git a/src/utils/depositGuideText.ts b/src/utils/depositGuideText.ts index a7e9807..d1e63d0 100644 --- a/src/utils/depositGuideText.ts +++ b/src/utils/depositGuideText.ts @@ -18,10 +18,10 @@ export const DEFAULT_DEPOSIT_SUPPORT_MESSAGE_TEXT = 'باسلام، %نام هستم. کدپیگیری و مبلغ واریزی من:' /** الگوی متغیر نام — ٪نام / %نام / % نام / %نام% */ -const NAME_PLACEHOLDER_RE = /[%٪]\s*نام(?:\s*[%٪])?/gu -const CARD_PLACEHOLDER_RE = /[%٪]\s*کارت(?:\s*[%٪])?/gu -const ACCOUNT_PLACEHOLDER_RE = /[%٪]\s*حساب(?:\s*[%٪])?/gu -const SHEBA_PLACEHOLDER_RE = /[%٪]\s*شبا(?:\s*[%٪])?/gu +const NAME_PLACEHOLDER_RE = /[%٪]\s*نام[%٪]?/gu +const CARD_PLACEHOLDER_RE = /[%٪]\s*کارت[%٪]?/gu +const ACCOUNT_PLACEHOLDER_RE = /[%٪]\s*حساب[%٪]?/gu +const SHEBA_PLACEHOLDER_RE = /[%٪]\s*شبا[%٪]?/gu export function getCustomerNameFromUser(): string { try { @@ -47,21 +47,72 @@ export function renderDepositSupportMessageText( return template.replace(NAME_PLACEHOLDER_RE, name) } -/** جایگزینی متغیرها در متن راهنمای واریز — ٪نام / %نام، ٪کارت / %کارت، ٪حساب / %حساب، ٪شبا / %شبا */ +/** + * حذف شماره‌های حساب، شبا و کارت و همچنین ارقام زائد از متن راهنما؛ + * این اطلاعات در ردیف‌های اختصاصی مودال با دکمه کپی نمایش داده می‌شوند. + */ +function stripDepositGuideNumbers(text: string, vars?: DepositGuideVars): string { + let cleaned = text + + if (vars) { + const rawValues = [ + vars.sheba, + vars.sheba ? vars.sheba.replace(/^IR/i, '').trim() : '', + vars.sheba ? vars.sheba.replace(/^IR/i, '').replace(/\s+/g, '') : '', + vars.sheba ? formatDepositSheba(vars.sheba) : '', + vars.cardNumber, + vars.cardNumber ? vars.cardNumber.replace(/\s+/g, '') : '', + vars.cardNumber ? formatDepositCardNumber(vars.cardNumber) : '', + vars.accountNumber, + vars.accountNumber ? vars.accountNumber.replace(/\s+/g, '') : '', + ] + .map((v) => String(v ?? '').trim()) + .filter((v) => v.length >= 6) + + rawValues.sort((a, b) => b.length - a.length) + for (const val of rawValues) { + if (!val) continue + const escaped = val.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + cleaned = cleaned.replace(new RegExp(escaped, 'gi'), '') + } + } + + // حذف توالی‌های رقمی ۵ رقم یا بیشتر (فارسی و انگلیسی با فاصله یا خط تیره بین ارقام) + cleaned = cleaned.replace(/(?:^|[^\w\d۰-۹])[\d۰-۹][\d۰-۹\s-]{3,}[\d۰-۹](?=[^\w\d۰-۹]|$)/gu, '') + + // پالایش خطوط: حذف خطوطی که صرفاً از رقم/فاصله/علائم تشکیل شده‌اند یا برچسب‌های مرده + const lines = cleaned.split('\n') + const filteredLines = lines + .map((line) => { + const withoutDigitsAndPunct = line.replace(/[\d۰-۹\s.,:;–—/\\()-]/g, '') + if (withoutDigitsAndPunct.length === 0) { + return '' + } + const trimmed = line.trim() + if (/^(?:شماره\s*(?:شبا|حساب|کارت)|شبا|حساب|کارت)\s*[::-]?$/u.test(trimmed)) { + return '' + } + return trimmed + }) + .filter((line) => line.length > 0) + + return filteredLines.join('\n').trim() +} + +/** جایگزینی متغیرها در متن راهنمای واریز — ٪نام / %نام (کارت، حساب و شبا چون ردیف جداگانه دارند حذف می‌شوند) */ export function renderDepositGuideText( template: string, vars: DepositGuideVars, ): string { const accountHolder = String(vars.accountHolder ?? '').trim() - const cardNumber = String(vars.cardNumber ?? '').trim() - const accountNumber = String(vars.accountNumber ?? '').trim() - const sheba = String(vars.sheba ?? '').trim() - return template - .replace(SHEBA_PLACEHOLDER_RE, sheba) - .replace(ACCOUNT_PLACEHOLDER_RE, accountNumber) - .replace(CARD_PLACEHOLDER_RE, cardNumber) + let text = template + .replace(SHEBA_PLACEHOLDER_RE, '') + .replace(ACCOUNT_PLACEHOLDER_RE, '') + .replace(CARD_PLACEHOLDER_RE, '') .replace(NAME_PLACEHOLDER_RE, accountHolder) + + return stripDepositGuideNumbers(text, vars) } export function getDepositGuideVarsFromSettings(): DepositGuideVars { diff --git a/src/views/base/wallet/components/WalletDepositGuideModal.vue b/src/views/base/wallet/components/WalletDepositGuideModal.vue index 3265d43..17c4962 100644 --- a/src/views/base/wallet/components/WalletDepositGuideModal.vue +++ b/src/views/base/wallet/components/WalletDepositGuideModal.vue @@ -4,7 +4,7 @@ custom-footer :closable="false" wrap-class-name="app-premium-modal--no-header" - width="min(92vw, 380px)" + width="min(92vw, 420px)" >
+ + پیام به پشتیبانی (sms) + + +
+
+ + ثبت فیش و اطلاعات واریز +
+ +
+ + + + {{ depositAmountTomanText }} + +
+ +
+ + +
+ +
+ + +
+ + برای آپلود تصویر فیش کلیک کنید + JPG, PNG, WEBP, PDF (حداکثر ۱۰ مگابایت) +
+ +
+ پیش‌نمایش فیش +
+ + {{ receiptFile.name }} +
+ +
+
+ +
+ + +
+ + + ثبت درخواست واریز + +
@@ -115,11 +236,14 @@