<!--
 * @Author: your name
 * @Date: 2021-10-14 11:25:20
 * @LastEditTime: 2021-11-10 17:01:24
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /data-show/src/views/WeiboDetails/weiboUserActiveArea/index.vue
-->
<template>
  <div class="wua-outter" v-loading="load">
    <v-label-div title="主帖ID区域分布" :showLine="false" :eStyle="{'border-style': 'none'}"> </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 { getRegion } from "@/api/ModelForumDetails";
import createOptD1 from "./opt1";
import createOptD2 from "./opt2";
export default {
  name: "MainPostUserActiveArea",
  data() {
    return {
      load: false,
      form: {
        sBrand: "",
        token: "",
        sSeriesName: "",
        iBBsType: 2
      },
      opt1: {},
      opt2: {},
    };
  },
  created() {
    this.form.token = this.getToken;
    this.form.sBrand = this.getBrand.brandname || '奥迪';
    this.form.sSeriesName = this.getModel.name;
    this.getData();
  },
  methods: {
    getData() {
      this.load = true;
      let obj = Object.assign({}, this.getCtime2, this.form);
      getRegion(obj).then((res) => {
        let data = res.data || {};
        let arr = this.toArr(data);
        let dx = []; //省份
        let ds = []; //数据
        arr.forEach((ele) => {
          let value = ele.value;
          dx.push(ele.name);
          ds.push(value);
        });
        let dm = arr //省份和数据
        this.opt1 = createOptD1(dx, ds);
        this.opt2 = createOptD2(dm);
        this.load = false;
      });
    },
    // 将对象变成数组
    toArr(obj) {
      let arr = [];
      for (let key in obj) {
        let o = {
          name: key,
          value: obj[key] * 1,
        };
        arr.push(o);
      }
      return arr;
    },
  },
};
</script>

<style lang="less" scoped>
.wua-outter {
  width: 936px;
  height: 412px;
  .wua-inner {
    width: 100%;
    height: calc(100% - 48px);
    display: flex;
    justify-content: flex-start;
    .d1 {
      width: 479px;
      height: 100%;
    }
    .d2 {
      width: 420px;
      height: 100%;
      margin-left: 16px;
    }
  }
}
</style>
