Commit b22a2565 by 李伟康

commit

1 parent 112c52c8
......@@ -6,7 +6,6 @@
title-inactive-color="#BBB"
title-active-color="#2c2c2c"
@click="click"
:key="updata"
>
<template v-for="(i,index) in data">
<van-tab
......@@ -33,7 +32,10 @@ export default {
type: Number,
default: 0
},
updata: null
updata: {
type: Number,
default: new Date().getTime()
}
},
data () {
return {
......
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()
}
if (this.$route.meta.isTab) this.init()
},
methods: {
init() {
this.showLoading()
let { tabIndex, pageNum } = this
this[`getList_${tabIndex}`](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
}
}
}
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()
let { tabIndex, pageNum } = this
this[`getList_${tabIndex}`](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
}
}
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!