index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <header>
  3. <div id="header">
  4. <!-- 主页路由菜单 开始 -->
  5. <div class="router-index" v-if="!home">
  6. <!-- <router-link
  7. class="router-left"
  8. :class="title == route.meta.title ? 'router_left2' : 'router_left1'"
  9. v-for="route in router.slice(1, 2)"
  10. :key="route"
  11. :to="route.path"
  12. v-show="route.meta.type === 'index'"
  13. >
  14. <span>{{ route.meta.title }}</span>
  15. </router-link>
  16. <a
  17. :href="'https://wx.ewoogi.com/manage/#/'"
  18. class="router-left router_left1"
  19. >后台管理</a
  20. > -->
  21. <!-- <a
  22. :href="'http://localhost:9999/#/login?userName=admin'"
  23. target="_blank"
  24. class="router-left router_left1"
  25. >后台管理</a
  26. > -->
  27. </div>
  28. <!-- 主页路由菜单 结束 -->
  29. <!-- 站点路由菜单 开始 -->
  30. <div class="router-menu" v-if="home">
  31. <div class="select">
  32. <span>当前站点:</span>
  33. <el-select
  34. v-model="value"
  35. @change="el_select"
  36. placeholder="请选择"
  37. popper-class="menu_select"
  38. filterable
  39. >
  40. <el-option
  41. v-for="(item, index) in options"
  42. :key="index"
  43. :label="item.label"
  44. :value="item.value"
  45. >
  46. </el-option>
  47. </el-select>
  48. </div>
  49. <div class="site_one" style="display: flex">
  50. <router-link
  51. class="router-left"
  52. :class="title == route.meta.title ? 'router_left2' : 'router_left1'"
  53. v-for="route in router.slice(2, 4)"
  54. :key="route"
  55. :to="route.path"
  56. v-show="route.meta.type === 'menu'"
  57. >
  58. <span>{{ route.meta.title }}</span>
  59. </router-link>
  60. </div>
  61. <div class="site_two" style="display: flex">
  62. <router-link
  63. class="router-rigth"
  64. :class="
  65. title == route.meta.title ? 'router_rigth2' : 'router_rigth1'
  66. "
  67. v-for="route in router.slice(4, 6)"
  68. :key="route"
  69. :to="route.path"
  70. v-show="route.meta.type === 'menu'"
  71. >
  72. <span>{{ route.meta.title }}</span>
  73. </router-link>
  74. </div>
  75. </div>
  76. <!-- 站点路由菜单 结束 -->
  77. <div class="title">{{ name }}</div>
  78. <div class="rigth">
  79. <div class="showTime">{{ time }}</div>
  80. <router-link class="home" to="/home" v-if="home"></router-link>
  81. <div class="news">
  82. <div></div>
  83. <!-- <span><a>9</a></span> -->
  84. </div>
  85. <div class="admin"></div>
  86. </div>
  87. </div>
  88. </header>
  89. </template>
  90. <script>
  91. import api from "@/api/index";
  92. import { getToken } from "@/utils/auth";
  93. export default {
  94. name: "App",
  95. data() {
  96. return {
  97. title: "",
  98. name: "",
  99. router: [],
  100. home: false,
  101. options: [],
  102. value: 1,
  103. time: null,
  104. assToken: "",
  105. username: "",
  106. password: "",
  107. };
  108. },
  109. components: {},
  110. mounted() {
  111. this.assToken = getToken();
  112. setInterval(() => {
  113. this.$store.commit("getTimeAll");
  114. var time = this.$store.state.Time_All;
  115. this.time =
  116. time[0] +
  117. "-" +
  118. (time[1] < 9 ? "0" + (time[1] + 1) : time[1] + 1) +
  119. "-" +
  120. (time[2] < 10 ? "0" + time[2] : time[2]) +
  121. " " +
  122. (time[3] < 10 ? "0" + time[3] : time[3]) +
  123. ":" +
  124. (time[4] < 10 ? "0" + time[4] : time[4]) +
  125. ":" +
  126. (time[5] < 10 ? "0" + time[5] : time[5]);
  127. }, 0);
  128. this.router = this.$router.options.routes;
  129. // console.log(this.router);
  130. },
  131. methods: {
  132. el_select(val) {
  133. // console.log(val);
  134. for (let i in this.options) {
  135. if (this.options[i].value == val) {
  136. this.name = this.options[i].label;
  137. }
  138. }
  139. // localStorage.clear();
  140. localStorage.removeItem("Overview")
  141. localStorage.setItem("Overview", [val, this.name]);
  142. },
  143. //下拉列表api请求
  144. options_api() {
  145. api.options_api().then((requset) => {
  146. this.options=[]
  147. // console.log(requset)
  148. var list = requset.data;
  149. for (let i in list) {
  150. this.options.push({ label: list[i].siteName, value: list[i].id });
  151. }
  152. });
  153. },
  154. },
  155. watch: {
  156. value(val) {
  157. this.$store.commit("increment", val);
  158. },
  159. $route: function () {
  160. var type = this.$route.meta.type;
  161. var title = this.$route.meta.title;
  162. var name = this.$route.meta.name;
  163. this.title = title;
  164. this.name = name;
  165. type === "menu"
  166. ? setTimeout(() => {
  167. this.options_api();
  168. }, 100)
  169. : "";
  170. var getlocal = localStorage.getItem("Overview");
  171. if (
  172. getlocal != undefined &&
  173. getlocal != null &&
  174. getlocal != "" &&
  175. type !== "index"
  176. ) {
  177. this.value = parseInt(getlocal.split(",")[0]);
  178. this.name = getlocal.split(",")[1];
  179. }
  180. type === "menu" ? (this.home = true) : (this.home = false);
  181. },
  182. },
  183. };
  184. </script>
  185. <style scoped lang="less">
  186. #header {
  187. -moz-user-select: none; //设置文本不可选中
  188. -webkit-user-select: none; //设置文本不可选中
  189. user-select: none; //设置文本不可选中
  190. .router-index {
  191. position: absolute;
  192. display: flex;
  193. height: 100%;
  194. line-height: 1rem;
  195. // margin-left: 1rem;
  196. .router-left {
  197. width: 1.525rem;
  198. height: 0.5rem;
  199. display: block;
  200. text-align: center;
  201. line-height: 0.5rem;
  202. margin: 0.125rem;
  203. font-size: 0.225rem;
  204. }
  205. .router-left:hover {
  206. background: url(./../assets/images/router_left2.png) no-repeat;
  207. background-size: cover;
  208. color: #fac112;
  209. }
  210. .router_left1 {
  211. background: url(./../assets/images/router_left1.png) no-repeat;
  212. color: #fff;
  213. background-size: cover;
  214. }
  215. .router_left2 {
  216. background: url(./../assets/images/router_left2.png) no-repeat;
  217. color: #fac112;
  218. background-size: cover;
  219. }
  220. }
  221. .router-menu {
  222. position: absolute;
  223. display: flex;
  224. height: 100%;
  225. line-height: 1rem;
  226. margin-left: 0.5rem;
  227. .select {
  228. display: flex;
  229. span {
  230. // position: absolute;
  231. font-family: Microsoft YaHei Regular, Microsoft YaHei Regular-Regular;
  232. color: #fff;
  233. font-weight: 400;
  234. font-size: 0.225rem;
  235. height: 100%;
  236. line-height: 0.75rem;
  237. }
  238. }
  239. .router-left {
  240. width: 1.525rem;
  241. height: 0.5rem;
  242. display: block;
  243. text-align: center;
  244. line-height: 0.5rem;
  245. margin: 0.125rem;
  246. font-size: 0.225rem;
  247. }
  248. .router-left:hover {
  249. background: url(./../assets/images/router_left2.png) no-repeat;
  250. background-size: cover;
  251. color: #fac112;
  252. }
  253. .router_left1 {
  254. background: url(./../assets/images/router_left1.png) no-repeat;
  255. color: #fff;
  256. background-size: cover;
  257. }
  258. .router_left2 {
  259. background: url(./../assets/images/router_left2.png) no-repeat;
  260. color: #fac112;
  261. background-size: cover;
  262. }
  263. .site_one {
  264. margin-left: 1.5rem;
  265. }
  266. .site_two {
  267. position: absolute;
  268. margin-left: 14.9rem;
  269. }
  270. .router-rigth {
  271. width: 1.525rem;
  272. height: 0.5rem;
  273. display: block;
  274. text-align: center;
  275. line-height: 0.5rem;
  276. margin: 0.125rem;
  277. font-size: 0.225rem;
  278. }
  279. .router-rigth:hover {
  280. background: url(./../assets/images/router_right2.png) no-repeat;
  281. background-size: cover;
  282. color: #fac112;
  283. }
  284. .router_rigth1 {
  285. background: url(./../assets/images/router_right1.png) no-repeat;
  286. color: #fff;
  287. background-size: cover;
  288. }
  289. .router_rigth2 {
  290. background: url(./../assets/images/router_right2.png) no-repeat;
  291. color: #fac112;
  292. background-size: cover;
  293. }
  294. }
  295. .title {
  296. font-size: 0.5rem;
  297. color: #fff;
  298. font-family: PangMenZhengDao Regular, PangMenZhengDao Regular-Regular;
  299. font-weight: 600;
  300. letter-spacing: 3px;
  301. text-align: center;
  302. line-height: 1rem;
  303. margin: 0 auto;
  304. width: 6rem;
  305. overflow: hidden;
  306. white-space: nowrap;
  307. text-overflow: ellipsis;
  308. }
  309. .rigth {
  310. position: absolute;
  311. top: 0;
  312. right: 0;
  313. display: flex;
  314. div {
  315. margin-right: 0.17rem;
  316. }
  317. .home {
  318. width: 0.3125rem;
  319. height: 0.25rem;
  320. margin-top: 0.25rem;
  321. background: url(./../assets/images/home.png) no-repeat;
  322. background-size: cover;
  323. margin-right: 0.3rem;
  324. }
  325. .showTime {
  326. font-size: 0.25rem;
  327. font-family: Microsoft YaHei Regular, Microsoft YaHei Regular-Regular;
  328. font-weight: 400;
  329. color: #fff;
  330. line-height: 0.75rem;
  331. margin-right: 0.25rem;
  332. }
  333. .news {
  334. font-size: 0.25rem;
  335. color: #fff;
  336. line-height: 0.35rem;
  337. cursor: pointer;
  338. div {
  339. width: 0.3rem;
  340. height: 0.2375rem;
  341. margin-top: 0.25rem;
  342. background: url(./../assets/images/news.png) no-repeat;
  343. background-size: cover;
  344. }
  345. span {
  346. position: absolute;
  347. text-align: center;
  348. width: 0.2rem;
  349. height: 0.2rem;
  350. line-height: 0.2rem;
  351. background-color: red;
  352. border-radius: 100%;
  353. top: 0.12rem;
  354. right: 0.75rem;
  355. a {
  356. display: block;
  357. width: 0.2rem;
  358. height: 0.2rem;
  359. color: #fff;
  360. transform: scale(0.7, 0.7);
  361. }
  362. }
  363. }
  364. .admin {
  365. width: 0.325rem;
  366. height: 0.325rem;
  367. margin-top: 0.2rem;
  368. background: url(./../assets/images/admin.png) no-repeat;
  369. background-size: cover;
  370. cursor: pointer;
  371. }
  372. }
  373. }
  374. </style>
  375. <style lang="less">
  376. .menu_select .el-popper__arrow::before {
  377. border-top-color: transparent !important;
  378. border-left-color: transparent !important;
  379. background: rgba(0, 244, 253, 1) !important;
  380. }
  381. .el-select__popper {
  382. background-color: #082333 !important;
  383. }
  384. .menu_select {
  385. border: 1px solid rgba(0, 244, 253, 1) !important;
  386. > div {
  387. border: transparent !important;
  388. }
  389. }
  390. .el-select-dropdown__item.selected {
  391. color: rgba(0, 244, 253, 1) !important;
  392. }
  393. .el-select-dropdown__item {
  394. color: #fff !important;
  395. padding: 0 20px !important;
  396. text-align: center !important;
  397. }
  398. .el-select-dropdown__item:hover {
  399. background: rgba(0, 244, 253, 0.2) !important;
  400. }
  401. .el-scrollbar__view {
  402. background: rgba(0, 244, 253, 0) !important;
  403. }
  404. .menu_select .el-scrollbar {
  405. width: 2rem;
  406. }
  407. </style>