Commit 0866e4d0 authored by hewenhao's avatar hewenhao

feat: update

parent 409fc789
...@@ -36,19 +36,25 @@ Component({ ...@@ -36,19 +36,25 @@ Component({
if (this._loading || !this._hasNextPage) return if (this._loading || !this._hasNextPage) return
this._loading = true this._loading = true
this.setData({ loading: true }) this.setData({ loading: true })
await new Promise(resolve => setTimeout(resolve, 300)) await new Promise(resolve => setTimeout(resolve, 300))
const { list } = this.data const { list } = this.data
const currentPage = this._currentPage const currentPage = this._currentPage
const nextPage = currentPage + 1 const nextPage = currentPage + 1
let max = nextPage * PageSize let max = nextPage * PageSize
let hasNextPage = true let hasNextPage = true
if (max >= list.length) { if (max >= list.length) {
max = list.length max = list.length
hasNextPage = false hasNextPage = false
} }
const start = currentPage * PageSize const start = currentPage * PageSize
const newList = list.slice(start, max) const newList = list.slice(start, max)
const opts = {} as any const opts = {} as any
newList.forEach((item, index) => { newList.forEach((item, index) => {
opts[`realList[${index + start}]`] = item opts[`realList[${index + start}]`] = item
}) })
...@@ -57,7 +63,6 @@ Component({ ...@@ -57,7 +63,6 @@ Component({
this.setData(opts, () => { this.setData(opts, () => {
this._loading = false this._loading = false
this._currentPage = nextPage this._currentPage = nextPage
console.log(11111111, this._loading, hasNextPage)
this._hasNextPage = hasNextPage this._hasNextPage = hasNextPage
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment