123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 |
- <template>
- <!-- 顶部登录导航 -->
- <div class="LoginNav">
- <div class="logo">
- <template v-if="configInfor">
- <img
- :src="configInfor.logo_image_url"
- alt="logo"
- class="logo-image"
- @click="handleSelect"
- />
- </template>
- <template v-else>
- <span class="logo-img"> logo </span>
- </template>
- <ul class="logo-projectlist">
- <li
- v-for="(itemI, indexI) in projectList"
- :key="indexI"
- :class="indexI == LoginNavIndex ? 'active' : ''"
- @click="handleCommand(indexI)"
- >
- {{ itemI.name }}
- </li>
- </ul>
- </div>
- <div class="userName">
- <template v-if="routePath == '/GoodsDetail'">
- <el-dropdown
- style="margin-right: 16px; cursor: pointer"
- trigger="click"
- @command="changeLang"
- >
- <span class="el-dropdown-link" style="color: #000">
- {{ lang }}<i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown" style="width: 200px">
- <el-dropdown-item
- v-for="item in language_list"
- :key="item.language_type"
- :command="item"
- >{{ item.language_name }}</el-dropdown-item
- >
- </el-dropdown-menu>
- </el-dropdown>
- </template>
- <div v-if="!userMessage" class="selectLoginOrRegistration">
- <span @click="cutLoginReg">
- {{ routePath == "/GoodsDetail" ? $t("Key9") : "登录" }}
- </span>
- </div>
- <!-- 用户头像和用户名 -->
- <div class="user" v-else>
- <img
- @click="userShow = !userShow"
- class="headPhoto"
- :src="
- userMessage.image_url
- ? userMessage.image_url
- : require('../assets/login/Group3214.png')
- "
- alt=""
- />
- <span @click="userShow = !userShow">{{
- userMessage.user_real_name
- }}</span>
- <div class="userShow" v-show="userShow">
- <p @click="gopresonal">
- <img src="../assets/login/project7.png" alt="" />
- {{ routePath == "/GoodsDetail" ? $t("Key38") : "个人中心" }}
- </p>
- <p @click="QuitLogin">
- <img src="../assets/login/Frame77.png" alt="" />
- {{ routePath == "/GoodsDetail" ? $t("Key39") : "退出登录" }}
- </p>
- </div>
- </div>
- <!-- 消息 铃铛图片 -->
- <div class="message" @click="gopresonal">
- <img src="../assets/login/Vector.png" alt="" />
- <span class="redDot" v-if="is_exist == 'true'"></span>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import { getToken, removeToken, getConfig } from "@/utils/auth";
- import Cookies from "js-cookie";
- import { getConfigInfor } from "@/utils/index";
- import {
- getLearnWebContent,
- getStaticContent,
- getContentFile,
- } from "@/api/ajax";
- //import { setI18nLang } from "@/utils/i18n";
- import { saveSession, getSession, removeSession } from "@/utils/role";
- export default {
- name: "LayoutHeader",
- props: [],
- data() {
- return {
- configInfor: null,
- activeIndex: "2", // 主导航索引
- LoginNavIndex: 0, //下拉框导航索引
- projectName: "",
- projectList: [],
- teacherProList: [
- //普通教师
- {
- id: 0,
- name: "教学中心",
- img: "project1",
- },
- {
- id: 2,
- name: "教培中心",
- img: "project3",
- },
- {
- id: 3,
- name: "教研中心",
- img: "project4",
- },
- {
- id: 4,
- name: "考试中心",
- img: "project5",
- },
- {
- id: 5,
- name: "学习中心",
- img: "project6",
- },
- {
- id: 6,
- name: "个人中心",
- img: "project7",
- },
- ],
- stuProList: [
- {
- id: 0,
- name: "教学中心",
- img: "project1",
- },
- {
- id: 5,
- name: "学习中心",
- img: "project6",
- },
- {
- id: 6,
- name: "个人中心",
- img: "project7",
- },
- ],
- userMessage: null,
- userShow: false,
- language_list: [],
- lang: "",
- is_exist: "false",
- headTimer: null,
- routePath: "",
- };
- },
- watch: {},
- computed: {
- ...mapGetters(["language_type"]),
- },
- methods: {
- // 切换导航
- handleSelect() {
- window.location.href = "/";
- },
- // 切换项目
- handleCommand(command) {
- let _this = this;
- _this.LoginNavIndex = command;
- if (!_this.userMessage) {
- //this.$message.warning("请重新登录");
- window.location.href = "/";
- return;
- }
- _this.projectName = this.projectList[command].name;
- let relative_path = _this.projectList[command].relative_path;
- location.href = relative_path;
- },
- gopresonal() {
- window.location.href = `/GCLS-Personal/#/EnterSys`;
- },
- // 切换登录的注册
- cutLoginReg() {
- window.location.href = "/";
- },
- QuitLogin() {
- removeToken();
- removeSession("SysList");
- Cookies.remove("userMessage");
- Cookies.remove("session_id");
- Cookies.remove("user_code");
- Cookies.remove("user_type");
- this.userShow = false;
- this.userMessage = null;
- window.location.href = "/";
- },
- getLangList() {
- let MethodName = "language_manager-GetLanguageList";
- let data = {};
- getStaticContent(MethodName, data).then((res) => {
- this.language_list = res.language_list;
- for (let i = 0; i < this.language_list.length; i++) {
- let item = this.language_list[i];
- if (item.language_type == this.language_type) {
- this.lang = item.language_name;
- break;
- }
- }
- });
- },
- async changeLang(command) {
- console.log(command);
- this.lang = command.language_name;
- let lang_type = command.language_type;
- await setI18nLang(lang_type);
- this.$router.go(0);
- },
- getChildSysList() {
- let _this = this;
- let MethodName = "login_control-GetChildSysList_CanEnter_PC";
- getContentFile(MethodName, {})
- .then((res) => {
- if (res.child_sys_list && res.child_sys_list.length > 0) {
- _this.projectList = res.child_sys_list;
- _this.projectList.forEach((item, index) => {
- if (item.key == "GCLS-Book") {
- _this.LoginNavIndex = index;
- }
- });
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- //是否存在我未阅读的消息
- getNotReadMessage() {
- let MethodName = "message-message_manager-IsExistMyMessage_NotRead";
- let data = {};
- getLearnWebContent(MethodName, data).then((res) => {
- this.is_exist = res.is_exist;
- });
- },
- async _getConfig() {
- this.configInfor = await getConfigInfor();
- },
- },
- created() {
- let _this = this;
- let routePath = this.$route.path;
- this.routePath = routePath;
- let config = getConfig();
- if (config) {
- _this.configInfor = JSON.parse(config);
- } else {
- _this._getConfig();
- }
- _this.getChildSysList();
- },
- mounted() {
- let _this = this;
- let user = getToken();
- if (user) {
- _this.userMessage = JSON.parse(user);
- let popedom_code_list = _this.userMessage.popedom_code_list;
- if (popedom_code_list.indexOf(2000003) > -1) {
- _this.projectName = "教材管理系统";
- } else {
- _this.projectName = "学习中心";
- }
- _this.getLangList();
- _this.getNotReadMessage();
- _this.headTimer = setInterval(() => {
- _this.getNotReadMessage();
- }, 120000);
- }
- },
- beforeDestroy() {
- if (this.headTimer) {
- //如果定时器还在运行 或者直接关闭,不用判断
- clearInterval(this.headTimer); //关闭
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .LoginNav {
- height: 64px;
- position: relative;
- display: flex;
- align-items: center;
- justify-content: space-between;
- box-sizing: border-box;
- padding: 0px 24px;
- z-index: 999;
- background: #ffffff;
- box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.15);
- font-family: "sourceR";
- .logo {
- &-image {
- // width: 188px;
- height: 48px;
- cursor: pointer;
- }
- display: flex;
- align-items: center;
- .logo-projectlist {
- display: flex;
- padding: 0 24px;
- height: 64px;
- list-style: none;
- li {
- padding: 0 12px;
- color: rgba(0, 0, 0, 0.45);
- font-size: 16px;
- line-height: 64px;
- cursor: pointer;
- font-weight: 500;
- &:hover {
- background: #f6f6f6;
- }
- &.active {
- color: #ff9900;
- background: #ffefd6;
- }
- }
- }
- }
- .userName {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- .seek {
- margin-right: 100px;
- position: relative;
- img {
- left: 10px;
- top: 11px;
- position: absolute;
- }
- }
- .flag {
- position: relative;
- top: 5px;
- }
- .headPhoto {
- width: 50px;
- height: 50px;
- // background: url("../assets/teacherTrain/image 4.png") no-repeat 100% 100%;
- // background-size: 100%;
- border-radius: 50%;
- // margin-right: 10px;
- }
- .message {
- height: 100%;
- position: relative;
- display: flex;
- justify-content: center;
- align-items: center;
- margin-left: 23px;
- cursor: pointer;
- img {
- width: 18px;
- height: 24px;
- }
- .redDot {
- position: absolute;
- top: 2px;
- right: -2px;
- width: 6px;
- height: 6px;
- display: inline-block;
- background: red;
- border-radius: 50%;
- }
- }
- .selectLoginOrRegistration {
- display: flex;
- height: 32px;
- border: 1px solid #ffffff;
- box-sizing: border-box;
- border-radius: 4px;
- justify-content: space-evenly;
- align-items: center;
- padding: 0 16px;
- > span {
- cursor: pointer;
- font-size: 16px;
- color: #fff;
- }
- }
- .user {
- display: flex;
- align-items: center;
- cursor: pointer;
- position: relative;
- > img {
- width: 34px;
- height: 34px;
- }
- > span {
- font-size: 20px;
- padding-left: 10px;
- }
- .userShow {
- position: absolute;
- width: 156px;
- height: 96px;
- background: #ffffff;
- box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
- border-radius: 8px;
- bottom: -100px;
- color: black;
- z-index: 9999;
- img {
- width: 24px;
- height: 24px;
- margin-right: 10px;
- }
- p {
- font-size: 16px;
- height: 40px;
- display: flex;
- align-items: center;
- padding-left: 20px;
- margin: 0;
- margin-top: 5px;
- }
- > p:hover {
- background: #f2f2f2;
- }
- }
- }
- }
- }
- </style>
- <style lang="scss">
- .LoginNav {
- .el-dropdown-menu__item {
- line-height: 40px;
- display: flex;
- justify-content: center;
- align-items: center;
- > span {
- font-family: "sourceR";
- font-size: 16px;
- }
- }
- .el-menu--horizontal > .el-menu-item {
- height: 64px;
- line-height: 68px;
- }
- .el-dropdown {
- display: block;
- > span {
- font-family: "sourceR";
- font-size: 16px;
- }
- }
- }
- .projectList {
- &.el-dropdown-menu__item {
- line-height: 40px;
- display: flex;
- align-items: center;
- color: #000000;
- > img {
- top: 0;
- }
- > span {
- line-height: 40px;
- font-family: "sourceR";
- }
- }
- &:hover {
- background: rgba(255, 153, 0, 0.1) !important;
- color: #000 !important;
- }
- &.menuActive {
- background: #ff9900;
- }
- }
- </style>
|