jianhliList.js 2.3 KB
// pages/jiangliList/jianhliList.js
import {
  request
} from "../../request/index.js";
const a = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeindex: 0,
    page: 1,
    lieji: 0,
    list:[],
    last_page: null,
    show: false
  },

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

  },

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

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    let that = this
      that.jianglilist()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    let that = this
    console.log("触底")
    if(that.data.page == that.data.last_page){
      // wx.showToast({
      //   title: '没有更多数据啦!',
      //   icon: 'none'
      // })
      that.setData({
        show: true
      })
    }else{
      that.setData({
        page:  that.data.page + 1
      })
      that.jianglilist()
    }
    
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },

  switchdianji(e){
    var that = this;
    console.log(e.currentTarget.dataset.current)
    that.setData( {
      activeindex: e.currentTarget.dataset.current
      })
      that.setData({
        list: [],
        page: 1,
        show: false
      })
    that.jianglilist()
  },
  async jianglilist() { // 列表
    let that = this
    let token = wx.getStorageSync('token')
    let list = that.page == 1 ? [] : that.data.list
    request({
      url: 'api/my2/Active2BonusList',
      data: {
        page: that.data.page,
        list: 12,
        type: Number(that.data.activeindex) + Number(1),
      }
    }).then(res => {
      console.log(res.data.data.data.data)
      that.setData({
        lieji: res.data.data.sum,
        last_page: res.data.data.data.last_page
      })
      let good = list.concat(res.data.data.data.data)
        that.setData({
          list: good,
        })
    }).catch(err => {
      //  console.log(err);
      that.setData({
        msg: err.msg
      })
    })
  },

})