index.vue 2.5 KB

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