You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.3 KiB
112 lines
3.3 KiB
<!--
|
|
* @Author: xw
|
|
* @Date: 2021-10-12 11:06:58
|
|
* @LastEditTime: 2021-11-16 15:43:24
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description: 热门事件
|
|
* @FilePath: /data-show/src/views/BrandInsight/popularEvents/index.vue
|
|
-->
|
|
<template>
|
|
<div class="pe-outter" v-loading="load">
|
|
<v-label-div title="热点事件" :showLine="false" :eStyle="{'border-style': 'none'}"></v-label-div>
|
|
<div class="pe-inner">
|
|
<v-echarts :opt="opt"></v-echarts>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import moment from "moment";
|
|
import { getHotEventsType } from "@/api/BrandInsight";
|
|
import createOpt from "./opt";
|
|
export default {
|
|
name: "popularEvents",
|
|
props: ["brand"],
|
|
data() {
|
|
return {
|
|
load: false,
|
|
form: {
|
|
sBrand: "",
|
|
token: "",
|
|
},
|
|
opt: {},
|
|
};
|
|
},
|
|
created() {
|
|
this.form.token = this.getToken;
|
|
this.form.sBrand = this.getBrand.brandname || this.brand;
|
|
this.getData();
|
|
},
|
|
methods: {
|
|
getData() {
|
|
let obj = Object.assign({}, this.getCtime2, this.form);
|
|
this.load = true;
|
|
getHotEventsType(obj).then((res) => {
|
|
let data = res.data;
|
|
let arr = data.Data || [];
|
|
let type = data.Type || {};
|
|
let obj = {};
|
|
Object.keys(type).forEach((ele) => {
|
|
obj[ele] = [];
|
|
});
|
|
this.sortDataArr(arr)
|
|
let dx = [];
|
|
arr.forEach((ele) => {
|
|
let m1 = moment(ele.maxSourcetime).format('HH:mm');
|
|
// let m2 = moment(m1).valueOf()
|
|
dx.push(m1)
|
|
let a = [
|
|
m1,
|
|
ele.events_count * 1,
|
|
ele.events_influence,
|
|
ele.events_brand,
|
|
ele.events_title,
|
|
ele.events_type,
|
|
ele.maxSourcetime,
|
|
ele.summary,
|
|
];
|
|
obj[ele.events_type].push(a);
|
|
});
|
|
|
|
this.opt = createOpt(dx, obj);
|
|
this.load = false;
|
|
});
|
|
},
|
|
// 数组排序
|
|
sortDataArr(arr) {
|
|
for(let i=0; i < arr.length; i++) {
|
|
for(let j = i+1; j < arr.length; j++) {
|
|
let t1 = moment(arr[i].maxSourcetime).format('HH:mm');
|
|
let t2 = moment(arr[j].maxSourcetime).format('HH:mm');
|
|
let a = t1.split(":");
|
|
let x1 = a[0]*60 + a[1]*1;
|
|
let b = t2.split(":");
|
|
let x2 = b[0]*60 + b[1]*1;
|
|
let diff = x2 - x1;
|
|
if(diff < 0) {
|
|
let ele1 = arr[i];
|
|
let ele2 = arr[j];
|
|
let ele3 = ele1;
|
|
arr[i] = ele2;
|
|
arr[j] = ele3;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
.pe-outter {
|
|
width: 928px;
|
|
height: 412px;
|
|
margin-left: 16px;
|
|
.pe-inner {
|
|
width: 100%;
|
|
height: calc(100% - 48px);
|
|
}
|
|
}
|
|
</style>
|