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

  /**
	 * 页面的初始数据
	 */
  data: {
    language: '',
    usable: 0.0,
    sure_usable: ""
  },

  /**
	 * 生命周期函数--监听页面加载
	 */
  onLoad: function(options) {
    this.usable = 0.0;
    this.sure_usable = "";
    // this.toi = this.fun.getKeyByI();
    //获取数据
    this.getStoreInfo();
  },

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

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },
  getStoreInfo() {
    let urlStr = app.getNetAddresss("plugin.froze.Frontend.Controllers.page.index");
    app._getNetWork({
      url: urlStr,
      success: (res) => {
        let resData = res.data;
        if (resData.result === 1) {
          this.setData({
            usable: resData.data.thaw
          });
        } else {
          wx.showToast({
            title: resData.msg,
            icon: "none"
          });
        }
      },
      fail: function(res) {
        console.log(res);
      }
    });
  },
  confirm() {
    if (this.data.sure_usable == undefined || this.data.sure_usable <= 0) {
      wx.showToast({
        title: "提现数值不可低于0",
        icon: "none"
      });
      return;
    }
    let urlStr = app.getNetAddresss("plugin.froze.Frontend.Modules.Froze.Controllers.withdraw.index");
    urlStr += "&change_value=" + this.data.sure_usable;
    app._getNetWork({
      url: urlStr,
      success: (res) => {
        console.log(res, '数据');
        if (res.data.result === 1) {
          // 跳转到提现页面
          wx.navigateTo({
            url: '/packageA/member/withdrawal/withdrawal'
          });
        } else {
          wx.showToast({
            title: res.data.msg,
            icon: "none"
          });
        }
      },
      fail: function(res) {
        console.log(res);
      }
    });
  },
  // 输入框改变的时候触发
  onChange(val) {
    this.setData({
      sure_usable: val.detail
    });
  }
});
