let app = getApp() Page({ data: { currentTab: 0, homelist: [], DOMAIN_NAME: app.IMG_NAME, loading: false, noMore: false, loadingFailed: false, pageNo: 1 }, /** * 生命周期函数--监听页面加载 */ onShow(e) { this.setData({ pageNo: 1, homelist: [] }) this.getData() }, navDetail(e) { console.log(e) wx.navigateTo({ url: '../index/detail/detail?id=' + e.currentTarget.dataset.id, }) }, //请求数据 getData(isPage) { let that = this let params = { pageNum: that.data.pageNo, pageSize: 10 } app.AjaxRequest('get', { 'content-type': 'application/json', 'Authorization': 'Bearer ' + app.Getopenid() }, '/customer/list', params, function (res) { if (res.code == 0) { if (isPage) { let homelist = that.data.homelist.concat(res.rows) that.setData({ homelist, loading: false }) if (that.data.homelist.length === res.total) { that.setData({ noMore: true, loading: false }) } } else { that.setData({ homelist: res.rows, loading: false }) } } }) }, scrollToLower(e) { if (!this.data.loading && !this.data.noMore) { this.setData({ loading: true, pageNo: this.data.pageNo + 1 }) this.getData(true) } } })