<!--
 * @Author: your name
 * @Date: 2021-10-15 15:58:57
 * @LastEditTime: 2021-10-15 16:52:25
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /data-show/src/views/BrandComparison/brandCommunicationTOPMedia/index.vue
-->
<template>
  <div class="bcm-outter">
    <v-label-div title="品牌传播TOP媒体"> </v-label-div>
    <div class="bcm-inner">
      <div class="bcm-item" v-for="(item, index) in arrList" :key="index">
        <span class="ss1" :style="{ color: colors[index] }">{{
          item.key
        }}</span>
        <v-ranking-bcm
          v-for="(it, n) in item.value"
          :key="n"
          :label="it.key"
          :num="it.num"
          :val="it.value"
        ></v-ranking-bcm>
      </div>
    </div>
  </div>
</template>
<script>
import { getSourceTopCount0528C } from "@/api/BrandComparison";
import vRankingBcm from "./v-ranking-bcm";
export default {
  name: "brandCommunicationTOPMedia",
  components: {
    vRankingBcm,
  },
  data() {
    return {
      colors: [
        "#3373CC",
        "#63AECC",
        "#54BF93",
        "#CC9D12",
        "#CC7733",
        "#CC5B41",
      ],
      form: {
        token: "",
        sBrand: "",
      },
      arrList:[],
    };
  },
  created() {
    this.initData();
  },
  methods: {
    initData() {
      this.form.token = this.getToken;
      let arr = this.getBComparison;
      let brands = [];
      arr.forEach((ele) => {
        brands.push(ele.name);
      });
      this.form.sBrand = brands.toString();
      this.getData();
    },
    getData() {
      return new Promise((resolve, reject) => {
        let obj = Object.assign({}, this.getCtime2, this.form);
        getSourceTopCount0528C(obj)
          .then((res) => {
            let data = res.data || [];
            data.forEach(ele => {
                for(let index = 0 ; index<ele.value.length;index++){
                    ele.value[index].num = index + 1;
                }
            });
            this.arrList = data;
            resolve(data);
          })
          .catch(() => {
            reject(false);
          });
      });
    },
  },
};
</script>

<style lang="less" scoped>
.bcm-outter {
  width: 100%;
  height: 460px;
  border: 2px solid #0f2a4d;
  margin-top: 16px;
  .bcm-inner {
    width: 100%;
    height: calc(100% - 48px);
    display: flex;
    justify-content: flex-start;
    .bcm-item {
      width: 282px;
      margin-left: 27px;
      .ss1 {
        display: block;
        font-size: 18px;
        color: #fff;
        font-weight: 500;
        padding-top: 14px;
      }
    }
  }
}
</style>
