Index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <el-container style="height: 100%">
  3. <el-header class="header" v-show="flag">
  4. <div v-if="userinfo.logo">
  5. <img
  6. :src="userinfo.logo"
  7. alt=""
  8. style="position: absolute; left: 20px; top: 20px; max-width: 136px"
  9. />
  10. </div>
  11. <!-- 用户 -->
  12. <div class="userinfo">
  13. 欢迎您,{{ username }}
  14. </div>
  15. <!-- 标题 -->
  16. <div class="sysName">
  17. <h2 v-if="userinfo.user_header">{{ userinfo.user_header}}</h2>
  18. <h2 v-else>可视农业应用系统</h2>
  19. <p>
  20. Agricultural Visualization Monitoring System
  21. </p>
  22. </div>
  23. <div class="site" v-if="userinfo.site">
  24. <i class="iconfont icon-jidi"></i>
  25. <span>{{ userinfo.site }}</span>
  26. </div>
  27. <span class="header_btn" @click="hCheckFun">[隐藏]</span>
  28. </el-header>
  29. <el-header class="header2" v-show="!flag">
  30. <h3 v-if="userinfo.user_header">{{ userinfo.user_header }}</h3>
  31. <h3 v-else>可视农业应用系统</h3>
  32. <div class="site" v-if="userinfo.site">
  33. <i class="iconfont icon-jidi"></i>
  34. <span>{{ userinfo.site }}</span>
  35. </div>
  36. <span class="header_btn" @click="hCheckFun">[展开]</span>
  37. </el-header>
  38. <el-container style="overflow: auto">
  39. <el-aside width="200px">
  40. <el-menu
  41. :default-active="$route.path"
  42. :collapse-transition="false"
  43. class="el-menu-vertical-demo"
  44. :router="isRouter"
  45. active-text-color="rgb(57, 249, 190)"
  46. >
  47. <el-menu-item index="/index/monitor1">
  48. <i :class="iconObj[20]"></i>
  49. <span slot="title">可视农业应用系统</span>
  50. </el-menu-item>
  51. <el-menu-item index="/index/list1">
  52. <i :class="iconObj[22]"></i>
  53. <span slot="title">设备列表</span>
  54. </el-menu-item>
  55. <el-menu-item index="/index/userManger1">
  56. <i :class="iconObj[23]"></i>
  57. <span slot="title">用户管理</span>
  58. </el-menu-item>
  59. </el-menu>
  60. </el-aside>
  61. <el-main>
  62. <router-view></router-view>
  63. </el-main>
  64. </el-container>
  65. </el-container>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. isRouter: true,
  72. iconObj: {
  73. 20: "iconfont icon-jiankong",
  74. 22: "iconfont icon-shebei",
  75. 23: "iconfont icon-xitong",
  76. },
  77. flag: true,
  78. active: 1,
  79. userinfo: {},
  80. username: "",
  81. userphoto: "",
  82. };
  83. },
  84. created: function () {
  85. this.getuserinfo();
  86. },
  87. computed: {},
  88. mounted() {},
  89. methods: {
  90. hCheckFun() {
  91. this.flag = !this.flag;
  92. },
  93. getuserinfo() {
  94. this.$axios({
  95. method: "post",
  96. url: "userinfo_",
  97. }).then((res) => {
  98. this.username = res.data.username;
  99. this.userphoto = res.data.userphoto;
  100. localStorage.setItem("username", res.data.username); // 0管理员 1用户
  101. });
  102. this.$axios({
  103. method: "get",
  104. url: "user_detail",
  105. }).then((res) => {
  106. this.userinfo = res.data;
  107. localStorage.setItem("have_type", this.userinfo.have_type); // 0管理员 1用户
  108. localStorage.setItem("staff", this.userinfo.staff); // 1是admin
  109. });
  110. },
  111. },
  112. };
  113. </script>
  114. <style scoped lang="less">
  115. .header {
  116. position: relative;
  117. width: 100%;
  118. height: 177px !important;
  119. border-bottom: 2px solid #272b3a;
  120. background: #272b3a no-repeat center / 100% 100%
  121. url(../assets/images/monitor/h_bg.jpg);
  122. .userinfo {
  123. color: #fff;
  124. position: absolute;
  125. top: 10px;
  126. right: 10px;
  127. .userheadImg {
  128. width: 35px;
  129. height: 35px;
  130. border-radius: 50%;
  131. vertical-align: middle;
  132. margin-right: 6px;
  133. }
  134. }
  135. .sysName {
  136. color: #fff;
  137. text-align: center;
  138. h2 {
  139. font-size: 26px;
  140. }
  141. p {
  142. font-size: 14px;
  143. }
  144. margin-top: 50px;
  145. }
  146. .logInfo {
  147. color: #fff;
  148. position: absolute;
  149. top: 10px;
  150. left: 20px;
  151. display: flex;
  152. flex-direction: row;
  153. align-items: center;
  154. img {
  155. width: auto;
  156. height: 40px;
  157. }
  158. h3 {
  159. margin: 0;
  160. margin-left: 20px;
  161. }
  162. }
  163. }
  164. .header2 {
  165. border-bottom: 2px solid #272b3a;
  166. position: relative;
  167. background-color: #323749;
  168. color: #fff;
  169. }
  170. .site {
  171. position: absolute;
  172. right: 90px;
  173. bottom: 10px;
  174. z-index: 888;
  175. font-size: 14px;
  176. color: #ffffff;
  177. span {
  178. color: #fff;
  179. letter-spacing: 1px;
  180. font-size: 13px;
  181. }
  182. }
  183. .header_btn {
  184. position: absolute;
  185. color: #727272;
  186. font-size: 14px;
  187. right: 20px;
  188. bottom: 10px;
  189. cursor: pointer;
  190. }
  191. .header_btn:hover {
  192. color: #fff;
  193. }
  194. .el-aside {
  195. background: #474e60;
  196. .el-menu {
  197. background: #232735;
  198. .el-menu-item {
  199. color: #909399;
  200. }
  201. .is-active {
  202. background-color: rgba(45, 111, 102, 0.4);
  203. }
  204. .el-menu-item:focus,
  205. .el-menu-item:hover {
  206. color: #39f9be;
  207. background-color: rgba(45, 111, 102, 0.4);
  208. i {
  209. color: #39f9be;
  210. }
  211. }
  212. }
  213. }
  214. .el-main {
  215. padding: 0;
  216. background-color: #f6f6f6;
  217. }
  218. </style>