mounted () {
this.getCheckBoxFn()
this.handleQuery()
window.addEventListener('scroll', this.windowScroll, true)
},
destroyed () {
window.removeEventListener('scroll', this.windowScroll)
},
beforeRouteLeave () {
window.removeEventListener('scroll', this.windowScroll)
},
getList () {
if (this.loading) return
this.loading = true
getFlightList(this.queryParams).then(({ list }) => {
this.tableData = this.tableData.concat(list)
this.noMore = list.length < 10
this.queryParams.pageNum += 1
}).finally(() => { this.loading = false })
},
getCHeight (father, son) {
const [fatherH, sonH] = [father.clientHeight, son.clientHeight]
return fatherH && sonH ? Math.min(fatherH, sonH) : Math.max(fatherH, sonH)
},
getSHeight (father, son) {
return Math.max(father.scrollHeight, son.scrollHeight)
},
getSTop (father, son) {
const [fatherH, sonH] = [father.scrollTop, son.scrollTop]
return sonH && sonH ? sonH : fatherH
},
windowScroll () {
const [father, son] = [document.querySelector('.wrap-box-content'), document.querySelector('.wrap-box-content-list')]
const { getSTop, getCHeight, getSHeight, getList, noMore } = this
getSTop(father, son) + getCHeight(father, son) === getSHeight(father, son) && !noMore && getList()
},