var app = getApp();
Page({
  data: {
    sortList: [],
    noThreeSortList: [],
    userTraining: '',
    userRanking: '',
    avatar: '',
    name: '',
  },
  onLoad: function () {
    let me = this;
    // 请求前加Loading
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    wx.request({
      url: app.globalData.apiUrl + 'ranks/trainRanking',
      method: 'POST',
      data: {
        token: wx.getStorageSync('token')
      },
      success: function (res) {
        // 请求成功后关闭Loading
        wx.hideLoading();
        if(res.data.errno==200){
          let newArr = res.data.data.rankList.filter(item => item.ranking > 3)
          me.setData({
            userTraining: res.data.data.userTraining,
            userRanking: res.data.data.userRanking,
            sortList: res.data.data.rankList,
            noThreeSortList: newArr,
            name: res.data.data.name,
            avatar: res.data.data.avatar,
          })
        }else{
          wx.showModal({
            title: '提示',
            showCancel: false,
            content: res.data.msg
          })
        }
      }
    })
  },
})