<template>
  <div class="repairing">
    <app-header></app-header>
    <el-container>
      <el-aside style="width:max-width:200px">
        <left-side></left-side>
      </el-aside>
      <el-main class="repairingMain">
          <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import header from "./components/header/header.vue";
import leftside from "./components/header/leftside.vue";
import bus from "./components/header/bus.js";
import { Toast } from "vant";
export default {
  components: {
    appHeader: header,
    leftSide: leftside
  },
  name: "index",
  created() {
    this.setRem();
    window.addEventListener("resize", this.setRem);
    window.addEventListener("orientationchange", this.setRem);
    this.setListener();
  },
  methods: {
    setRem() {
      var html = document.querySelector("html");
      var width = html.getBoundingClientRect().width;
      // console.log(width);
      if(width>=1680){
        html.style.fontSize = width/180 + "px";
      }else if(width>1280&&width<1680){
        html.style.fontSize = width/140 + "px";
      }else{
        html.style.fontSize = width/120 + "px";
      }
      // console.log(html.style.fontSize);

    },
    setListener() {
      let loading = null;
      this.$on("global:INTERFACE_ACTION", option => {
        switch (option.error_no) {
          //成功
          case "0":
            if (loading) {
              Toast.clear();
            }
            break;
          //全局加载提示
          case "1":
            loading = Toast.loading({
              duration: 0,
              mask: true,
              loadingType: "spinner",
              message: "加载中"
            });
            break;
          //关闭加载
          case "2":
            if (loading) {
              Toast.clear();
            }
            break;
          //跳转
          case "3":
            this.$router.push(option.data.url);
            break;
          //重定向
          case "4":
            this.$router.replace(option.data.url);
            break;
          default:
            if (loading) {
              Toast.clear();
            }
            this.$mytoast({
              message: option.error_info
            });
        }
      });
    },
  }
};
</script>

<style lang="stylus">
    
</style>
