index.vue
4.42 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
<template>
<div class="home nafmii-head-bg1">
<nafm-header :leftArrow="false" navClass="nafmii-head-bg1">
<div class="head-custom-container">
<SearchInput
:placeholder="$t('home.searchPlaceholder')"
:readonly="true"
@click="handleSearch"
/>
<div class="head-message-box">
<img src="@/assets/icon/message.png" alt="" />
</div>
</div>
</nafm-header>
<main>
<NafmPullRefresh v-model="refresh" @refresh="fetchData">
<template #loading>
<van-loading size="20px" color="#fff">加载中...</van-loading>
</template>
<HomeBanner :data="HomeData" />
<MenuModule :data="HomeData" />
<HotScrollBar :data="HomeData" />
<DataModule
v-for="(item, idx) in modules"
:key="idx"
v-bind="item"
:datas="item.datas"
@clickMore="handleMore(item)"
@clickItem="handleItem"
@clickTop="handleTop(item)"
/>
</NafmPullRefresh>
</main>
</div>
</template>
<script>
import { mapState } from "vuex";
import SearchInput from '@/components/SearchInput'
import NafmPullRefresh from '@/components/NafmPullRefresh'
import HomeBanner from './components/HomeBanner'
import MenuModule from './components/MenuModule'
import HotScrollBar from './components/HotScrollBar'
import DataModule from '@/components/HomeDataListModule'
export default {
name: "Home",
components: { NafmPullRefresh, HomeBanner, MenuModule, HotScrollBar, DataModule, SearchInput },
data () {
const datas = [
{
isRecommend: true,
title: '创新推出碳中和债,助理实现30·60目标创新推出碳中和债,助理实现30·60目标创新推出碳中和债,助理实现30·60目标',
date: '2020-02-02',
dataType: '产品创新'
},
{
isRecommend: false,
title: '创新推出碳中和债,助理实现30·60目标创新推出碳中和60目标',
date: '2020-02-02',
dataType: '产品创新'
},
{
isRecommend: false,
title: '创新推出碳中和债,助理实现30·60目标出',
date: '2020-02-02',
dataType: '产品创新'
}
]
return {
refresh: false,
modules: [
{ type: '1', name: this.$t('home.disclosure'), dateText: this.$t('home.disclosureDate'), datas, showTop: false },
{ type: '2', name: this.$t('home.news'), dateText: this.$t('home.updateDate'), datas, showTop: true },
{ type: '3', name: this.$t('home.registered'), dateText: this.$t('home.updateDate'), datas, showTop: true }
]
};
},
computed: {
...mapState('home', {
HomeData: state => state.HomeData,
// Banner: state => {
// const { carouseTime, carouseVOList } = state.HomeData || {}
// }
})
},
methods: {
handleSearch () {
this.$router.push({ name: 'GlobalSearch' })
},
fetchData () {
this.$store.dispatch('home/AGetHomeData').then(res => {
setTimeout(() => {
this.refresh = false
}, 2000);
})
},
handleTop (module) {
const modules = []
for (const item of this.modules) {
const showTop = item.type != module.type
!showTop ? modules.unshift(item) : modules.push(item)
Object.assign(item, { showTop })
}
this.modules = modules
},
handleMore (module) {
},
handleItem (item) {
}
},
mounted () {
this.fetchData()
}
};
</script>
<style lang="less" scoped>
.home {
@PaddingSize: 15px;
main {
padding: 0 @PaddingSize;
/deep/.van-pull-refresh__head {
color: white;
}
}
}
@PaddingSize: 15px;
@HeadHeight: 50px;
.head-custom-container {
width: 100%;
height: @HeadHeight;
display: flex;
align-items: center;
@InputHeight: 33px;
.search-input-box {
width: 100%;
height: @InputHeight;
border-radius: calc(@InputHeight / 2);
background-color: rgba(255, 255, 255, 0.2);
padding: 0 @PaddingSize;
display: flex;
align-items: center;
@SearchIconSize: 12px;
.search-icon {
background: white;
width: @SearchIconSize;
height: @SearchIconSize;
}
.search-placeholder {
color: white;
font-size: 12px;
padding-left: 22px;
}
}
@MessageBoxSize: 23px;
.head-message-box {
width: @MessageBoxSize;
height: @MessageBoxSize;
margin-left: @PaddingSize;
}
}
</style>