Header.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. <template>
  2. <!-- 顶部登录导航 -->
  3. <div class="LoginNav1" v-if="isData">
  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" v-if="!projectShow">
  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. <template v-else-if="seekShow">
  24. <div class="ylk_seek" @keydown="downSeek">
  25. <input type="text" v-model="keyword" />
  26. <div @click="seekresult">搜索</div>
  27. </div>
  28. </template>
  29. <el-popover
  30. placement="bottom"
  31. width="335"
  32. trigger="click"
  33. v-model="visibleOption"
  34. v-if="seekOptions"
  35. >
  36. <div class="set_corpus_dv">
  37. <span>选择难度</span>
  38. <el-select
  39. style="width: 205px"
  40. v-model="corpus.difficlty"
  41. placeholder="请选择"
  42. >
  43. <el-option v-for="(itemD,indexD) in difficltyList" :key="indexD" :label="itemD.label" :value="itemD.value"></el-option>
  44. </el-select>
  45. </div>
  46. <div class="set_corpus_dv">
  47. <span>选择范围</span>
  48. <el-select
  49. style="width: 205px"
  50. v-model="corpus.scope"
  51. placeholder="请选择"
  52. >
  53. <el-option v-for="(itemD,indexD) in scopeList" :key="indexD" :label="itemD.label" :value="itemD.value"></el-option>
  54. </el-select>
  55. </div>
  56. <div class="set_corpus_dv">
  57. <span>句子长度</span>
  58. <el-input
  59. v-model="corpus.sentenceStart"
  60. style="width: 55px; margin-right: 8px;"
  61. onkeyup="value=value.replace(/^0+(\d)|[^\d]+/g,'')"
  62. class="numbre-input"
  63. ></el-input>
  64. ——
  65. <el-input
  66. v-model="corpus.sentenceEnd"
  67. style="width: 55px; margin-left: 8px"
  68. onkeyup="value=value.replace(/^0+(\d)|[^\d]+/g,'')"
  69. class="numbre-input"
  70. ></el-input>
  71. </div>
  72. <div class="set_corpus_submit">
  73. <div @click="visibleOption = false">取消</div>
  74. <div @click="visibleOption = false">确认</div>
  75. </div>
  76. <div slot="reference" class="set_corpus" style="margin-left: 24px;cursor:pointer;">设置条件</div>
  77. </el-popover>
  78. </div>
  79. <div class="userName">
  80. <template v-if="seekOption">
  81. <el-popover
  82. placement="bottom"
  83. width="335"
  84. trigger="click"
  85. v-model="visible"
  86. >
  87. <div class="set_corpus_dv">
  88. <span>选择难度</span>
  89. <el-select
  90. style="width: 205px"
  91. v-model="corpus.difficlty"
  92. placeholder="请选择"
  93. >
  94. <el-option v-for="(itemD,indexD) in difficltyList" :key="indexD" :label="itemD.label" :value="itemD.value"></el-option>
  95. </el-select>
  96. </div>
  97. <div class="set_corpus_dv">
  98. <span>选择范围</span>
  99. <el-select
  100. style="width: 205px"
  101. v-model="corpus.scope"
  102. placeholder="请选择"
  103. >
  104. <el-option v-for="(itemD,indexD) in scopeList" :key="indexD" :label="itemD.label" :value="itemD.value"></el-option>
  105. </el-select>
  106. </div>
  107. <div class="set_corpus_dv">
  108. <span>句子长度</span>
  109. <el-input
  110. v-model="corpus.sentenceStart"
  111. style="width: 55px; margin-right: 8px;"
  112. onkeyup="value=value.replace(/^0+(\d)|[^\d]+/g,'')"
  113. class="numbre-input"
  114. ></el-input>
  115. ——
  116. <el-input
  117. v-model="corpus.sentenceEnd"
  118. style="width: 55px; margin-left: 8px"
  119. onkeyup="value=value.replace(/^0+(\d)|[^\d]+/g,'')"
  120. class="numbre-input"
  121. ></el-input>
  122. </div>
  123. <div class="set_corpus_submit">
  124. <div @click="visible = false">取消</div>
  125. <div @click="visible = false">确认</div>
  126. </div>
  127. <div slot="reference" class="set_corpus">设置</div>
  128. </el-popover>
  129. </template>
  130. <template>
  131. <el-dropdown
  132. style="margin-right: 16px; cursor: pointer"
  133. trigger="click"
  134. @command="changeLang"
  135. >
  136. <span class="el-dropdown-link" style="color: #000000">
  137. {{ lang }}
  138. <i class="el-icon-arrow-down el-icon--right"></i>
  139. </span>
  140. <el-dropdown-menu slot="dropdown" style="width: 200px">
  141. <el-dropdown-item
  142. v-for="item in language_list"
  143. :key="item.language_type"
  144. :command="item"
  145. >{{ item.language_name }}</el-dropdown-item
  146. >
  147. </el-dropdown-menu>
  148. </el-dropdown>
  149. </template>
  150. <div v-if="!userMessage" class="selectLoginOrRegistration">
  151. <span @click="cutLoginReg"> <!-- 登录 -->{{ $t("Key9") }} </span>
  152. </div>
  153. <!-- 用户头像和用户名 -->
  154. <div class="user" v-else>
  155. <img
  156. @click="userShow = !userShow"
  157. class="headPhoto"
  158. :src="
  159. userMessage.image_url
  160. ? userMessage.image_url
  161. : require('../assets/login/Group3214.png')
  162. "
  163. alt=""
  164. />
  165. <span @click="userShow = !userShow">{{
  166. userMessage.user_real_name
  167. }}</span>
  168. <div class="userShow" v-show="userShow">
  169. <p @click="gotoPersonalcenter">
  170. <img src="../assets/login/project7.png" alt="" />
  171. <!-- 个人中心 -->{{ $t("Key8") }}
  172. </p>
  173. <p @click="QuitLogin">
  174. <img src="../assets/login/Frame77.png" alt="" />
  175. <!-- 退出登录 -->{{ $t("Key39") }}
  176. </p>
  177. </div>
  178. </div>
  179. <!-- 消息 铃铛图片 -->
  180. <div class="message">
  181. <img
  182. @click="gotoPersonalcenter"
  183. src="../assets/login/Vector.png"
  184. alt=""
  185. />
  186. <span class="redDot" v-if="is_exist == 'true'"></span>
  187. </div>
  188. </div>
  189. </div>
  190. </template>
  191. <script>
  192. import { mapGetters } from "vuex";
  193. import { getToken, removeToken } from "@/utils/auth";
  194. import Cookies from "js-cookie";
  195. import {
  196. getContent,
  197. getStaticContent,
  198. getLearnWebContent,
  199. getContentFile,
  200. } from "@/api/api";
  201. import { setI18nLang } from "@/utils/i18n";
  202. import { getConfig } from "@/utils/auth";
  203. import { saveSession, getSession, removeSession } from "@/utils/role";
  204. import { updateWordPack } from "@/utils/i18n";
  205. export default {
  206. name: "LayoutHeader",
  207. props: ["projectShow", "seekShow", "seekOption","seekOptions"],
  208. data() {
  209. return {
  210. keyword: this.$route.query.keyword?this.$route.query.keyword:'',
  211. visible: false,
  212. visibleOption: false,
  213. corpus: {
  214. difficlty: null,
  215. scope: null,
  216. sentenceStart: null,
  217. sentenceEnd: null,
  218. },
  219. activeIndex: "2", // 主导航索引
  220. LoginNavIndex: 0, //下拉框导航索引
  221. projectName: "教研中心",
  222. projectList: [],
  223. is_exist: "false",
  224. teacherProList: [
  225. //普通教师
  226. {
  227. id: 0,
  228. name: "教学中心",
  229. img: "project1",
  230. },
  231. {
  232. id: 2,
  233. name: "教培中心",
  234. img: "project3",
  235. },
  236. {
  237. id: 3,
  238. name: "教研中心",
  239. img: "project4",
  240. },
  241. {
  242. id: 5,
  243. name: "学习中心",
  244. img: "project6",
  245. },
  246. {
  247. id: 4,
  248. name: "考试中心",
  249. img: "project5",
  250. },
  251. {
  252. id: 6,
  253. name: "个人中心",
  254. img: "project7",
  255. },
  256. ],
  257. stuProList: [
  258. {
  259. id: 0,
  260. name: "教学中心",
  261. img: "project1",
  262. },
  263. {
  264. id: 5,
  265. name: "学习中心",
  266. img: "project6",
  267. },
  268. {
  269. id: 6,
  270. name: "个人中心",
  271. img: "project7",
  272. },
  273. ],
  274. userMessage: null,
  275. userShow: false,
  276. language_list: [],
  277. lang: "",
  278. headTimer: null,
  279. configInfor: null,
  280. isData: false,
  281. difficltyList: [
  282. {
  283. value: '',
  284. label: '全部'
  285. }
  286. ],
  287. scopeList: [
  288. {
  289. value: '',
  290. label: '全部'
  291. }
  292. ]
  293. };
  294. },
  295. watch: {},
  296. computed: {
  297. ...mapGetters(["language_type"]),
  298. },
  299. methods: {
  300. downSeek(e) {
  301. if (e.keyCode == 13) {
  302. if (!this.keyword) {
  303. this.$message.warning("请先输入内容");
  304. return;
  305. }
  306. this.seekresult();
  307. }
  308. },
  309. seekresult() {
  310. this.$router.replace({
  311. path: "/corpus/Result",
  312. query: {
  313. keyword: this.keyword,
  314. },
  315. });
  316. this.$emit("changehzdata");
  317. },
  318. // 前往个人中心
  319. gotoPersonalcenter() {
  320. if (!this.userMessage) {
  321. this.$message.warning("请先登录");
  322. return;
  323. }
  324. let MethodName = "login_control-CreateAccessCode";
  325. let acsCode = "";
  326. // getContent(MethodName, UserCode, UserType, SessionID).then((res) => {
  327. // acsCode = res.access_code;
  328. location.href = `/GCLS-Personal/#/EnterSys`;
  329. // });
  330. },
  331. // 切换导航
  332. handleSelect(key, keyPath) {
  333. window.location.href = "/";
  334. },
  335. // 切换项目
  336. handleCommand(command) {
  337. let _this = this;
  338. _this.LoginNavIndex = command;
  339. if (!_this.userMessage) {
  340. this.$message.warning("请先登录");
  341. this.projectName = this.$t("Key5"); //"教研中心";
  342. window.location.href = "/";
  343. return;
  344. }
  345. _this.projectName = _this.projectList[command].name;
  346. let relative_path = _this.projectList[command].relative_path;
  347. location.href = relative_path;
  348. },
  349. // 切换登录的注册
  350. cutLoginReg() {
  351. window.location.href = "/";
  352. },
  353. QuitLogin() {
  354. window.location.href = "/";
  355. removeSession("SysList");
  356. removeToken();
  357. Cookies.remove("JSESSIONID");
  358. this.userShow = false;
  359. this.userMessage = null;
  360. sessionStorage.removeItem("useragent_root_close");
  361. },
  362. getLangList() {
  363. let MethodName = "language_manager-GetLanguageList";
  364. let data = {};
  365. getStaticContent(MethodName, data).then((res) => {
  366. this.language_list = res.language_list;
  367. for (let i = 0; i < this.language_list.length; i++) {
  368. let item = this.language_list[i];
  369. if (item.language_type == this.language_type) {
  370. this.lang = item.language_name;
  371. break;
  372. }
  373. }
  374. });
  375. },
  376. async changeLang(command) {
  377. console.log(command);
  378. this.lang = command.language_name;
  379. let lang_type = command.language_type;
  380. await setI18nLang(lang_type);
  381. this.$router.go(0);
  382. },
  383. getNotReadMessage() {
  384. let MethodName = "message-message_manager-IsExistMyMessage_NotRead";
  385. let data = {};
  386. getLearnWebContent(MethodName, data).then((res) => {
  387. this.is_exist = res.is_exist;
  388. });
  389. },
  390. // async _getConfig() {
  391. // this.configInfor = await getConfigInfor();
  392. // },
  393. getChildSysList() {
  394. let _this = this;
  395. let MethodName = "login_control-GetChildSysList_CanEnter_PC";
  396. getContentFile(MethodName, {})
  397. .then((res) => {
  398. if (res.child_sys_list && res.child_sys_list.length > 0) {
  399. let invok_module = this.$route.query.invok_module;
  400. _this.projectList = res.child_sys_list;
  401. for (let i = 0; i < _this.projectList.length; i++) {
  402. let item = _this.projectList[i];
  403. if (invok_module) {
  404. if (invok_module == item.key) {
  405. _this.LoginNavIndex = i;
  406. _this.projectName = item.name;
  407. }
  408. } else {
  409. let key = "GCLS-TC";
  410. if (key == item.key) {
  411. _this.LoginNavIndex = i;
  412. _this.projectName = item.name;
  413. }
  414. }
  415. }
  416. }
  417. })
  418. .catch((err) => {
  419. console.log(err);
  420. });
  421. },
  422. },
  423. async created() {
  424. let _this = this;
  425. _this.getChildSysList();
  426. console.log("v2022.03.18.10:25");
  427. let userInfor = getToken();
  428. if (userInfor) {
  429. await updateWordPack({
  430. word_key_list: ["Key9", "Key8", "Key39"],
  431. });
  432. this.isData = true;
  433. }
  434. },
  435. mounted() {
  436. let _this = this;
  437. let user = getToken();
  438. if (user) {
  439. _this.userMessage = JSON.parse(user);
  440. }
  441. let config = getConfig();
  442. if (config) {
  443. _this.configInfor = JSON.parse(config);
  444. }
  445. _this.getLangList();
  446. _this.getNotReadMessage();
  447. _this.headTimer = setInterval(() => {
  448. _this.getNotReadMessage();
  449. }, 120000);
  450. },
  451. beforeDestroy() {
  452. if (this.headTimer) {
  453. //如果定时器还在运行 或者直接关闭,不用判断
  454. clearInterval(this.headTimer); //关闭
  455. }
  456. },
  457. };
  458. </script>
  459. <style lang="scss" scoped>
  460. .LoginNav1 {
  461. // height: 74px;
  462. height: 64px;
  463. position: relative;
  464. display: flex;
  465. align-items: center;
  466. justify-content: space-between;
  467. box-sizing: border-box;
  468. padding: 0px 24px;
  469. z-index: 999;
  470. // background: #ffffff;
  471. // box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.15);
  472. font-family: "sourceR";
  473. .el-dropdown-link {
  474. img {
  475. width: 8px;
  476. height: 4px;
  477. vertical-align: middle;
  478. }
  479. }
  480. .logo {
  481. > img {
  482. // width: 188px;
  483. height: 48px;
  484. cursor: pointer;
  485. }
  486. &-img {
  487. font-style: normal;
  488. font-weight: 600;
  489. font-size: 30px;
  490. font-variant: small-caps;
  491. color: #000000;
  492. // color: #fff;
  493. margin-right: 29px;
  494. line-height: 64px;
  495. }
  496. display: flex;
  497. align-items: center;
  498. .logo-projectlist {
  499. display: flex;
  500. padding: 0 24px;
  501. height: 64px;
  502. list-style: none;
  503. li {
  504. padding: 0 12px;
  505. color: rgba(0, 0, 0, 0.45);
  506. font-size: 16px;
  507. line-height: 64px;
  508. font-weight: 500;
  509. cursor: pointer;
  510. white-space: nowrap;
  511. &:hover {
  512. background: #f6f6f6;
  513. }
  514. &.active {
  515. color: #ff9900;
  516. background: #ffefd6;
  517. }
  518. }
  519. }
  520. }
  521. .userName {
  522. display: flex;
  523. justify-content: flex-end;
  524. align-items: center;
  525. .set_corpus {
  526. width: 48px;
  527. height: 35px;
  528. background: #ebebeb;
  529. border-radius: 8px;
  530. font-weight: 400;
  531. font-size: 16px;
  532. line-height: 35px;
  533. text-align: center;
  534. color: #000000;
  535. cursor: pointer;
  536. margin-right: 24px;
  537. }
  538. .seek {
  539. margin-right: 100px;
  540. position: relative;
  541. img {
  542. left: 10px;
  543. top: 11px;
  544. position: absolute;
  545. }
  546. }
  547. .flag {
  548. position: relative;
  549. top: 5px;
  550. }
  551. .headPhoto {
  552. width: 50px;
  553. height: 50px;
  554. // background: url("../assets/teacherTrain/image 4.png") no-repeat 100% 100%;
  555. // background-size: 100%;
  556. border-radius: 50%;
  557. // margin-right: 10px;
  558. }
  559. .message {
  560. height: 100%;
  561. position: relative;
  562. display: flex;
  563. justify-content: center;
  564. align-items: center;
  565. margin-left: 23px;
  566. cursor: pointer;
  567. img {
  568. width: 18px;
  569. height: 24px;
  570. }
  571. .redDot {
  572. position: absolute;
  573. top: 2px;
  574. right: 2px;
  575. width: 6px;
  576. height: 6px;
  577. display: inline-block;
  578. background: red;
  579. border-radius: 50%;
  580. }
  581. }
  582. .selectLoginOrRegistration {
  583. display: flex;
  584. height: 32px;
  585. border: 1px solid #ffffff;
  586. box-sizing: border-box;
  587. border-radius: 4px;
  588. justify-content: space-evenly;
  589. align-items: center;
  590. padding: 0 16px;
  591. > span {
  592. cursor: pointer;
  593. font-size: 16px;
  594. color: #000000;
  595. }
  596. }
  597. .user {
  598. display: flex;
  599. align-items: center;
  600. cursor: pointer;
  601. position: relative;
  602. color: #000000;
  603. > img {
  604. width: 34px;
  605. height: 34px;
  606. }
  607. > span {
  608. font-size: 20px;
  609. padding-left: 10px;
  610. }
  611. .userShow {
  612. position: absolute;
  613. width: 156px;
  614. height: 96px;
  615. background: #ffffff;
  616. box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
  617. border-radius: 8px;
  618. bottom: -100px;
  619. left: -5px;
  620. color: #000000;
  621. img {
  622. width: 24px;
  623. height: 24px;
  624. margin-right: 10px;
  625. }
  626. p {
  627. font-size: 16px;
  628. height: 40px;
  629. display: flex;
  630. align-items: center;
  631. padding-left: 20px;
  632. margin: 0;
  633. margin-top: 5px;
  634. }
  635. > p:hover {
  636. background: #f2f2f2;
  637. }
  638. }
  639. }
  640. }
  641. .ylk_seek {
  642. margin-left: 24px;
  643. height: 35px;
  644. display: flex;
  645. input {
  646. width: 484px;
  647. height: 35px;
  648. background: #ffffff;
  649. border: 1px solid #669aff;
  650. outline: none;
  651. padding: 0 10px;
  652. box-sizing: border-box;
  653. }
  654. div {
  655. width: 80px;
  656. height: 100%;
  657. background: #669aff;
  658. border-width: 1px 1px 1px 0px;
  659. box-sizing: border-box;
  660. border-style: solid;
  661. border-color: #669aff;
  662. text-align: center;
  663. font-weight: 400;
  664. font-size: 16px;
  665. line-height: 35px;
  666. color: #ffffff;
  667. cursor: pointer;
  668. }
  669. }
  670. }
  671. </style>
  672. <style lang="scss">
  673. .LoginNav1 {
  674. .el-dropdown-menu__item {
  675. line-height: 40px;
  676. display: flex;
  677. justify-content: center;
  678. align-items: center;
  679. > span {
  680. font-family: "sourceR";
  681. font-size: 16px;
  682. }
  683. }
  684. .el-menu--horizontal > .el-menu-item {
  685. height: 64px;
  686. line-height: 64px;
  687. }
  688. .el-dropdown {
  689. display: block;
  690. > span {
  691. font-family: "sourceR";
  692. font-size: 16px;
  693. }
  694. }
  695. .el-menu-item.is-active i {
  696. color: white;
  697. }
  698. }
  699. .set_corpus_dv {
  700. display: flex;
  701. align-items: center;
  702. margin-bottom: 24px;
  703. > span {
  704. font-weight: 400;
  705. font-size: 16px;
  706. line-height: 19px;
  707. color: #000000;
  708. margin-right: 18px;
  709. }
  710. .numbre-input{
  711. .el-input__inner{
  712. padding: 0;
  713. text-align: center;
  714. }
  715. }
  716. }
  717. .set_corpus_submit {
  718. margin-top: 32px;
  719. display: flex;
  720. justify-content: flex-end;
  721. div {
  722. width: 44px;
  723. height: 32px;
  724. border-radius: 4px;
  725. font-weight: 400;
  726. font-size: 14px;
  727. line-height: 32px;
  728. text-align: center;
  729. cursor: pointer;
  730. }
  731. > :nth-child(2) {
  732. color: #ffffff;
  733. background: #4992ff;
  734. }
  735. > :nth-child(1) {
  736. color: #000000;
  737. margin-right: 8px;
  738. }
  739. }
  740. .projectList {
  741. &.el-dropdown-menu__item {
  742. line-height: 40px;
  743. display: flex;
  744. align-items: center;
  745. color: #000000;
  746. > img {
  747. top: 0;
  748. }
  749. > span {
  750. line-height: 40px;
  751. font-family: "sourceR";
  752. }
  753. }
  754. &:hover {
  755. background: #ff9900 !important;
  756. // background: rgba(255, 153, 0, 0.1) !important;
  757. color: #000 !important;
  758. // color: #fff;
  759. }
  760. &.menuActive {
  761. background: #ff9900;
  762. }
  763. }
  764. .el-popper{
  765. z-index: 100000 !important;
  766. }
  767. </style>