var app = getApp();
Page({
  data: {
    teenageName: '',
    avatar: '',
    beginTime: '',
    endTime: '',
    trainingTimes: '',
    trainingList: [],
    totalDuration: [],
  },
  onLoad: function () {
    let me = this;
    // 请求前加Loading
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    wx.request({
      url: app.globalData.apiUrl + 'Trainings/index',
      method: 'POST',
      data: {
        token: wx.getStorageSync('token')
      },
      success: function (res) {
        // 请求成功后关闭Loading
        wx.hideLoading();
        if(res.data.errno==200){
          me.setData({
            teenageName: res.data.data.teenageName,
            avatar: res.data.data.avatar,
            beginTime: res.data.data.beginTime,
            endTime: res.data.data.endTime,
            trainingTimes: res.data.data.trainingTimes,
            totalDuration: res.data.data.totalDuration,
            trainingList: res.data.data.trainingList,
          })
        }else{
          wx.showModal({
            title: '提示',
            showCancel: false,
            content: res.data.msg
          })
        }
      }
    })
  },
  // 更新计划
  update: function () {
    wx.navigateTo({
      url: '/pages/updatePlan/updatePlan'
    })
  },
})
