<!--
 * @Author: your name
 * @Date: 2021-10-12 18:18:20
 * @LastEditTime: 2021-11-01 09:59:18
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /data-show/src/views/BrandInsight/spreadTOPmodels/index.vue
-->
<template>
    <div class="stm-outter" v-loading="load">
        <v-label-div title="传播声量TOP品牌" :showLine="false" :eStyle="{ 'border-style': 'none' }"></v-label-div>
        <div class="stm-inner">
            <v-echarts :opt="opt" @getData="clickEchars"></v-echarts>
        </div>
    </div>
</template>

<script>
import { getHomeBrandGroupBy } from "@/api/KeyMediaHome/index.js"
import {getUserSeriesName} from "@/api/comm/index.js"
import createOpt from "./opt"
export default {
    name: "spreadTOPmodels",
    data() {
        return {
            load: false,
            form: {
                sSource: '',
                ilimitType: 0,
            },
            opt: {}
        }
    },
    created() {
        this.form.sSource = this.$route.query.source || "抖音";
        if (this.form.sSource == '汽车之家' && this.getCarCircle == 1) {
            this.form.ilimitType = 1;
        } else if (this.form.sSource == '懂车帝' && this.getCarCircle == 1) {
            this.form.ilimitType = 2;
        }
        this.getData();
    },
    methods: {
        getData() {
            let obj = Object.assign({}, this.getCtime2, this.form);
            this.load = true;
            getHomeBrandGroupBy(obj).then(res => {
                let data = res.data || [];
                let dx = [];
                let ds = [];
                data.forEach(ele => {
                    dx.push(ele.Key)
                    ds.push(ele.Value)
                })
                this.opt = createOpt(dx, ds);
                this.load = false;
            })
        },
        clickEchars(data) {
            if(!this.getToken) {return false}
            let ele = data;
            let brand = ele.axisValueLabel;
            let obj = {
                sBrandName: brand,
                token: this.getToken
            }
            getUserSeriesName(obj).then((res) => {
                let data = res.data || [];
                this.setModel(data[0]);
            });
            this.setBrand({ brandname: brand });
            this.$router.push("/brandInsight");
        }
    }
}
</script>
<style lang="less" scoped>
.stm-outter {
    width: 936px;
    height: 412px;
    border: 2px solid #0f2a4d;

    .stm-inner {
        width: 100%;
        height: calc(100% - 48px);
    }
}
</style>
