home.vue
5.56 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<template>
<div>
<home-slider v-model="homeSlider" :sliders="channel.slider" v-if="loadComponent"></home-slider>
<search-slider v-model="searchSlider" v-if="loadComponent"></search-slider>
<layout-body>
<header-box slot="header" class="home-header">
<span slot="left">
<i class="icon icon-back go-back-btn" v-if="showBack" @click="goBack"></i>
</span>
<span slot="title" class="logo">
</span>
<span slot="right">
<i class="icon icon-search-new" @click="searchSliderSwitch"></i>
<i class="icon icon-nav-new" @click="homeSliderSwitch"></i>
</span>
</header-box>
<scroller ref="scroller" @loading="loading">
<resource-box>
<div class="resources">
<component
:is="component.template_name"
v-for="(component, index) in (channel.home || []).filter(c => ['twoPicture', 'tfGoodsList', 'newSingleImage', 'BlkNewProductFloorResource'].some(k => k === c.template_name) )"
:lazy="index > 5"
v-if="loadComponent || index < 6"
:value="component"
:index="index"
:key="index"></component>
</div>
</resource-box>
</scroller>
</layout-body>
</div>
</template>
<script>
import {
FETCH_HOME_REQUEST,
FETCH_CHANNEL_REQUEST
} from 'store/channel/types';
import ResourceTwoImage from 'components/resources/resource-two-image';
import ResourceSingleImage from 'components/resources/resource-single-image';
import ResourceNewProductList from 'components/resources/resource-new-product-list';
import ResourceTfGoodsList from 'components/resources/resource-tfgoods-list';
import {SearchSlider} from 'components/search';
import {mapState} from 'vuex';
import {HomeSlider} from './components';
import {REPORT_YAS} from 'store/yoho/types';
import ResourceBox from 'components/resources/resource-box';
export default {
name: 'Channel',
data() {
return {
homeSlider: false,
searchSlider: false,
loadComponent: false,
showBack: false
};
},
asyncData({store}) {
return store.dispatch(FETCH_HOME_REQUEST);
},
computed: {
...mapState(['channel', 'yoho'])
},
methods: {
homeSliderSwitch() {
this.homeSlider = !this.homeSlider;
if (this.homeSlider) {
this.$store.dispatch(REPORT_YAS, {
params: {
appop: 'YB_H5_SECOND_HOME_BLK_SIDEBAR_C'
}
});
}
},
searchSliderSwitch() {
this.searchSlider = !this.searchSlider;
if (this.searchSlider) {
this.$store.dispatch(REPORT_YAS, {
params: {
appop: 'YB_H5_SECOND_HOME_BLK_SEARCH_C',
param: {
POS_ID: 101
}
}
});
}
},
async loading() {
await this.$store.dispatch(FETCH_HOME_REQUEST, true);
this.$refs.scroller.stop();
},
goBack() {
this.$store.dispatch(REPORT_YAS, {
params: {
appop: 'YB_H5_SECOND_HOME_BLK_BACK_C'
}
});
this.$yoho.goNewBack();
}
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.$yoho && vm.$yoho.blkBackStatus(false);
});
},
beforeRouteLeave(to, from, next) {
this.$yoho && this.$yoho.blkBackStatus(false);
next();
},
components: {
twoPicture: ResourceTwoImage,
tfGoodsList: ResourceTfGoodsList,
newSingleImage: ResourceSingleImage,
BlkNewProductFloorResource: ResourceNewProductList,
SearchSlider,
HomeSlider,
ResourceBox
},
mounted() {
if (this.$yoho.isAndroid) {
let appVersion = this.$cookie.get('app_version');
if (appVersion && typeof appVersion === 'string') {
let versions = appVersion.split('.');
if (versions.length === 3 &&
(+versions[0] > 6 ||
(+versions[0] === 6 && +versions[1] > 5) ||
(+versions[0] === 6 && +versions[1] === 5 && +versions[2] > 1))) {
this.showBack = true;
}
}
} else {
this.showBack = true;
}
setTimeout(() => {
this.loadComponent = true;
this.$store.dispatch(FETCH_CHANNEL_REQUEST, {gender: 'men'});
this.$store.dispatch(FETCH_CHANNEL_REQUEST, {gender: 'women'});
}, 500);
}
};
</script>
<style lang="scss">
.resources {
padding-bottom: 20px;
}
.home-header {
.icon {
width: auto !important;
float: left;
}
.icon-nav-new {
font-size: 34px !important;
margin-left: 30px;
}
.icon-search-new {
font-size: 42px !important;
}
.logo {
background-image: url("~statics/img/logo.png");
display: block;
width: 100%;
height: 100%;
background-position: center center;
background-repeat: no-repeat;
background-size: 124px 28px;
}
}
</style>