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

  /**
	 * 页面的初始数据
	 */
  data: {
    language: '',
    dataObj: {},
    ios_virtual_pay: false
  },

  /**
	 * 生命周期函数--监听页面加载
	 */
  onLoad: function(options) {
    this.getBalance();
    try {
      var value = wx.getStorageSync('ios_virtual_pay');
      if (value) {
        this.setData({
          ios_virtual_pay: value
        });
      }
    } catch (e) {
      console.log(e);
    }
  },

  /**
	 * 生命周期函数--监听页面初次渲染完成
	 */
  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.froze.Frontend.Controllers.page.index");
    app._getNetWork({
      url: urlStr,
      success: (response) => {
        let resData = response.data;
        if (resData.result === 1) {
          this.setData({
            dataObj: resData.data
          });
        } 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 == 'RechargeCoin' && this.data.ios_virtual_pay) {
      wx.showModal({
        title: '提示',
        content: '十分抱歉，由于相关规定，你暂时无法在这里充值！',
        confirmText: '知道了',
        showCancel: false,
        success(res) {}
      });
      return false;
    }
    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?type=" + 'FrozenCoin'
    });
  }

});
