Index.vue 5.1 KB

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