-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.vue
36 lines (31 loc) · 901 Bytes
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<script setup lang="ts">
import { useNuxtApp, onBeforeMount } from '#imports'
import { useUserStore } from '@/stores/user'
import { useCategoryStore } from '@/stores/categories'
const nuxtApp = useNuxtApp()
const storeUser = useUserStore()
const storeCategory = useCategoryStore()
const cartStore = useCartStore()
const route = useRoute()
const affiliate: string = route.query.affiliate as string
const coupon = (route.query.coupon as string) || ''
onBeforeMount(async () => {
await storeUser.getUser()
await storeCategory.getCategorys()
await nuxtApp.$router.isReady()
if (affiliate) {
await cartStore.setAffiliate(affiliate)
}
if (coupon) {
await cartStore.setCoupon(coupon)
}
})
nuxtApp.hook('page:finish', () => {
window.scrollTo(0, 0)
})
</script>
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>