article.vue
2.53 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
<template>
<Layout>
<LayoutHeader slot='header' title="推荐" :share="shareData"></LayoutHeader>
<LayoutScroll :infinite="true" :on-fetch="onFetch">
<div class="article-item" slot="item" slot-scope="{ data }">
<AvatarGroup :avatars="avatarList"></AvatarGroup>
<div :id="data.id" class="item">
<div class="avatar" :style="{backgroundImage: 'url(' + (data.avatar || '') + ')'}"></div>
<div class="bubble">
<p>{{ data.name }}</p>
<div class="meta">
<time class="posted-date">{{ data.time }}</time>
</div>
</div>
</div>
</div>
</LayoutScroll>
</Layout>
</template>
<script>
import {createNamespacedHelpers} from 'vuex';
import {Scroll, Loading} from 'cube-ui';
const {mapState, mapActions, mapMutations} = createNamespacedHelpers('article');
export default {
name: 'ArticlePage',
components: {
Loading,
Scroll
},
data() {
return {
avatarList: [
{ src: '//tvax3.sinaimg.cn/crop.0.0.996.996.50/b2226be7ly8fwi9zpop35j20ro0roq45.jpg' },
{ src: '//tvax2.sinaimg.cn/crop.0.0.828.828.50/006IPkwKly8fyhr791kkxj30n00n0q3u.jpg' },
{ src: '//tvax3.sinaimg.cn/crop.0.0.996.996.50/005X6MlLly8fy8wodh5o6j30ro0rowh6.jpg' },
{ src: '//tvax3.sinaimg.cn/crop.0.0.888.888.50/005EQCcnly8fytqpipvdqj30oo0oo76b.jpg' },
{ src: '//tvax4.sinaimg.cn/crop.0.0.996.996.50/006Tjwsbly8fzhvo4bconj30ro0rodhk.jpg' },
{ src: '//tva2.sinaimg.cn/crop.0.0.512.512.50/67f23b64jw8ercxqrzo88j20e80e8q38.jpg' },
{ src: '//tva2.sinaimg.cn/crop.107.517.1137.1137.50/bda75d7bjw8eyqx9d5x3fj211x1kwk5v.jpg' },
{ src: '//tvax2.sinaimg.cn/crop.0.0.828.828.50/006IPkwKly8fyhr791kkxj30n00n0q3u.jpg' },
],
list: [],
shareData: {},
scrollOptions: {
bounce: false
},
inx: 0
};
},
computed: {
...mapState(['articleList']),
},
methods: {
onFetch() {
const items = Array.from({length: 50}).map((v, i) => {
return {
name: 'chenfeng' + (i + 50 * this.inx)
}
})
this.inx++;
return Promise.resolve(items);
},
click() {
this.$refs.actionSheet.show();
setTimeout(() => {
this.initData();
this.forceUpdate();
}, 1000);
},
forceUpdate() {
this.$refs.scroll.forceUpdate();
},
initData() {
for (let i = 0; i < 100; i++) {
this.list.push(i);
}
}
}
};
</script>
<style lang="scss" scoped>
.article-item {
height: 100px;
}
</style>