index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="repairing">
  3. <app-header></app-header>
  4. <el-container>
  5. <el-aside style="width:max-width:200px">
  6. <left-side></left-side>
  7. </el-aside>
  8. <el-main class="repairingMain">
  9. <router-view></router-view>
  10. </el-main>
  11. </el-container>
  12. </div>
  13. </template>
  14. <script>
  15. import header from "./components/header/header.vue";
  16. import leftside from "./components/header/leftside.vue";
  17. import bus from "./components/header/bus.js";
  18. import { Toast } from "vant";
  19. export default {
  20. components: {
  21. appHeader: header,
  22. leftSide: leftside
  23. },
  24. name: "index",
  25. created() {
  26. this.setRem();
  27. window.addEventListener("resize", this.setRem);
  28. window.addEventListener("orientationchange", this.setRem);
  29. this.setListener();
  30. },
  31. methods: {
  32. setRem() {
  33. var html = document.querySelector("html");
  34. var width = html.getBoundingClientRect().width;
  35. // console.log(width);
  36. if(width>=1680){
  37. html.style.fontSize = width/180 + "px";
  38. }else if(width>1280&&width<1680){
  39. html.style.fontSize = width/140 + "px";
  40. }else{
  41. html.style.fontSize = width/120 + "px";
  42. }
  43. // console.log(html.style.fontSize);
  44. },
  45. setListener() {
  46. let loading = null;
  47. this.$on("global:INTERFACE_ACTION", option => {
  48. switch (option.error_no) {
  49. //成功
  50. case "0":
  51. if (loading) {
  52. Toast.clear();
  53. }
  54. break;
  55. //全局加载提示
  56. case "1":
  57. loading = Toast.loading({
  58. duration: 0,
  59. mask: true,
  60. loadingType: "spinner",
  61. message: "加载中"
  62. });
  63. break;
  64. //关闭加载
  65. case "2":
  66. if (loading) {
  67. Toast.clear();
  68. }
  69. break;
  70. //跳转
  71. case "3":
  72. this.$router.push(option.data.url);
  73. break;
  74. //重定向
  75. case "4":
  76. this.$router.replace(option.data.url);
  77. break;
  78. default:
  79. if (loading) {
  80. Toast.clear();
  81. }
  82. this.$mytoast({
  83. message: option.error_info
  84. });
  85. }
  86. });
  87. },
  88. }
  89. };
  90. </script>
  91. <style lang="stylus">
  92. </style>