Header.vue 12 KB

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