<!--
 * @Author: xw
 * @Date: 2021-10-12 10:50:44
 * @LastEditTime: 2021-11-17 15:56:14
 * @LastEditors: Please set LastEditors
 * @Description: 热门事件列表
 * @FilePath: /data-show/src/views/BrandInsight/popularEventsList/index.vue
-->

<template>
    <div class="pe-ouuter" v-loading="load">
        <v-label-div title="消息数据" :showLine="false" :eStyle="{'border-style': 'none'}"></v-label-div>
        <div class="pe-inner">
            <dv-scroll-board :config="config" :style="{ width: '100%', height: '25rem' }" @click="handlerItem"/>
        </div>
    </div>
</template>

<script>
// import { getHotEventsList0528 } from "@/api/BrandInsight";
import {getList} from "@/api/KeyMediaEvent/index.js"
export default {
    name: "popularEventsList",
    props: ["brand"],
    data() {
        return {
            load: false,
            form: {
                token: "",
                sRele: '',
                sSource: '',
                ilimitType: 0,
                iPageIndex: 1,
                iPageSize: 100,
            },
            config: {},
            darr: []
        };
    },
    created() {
        this.form.token = this.getToken;
        this.form.sRele = this.$route.query.id || '';
        this.form.sSource = this.$route.query.source || "抖音";
        if(this.form.sSource == '汽车之家') {
        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;
            getList(obj).then(res => {
                let data = res.data;
                let arr = [];
                let arr2 = [];
                data.forEach(ele => {
                    let a = [
                        `<span style='cursor: pointer;'>${ele._source.title}</span>`,
                        ele._source.user_author,
                        ele._source.sourcetime,
                    ];
                    let b = [
                        `<span style='cursor: pointer;'>${ele._source.itle}</span>`,
                        ele._source.user_author,
                        ele._source.sourcetime,
                        ele._source.id
                    ];
                    arr.push(a);
                    arr2.push(b);
                    this.darr = arr2;
                    this.config = {
                        headerBGC: "rgba(16,33,59)",
                        oddRowBGC: "#173b6d",
                        evenRowBGC: "rgba(69, 149, 244, 0)",
                        columnWidth: [500,180,180],
                        rowNum: 8,
                        header: ["消息列表", "作者", "时间"],
                        data: arr,
                    };
                    this.load = false;
                })
            })
        },
         handlerItem(row) {
            let ele = this.darr[row.rowIndex];
            if(row.columnIndex === 0) {
                 let id = ele[4];
                 this.$router.push({path: '/eventDEC', query: {events_id: id}});
            }
        }
    },
};
</script>

<style lang="less" scoped>
.pe-ouuter {
    width: 934px;
    height: 459px;
    border: 2px solid #0f2a4d;
    .pe-inner {
        width: 100%;
        height: calc(100% - 48px);
    }
}
</style>
