<template>
  <div>
    <div class="list-header">
      <div class="header-text haeder-account">被邀请账号</div>
      <div class="header-text haeder-pay">付费金额</div>
      <div class="header-text header-time">购买时间</div>
      <div class="header-text header-back">佣金</div>
    </div>
    <div class="record-list">
      <div class="record-item" v-for="(item, index) in data" :key="index">
        <div class="body-text record-account">{{ item.newPhone | phone }}</div>
        <div class="body-text record-pay">¥{{ item.totalAmount }}</div>
        <div class="body-text record-time">{{ item.finishTime }}</div>
        <div class="body-text record-back">¥{{ item.rakeBackAmount | keepTwo}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BuyRecordList',
  props: {
    data: {
      type: Array,
      default: () => []
    }
  },
  filters: {
    phone(val) {
      if (!val) return ''
      return val.slice(0, 3) + '****' + val.slice(7)
    },
    // 保留小数2位
    keepTwo(val) {
      if (!val) return ''
      return Number(val).toFixed(2)
    }
  }
}
</script>

<style lang="scss" scoped>
.list-header{
  background-color: #FFEED7;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-around;

  

  .header-text{
    text-align: center;
    font-weight: 400;
    font-size: 12px;
    color: #333;
    line-height: 24px;
  }
}

.haeder-account,.record-account{
  flex: 0 0 75px;
}

.haeder-pay.record-pay{
  flex: 0 0 48px;
}
.header-time,.record-time{
  flex: 0 0 130px;
}

.header-back,.record-back{
  flex: 0 0 48px;
}

.record-list{
  min-height: 165px;
}

.record-item{
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-around;

  .body-text{
    text-align: center;
    line-height: 33px;
  }
}
</style>