<template>
  <div class="league-nums">
    <div class="nav">
      <van-icon
        name="arrow-left"
        size="20"
        class="nav-left"
        @click="$router.go(-1)"
      />
      <span class="nav-title">团员总人数</span>
    </div>
    <div class="panel-list">
      <div class="panel-item" v-for="(item, index) in list" :key="index">
        <span class="panel-item-num">{{ item.num }}</span>
        <div class="panel-item-label">
          <span>{{ item.label }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getMyTeam } from "@/api/grade";
export default {
  name: "leagueNums",
  data() {
    return {
      list: [
        {
          num: "",
          label: "普通用户",
          field: "normalUserNum"
        },
        {
          num: "",
          label: "幼苗",
          field: "seedlingNum"
        },
        {
          num: "",
          label: "青铜树",
          field: "bronzeTreeNum"
        },
        {
          num: "",
          label: "白银树",
          field: "silverTreeNum"
        },
        {
          num: "",
          label: "黄金树",
          field: "goldTreeNum"
        },
        {
          num: "",
          label: "农场主",
          field: "farmerNum"
        },
        {
          num: "",
          label: "森林之星",
          field: "forestStartNum"
        },
        {
          num: "",
          label: "西田森合伙人",
          field: "partnerNum"
        }
      ]
    };
  },
  mounted() {
    this.getMyTeam();
  },
  methods: {
    getMyTeam() {
      getMyTeam(this.$userId).then(res => {
        if (res.data) {
          this.list.forEach(v => {
            v.num = res.data[v["field"]];
          });
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
$white: #ffffff;
.league-nums {
  width: 100%;
  height: 298px;
  background-image: url("../assets/images/森林状态.png");
  background-size: cover;
  .nav {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 46px;
    color: #fff;
    .nav-left {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 52px;
      height: 100%;
      line-height: 46px;
      text-align: center;
    }
    .nav-title {
      max-width: 60%;
      margin: 0 auto;
      font-weight: bold;
      font-size: 16px;
    }
  }
}
.panel-list {
  padding: 0 15px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-top: 20px;
  .panel-item {
    height: 113px;
    background-color: #ffffff;
    box-shadow: 0px 2px 12px 0px rgba(6, 0, 1, 0.04);
    border-radius: 4px;
    width: calc(50% - 8px);
    margin-bottom: 10px;
    text-align: center;
    padding-top: 15px;
    box-sizing: border-box;
  }
  .panel-item-num {
    height: 19px;
    font-family: DINCondensed-Bold;
    font-size: 26px;
    font-weight: normal;
    font-stretch: normal;
    line-height: 25px;
    letter-spacing: 0px;
    color: #333333;
  }
  .panel-item-label {
    display: flex;
    align-items: center;
    justify-content: center;
    span {
      font-family: PingFang-SC-Medium;
      font-size: 14px;
      font-weight: normal;
      font-stretch: normal;
      letter-spacing: 0px;
      color: #666666;
    }
    .nav-left {
      color: #666;
    }
  }
}
</style>
