小程序加载下一页内容

221 阅读1分钟

index.js

    let that = this;
    let alllistBefore = that.data.all_list;//原来的数据
    R.getActivity({ "p": that.data.pageNumber + 1, "n": 10 }).then(res => {
      if (res.data.code == 0) {
        console.log('活动主页列表成功');

        if (res.data.result.r_list.length != 0) {
          TOAST.showload();
          that.setData({
            all_list: alllistBefore.concat(res.data.result.r_list),//拼接数据
            pageNumber: that.data.pageNumber + 1  //页数+1
          })
        } else {
          console.log('没有更多的数据了');
          TOAST.showNormal('到底了~');
        }
      }
      else if (res.data.code == -100)
        console.log('活动主页列表失败');
    })