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

  /**
	 * 页面的初始数据
	 */
  data: {
    language: '',
    // 登陆会员冻结爱心值
    froze: 0,
    //自定义名称
    coin_name: "",
    // 登陆会员可用爱心值
    usable: 0,
    // 转让开关是否开启
    transfer_status: false,
    // 说明标题
    titlew: "",
    // 爱心值说明
    content: "",
    show: false, //显示
  },

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

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

  /**
	 * 生命周期函数--监听页面显示
	 */
  onShow: function() {
    this.getBalance();
  },

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

  },

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

  },

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

  },

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

  },

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

  },
  getBalance() {
    let urlStr = app.getNetAddresss("plugin.coin.Frontend.Controllers.page.index");
    app._getNetWork({
      url: urlStr,
      success: (response) => {
        let resData = response.data;
        if (resData.result === 1) {
          this.setData({
            froze: resData.data.froze,
            coin_name: resData.data.coin_name,
            title: resData.data.love_name,
            usable: resData.data.usable,
            transfer_status: resData.data.transfer_status
          });
        } else {
          wx.showToast({
            title: resData.msg,
            icon: 'none',
            duration: 2000
          });
        }
      },
      fail: function(res) {
        console.log(res);
      }
    });

  },
  getInfo() {
    let urlStr = app.getNetAddresss("plugin.coin.Frontend.Controllers.explain.index");
    app._getNetWork({
      url: urlStr,
      success: (response) => {
        let resData = response.data;
        if (resData.result === 1) {
          this.setData({
            content: resData.data.content,
            titlew: resData.data.title
          });
        } else {
          wx.showToast({
            title: resData.msg,
            icon: 'none',
            duration: 2000
          });
        }
      },
      fail: function(res) {
        console.log(res);
      }
    });
  },
  // 跳转页面
  gotoPage(e) {
    console.log(e);
    var url = e.target.dataset.url || e.currentTarget.dataset.url;
    if (url == 'overseas_explain') {
      this.setData({
        show: true
      });
      return;
    }
    wx.navigateTo({
      url: '/packageB/member/' + url + '/' + url
    });
  },
  onClickLeft() {
    this.setData({
      show: false
    });
  },
  onClickRight() {
    wx.navigateTo({
      url: "/packageB/member/overseas_list/overseas_list"
    });
  }

});
