Header.vue 16 KB

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