<template>
<view id="distributionCenter">
    <view class="distributionCenterpage">
        <view class="distributionCenter-top" :style="'background: ' + config.mainConfig">
            <view class="current-title">当前可提现</view>
            <view class="current-money">
                <span class="cur-num"><span class="current">￥</span>{{list.balance}}</span>
                <span class="cur-topic" @tap="withdraw">提现</span>
            </view>
        </view>
        <view class="distributionCenter-profit">
            <view class="addUp">
                <view class="earnings">累计收益</view>
                <view class="earnings-num">￥{{list.earnings_commission}}</view>
            </view>
            <view class="outStanding">
                <view class="earnings">未到账收益</view>
                <view class="earnings-num">￥{{list.unearnings_commission}}</view>
            </view>
        </view>
        <view class="distributionCenter-handle">
            <view data-url="/pages/distribution/cash/cash" @tap="jumpItem">
                <span class="iconfont icon-woyaotixian"></span>
                <span>我要提现</span>
            </view>
            <view data-url="/pages/distribution/order/order" @tap="jumpItem">
                <span class="iconfont icon-fenxiaodingdan"></span>
                <span>分销订单</span>
            </view>
           <!-- <view data-url="/pages/wallet/bank/bank" bindtap="jumpItem">
                <span  class="iconfont icon-shoukuanzhanghu"></span>
                <span>收款账户</span>
            </view>-->
            <view @tap="jumpsensus">
                <span class="iconfont icon-fenxiaotongji"></span>
                <span>分销统计</span>
            </view>
            <view @tap="jumpspread">
                <span class="iconfont icon-woyaotuiguang"></span>
                <span>我要推广</span>
            </view>
            <view @tap="jumpvip">
                <span class="iconfont icon-huiyuanguanli"></span>
                <span>会员管理</span>
            </view>
            <!-- <view data-url="/pages/distribution/coupon/coupon" @tap="jumpItem">
                <span class="iconfont icon-youhuiquan3"></span>
                <span>优惠券</span>
            </view> -->
            <view @tap="jumpPusher">
                <span class="iconfont icon-tuikeguanli"></span>
                <span>推客管理</span>
            </view>
        </view>

    </view>

</view>
</template>
<script>
import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';

export default {
  data() {
    return {
      show_confirm: false,
      show_title: '您暂未绑定支持提现的卡号或账户,是否现在进行绑定？',
      list: {},
      config: ''
    };
  },

  onShow() {
    this.getmoney();
   /* this.getBankAccount(); */

    if (config.BRAND.name == 'nuscents') {
      this.setData({
        show_title: '暂未绑定提现账户，现在去绑。'
      });
    }
  },

  onLoad() {
    // 第三方平台配置颜色
    var bgConfig = this.$cookieStorage.get('globalConfig') || '';
    this.setData({
      config: bgConfig
    });
  },

  components: {},
  props: {},
  methods: {
    jumpItem(e) {
      var url = e.currentTarget.dataset.url;
      wx.navigateTo({
        url: url
      });
    },

    withdraw() {
      wx.navigateTo({
        url: '/pages/distribution/cash/cash' //提现页面

      });
      return;

      if (this.data.info.type == 'customer_wechat') {} else {
        if (!this.data.info.hasAccount) {
          wx.showModal({
            content: this.data.show_title,
            showCancel: false,
            success: res => {
              if (res.confirm || !res.cancel && !res.confirm) {
                wx.navigateTo({
                  url: '/pages/wallet/bank-add/bank-add' //进入银行卡添加页面

                });
              }
            }
          });
        } else {
          wx.navigateTo({
            url: '/pages/distribution/cash/cash' //进入提现页面

          });
        }
      }
    },

    getBankAccount() {
      var token = this.$cookieStorage.get('user_token');
      this.$http.get({
        api: 'api/users/BankAccount/show/number',
        header: {
          Authorization: token
        }
      }).then(res => {
        if (res.statusCode == 200) {
          res = res.data;

          if (res.status) {
            // this.setData({
            //   info: res.data
            // });
		
			 this.info=res.data;
		
			
          } else {
            wx.showModal({
              content: '请求失败，请稍后重试',
              showCancel: false
            });
          }
        } else {
          wx.showModal({
            content: '请求失败，请稍后重试',
            showCancel: false
          });
        }
      }).catch(rej => {
        wx.showModal({
          content: '请求失败，请稍后重试',
          showCancel: false
        });
      });
    },

    //获取提现数据
    getmoney(e) {
      var token = this.$cookieStorage.get('user_token');
      this.$http.get({
        api: 'api/distribution/balance',
        header: {
          Authorization: token
        }
      }).then(res => {
        if (res.statusCode == 200) {
          var res = res.data;

          if (res.status) {
            this.setData({
              list: res.data
            });
          } else {
            wx.showModal({
              content: '请求失败，请稍后重试',
              showCancel: false
            });
          }
        } else {
          wx.showModal({
            content: '请求失败，请稍后重试',
            showCancel: false
          });
        }
      }).catch(rej => {
        wx.showModal({
          content: '请求失败，请稍后重试',
          showCancel: false
        });
      });
    },

    //跳分销统计
    jumpsensus(e) {
      wx.navigateTo({
        url: '/pages/distribution/sensus/sensus'
      });
    },

    //跳我要推广
    jumpspread(e) {
      wx.navigateTo({
        url: '/pages/distribution/spread/spread'
      });
    },

    //跳vip管理
    jumpvip(e) {
      wx.navigateTo({
        url: '/pages/distribution/vipManage/vipManage'
      });
    },

    //    跳推客中心
    jumpPusher() {
      wx.navigateTo({
        url: '/pages/distribution/pusher/pusher'
      });
    },

    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  },
  computed: {},
  watch: {}
};
</script>
<style rel="stylesheet/less" lang="less">
    @import "distributionCenter";
</style>