/
index.vue
143 lines (128 loc) · 4.2 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<template>
<v-container class="main-container homefone">
<v-sheet
v-if="ready"
id="main-content"
class="homefone"
>
<MainNavBar :page.sync="page" />
<!-- ============================= TOP ============================= -->
<v-row ref="top" width="100%" justify="center">
<HomeTop :page.sync="page" />
</v-row>
<!-- ============================= LIST ============================= -->
<v-row ref="list" width="100%" justify="center">
<LazyHydrate when-idle>
<List
:list="$store.state.content.list"
:page.sync="goto"
/>
</LazyHydrate>
</v-row>
<!-- ============================= DGTEK ============================= -->
<v-row ref="dgtek" width="100%" justify="center">
<LazyHydrate when-idle>
<GreenSection />
</LazyHydrate>
</v-row>
<!-- ============================= INTERNET PLANS ============================= -->
<v-row ref="plans" width="100%" justify="center">
<LazyHydrate when-idle>
<InternetPlans :page.sync="goto" />
</LazyHydrate>
</v-row>
<!-- ============================= HOW TO CONNECT ============================= -->
<v-row ref="how-to-connect" width="100%" justify="center">
<LazyHydrate when-idle>
<HowToConnect :page.sync="goto" />
</LazyHydrate>
</v-row>
<!-- ============================= TESTIMONIALS ============================= -->
<v-row ref="testimonials" width="100%" justify="center">
<LazyHydrate when-idle>
<Testimonials :page.sync="goto" />
</LazyHydrate>
</v-row>
<!-- ============================= FAQ ============================= -->
<v-row ref="faq" width="100%" justify="center">
<LazyHydrate when-idle>
<FAQ :page.sync="goto" />
</LazyHydrate>
</v-row>
</v-sheet>
</v-container>
</template>
<script>
import LazyHydrate from 'vue-lazy-hydration'
import { mapState, mapGetters } from 'vuex'
import 'pineapple-main-nav-bar'
import 'pineapple-how-to-connect'
import 'pineapple-internet-plans'
import 'pineapple-testimonials'
import 'pineapple-faq'
export default {
components: {
LazyHydrate,
HomeTop: () => import('@/components/HomeTop.vue'),
List: () => import('@/components/List.vue'),
GreenSection: () => import('@/components/GreenSection.vue')
},
async asyncData ({ store, $axios }) {
const generalInfo = (await $axios.get('/content/general')).data
store.dispatch('UPDATE_GENERAL_INFO', generalInfo)
const homePageContent = (await $axios.get('/content/2')).data
store.commit('UPDATE_COMMON_INFO', homePageContent)
store.dispatch('content/UPDATE_CONTENT', homePageContent)
return {}
},
data: () => ({
main: null,
page: undefined,
goto: undefined
}),
computed: {
...mapState({
browserTabTitle: state => state.browserTabTitle,
emailSubject: state => state.emailSubject,
emailText: state => state.emailText
}),
...mapGetters(['pageHeight']),
ready () {
return !!this.$store.state.content.top
}
},
watch: {
/* Buttons on page */
goto (val) {
if (!val || !process.client) { return }
const target = val === '#contact' ? '#top' : val
const elem = target === '#footer' ? document.getElementById('pineapple-footer') : this.$refs[target.slice(1)]
if (!elem || elem.nodeType !== 1) { return }
elem.scrollIntoView({ behavior: 'smooth' })
this.goto = undefined
},
/* Buttons of main nav bar */
page (val) {
if (!val || !process.client) { return }
/* Inside page transition */
if (val.indexOf('#') === 0) {
const elem = val === '#footer' ? document.getElementById('pineapple-footer') : this.$refs[val.slice(1)]
elem.scrollIntoView({ behavior: 'smooth' })
this.page = undefined
return
}
/* Go to external url */
if (val.indexOf('http') === 0) {
window.open(val, '_blank')
this.page = undefined
return
}
/* Go to page */
this.$router.push({ name: val })
this.page = undefined
}
},
mounted () {
}
}
</script>