<!-- 我的账户 -->
<template>
  <view>
    <global-loading />
	<view class="container" v-if="ifShow">
		<view class="balance">
		</view>
    <view class="balanceInfo">
      <view class="infoBox">
        <view class="fs28 font-color-ABAFE0 mar-top-20">{{$t('common.balance')}}</view>
        <view v-if="accountInfo.price != null " class="cur-balance">{{accountInfo.price}}</view>
        <view v-else class="cur-balance">0.00</view>
      </view>
    </view>
<!--		<view class="balance-operation">
			<view class="item-btn" @click="memberAccountWithdraw">
				<image class="item-btn-icon" src="http://36.138.125.206:8081/ceres-local-file/static/images/withdraw.png" mode="widthFix"></image>
				<view class="item-btn-text">{{$t('common.withdraw')}}</view>
				<image class="item-btn-right" src="http://36.138.125.206:8081/ceres-local-file/static/images/greyArrow.png" mode="widthFix"></image>
			</view>
		</view>-->
    <view style="display: flex;justify-content: center;margin-top: 60rpx">
      <view class="with-draw-btn" @click="memberAccountWithdraw">{{$t('common.withdraw')}}</view>
    </view>

	</view>
  </view>
</template>

<script>
	const NET = require('../../utils/request')
	const API = require('../../config/api')
	export default {
		data() {
			return {
				accountInfo:[],
        ifShow: false
			}
		},
		onShow() {
			this.getBalance()
		},
		onBackPress(e) {
			if (e.from === 'navigateBack') {
				return false;
			}
			this.back();
			return true;
		},
		methods: {
			back(){
				uni.switchTab({
					url:'../../pages/tabbar/user/index'
				});
			},
			getBalance(){
				const _ = this
        // uni.showLoading({
        //   mask: true,
        //   title: '加载中...'
        // })
				NET.request(API.GetDistributor,{},"GET").then(res => {
          uni.hideLoading()
          this.ifShow = true
					_.accountInfo = res.data
				}).catch(res => {

				})
			},
			memberAccountWithdraw(){
				if(this.accountInfo.price <= 0 ){
					uni.showToast({
						title: "您暂时没有余额,不能提现",
						duration: 2000,
						icon: 'none'
					})
				}else{
					uni.navigateTo({
						url:'withdraw'
					})
				}
			}
		},
		filters: {
			parseMoney(money){
				return parseFloat(money/100).toFixed(2)
			}
		}
	}
</script>

<style lang="scss">
page {
  background: #F8F8F8;
}
	.container{
		background: #f8f8f8;
		.balance{
			display: block;
			height: 400rpx;
			background: url("http://36.138.125.206:8081/ceres-local-file/image/bankBg.png") no-repeat center top;
      background-size: cover;
			text-align:center;
      padding: 100rpx 20rpx 0 20rpx;
		}
    .balanceInfo {
      width: 100%;
      background: url("http://36.138.125.206:8081/ceres-local-file/image/accountBg.png") no-repeat center top;
      height: 451rpx;
      background-size: cover;
      margin: -300rpx auto 0 auto;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 20rpx;
      .infoBox {
        text-align: center;
        .cur-balance{
          font-size:70rpx;
          color: #ffffff;
        }
      }
    }
    .balance-operation {
      margin-top: 38rpx;
      padding: 0 24rpx;
      .item-btn {

      }
    }
	}
	.item-btn{
		width: 100%;
		height: 100upx;
		display: flex;
		flex-direction: row;
		align-items: center;
		box-sizing: border-box;
		background-color: #fff;
		padding: 0 30upx;
		.item-btn-icon{
			width: 90upx;
			height: 90upx;
		}
		.item-btn-text{
			font-size:28upx;
			margin-left: 20upx;
			font-weight:500;
			flex: 1;
			color:rgba(102,102,102,1);
		}
		.item-btn-right{
			width: 60upx;
			height: 60upx;
		}

	}
	.mt20{
		margin-top: 20upx;
	}
	.mt1{
		margin-top: 1upx;
	}

  .with-draw-btn{
    background-color: #252744;
    border-radius: 50rpx;
    width: 690rpx;
    height: 98rpx;
    margin-bottom: 68rpx;
    position: fixed;
    bottom: 0;
    line-height: 98rpx;
    color: #ffffff;
    text-align: center;
    font-size: 32rpx;
  }
</style>