// packageD/auction/auction-mine/auctionIntegralCash/auctionIntegralCash.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    cash:'',
    radio:'1'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getDgetStoreInfoata();
  },
  userValinp(e){
    console.log(e.detail);
    let ind = e.detail;
    this.setData({
      radio:ind
    });
  },
  iscash(e){
    this.setData({
      cash:e.detail.value
    });
  },
  sureCash(){
    let that = this;
    console.log(that.data.cash);
    if (!that.data.cash) {
      wx.showToast({
        title: '请输入提现金额',
        icon:'none',
        duration:1000
      });
      return;
    }
    let json = {
      withdraw_money: this.data.cash, 
      withdraw_type: this.data.radio
    };
    let urlStr = app.getNetAddresss('plugin.auction.api.prepayment.withdraw.withdraw');
    app._getNetWork({
      url: urlStr,
      data:json,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          wx.showToast({
            title: res.msg,
            duration:1000,
            icon:'none',
            success(){
              setTimeout(() => {
                wx.navigateBack({
                  delta: 1
                });
              }, 1500);
            }
          });
        } 
      },
      fail: function (res) {
        console.log(res);
        wx.showToast({
          title: res.msg,
          icon: "none",
          duration: 1000
        });
      }
    });
    $http
      .get(
        "plugin.integral.Frontend.Modules.Integral.Controllers.Withdraw",
        { change_value: this.cash },
        `$${this.fun.initWithdrawal()}中`
      )
      .then(response => {
        if (response.result === 1) {
          this.getData();
          this.$router.push(this.fun.getUrl("withdrawal"));
          Toast(`${this.fun.initWithdrawal()}成功`);
        } else {
          Toast(response.msg);
        }
      })
      .catch(error => {
        console.log(error);
      });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },
  getDgetStoreInfoata(){
    var that = this;
    let urlStr = app.getNetAddresss('plugin.auction.api.prepayment.withdraw.page');
    app._getNetWork({
      url: urlStr,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          console.log(res);
          that.setData({
            Data:res.data,
            integralShow:res.data.alipay,
            withdraw_status:res.data.wechat
          });
        } else {
          wx.showToast({
            title: res.msg,
            icon: "none",
            duration: 1000
          });
        }
      },
      fail: function (res) {
        console.log(res);
        wx.showToast({
          title: res.msg,
          icon: "none",
          duration: 1000
        });
      }
    });
  },
});