From 41042355469e02c6e4f2d027402a00361b8dbe55 Mon Sep 17 00:00:00 2001 From: adonis Date: Sat, 5 Sep 2026 17:02:22 +0330 Subject: [PATCH] feat: landing settings helper plus wallet and profile UX fixes Expose landing_* readers, fix OTP contrast on dark modal, and keep auth badge/card submit loading consistent. Co-authored-by: Cursor --- src/assets/css/main.less | 6 +++ src/components/BasicPacks/BasicModal.vue | 1 + src/utils/landingSettings.ts | 45 +++++++++++++++++++ .../base/user/composables/useUserPage.ts | 13 +++++- .../wallet/components/WalletAddCardForm.vue | 4 +- .../base/wallet/composables/useWalletPage.ts | 21 +++++++-- .../base/wallet/mobile/MobileWalletView.vue | 4 +- 7 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 src/utils/landingSettings.ts diff --git a/src/assets/css/main.less b/src/assets/css/main.less index d589975..145c7f3 100644 --- a/src/assets/css/main.less +++ b/src/assets/css/main.less @@ -179,10 +179,16 @@ body.van-overflow-hidden { border: 1px solid #d1d5db; border-radius: 4px; background-color: white; + color: #111827; + caret-color: #111827; + -webkit-text-fill-color: #111827; + color-scheme: light; //@apply bg-gray-50; &:focus-visible { background-color: #fff; + color: #111827; + -webkit-text-fill-color: #111827; //display: none; outline: none; border: 1px solid #a72b77 !important; diff --git a/src/components/BasicPacks/BasicModal.vue b/src/components/BasicPacks/BasicModal.vue index 5f45df1..9315194 100644 --- a/src/components/BasicPacks/BasicModal.vue +++ b/src/components/BasicPacks/BasicModal.vue @@ -11,6 +11,7 @@ :width="props.width" :ok-text="props.okText" :cancel-text="props.cancelText" + :confirm-loading="props.loading" :closable="props.closable" :wrapClassName="props.wrapClassName" > diff --git a/src/utils/landingSettings.ts b/src/utils/landingSettings.ts new file mode 100644 index 0000000..b6ff707 --- /dev/null +++ b/src/utils/landingSettings.ts @@ -0,0 +1,45 @@ +export const LANDING_SETTING_PREFIXES = [ + 'landing_site', + 'landing_header', + 'landing_hero', + 'landing_live_price', + 'landing_calculator', + 'landing_feature', + 'landing_steps', + 'landing_trust', + 'landing_faq', + 'landing_buttom_cta', + 'landing_footer' +] as const + +export type LandingSettingPrefix = (typeof LANDING_SETTING_PREFIXES)[number] + +function isFlagOn(value: unknown): boolean { + const v = String(value ?? '').trim().toLowerCase() + return v === 'true' || v === '1' || v === 'yes' || v === 'activate' +} + +export function isLandingEnabled(getByKey: (key: string) => unknown): boolean { + return isFlagOn(getByKey('has_landing')) +} + +export function getLandingSetting(getByKey: (key: string) => unknown, key: string): string { + return String(getByKey(key) ?? '') +} + +export function matchesLandingPrefix(key: string, prefix: string): boolean { + return key === prefix || key.startsWith(`${prefix}_`) +} + +export function pickLandingSettings( + settings: Array<{ key?: string | number; value?: unknown }>, + prefix: string +): Record { + const out: Record = {} + for (const row of settings) { + const key = String(row.key ?? '') + if (!matchesLandingPrefix(key, prefix)) continue + out[key] = String(row.value ?? '') + } + return out +} diff --git a/src/views/base/user/composables/useUserPage.ts b/src/views/base/user/composables/useUserPage.ts index 0a0a349..485721c 100644 --- a/src/views/base/user/composables/useUserPage.ts +++ b/src/views/base/user/composables/useUserPage.ts @@ -1,4 +1,4 @@ -import { computed, inject, onMounted, provide, ref, type InjectionKey } from 'vue' +import { computed, inject, onMounted, provide, ref, watch, type InjectionKey } from 'vue' import { loading, removeToken } from '@/utils' import { guideTypePassword, @@ -78,7 +78,7 @@ export function useUserPage() { const isLegal = computed(() => { const result = { title: '', color: '', icon: '' } - switch (userFormState.value.is_legal) { + switch (userStore.userInfo?.is_legal) { case 0: result.title = 'احراز هویت نشده' result.color = 'reject' @@ -205,6 +205,7 @@ kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}` loading.value = true const res: any = await updateMe(userFormState.value) await userStore.getMyInfo() + setForm() editPassVisible.value = false message.success( res?.message || 'اطلاعات شما با موفقیت به روز رسانی شد', @@ -254,6 +255,14 @@ kh.kashkolgold.ir/login?id=${userStore.userInfo?.referral_id}` } }) + watch( + () => userStore.userInfo, + (info) => { + if (!info) return + setForm() + }, + ) + const context: UserPageContext = { userStore, userFormState, diff --git a/src/views/base/wallet/components/WalletAddCardForm.vue b/src/views/base/wallet/components/WalletAddCardForm.vue index e05ca96..f88f1cc 100644 --- a/src/views/base/wallet/components/WalletAddCardForm.vue +++ b/src/views/base/wallet/components/WalletAddCardForm.vue @@ -6,12 +6,12 @@ - - ثبت + ثبت diff --git a/src/views/base/wallet/composables/useWalletPage.ts b/src/views/base/wallet/composables/useWalletPage.ts index 94acf1c..29325fd 100644 --- a/src/views/base/wallet/composables/useWalletPage.ts +++ b/src/views/base/wallet/composables/useWalletPage.ts @@ -15,6 +15,7 @@ import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout' import type { TableEngineInput, TableOutput } from '@/models/table' import { getTransactionTable, getTransactionTable2 } from '@/api/transaction' import { formatWalletMinHint, parseWalletMinRial } from '@/utils/walletMinAmount' +import { useWalletAssets } from '@/composables/useWalletAssets' export interface WalletPageContext { isDeposit: ReturnType> @@ -53,11 +54,13 @@ export function useWalletPage() { const walletStore = useWalletStore() const userStore = useUserStore() const settingsStore = useSettingsStore() + const { loadWalletAssets } = useWalletAssets() const isDesktop = useDesktopBreakpoint() const showAddCard = ref(false) const chargeAccountModal = ref(false) const showConfirmCode = ref(false) const infoVisible = ref(false) + const withdrawInFlight = ref(false) const refOtpInput = ref | null>(null) const mobileDepositScrollEl = ref(null) const desktopDepositScrollEl = ref(null) @@ -151,15 +154,16 @@ export function useWalletPage() { } async function addCard() { + if (loading.value) return try { loading.value = true const res: any = await createCard(cardForm.value) - await getCards() showAddCard.value = false cardForm.value = { birth_date: 0, shaba_number: '' } message.success( res?.message || 'اطلاعات کارت بانکی شما ثبت شد و پس از تایید ادمین فعال سازی خواهد شد', ) + await getCards() } catch (e) { console.log(e) } finally { @@ -223,18 +227,27 @@ export function useWalletPage() { } async function handleOnComplete(value: string) { + if (withdrawInFlight.value) { + return + } + withdrawInFlight.value = true try { infoVisible.value = true showConfirmCode.value = false await withdraw({ ...form.value, otp: value }) - await walletStore.getMyWallet() + await Promise.all([ + walletStore.getMyWallet(), + loadWalletAssets(true), + ]) await message.success('عملیات با موفقیت انجام شد') resetData() } catch (e) { console.log(e) + } finally { + infoVisible.value = false + refOtpInput.value?.clearInput() + withdrawInFlight.value = false } - infoVisible.value = false - refOtpInput.value?.clearInput() } onMounted(async () => { diff --git a/src/views/base/wallet/mobile/MobileWalletView.vue b/src/views/base/wallet/mobile/MobileWalletView.vue index b8b6a6b..54773cf 100644 --- a/src/views/base/wallet/mobile/MobileWalletView.vue +++ b/src/views/base/wallet/mobile/MobileWalletView.vue @@ -188,12 +188,12 @@ - -
ثبت
+ ثبت
بازگشت