pageMixin.js
1.01 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
export default {
data () {
return {
tabIndex: 0,
pageNum: 1,
list: [],
total: 0,
flag: false,
updata: new Date().getTime()
}
},
mounted () {
let { tabIndex } = this.getQuery()
if (tabIndex) {
this.tabIndex = Number(tabIndex)
// this.updata = new Date().getTime()
this.init()
return
}
if (this.$route.meta.isTab) this.init()
},
methods: {
init () {
this.showLoading()
this.getList(this.pageNum)
},
change (index) {
this.tabIndex = index
this.clearData()
},
clearData () {
this.flag = false
this.pageNum = 1
this.list = []
if (this.$refs.scrollView) this.$refs.scrollView.finished = false
this.init()
},
onReachBottom () {
let { total, pageNum, list } = this
this.$refs.scrollView.loading = false
if (list.length == total) {
this.$refs.scrollView.finished = true
return
}
if (Math.ceil(total / 10) > pageNum) {
this.pageNum = pageNum + 1
this.init()
} else {
this.$refs.scrollView.finished = true
}
}
}
}