const api = require("../../../../utils/api") import { getTimestamp } from "../../../../utils/common" Page({ data: { loadMoreType: "none", loadMoreVisible: false, newsList: [], pageNo: 1, pageSize: 10, }, onLoad () { this.getNewsList() }, onReachBottom () { this.setData({ loadMoreVisible: true }) if (this.data.loadMoreType === "loading") { this.data.pageNo += 1 this.getNewsList() } }, getNewsList: function () { let that = this let para = { pageIndex: this.data.pageNo, pageSize: this.data.pageSize, timestamp: getTimestamp() } api.newsList(para).then(function (res) { that.setData({ first: false, newsList: that.data.newsList.concat(res.data), loadMoreType: res.data.length === that.data.pageSize ? "loading" : "none", }) }).catch(() => { that.setData({ loadMoreType: "none", newsList: [] }) }) }, })