index.vue 2.5 KB

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