index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view>
  3. <!-- 建议放在外层 -->
  4. <u-navbar
  5. :bgStatusImage="backPic0"
  6. :bgImage="backPic"
  7. title="设备中心"
  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. v-if="!menushow"
  20. class="devic-box-tab"
  21. :current="PageCur"
  22. :list="tabList"
  23. @click="NavChange"
  24. ></u-tabs>
  25. <view class="">
  26. <home
  27. cur="home"
  28. :showColum="showColum"
  29. v-if="PageCur == '0' && !menushow"
  30. :key="0"
  31. :deviceType="deviceType"
  32. @setMenushow="setMenushow"
  33. ></home>
  34. <history
  35. :key="1"
  36. cur="history"
  37. :showColum="showColum"
  38. :deviceType="deviceType"
  39. v-if="PageCur == '1' && !menushow"
  40. @setMenushow="setMenushow"
  41. ></history>
  42. <operation
  43. :key="2"
  44. :showColum="showColum"
  45. :deviceType="deviceType"
  46. cur="operation"
  47. v-if="PageCur == '2' && !menushow"
  48. @setMenushow="setMenushow"
  49. ></operation>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import api from "@/api/api";
  55. import DeviceMenu from "./devicemenu/devicemenu.vue";
  56. export default {
  57. components: {
  58. DeviceMenu,
  59. },
  60. data() {
  61. return {
  62. backPic0: "url(/static/topnavbar0.png)",
  63. backPic: "url(../../static/topnavbar.png)",
  64. PageCur: "0",
  65. showColum: {},
  66. menushow: true,
  67. deviceType: "",
  68. tabList: [
  69. {
  70. name: "设备监测",
  71. },
  72. {
  73. name: "历史数据",
  74. },
  75. {
  76. name: "操作记录",
  77. },
  78. ],
  79. };
  80. },
  81. created() {
  82. this.getShowColum();
  83. },
  84. onLoad: function () {
  85. this.PageCur = "0";
  86. },
  87. methods: {
  88. NavChange: function (item) {
  89. this.PageCur = item.index;
  90. this.menushow = false;
  91. },
  92. devicemenuShow(e) {
  93. this.menushow = !this.menushow;
  94. },
  95. menuClick(id) {
  96. debugger;
  97. // this.TabCur = id;
  98. this.deviceType = id;
  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>