123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 |
- <template>
- <!-- 顶部登录导航 -->
- <div class="LoginNav1">
- <div class="logo" v-if="configInfor">
- <img
- v-if="configInfor.logo_image_url"
- :src="configInfor.logo_image_url"
- alt=""
- />
- <span class="logo-img" v-else>logo</span>
- <el-menu
- :default-active="activeIndex"
- class="el-menu-demo"
- mode="horizontal"
- @select="handleSelect"
- text-color="#fff"
- active-text-color="#FF9900"
- >
- <el-menu-item index="1">主页</el-menu-item>
- <el-menu-item index="2">
- <template v-if="projectList.length > 1">
- <el-dropdown trigger="click" @command="handleCommand">
- <span
- class="el-dropdown-link"
- :style="{ color: activeIndex == 2 ? '#FF9900' : '#fff' }"
- >
- {{ projectName }}
- <!-- SYSTEM -->
- <img
- v-if="activeIndex == 2"
- src="../assets/teacherdev/headerDownlod.png"
- alt=""
- />
- <img
- v-else
- src="../assets/teacherdev/headerDownlod2.png"
- alt=""
- />
- </span>
- <el-dropdown-menu slot="dropdown" style="min-width: 278px">
- <el-dropdown-item
- :class="i == LoginNavIndex ? 'menuActive' : ''"
- :command="i"
- :key="i"
- class="projectList"
- v-for="(item, i) in projectList"
- >
- <img
- style="position: relative; width: 24px"
- :src="item.icon_url_memu_default"
- alt=""
- />
- <span style="margin-left: 16px">
- {{ item.name }}
- </span>
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </template>
- <template v-else>{{
- projectList.length > 0 && projectList[0].name
- }}</template>
- </el-menu-item>
- </el-menu>
- </div>
- <div class="userName">
- <template>
- <el-dropdown
- style="margin-right: 16px; cursor: pointer"
- trigger="click"
- @command="changeLang"
- >
- <span class="el-dropdown-link" style="color: #fff">
- {{ lang }}
- <img src="../assets/teacherdev/headerDownlod2.png" alt="" />
- </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">登录</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="gotoPersonalcenter">
- <img src="../assets/login/project7.png" alt="" />
- 个人中心
- </p>
- <p @click="QuitLogin">
- <img src="../assets/login/Frame77.png" alt="" />
- 退出登录
- </p>
- </div>
- </div>
- <!-- 消息 铃铛图片 -->
- <div class="message">
- <img
- @click="gotoPersonalcenter"
- src="../assets/login/Vector2.png"
- alt=""
- />
- <span class="redDot" v-if="is_exist == 'true'"></span>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import { getToken, removeToken } from "@/utils/auth";
- import Cookies from "js-cookie";
- import { getContent, getStaticContent, getLearnWebContent } from "@/api/api";
- import { setI18nLang } from "@/utils/i18n";
- import { getConfig } from "@/utils/auth";
- import { saveSession, getSession, removeSession } from "@/utils/role";
- export default {
- name: "LayoutHeader",
- props: [],
- data() {
- return {
- activeIndex: "2", // 主导航索引
- LoginNavIndex: 0, //下拉框导航索引
- projectName: "教研中心",
- projectList: [],
- is_exist: "false",
- teacherProList: [
- //普通教师
- {
- id: 0,
- name: "教学中心",
- img: "project1",
- },
- {
- id: 2,
- name: "教培中心",
- img: "project3",
- },
- {
- id: 3,
- name: "教研中心",
- img: "project4",
- },
- {
- id: 5,
- name: "学习中心",
- img: "project6",
- },
- {
- id: 4,
- name: "考试中心",
- img: "project5",
- },
- {
- 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: "",
- headTimer: null,
- configInfor: null,
- };
- },
- watch: {},
- computed: {
- ...mapGetters(["language_type"]),
- },
- methods: {
- // 前往个人中心
- gotoPersonalcenter() {
- if (!this.userMessage) {
- this.$message.warning("请先登录");
- return;
- }
- let MethodName = "login_control-CreateAccessCode";
- let acsCode = "";
- // getContent(MethodName, UserCode, UserType, SessionID).then((res) => {
- // acsCode = res.access_code;
- location.href = `/GCLS-Personal/#/EnterSys`;
- // });
- },
- // 切换导航
- handleSelect(key, keyPath) {
- this.activeIndex = key;
- if (this.activeIndex == 1) {
- window.location.href = "/";
- }
- },
- // 切换项目
- handleCommand(command) {
- let _this = this;
- _this.LoginNavIndex = command;
- if (!_this.userMessage) {
- this.$message.warning("请先登录");
- this.projectName = "教研中心";
- window.location.href = "/";
- return;
- }
- _this.projectName = _this.projectList[command].name;
- let relative_path = _this.projectList[command].relative_path;
- location.href = relative_path;
- },
- // 切换登录的注册
- cutLoginReg() {
- window.location.href = "/";
- },
- QuitLogin() {
- window.location.href = "/";
- removeSession("SysList");
- removeToken();
- Cookies.remove("JSESSIONID");
- this.userShow = false;
- this.userMessage = null;
- },
- 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);
- },
- 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();
- // },
- getChildSysList() {
- let _this = this;
- let MethodName = "login_control-GetChildSysList_CanEnter_PC";
- getContent(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-TC") {
- _this.LoginNavIndex = index;
- }
- });
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- },
- created() {
- let _this = this;
- _this.getChildSysList();
- },
- mounted() {
- let _this = this;
- let user = getToken();
- if (user) {
- _this.userMessage = JSON.parse(user);
- }
- _this.configInfor = JSON.parse(getConfig());
- _this.getLangList();
- _this.getNotReadMessage();
- _this.headTimer = setInterval(() => {
- _this.getNotReadMessage();
- }, 120000);
- },
- beforeDestroy() {
- if (this.headTimer) {
- //如果定时器还在运行 或者直接关闭,不用判断
- clearInterval(this.headTimer); //关闭
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .LoginNav1 {
- // height: 74px;
- 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";
- .el-dropdown-link {
- img {
- width: 8px;
- height: 4px;
- vertical-align: middle;
- }
- }
- .logo {
- > img {
- width: 188px;
- height: 64px;
- }
- &-img {
- font-style: normal;
- font-weight: 600;
- font-size: 30px;
- font-variant: small-caps;
- // color: #000000;
- color: #fff;
- margin-right: 29px;
- line-height: 64px;
- }
- display: flex;
- align-items: center;
- .el-menu-demo {
- background: rgba(0, 0, 0, 0);
- // margin-left: 100px;
- li:hover {
- background: none;
- }
- li {
- font-size: 16px;
- background: none;
- }
- }
- // 取消组件默认的样式
- .el-menu.el-menu--horizontal {
- border-bottom: none;
- }
- }
- .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;
- img {
- width: 24px;
- cursor: pointer;
- }
- .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;
- color: #fff;
- > img {
- width: 34px;
- height: 34px;
- }
- > span {
- font-size: 16px;
- 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;
- left: -5px;
- color: black;
- 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">
- .LoginNav1 {
- .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: 64px;
- }
- .el-dropdown {
- display: block;
- > span {
- font-family: "sourceR";
- font-size: 16px;
- }
- }
- .el-menu-item.is-active i {
- color: white;
- }
- }
- .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: #ff9900 !important;
- // background: rgba(255, 153, 0, 0.1) !important;
- color: #000 !important;
- // color: #fff;
- }
- &.menuActive {
- background: #ff9900;
- }
- }
- </style>
|