index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="ranking">
  3. <div class="tip">数据来源于集团大数据平台</div>
  4. <div v-show="errorInformation.text === ''">
  5. <keep-alive>
  6. <component
  7. :active="errorInformation.text === '' && active === 1"
  8. @start="comError"
  9. :is="tabs[active].com"
  10. />
  11. </keep-alive>
  12. </div>
  13. <van-empty
  14. v-show="errorInformation.text !== ''"
  15. :image="errorInformation.type"
  16. :description="errorInformation.text"
  17. />
  18. <van-tabbar v-model="active" active-color="#ee0a24" @change="change">
  19. <van-tabbar-item
  20. v-for="item in tabs"
  21. :key="item.icon"
  22. :icon="item.icon"
  23. >{{ item.name }}</van-tabbar-item
  24. >
  25. </van-tabbar>
  26. </div>
  27. </template>
  28. <script>
  29. // @ is an alias to /src
  30. import {
  31. Tabbar as vanTabbar,
  32. TabbarItem as vanTabbarItem,
  33. Empty as vanEmpty,
  34. } from "vant";
  35. import "vant/lib/empty/style/index";
  36. import "vant/lib/tabbar/style/index";
  37. import "vant/lib/tabbar-item/style/index";
  38. import tvList from "./components/tvList.vue";
  39. import moveClient from "./components/moveClient.vue";
  40. // import {} from "../utils/tool";
  41. // import {} from "../api/index";
  42. export default {
  43. name: "Ranking",
  44. data() {
  45. return {
  46. active: window.sessionStorage
  47. ? sessionStorage.getItem("active") - 0 || 0
  48. : 0,
  49. tabs: [
  50. {
  51. name: "大屏排行",
  52. icon: "tv-o",
  53. com: "tvList",
  54. },
  55. {
  56. name: "新媒体排行",
  57. icon: "bar-chart-o",
  58. com: "moveClient",
  59. },
  60. ],
  61. errorInformation: {
  62. text: "",
  63. type: "search",
  64. },
  65. };
  66. },
  67. mounted() {},
  68. computed: {},
  69. methods: {
  70. change() {
  71. if (window.sessionStorage) sessionStorage.setItem("active", this.active);
  72. },
  73. comError(data) {
  74. let p = {
  75. text: "",
  76. type: "search",
  77. };
  78. if (data.status === 200) {
  79. this.errorInformation = p;
  80. return;
  81. }
  82. p.text = data.msg || "网络错误";
  83. p.type = "network";
  84. this.errorInformation = p;
  85. },
  86. },
  87. beforeUnmount() {},
  88. components: {
  89. vanTabbar,
  90. vanTabbarItem,
  91. vanEmpty,
  92. tvList,
  93. moveClient,
  94. },
  95. };
  96. </script>
  97. <style scoped>
  98. .ranking {
  99. width: 100vw;
  100. height: 100vh;
  101. padding-bottom: 50px;
  102. box-sizing: border-box;
  103. background-color: #fff;
  104. }
  105. .tip{
  106. text-align: center;
  107. font-size: 12px;
  108. color: #999;
  109. padding: 5px 0;
  110. }
  111. </style>