Detailed.js 1.98 KB
var t = getApp(),
  r = t.globalData,
  a = t.request,
  o = t.globalData.setting,
  os = o,
  i = require("../../../utils/util.js"),
  ut = i,
  s = require("../../../utils/common.js");

Page({
  /**
   * 页面的初始数据
   */
  data: {
    url: o.imghost,
    arrayDetailed: [],//明细数组
    page: 1,
    pageSize: 20,
    isDetailed: 0,
    total: 0,
    ismore: 0,//数据是否加载完毕
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },
  selectDetailed: function() {
    var th = this, e = th;
    getApp().request.promiseGet("/api/weshop/plus/vip/mem/referee/page", {
        data: {
          storeId: o.stoid,
          userId: r.user_id,
          page: th.data.page,
          pageSize: th.data.pageSize
        }
      }).then(res => {
		  
		th.setData({isDetailed:1})  
        if(res.data.code==0 && res.data.data.pageData &&  res.data.data.pageData.length>0) {
          th.data.page++;//当前页数+1
          var arr1 = th.data.arrayDetailed;//获取明细数组
          var arr2 = res.data.data.pageData;//获取当前查询数据
          var arr3 = [...arr1, ...arr2];//把当前查询数组拼接到原本数组后面

          var ismore = 0;
          if (arr3.length == res.data.data.total) ismore = 1 //数据已加载完判断

          th.setData({
            arrayDetailed: arr3,
            total: res.data.data.total,
            ismore: ismore,
            isDetailed: 1
          })
        }
      }),
      wx.stopPullDownRefresh();

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.selectDetailed();
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

    if (this.data.total <= this.data.pageSize) return;
    if (this.data.ismore) {
      t.my_warnning("加载完啦!", 0, this);
      return
    };
    this.selectDetailed();
  }
})