// pages/member/rankingListSecond/rankingListSecond.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    language: '',
    sum_activation_love: null,
    activation_love2: null,
    love_name: "", //爱心值自定义名称
    usable: 0, // 登陆会员可用爱心值
    member_froze_love: '', //会员冻结爱心值
    fixed_proportion: '', // 固定激活比例
    fixed_activation_love: '', // 固定激活值
    first_commission: null, //	一级粉丝数据
    second_three_Commission: null, //	二三级粉丝数据
    other: null, //	其他数据
    order_money: null, //	订单金额
    order_money2: null, //  二三级订单金额
    proportion: null, //	激活比例
    proportion2: null, //	二三级激活比例
    team_leve_award: null, //	团队等级奖励值
    fetter_proportion: null, //	激活上线
    actual_activation_love: null, //	实际激活金额
    created_id: null, //	该记录ID值
    created_at: null, //	激活时间
    order_sn: null, //	激活流水号
    search: '', //url参数
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      search: options.id
    });
    this.getUsable();
    this.getBalance();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    let language = wx.getStorageSync('langIndex');
    this.setData({ 'language': language.en});
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },
  getUsable() {
    let urlStr = app.getNetAddresss("plugin.love.Frontend.Controllers.page.index");
    app._getNetWork({
      url: urlStr,
      success: (res) => {
        if (res.data.result === 1) {
          this.setData({
            usable: res.data.data.usable,
            love_name: res.data.data.love_name
          });
        } else {
          wx.showToast({
            title: res.data.msg,
            icon: "none"
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  getBalance() {
    let urlStr = app.getNetAddresss("plugin.love.Frontend.Modules.Love.Controllers.activation-record-detail.index");
    let id = this.data.search; //获取路由的id
    urlStr += "&record_id=" + id;
    app._getNetWork({
      url: urlStr,
      success: (res) => {
        if (res.data.result === 1) {
          this.setData({
            member_froze_love: res.data.data.fixed_activation.member_froze_love,
            fixed_proportion: res.data.data.fixed_activation.fixed_proportion,
            order_money: res.data.data.first_commission.order_money,
            fixed_activation_love: res.data.data.fixed_activation.fixed_activation_love,
            proportion: res.data.data.first_commission.proportion,
            activation_love: res.data.data.first_commission.activation_love,
            order_money2: res.data.data.second_three_Commission.order_money,
            proportion2: res.data.data.second_three_Commission.proportion,
            activation_love2: res.data.data.second_three_Commission.activation_love,
            team_leve_award: res.data.data.second_three_Commission.team_leve_award,
            fetter_proportion: res.data.data.second_three_Commission.fetter_proportion,
            created_id: res.data.data.other.id,
            created_at: res.data.data.other.created_at,
            sum_activation_love: res.data.data.other.sum_activation_love,
            actual_activation_love: res.data.data.other.actual_activation_love
          });
        } else {
          wx.showToast({
            title: res.data.msg,
            icon: "none"
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });

  }
});