index.js 2.45 KB
// integration/pages/point/index/index.js
import MineApi from '../../../api'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    score: {},
    pageSize: 10,
    pageNum: 1,
    total: 0,
    scoreList: []
  },

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

  },
  //我要兑换
  toTiXian() {
    let {
      score
    } = this.data
    // 新的积分兑换页面
    wx.$router.go('integration.toCash', {
      score
    })
  },
  toWatchNote() {
    wx.$router.go('integration.record')
  },
  // 触底刷新
  mineReachBottom() {
    let {
      pageNum,
      total,
      pageSize
    } = this.data
    if (pageNum * pageSize >= total) {
      this.nothing = true
      return
    }
    this.setData({
      pageNum: pageNum + 1
    }, () => {

      this.getInMoneyList()
    })
  },
  //下拉刷新
  mineRefresh() {
    this.nothing = false
    this.setData({
      pageNum: 1
    }, () => {
      this.getInMoneyList()
      this.getWithdrawalData()
    })
  },
  //获取员工积分详情
  getWithdrawalData() {
    MineApi.getScoreDetailApi().then(res => {
      if (res.code == 0) {
        this.setData({
          score: res.data
        })
      }
    })
  },
  // 获取收益明细
  getInMoneyList() {
    if (this.nothing) return
    const {
      pageSize,
      pageNum,
      scoreList
    } = this.data
    MineApi.getScoreListApi({
      pageSize,
      pageNum
    }).then((res) => {
      console.log(res)
      let data;
      if (res.code == 0) {
        data = res.data?.data ? res.data?.data : []
      }
      this.setData({
        scoreList: pageNum == 1 ? data : [...scoreList, ...data],
        total: res.data.count,
        mineTrigger: false
      })
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    //员工积分详情
    this.getWithdrawalData()
    // 积分列表 
    this.getInMoneyList()
    this.setData({
      isFullSucreen: wx.$util.isFullSucreen(true)
    })
  },

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

  },

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

  },

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

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

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

  }
})