list.vue
2.76 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
<template>
<div>
<Scroll
ref="scroll"
class="list"
:data="noticeList"
:options="scrollOption"
@pulling-up="onPullingUp">
<div class="content-root">
<NoticeItem v-for="(item, index) in noticeList" :key="index" :data="item"></NoticeItem>
</div>
</Scroll>
</div>
</template>
<script>
import { createNamespacedHelpers } from 'vuex';
const { mapState, mapActions} = createNamespacedHelpers('notice');
import NoticeItem from './noticeItem';
import {
Style,
Scroll,
RecycleList
} from 'cube-ui';
// import { resolve } from 'dns';
export default {
components: {
NoticeItem,
Scroll,
RecycleList,
Style
},
name: 'NoticeListPage',
data(){
return {
data: {},
noMore: false,
scrolling: false,
scrollOption: {
// bounce: false,
pullUpLoad:true,
},
};
},
created(){
// console.log(this.noticeList)
this.fetchNoticeList();
},
// activated(){
// this.fetchList();
// },
// async serverPrefetch(){
// this.fetchNoticeList();
// },
mounted(){
// this.fetchNoticeList();
},
computed: {
...mapState(['noticeList','fetchNoticePage']),
},
methods:{
...mapActions(['fetchNoticeList']),
onScroll(){
console.log('onScroll')
this.scrolling = true;
this._scTimer && clearTimeout(this._scTimer);
this._scTimer = setTimeout(() => {
this.scrolling = false;
}, 400);
},
onPullingUp(){
console.log('onPullingUp:'+this.noMore)
},
onPullingDown() {
console.log('onPullingDown:'+this.noMore)
},
onFetch() {
// console.log('fetchList:'+this.noticeList)
// let items = []
// return new Promise((resolve) => {
// // 模拟请求 50 条数据,因为 size 设置为 50
// setTimeout(() => {
// for (let i = 0; i < 50; i++) {
// items.push({
// id: i,
// avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/danpliego/128.jpg',
// msg: '123',
// time: 'Thu Oct 25 2018 15:02:12 GMT+0800 (中国标准时间)'
// })
// }
// resolve(items)
// }, 1000)
// })
if (this.noMore) {
return;
}
this.fetchNoticeList();
// this.fetchNoticeList({}).then(res => {
// if (+this.fetchNoticePage > +get(res, 'data.totalPage')) {
// this.noMore = true;
// }
// this.$nextTick(() => {
// this.$refs.scroll.forceUpdate(true);
// });
// });
}
},
}
</script>
<style>
.list{
/* height: 400px; */
width: 100%;
}
.content-root{
/* height: 400px; */
width: 100%;
}
</style>