<template>
  <div class="balance-detail-box">
    <div class="balance-detail">
      <div @click="detail">
        <div class="balance-detail-title">{{TopTitle}}
          <md-icon :name="iconType" @click.stop="showAmount"></md-icon>
        </div>
        <div class="balance-detail-amount">
          <md-amount v-if="isShowAmount"
                     :value="amount"
                     has-separator
          ></md-amount>
          <span v-else>****</span>
        </div>
        <div class="balance-detail-no">{{earningsState}}</div>
        <div class="balance-detail-brief"></div>
        <div class="balance-detail-profit">
          <div class="balance-detail-profit-text">
            <span>{{profitTitle}}</span>
            <span>
              <md-amount v-if="isShowAmount"
                         :value="profit"
                         has-separator
              ></md-amount>
              <span v-else>****</span>
            </span>
          </div>
          <div class="balance-detail-profit-text">
            <span>{{interestRatesTitle}}</span>
            <span>{{interestRates}}</span>
          </div>
        </div>
      </div>
      <div class="balance-detail-btn">
        <span @click="shiftTo">{{leftButton}}</span>
        <span @click="shiftOut">{{rightButton}}</span>
      </div>
    </div>
  </div>
</template>

<script>
  import Icon from '../icon'
  import Amount from '../amount'
  export default {
    name: 'md-show-amount',
    components: {
      [Icon.name]: Icon,
      [Amount.name]: Amount
    },
    props: {
      TopTitle: {
        type: String,
        default: '总金额(元)'
      },
      amount: {
        type: Number,
        default: 0
      },
      earningsState: {
        type: String,
        default: '暂无收益'
      },
      profitTitle: {
        type: String,
        default: '累计收益(元)'
      },
      profit: {
        type: Number,
        default: 0
      },
      interestRatesTitle: {
        type: String,
        default: '七日年化(%)'
      },
      interestRates: {
        type: Number,
        default: 0
      },
      leftButton: {
        type: String,
        default: '转入'
      },
      rightButton: {
        type: String,
        default: '转出'
      }
    },
    data () {
      return {
        iconType: 'visible',
        isShowAmount: true
      }
    },
    methods: {
      showAmount () {
        if (this.isShowAmount) {
          this.iconType = 'invisible'
        } else {
          this.iconType = 'visible'
        }
        this.isShowAmount = !this.isShowAmount
      },
      shiftTo(){
        this.$emit('shiftTo')
      },
      shiftOut(){
        this.$emit('shiftOut')
      },
      detail(){
        this.$emit('detail')
      }
    }
  }
</script>

<style scoped lang="stylus">
  .balance-detail-box {
    height: 420px;
    overflow: hidden;
    font-size: 14px;
    margin-bottom: 10px;
    background: linear-gradient(to bottom,color-primary,#fff);
  }

  .balance-detail {
    width: 94%;
    height: 360px;
    border: 0px solid #fff;
    border-radius: 5px;
    margin: 58px auto 0px auto;
    background-color: #fff;
    border-bottom: 1px solid #dedede;
    overflow: hidden;
    text-align: center;
  }
  .balance-detail-title{
    margin-top: 40px;
  }
  .balance-detail-amount{
    font-size: 28px;
    height: 72px;
    line-height: 70px;
  }

  .balance-detail-no{
    height: 30px;
    line-height: 30px;
    width: 160px;
    /*font-size: 14px;*/
    background-color: #f8f8f8;
    border: 0px;
    border-radius: 20px;
    margin: 0px auto;
  }
  .balance-detail-brief{
    height: 30px;
    line-height: 30px;
    /*font-size: 14px;*/
    color: #dedede;
  }
  .balance-detail-profit{
    margin-top: 10px;
    display: flex;
  }
  .balance-detail-profit-text{
    width: 50%;
    line-height: 30px;
  }
  .balance-detail-profit-text  span{
    display: block;
    text-align: center;
  }
  .balance-detail-profit-text > span:first-child{
    color: #dedede;
  }
  .balance-detail-btn{
    margin-top: 20px;
    display: flex;
    justify-content: space-around;
  }
  .balance-detail-btn > span{
    width: 44%;
    text-align: center;
    height: 44px;
    line-height: 44px;
    font-size: 18px;
    border-radius: 2px;
  }
  .balance-detail-btn > span:first-child{
    background-color: #fdf6f0;
    color: #dc5b2d;
  }
  .balance-detail-btn > span:last-child{
    background-color: color-primary;
    color: color-text-base-inverse;
  }
</style>
