Header.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <template>
  2. <!-- 顶部登录导航 -->
  3. <div class="LoginNav1">
  4. <div class="logo" v-if="configInfor">
  5. <img
  6. v-if="configInfor.logo_image_url"
  7. :src="configInfor.logo_image_url"
  8. alt=""
  9. />
  10. <span class="logo-img" v-else>logo</span>
  11. <el-menu
  12. :default-active="activeIndex"
  13. class="el-menu-demo"
  14. mode="horizontal"
  15. @select="handleSelect"
  16. text-color="#fff"
  17. active-text-color="#FF9900"
  18. >
  19. <el-menu-item index="1">主页</el-menu-item>
  20. <el-menu-item index="2">
  21. <template v-if="projectList.length > 1">
  22. <el-dropdown trigger="click" @command="handleCommand">
  23. <span
  24. class="el-dropdown-link"
  25. :style="{ color: activeIndex == 2 ? '#FF9900' : '#fff' }"
  26. >
  27. {{ projectName }}
  28. <!-- SYSTEM -->
  29. <img
  30. v-if="activeIndex == 2"
  31. src="../assets/teacherdev/headerDownlod.png"
  32. alt=""
  33. />
  34. <img
  35. v-else
  36. src="../assets/teacherdev/headerDownlod2.png"
  37. alt=""
  38. />
  39. </span>
  40. <el-dropdown-menu slot="dropdown" style="min-width: 278px">
  41. <el-dropdown-item
  42. :class="i == LoginNavIndex ? 'menuActive' : ''"
  43. :command="i"
  44. :key="i"
  45. class="projectList"
  46. v-for="(item, i) in projectList"
  47. >
  48. <img
  49. style="position: relative; width: 24px"
  50. :src="item.icon_url_memu_default"
  51. alt=""
  52. />
  53. <span style="margin-left: 16px">
  54. {{ item.name }}
  55. </span>
  56. </el-dropdown-item>
  57. </el-dropdown-menu>
  58. </el-dropdown>
  59. </template>
  60. <template v-else>{{
  61. projectList.length > 0 && projectList[0].name
  62. }}</template>
  63. </el-menu-item>
  64. </el-menu>
  65. </div>
  66. <div class="userName">
  67. <template>
  68. <el-dropdown
  69. style="margin-right: 16px; cursor: pointer"
  70. trigger="click"
  71. @command="changeLang"
  72. >
  73. <span class="el-dropdown-link" style="color: #fff">
  74. {{ lang }}
  75. <img src="../assets/teacherdev/headerDownlod2.png" alt="" />
  76. </span>
  77. <el-dropdown-menu slot="dropdown" style="width: 200px">
  78. <el-dropdown-item
  79. v-for="item in language_list"
  80. :key="item.language_type"
  81. :command="item"
  82. >{{ item.language_name }}</el-dropdown-item
  83. >
  84. </el-dropdown-menu>
  85. </el-dropdown>
  86. </template>
  87. <div v-if="!userMessage" class="selectLoginOrRegistration">
  88. <span @click="cutLoginReg">登录</span>
  89. </div>
  90. <!-- 用户头像和用户名 -->
  91. <div class="user" v-else>
  92. <img
  93. @click="userShow = !userShow"
  94. class="headPhoto"
  95. :src="
  96. userMessage.image_url
  97. ? userMessage.image_url
  98. : require('../assets/login/Group3214.png')
  99. "
  100. alt=""
  101. />
  102. <span @click="userShow = !userShow">{{
  103. userMessage.user_real_name
  104. }}</span>
  105. <div class="userShow" v-show="userShow">
  106. <p @click="gotoPersonalcenter">
  107. <img src="../assets/login/project7.png" alt="" />
  108. 个人中心
  109. </p>
  110. <p @click="QuitLogin">
  111. <img src="../assets/login/Frame77.png" alt="" />
  112. 退出登录
  113. </p>
  114. </div>
  115. </div>
  116. <!-- 消息 铃铛图片 -->
  117. <div class="message">
  118. <img
  119. @click="gotoPersonalcenter"
  120. src="../assets/login/Vector2.png"
  121. alt=""
  122. />
  123. <span class="redDot" v-if="is_exist == 'true'"></span>
  124. </div>
  125. </div>
  126. </div>
  127. </template>
  128. <script>
  129. import { mapGetters } from "vuex";
  130. import { getToken, removeToken } from "@/utils/auth";
  131. import Cookies from "js-cookie";
  132. import { getContent, getStaticContent, getLearnWebContent } from "@/api/api";
  133. import { setI18nLang } from "@/utils/i18n";
  134. import { getConfig } from "@/utils/auth";
  135. import { saveSession, getSession, removeSession } from "@/utils/role";
  136. export default {
  137. name: "LayoutHeader",
  138. props: [],
  139. data() {
  140. return {
  141. activeIndex: "2", // 主导航索引
  142. LoginNavIndex: 0, //下拉框导航索引
  143. projectName: "教研中心",
  144. projectList: [],
  145. is_exist: "false",
  146. teacherProList: [
  147. //普通教师
  148. {
  149. id: 0,
  150. name: "教学中心",
  151. img: "project1",
  152. },
  153. {
  154. id: 2,
  155. name: "教培中心",
  156. img: "project3",
  157. },
  158. {
  159. id: 3,
  160. name: "教研中心",
  161. img: "project4",
  162. },
  163. {
  164. id: 5,
  165. name: "学习中心",
  166. img: "project6",
  167. },
  168. {
  169. id: 4,
  170. name: "考试中心",
  171. img: "project5",
  172. },
  173. {
  174. id: 6,
  175. name: "个人中心",
  176. img: "project7",
  177. },
  178. ],
  179. stuProList: [
  180. {
  181. id: 0,
  182. name: "教学中心",
  183. img: "project1",
  184. },
  185. {
  186. id: 5,
  187. name: "学习中心",
  188. img: "project6",
  189. },
  190. {
  191. id: 6,
  192. name: "个人中心",
  193. img: "project7",
  194. },
  195. ],
  196. userMessage: null,
  197. userShow: false,
  198. language_list: [],
  199. lang: "",
  200. headTimer: null,
  201. configInfor: null,
  202. };
  203. },
  204. watch: {},
  205. computed: {
  206. ...mapGetters(["language_type"]),
  207. },
  208. methods: {
  209. // 前往个人中心
  210. gotoPersonalcenter() {
  211. if (!this.userMessage) {
  212. this.$message.warning("请先登录");
  213. return;
  214. }
  215. let MethodName = "login_control-CreateAccessCode";
  216. let acsCode = "";
  217. // getContent(MethodName, UserCode, UserType, SessionID).then((res) => {
  218. // acsCode = res.access_code;
  219. location.href = `/GCLS-Personal/#/EnterSys`;
  220. // });
  221. },
  222. // 切换导航
  223. handleSelect(key, keyPath) {
  224. this.activeIndex = key;
  225. if (this.activeIndex == 1) {
  226. window.location.href = "/";
  227. }
  228. },
  229. // 切换项目
  230. handleCommand(command) {
  231. let _this = this;
  232. _this.LoginNavIndex = command;
  233. if (!_this.userMessage) {
  234. this.$message.warning("请先登录");
  235. this.projectName = "教研中心";
  236. window.location.href = "/";
  237. return;
  238. }
  239. _this.projectName = _this.projectList[command].name;
  240. let relative_path = _this.projectList[command].relative_path;
  241. location.href = relative_path;
  242. },
  243. // 切换登录的注册
  244. cutLoginReg() {
  245. window.location.href = "/";
  246. },
  247. QuitLogin() {
  248. window.location.href = "/";
  249. removeSession("SysList");
  250. removeToken();
  251. Cookies.remove("JSESSIONID");
  252. this.userShow = false;
  253. this.userMessage = null;
  254. },
  255. getLangList() {
  256. let MethodName = "language_manager-GetLanguageList";
  257. let data = {};
  258. getStaticContent(MethodName, data).then((res) => {
  259. this.language_list = res.language_list;
  260. for (let i = 0; i < this.language_list.length; i++) {
  261. let item = this.language_list[i];
  262. if (item.language_type == this.language_type) {
  263. this.lang = item.language_name;
  264. break;
  265. }
  266. }
  267. });
  268. },
  269. async changeLang(command) {
  270. console.log(command);
  271. this.lang = command.language_name;
  272. let lang_type = command.language_type;
  273. await setI18nLang(lang_type);
  274. this.$router.go(0);
  275. },
  276. getNotReadMessage() {
  277. let MethodName = "message-message_manager-IsExistMyMessage_NotRead";
  278. let data = {};
  279. getLearnWebContent(MethodName, data).then((res) => {
  280. this.is_exist = res.is_exist;
  281. });
  282. },
  283. // async _getConfig() {
  284. // this.configInfor = await getConfigInfor();
  285. // },
  286. getChildSysList() {
  287. let _this = this;
  288. let MethodName = "login_control-GetChildSysList_CanEnter_PC";
  289. getContent(MethodName, {})
  290. .then((res) => {
  291. if (res.child_sys_list && res.child_sys_list.length > 0) {
  292. _this.projectList = res.child_sys_list;
  293. _this.projectList.forEach((item, index) => {
  294. if (item.key == "GCLS-TC") {
  295. _this.LoginNavIndex = index;
  296. }
  297. });
  298. }
  299. })
  300. .catch((err) => {
  301. console.log(err);
  302. });
  303. },
  304. },
  305. created() {
  306. let _this = this;
  307. _this.getChildSysList();
  308. },
  309. mounted() {
  310. let _this = this;
  311. let user = getToken();
  312. if (user) {
  313. _this.userMessage = JSON.parse(user);
  314. }
  315. _this.configInfor = JSON.parse(getConfig());
  316. _this.getLangList();
  317. _this.getNotReadMessage();
  318. _this.headTimer = setInterval(() => {
  319. _this.getNotReadMessage();
  320. }, 120000);
  321. },
  322. beforeDestroy() {
  323. if (this.headTimer) {
  324. //如果定时器还在运行 或者直接关闭,不用判断
  325. clearInterval(this.headTimer); //关闭
  326. }
  327. },
  328. };
  329. </script>
  330. <style lang="scss" scoped>
  331. .LoginNav1 {
  332. // height: 74px;
  333. height: 64px;
  334. position: relative;
  335. display: flex;
  336. align-items: center;
  337. justify-content: space-between;
  338. box-sizing: border-box;
  339. padding: 0px 24px;
  340. z-index: 999;
  341. // background: #ffffff;
  342. // box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.15);
  343. font-family: "sourceR";
  344. .el-dropdown-link {
  345. img {
  346. width: 8px;
  347. height: 4px;
  348. vertical-align: middle;
  349. }
  350. }
  351. .logo {
  352. > img {
  353. width: 188px;
  354. height: 64px;
  355. }
  356. &-img {
  357. font-style: normal;
  358. font-weight: 600;
  359. font-size: 30px;
  360. font-variant: small-caps;
  361. // color: #000000;
  362. color: #fff;
  363. margin-right: 29px;
  364. line-height: 64px;
  365. }
  366. display: flex;
  367. align-items: center;
  368. .el-menu-demo {
  369. background: rgba(0, 0, 0, 0);
  370. // margin-left: 100px;
  371. li:hover {
  372. background: none;
  373. }
  374. li {
  375. font-size: 16px;
  376. background: none;
  377. }
  378. }
  379. // 取消组件默认的样式
  380. .el-menu.el-menu--horizontal {
  381. border-bottom: none;
  382. }
  383. }
  384. .userName {
  385. display: flex;
  386. justify-content: flex-end;
  387. align-items: center;
  388. .seek {
  389. margin-right: 100px;
  390. position: relative;
  391. img {
  392. left: 10px;
  393. top: 11px;
  394. position: absolute;
  395. }
  396. }
  397. .flag {
  398. position: relative;
  399. top: 5px;
  400. }
  401. .headPhoto {
  402. width: 50px;
  403. height: 50px;
  404. // background: url("../assets/teacherTrain/image 4.png") no-repeat 100% 100%;
  405. // background-size: 100%;
  406. border-radius: 50%;
  407. // margin-right: 10px;
  408. }
  409. .message {
  410. height: 100%;
  411. position: relative;
  412. display: flex;
  413. justify-content: center;
  414. align-items: center;
  415. margin-left: 23px;
  416. img {
  417. width: 24px;
  418. cursor: pointer;
  419. }
  420. .redDot {
  421. position: absolute;
  422. top: 2px;
  423. right: 2px;
  424. width: 6px;
  425. height: 6px;
  426. display: inline-block;
  427. background: red;
  428. border-radius: 50%;
  429. }
  430. }
  431. .selectLoginOrRegistration {
  432. display: flex;
  433. height: 32px;
  434. border: 1px solid #ffffff;
  435. box-sizing: border-box;
  436. border-radius: 4px;
  437. justify-content: space-evenly;
  438. align-items: center;
  439. padding: 0 16px;
  440. > span {
  441. cursor: pointer;
  442. font-size: 16px;
  443. color: #fff;
  444. }
  445. }
  446. .user {
  447. display: flex;
  448. align-items: center;
  449. cursor: pointer;
  450. position: relative;
  451. color: #fff;
  452. > img {
  453. width: 34px;
  454. height: 34px;
  455. }
  456. > span {
  457. font-size: 16px;
  458. padding-left: 10px;
  459. }
  460. .userShow {
  461. position: absolute;
  462. width: 156px;
  463. height: 96px;
  464. background: #ffffff;
  465. box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
  466. border-radius: 8px;
  467. bottom: -100px;
  468. left: -5px;
  469. color: black;
  470. img {
  471. width: 24px;
  472. height: 24px;
  473. margin-right: 10px;
  474. }
  475. p {
  476. font-size: 16px;
  477. height: 40px;
  478. display: flex;
  479. align-items: center;
  480. padding-left: 20px;
  481. margin: 0;
  482. margin-top: 5px;
  483. }
  484. > p:hover {
  485. background: #f2f2f2;
  486. }
  487. }
  488. }
  489. }
  490. }
  491. </style>
  492. <style lang="scss">
  493. .LoginNav1 {
  494. .el-dropdown-menu__item {
  495. line-height: 40px;
  496. display: flex;
  497. justify-content: center;
  498. align-items: center;
  499. > span {
  500. font-family: "sourceR";
  501. font-size: 16px;
  502. }
  503. }
  504. .el-menu--horizontal > .el-menu-item {
  505. height: 64px;
  506. line-height: 64px;
  507. }
  508. .el-dropdown {
  509. display: block;
  510. > span {
  511. font-family: "sourceR";
  512. font-size: 16px;
  513. }
  514. }
  515. .el-menu-item.is-active i {
  516. color: white;
  517. }
  518. }
  519. .projectList {
  520. &.el-dropdown-menu__item {
  521. line-height: 40px;
  522. display: flex;
  523. align-items: center;
  524. color: #000000;
  525. > img {
  526. top: 0;
  527. }
  528. > span {
  529. line-height: 40px;
  530. font-family: "sourceR";
  531. }
  532. }
  533. &:hover {
  534. background: #ff9900 !important;
  535. // background: rgba(255, 153, 0, 0.1) !important;
  536. color: #000 !important;
  537. // color: #fff;
  538. }
  539. &.menuActive {
  540. background: #ff9900;
  541. }
  542. }
  543. </style>