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.

168 lines
5.0 KiB

<!--
* @Author: your name
* @Date: 2021-10-12 15:24:48
* @LastEditTime: 2021-11-01 18:03:30
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /data-show/src/views/BrandInsight/weiboVolumeTrend/index.vue
-->
<template>
<div class="wvt-outter" v-loading="load">
<v-label-div title="微博声量趋势" :showLine="false" :eStyle="{ 'border-style': 'none' }">
</v-label-div>
<div class="wvt-inner">
<v-echarts :opt="opt" @clickMark="clickMark"></v-echarts>
</div>
<div class="vshow" v-if="modelShow" :style="modelStyle">
<vLabel-div title="实时热点事件">
<a-button @click="closeBox">关闭</a-button>
</vLabel-div>
<div class="vshow-item" v-for="(item, index) in urlArr" :key="index">
<a class="vshow-link" :href="item.url" v-if="item.column == activeCol" target="tar">{{item.title}}</a>
</div>
</div>
</div>
</template>
<script>
import { getCountTime0528 } from "@/api/ModelInsight";
import {doStr} from "@/utils/gol/dataTool"
import createOpt from "./opt";
export default {
name: "ml-weibo-volume-trend",
props: ["brand", "model"],
data() {
return {
//弹出框//
modelStyle:{
left: '',
top: ''
},
modelShow: false,
ecbox:{//图表宽高
width:618,
height:490
},
ecmodel:{//弹框宽高
width:300,
height:280
},
activeCol: 0,
//-*-//
load: false,
form: {
sBrand: "",
sSeriesName: "",
token: "",
},
opt: {},
urlArr: []
};
},
watch: {
model: {
handler(val) {
if (val) {
this.form.token = this.getToken;
this.form.sBrand = this.brand;
this.form.sSeriesName = this.model;
this.getData();
}
},
immediate: true,
},
},
methods: {
//--弹出框--//
clickMark(data) {
this.activeCol = data.index
this.modelShow = true;
let mw = window.event;
if((this.ecbox.width - mw.offsetX - 20) > this.ecmodel.width) {
this.modelStyle.left = mw.offsetX + 20 + "px"
} else {
this.modelStyle.left = mw.offsetX - this.ecmodel.width - 20 + "px"
}
if((this.ecbox.height - mw.offsetY - 20) > this.ecmodel.height) {
this.modelStyle.top = mw.offsetY + "px"
} else {
this.modelStyle.top = mw.offsetY - this.ecmodel.height + "px"
}
},
closeBox() {
this.modelShow = false;
},
//----//
getData() {
this.load = true;
let obj = Object.assign({}, this.getCtime2, this.form);
getCountTime0528(obj).then((res) => {
let data = res.data || [];
console.log(data)
let dx = [];
let ds = [];
let hotTopArr = [];
let urlArr = [];
let hotIndex = [];
let dataI = 0;
data.forEach((ele) => {
let key = ele.Time;
let value = ele.value;
dx.push(key);
ds.push(value);
if(ele.hotTop[0]) {
ele.hotTop.forEach((e) => {
let urlObj = {
column: dataI,
title: doStr(e.title, 30),
url: e.url
};
urlArr.push(urlObj);
})
}
let obj = {
label: key,
hotTop: ele.hotTop
}
hotTopArr.push(obj);
dataI = dataI + 1;
});
this.urlArr = urlArr;
//获取有热点信息的索引
for(let i = 0; i<hotTopArr.length; i++) {
if(hotTopArr[i].hotTop != '') {
hotIndex.push(i)
}
}
this.opt = createOpt(dx, ds, hotIndex);
this.load = false;
});
},
},
};
</script>
<style lang="less" scoped>
.wvt-outter {
width: 570px;
height: 412px;
margin-left: 16px;
.wvt-inner {
width: 100%;
height: calc(100% - 48px);
}
}
.vshow{
position: absolute;
width: 300px;
background: rgb(3, 18, 36);
border: 4px solid #0f2a4d;
.vshow-item {
padding: 11px;
width: 100%;
font-size: 15px;
color: rgb(54, 189, 239);
}
}
</style>