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.
146 lines
3.4 KiB
146 lines
3.4 KiB
<!--
|
|
* @Author: your name
|
|
* @Date: 2021-10-14 11:25:20
|
|
* @LastEditTime: 2021-10-16 11:31:16
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description: In User Settings Edit
|
|
* @FilePath: /data-show/src/views/WeiboDetails/weiboUserActiveArea/index.vue
|
|
-->
|
|
<template>
|
|
<div class="wua-outter">
|
|
<v-label-div
|
|
title="用户区域分布"
|
|
:showLine="false"
|
|
:eStyle="{ 'border-style': 'none' }"
|
|
>
|
|
<v-tab-group :btns="this.brandArr" @change="handlerTab"></v-tab-group>
|
|
</v-label-div>
|
|
<div class="wua-inner">
|
|
<div class="d1">
|
|
<v-echarts :opt="opt1"></v-echarts>
|
|
</div>
|
|
<div class="d2">
|
|
<v-echars-map :opt="opt2"></v-echars-map>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { getRegionWeiBoC } from "@/api/BrandComparison/BrandWeibo.js";
|
|
import createOptD1 from "./opt1";
|
|
import createOptD2 from "./opt2";
|
|
export default {
|
|
name: "userAreaDistribution",
|
|
data() {
|
|
return {
|
|
opt1: {},
|
|
opt2: {},
|
|
form: {
|
|
token: "",
|
|
sBrand: "",
|
|
},
|
|
dataSource: [],
|
|
brandArr: [],
|
|
};
|
|
},
|
|
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();
|
|
Promise.all([this.getData()]).then(() => {
|
|
// 什么也不执行
|
|
this.handlerTab(0);
|
|
});
|
|
},
|
|
getData() {
|
|
return new Promise((resolve, reject) => {
|
|
let obj = Object.assign({}, this.getCtime2, this.form);
|
|
getRegionWeiBoC(obj)
|
|
.then((res) => {
|
|
let data = res.data || [];
|
|
//dx省份 ds数据 dm省份和数据的对象数组
|
|
let mapArr = [];
|
|
let brandList = [];
|
|
data.forEach((ele) => {
|
|
let dx = [];
|
|
let ds = [];
|
|
let dm = this.toArr(ele.Data);
|
|
dm.forEach((e) => {
|
|
//处理直辖市
|
|
e.name = e.name.replace('省', '');
|
|
dx.push(e.name);
|
|
ds.push(e.value);
|
|
});
|
|
let o = {
|
|
name: ele.Name,
|
|
dx: dx,
|
|
ds: ds,
|
|
dm: dm,
|
|
//opt1: createOptD1(),
|
|
//opt2: createOptD2(),
|
|
//tapIndex: 0
|
|
};
|
|
brandList.push(ele.Name);
|
|
mapArr.push(o);
|
|
});
|
|
this.dataSource = mapArr;
|
|
this.brandArr = brandList;
|
|
resolve(data);
|
|
})
|
|
.catch(() => {
|
|
reject(false);
|
|
});
|
|
});
|
|
},
|
|
// 将对象变成数组
|
|
toArr(obj) {
|
|
let arr = [];
|
|
for (let key in obj) {
|
|
let o = {
|
|
name: key,
|
|
value: obj[key] * 1,
|
|
};
|
|
arr.push(o);
|
|
}
|
|
return arr;
|
|
},
|
|
// 切换数据
|
|
handlerTab(n) {
|
|
this.opt1 = createOptD1(this.dataSource[n].dx, this.dataSource[n].ds);
|
|
this.opt2 = createOptD2(this.dataSource[n].dm);
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
.wua-outter {
|
|
width: 944px;
|
|
height: 412px;
|
|
.wua-inner {
|
|
width: 100%;
|
|
height: calc(100% - 48px);
|
|
display: flex;
|
|
justify-content: flex-start;
|
|
.d1 {
|
|
width: 479px;
|
|
height: 100%;
|
|
}
|
|
.d2 {
|
|
width: 465px;
|
|
height: 100%;
|
|
margin-left: 16px;
|
|
}
|
|
}
|
|
}
|
|
</style>
|