index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view>
  3. <!-- 建议放在外层 -->
  4. <u-navbar
  5. title="设备中心"
  6. :bgImage="backPic"
  7. :bgStatusImage="backPic0"
  8. @leftClick="devicemenuShow"
  9. :safeAreaInsetTop="true"
  10. >
  11. <view class="u-nav-slot" slot="left">
  12. <u-icon name="list" size="20"> </u-icon>
  13. </view>
  14. </u-navbar>
  15. <view v-if="menushow" class="menupage">
  16. <DeviceMenu @menuClick="menuClick"></DeviceMenu>
  17. </view>
  18. <u-tabs
  19. class="devic-box-tab"
  20. :current="PageCur"
  21. :list="tabList"
  22. @click="NavChange"
  23. ></u-tabs>
  24. <view class="">
  25. <home
  26. cur="home"
  27. :showColum="showColum"
  28. v-if="PageCur == '0' && !menushow"
  29. :key="0"
  30. :deviceType="deviceType"
  31. @setMenushow="setMenushow"
  32. ></home>
  33. <history
  34. :key="1"
  35. cur="history"
  36. :showColum="showColum"
  37. :deviceType="deviceType"
  38. v-if="PageCur == '1' && !menushow"
  39. @setMenushow="setMenushow"
  40. ></history>
  41. <operation
  42. :key="2"
  43. :showColum="showColum"
  44. :deviceType="deviceType"
  45. cur="operation"
  46. v-if="PageCur == '2' && !menushow"
  47. @setMenushow="setMenushow"
  48. ></operation>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import api from "@/api/api";
  54. import DeviceMenu from "./devicemenu/devicemenu.vue";
  55. export default {
  56. components: {
  57. DeviceMenu,
  58. },
  59. data() {
  60. return {
  61. backPic0: "url(/static/topnavbar0.png)",
  62. backPic: "url(/static/topnavbar.png)",
  63. PageCur: "0",
  64. showColum: {},
  65. menushow: false,
  66. deviceType: "gate",
  67. tabList: [
  68. {
  69. name: "设备监测",
  70. },
  71. {
  72. name: "历史数据",
  73. },
  74. {
  75. name: "操作记录",
  76. },
  77. ],
  78. };
  79. },
  80. created() {
  81. this.getShowColum();
  82. },
  83. onLoad: function () {
  84. this.PageCur = "0";
  85. },
  86. methods: {
  87. NavChange: function (item) {
  88. this.PageCur = item.index;
  89. this.menushow = false;
  90. },
  91. devicemenuShow(e) {
  92. this.menushow = !this.menushow;
  93. },
  94. menuClick(id) {
  95. // debugger
  96. // this.TabCur = id;
  97. this.deviceType = id;
  98. console.log(this.deviceType, "设备类型");
  99. this.menushow = false;
  100. },
  101. getShowColum() {
  102. new Promise((resolve, reject) => {
  103. api
  104. .getShowColum({})
  105. .then((response) => {
  106. if (response.data.code == 200) {
  107. var showlist = response.data.result;
  108. this.$store.commit("SET_SHOWCOLUM", showlist);
  109. this.showColum = showlist;
  110. } else {
  111. resolve(response);
  112. }
  113. })
  114. .catch((error) => {
  115. console.log("catch===>response", response);
  116. reject(error);
  117. });
  118. });
  119. },
  120. setMenushow(params) {
  121. if (params) {
  122. this.menushow = params.menushow;
  123. }
  124. },
  125. },
  126. };
  127. </script>
  128. <style lang="scss" scoped>
  129. .devic-box-tab {
  130. // margin-top: 50px;
  131. }
  132. </style>