feat(user): identity gate for wallet/gift card and custom nav icons
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
type CustomerGiftCardItem,
|
||||
} from '@/api/giftCard'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { isCustomerIdentityVerified } from '@/utils/customerIdentity'
|
||||
|
||||
export interface GiftCardPageContext {
|
||||
form: Ref<{ code: string }>
|
||||
@@ -17,6 +19,7 @@ export interface GiftCardPageContext {
|
||||
listLoading: Ref<boolean>
|
||||
loadMyGiftCards: () => Promise<void>
|
||||
fillCode: (code: string) => void
|
||||
identityRequiredVisible: Ref<boolean>
|
||||
}
|
||||
|
||||
export const GIFT_CARD_PAGE_CONTEXT_KEY: InjectionKey<GiftCardPageContext> =
|
||||
@@ -29,6 +32,8 @@ export function useGiftCardPage() {
|
||||
const available = ref<CustomerGiftCardItem[]>([])
|
||||
const history = ref<CustomerGiftCardItem[]>([])
|
||||
const listLoading = ref(false)
|
||||
const identityRequiredVisible = ref(false)
|
||||
const userStore = useUserStore()
|
||||
|
||||
const disableButton = computed(() => {
|
||||
if (!loading.value) {
|
||||
@@ -56,6 +61,10 @@ export function useGiftCardPage() {
|
||||
}
|
||||
|
||||
async function registerGiftCard() {
|
||||
if (!isCustomerIdentityVerified(userStore.userInfo?.is_legal)) {
|
||||
identityRequiredVisible.value = true
|
||||
return
|
||||
}
|
||||
const code = form.value.code.trim()
|
||||
if (!code) return
|
||||
|
||||
@@ -94,6 +103,7 @@ export function useGiftCardPage() {
|
||||
listLoading,
|
||||
loadMyGiftCards,
|
||||
fillCode,
|
||||
identityRequiredVisible,
|
||||
}
|
||||
|
||||
provide(GIFT_CARD_PAGE_CONTEXT_KEY, context)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<div class="gift-card-page-root">
|
||||
<DesktopGiftCardView v-show="isDesktop" />
|
||||
<MobileGiftCardView v-show="!isDesktop" />
|
||||
<IdentityRequiredDialog v-model:show="identityRequiredVisible" action="ثبت کد هدیه" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -10,10 +11,11 @@ import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||
import { useGiftCardPage } from './composables/useGiftCardPage'
|
||||
import DesktopGiftCardView from './desktop/DesktopGiftCardView.vue'
|
||||
import MobileGiftCardView from './mobile/MobileGiftCardView.vue'
|
||||
import IdentityRequiredDialog from '@/components/IdentityRequiredDialog.vue'
|
||||
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
|
||||
useGiftCardPage()
|
||||
const { identityRequiredVisible } = useGiftCardPage()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user