<template>
  <div class="app">
    <router-view></router-view>
  </div>
</template>

<script>
import local from "@/utils/local";
import mq from "@/mixin/mq";
import { getHomeInfo } from "@/api";
import { mapMutations } from "vuex";
export default {
  mixins: [mq],
  data() {
    return {
      routeQuery: "",
      devicenum: "",
      linkDom: null, // 换皮
    };
  },
  created() {
    this.getInfo();
    // 开发环境
    if (process.env.NODE_ENV == "development") {
      let obj = {
        deviceInfo: {
          enabled: 1,
          productId: 3,
          productName: "样表系统",
          siteCode: "511500000000-0001",
          siteId: 1,
          siteName: "宜宾市民中心",
          source: 1,
        },
        rabbmitInfo: {
          downTopicFilter: "/down/" + "dsadsdsadsa",
          exchangeName: "phxt.hjq",
          host: "10.12.185.213",
          messageTtl: "86400000",
          password: "admin@2020",
          port: 5672,
          uploadTopicFilter: "/upload/" + "dsadsdsadsa",
          username: "taxi_mq",
          virtualHost: "/",
        },
        serviceInfo: {
          homeUrl: "http://192.168.0.24:8080/#/",
          serverUrl: "http://10.12.185.213:11098",
        },
      };
      this.WebSocketMq(obj);
    }
  },
  methods: {
    ...mapMutations(["SET_homeInfo", "SET_datumList", "SET_matterList"]),
    // 简析url
    urlGet() {
      let q = {};
      let search = location.search;
      let hash = location.hash;
      if (search) {
        location.search.replace(/([^?&=]+)=([^&]+)/g, function (_, k, v) {
          return (q[k] = v);
        });
      } else if (hash) {
        location.hash.replace(/([^?&=]+)=([^&]+)/g, function (_, k, v) {
          return (q[k] = v);
        });
      }
      return q;
    },
    // 获取地址栏信息
    getInfo() {
      let routeQuery = this.urlGet();
      if (JSON.stringify(routeQuery) !== "{}") {
        let { devicenum, deviceInfo } = routeQuery;
        this.devicenum = devicenum;
        local.setLocal("devicenum", devicenum);
        local.setLocal("siteId", deviceInfo.siteId);
      }
    },
    // 获取首页信息
    async getHomeInfo() {
      let res = await getHomeInfo({});
      let { data, code } = res.data;
      if (code === 1) {
        data.hotWords = data.hotWords.map((v) => v.hotwords);
        this.homeInfo = data;
        this.SET_homeInfo(data);
        this.SET_datumList(data.datumList);
        this.SET_matterList(data.matterList);
      }
    },
    // 换肤
    getSetinfo() {
      console.log("皮肤设置");
      // let _this = this;
      // setinfo().then((res) => {
      //   const { code, data } = res.data;
      //   if (code == 1) {
      //     if (_this.linkDom) {
      //       _this.linkDom.remove();
      //     }
      //     if (data.css_path) {
      //       let link = document.createElement("link");
      //       _this.linkDom = link;
      //       link.rel = "stylesheet";
      //       link.href = data.css_path;
      //       document.getElementsByTagName("head")[0].appendChild(link);
      //     }
      //   }
      // });
    },
  },
};
</script>

<style lang="less">
.app {
  width: 100%;
  height: 100%;
  background-color: #f5f5f5;
  font-family: Source Han Sans CN;
  // display: flex;
  // overflow: auto;
  // &::-webkit-scrollbar {
  //   display: none;
  // }
}
:root {
  // 标题颜色
  --main-h1-color: #fff;
  /* 辅助颜色 */
  --main-assist-color: #59d1fe;
  --main-assist-color1: #59d1fe;
  --main-assist-color2: #f77234;
  --main-assist-color3: #f53f3f;
  --main-assist-color4: #58c09e;
  /* 主题颜色 */
  --main-theme-color: #0857e8;
  // 底部数据标题名称
  --main-sjbt-color: #666;
  // 渐变色(主色)
  --gradient-ramp-theme1: #0857e8;
  --gradient-ramp-theme2: #fd644f;
  --gradient-ramp-theme3: #58c09e;
  // 渐变色(辅色)
  --gradient-ramp-assist1: #59d1fe;
  --gradient-ramp-assist2: #f28e26;
  --gradient-ramp-assist3: #48fca5;
}
.main-bg-img {
  background: url("./assets/img/bg(1).jpg") no-repeat;
}
.main-kstd-img {
  background: url("./assets/img/btn_kuaisu.png") no-repeat;
}
</style>