123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- <template>
- <!-- 顶部登录导航 -->
- <!-- :style="{ background: headerBg }" -->
- <div class="LoginNav" :class="[type == 'black' ? 'LoginNav-black' : '']">
- <div class="logo">
- <div class="logo-name" @click="cutLoginReg">
- <!-- 二十一世纪英语智慧阅读平台 -->
- <!-- <img src="../assets/logo.png" /> -->
- <svg-icon icon-class="logos"></svg-icon>
- </div>
- <ul class="logo-projectlist">
- <li
- v-for="(itemI, indexI) in projectList"
- :key="indexI"
- :class="indexI == LoginNavIndex ? 'active' : ''"
- @click="handleCommand(indexI)"
- >
- {{ itemI.name }}
- <!-- <img
- class="active-img"
- v-if="indexI == LoginNavIndex"
- src="../assets/common/header_active.png"
- /> -->
- </li>
- </ul>
- </div>
- <div class="userName">
- <!-- <div :style="{background : userBg}" @click="handleLink('search','')"><img src="../assets/common/icon-search.png" /><label>搜索</label></div> -->
- <!-- <div :style="{background : userBg}"><img src="../assets/common/icon-shopping.png" /><label>购物车</label></div> -->
- <!-- <div :style="{background : userBg}" @click="handleLink('peraonal','like')"><img src="../assets/common/icon-like.png" /><label>收藏夹</label></div> -->
- <!-- <div :style="{background : userBg}" @click="handleLink('peraonal','')"><img src="../assets/common/icon-user.png" /></div> -->
- <div @click="handleLink('search', '')" title="搜索" class="search-btn">
- <svg-icon icon-class="search"></svg-icon>
- </div>
- <!-- <div @click="handleLink('peraonal','like')" title="收藏夹"><svg-icon icon-class="like-line"></svg-icon></div> -->
- <div class="login" v-if="!userShow">
- <a @click="toLogin">登录</a>
- <a @click="handleLink('register', '')">注册</a>
- </div>
- <el-dropdown @command="handleChange" v-else>
- <span class="el-dropdown-link">
- <el-image
- :src="
- touxiang
- ? touxiang
- : userMessage.image_url
- ? userMessage.image_url
- : require('../assets/avatar.png')
- "
- fit="cover"
- style="width: 24px; height: 24px; margin: 0 8px"
- >
- </el-image>
- <span class="name">{{ userMessage.user_name }}</span
- ><i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="personal">个人中心</el-dropdown-item>
- <el-dropdown-item
- command="orgManage"
- v-if="userMessage.is_org_manager === 'true'"
- >机构管理</el-dropdown-item
- >
- <el-dropdown-item command="logout">退出登录</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- <el-dialog
- :visible.sync="loginFlag"
- :show-close="false"
- :close-on-click-modal="false"
- :modal-append-to-body="false"
- width="504px"
- class="login-dialog"
- v-if="loginFlag"
- >
- <login
- @cancelLogin="cancelLogin"
- :toUrl="toUrl"
- :linkType="linkType"
- ></login>
- </el-dialog>
- </div>
- </template>
- <script>
- import { removeToken } from "@/utils/auth";
- import Cookies from "js-cookie";
- //import { setI18nLang } from "@/utils/i18n";
- import { removeSession } from "@/utils/role";
- import Login from "@/views/login.vue";
- import { getToken } from "@/utils/auth";
- export default {
- components: { Login },
- name: "LayoutHeader",
- props: [
- "headerBg",
- "headerBorder",
- "userBg",
- "LoginNavIndex",
- "type",
- "touxiang",
- ],
- data() {
- return {
- projectList: [
- {
- name: "商城",
- url: "/bookCity",
- },
- {
- name: "书架",
- url: "/bookShelf",
- },
- // {
- // name: "测评",
- // url: "/evaluation",
- // },
- {
- name: "词典",
- url: "/dictionary",
- },
- {
- name: "双语学生记者",
- url: "/reporter",
- },
- ],
- userMessage: getToken() ? JSON.parse(getToken()) : null,
- userShow: Cookies.get("HM21St_User_Token") ? true : false,
- loginFlag: false,
- toUrl: "",
- linkType: "",
- };
- },
- watch: {},
- computed: {},
- methods: {
- // 切换项目
- handleCommand(command) {
- this.toUrl = "";
- if (this.projectList[command].url !== "/bookShelf") {
- this.$router.push({
- path: this.projectList[command].url,
- });
- } else {
- if (this.userMessage) {
- this.$router.push({
- path: this.projectList[command].url,
- });
- } else {
- this.toUrl = this.projectList[command].url;
- this.loginFlag = true;
- }
- }
- },
- handleLogin(url, type) {
- this.toUrl = url;
- this.loginFlag = true;
- this.linkType = type;
- },
- // 切换登录的注册
- cutLoginReg() {
- window.location.href = "/";
- },
- QuitLogin() {
- removeToken();
- removeSession("SysList");
- Cookies.remove("registerToken");
- Cookies.remove("HM21St_User_Token");
- this.userShow = false;
- this.userMessage = null;
- window.location.href = "/";
- },
- handleLink(link, type) {
- let url =
- this.LoginNavIndex +
- "&&&" +
- this.userBg +
- "&&&" +
- this.headerBorder +
- "&&&" +
- this.headerBg;
- this.$router.push({
- path: "/" + link,
- query: {
- headerConfig: encodeURIComponent(url),
- type: encodeURIComponent(type),
- id: link === "orgManage" ? this.userMessage.org_id : "",
- },
- });
- },
- handleChange(com) {
- if (com === "personal") {
- this.handleLink("peraonal", "");
- } else if (com === "logout") {
- this.QuitLogin();
- } else if (com === "orgManage") {
- this.handleLink("orgManage", "");
- }
- },
- // 去登录
- toLogin() {
- this.loginFlag = true;
- },
- // 关闭登录弹窗
- cancelLogin() {
- this.loginFlag = false;
- },
- },
- created() {},
- mounted() {},
- beforeDestroy() {},
- };
- </script>
- <style lang="scss" scoped>
- .LoginNav {
- height: 64px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- box-sizing: border-box;
- background: #00adef;
- // border-bottom: 1px solid rgba(255, 255, 255, 0.12);
- z-index: 10;
- padding: 0 24px;
- position: fixed;
- width: 100%;
- top: 0;
- left: 0;
- .logo {
- display: flex;
- align-items: center;
- padding-right: 40px;
- .logo-name {
- cursor: pointer;
- font-size: 0;
- z-index: 2;
- .svg-icon {
- width: 204px;
- height: 32px;
- color: #ffffff;
- }
- }
- .logo-projectlist {
- display: flex;
- list-style: none;
- margin: 0;
- padding: 0;
- width: 100%;
- position: absolute;
- left: 0;
- top: 0;
- z-index: 1;
- justify-content: center;
- li {
- padding: 5px 20px;
- color: rgba(255, 255, 255, 0.48);
- font-size: 16px;
- line-height: 54px;
- cursor: pointer;
- white-space: nowrap;
- position: relative;
- &:hover {
- color: #ffffff;
- }
- &.active {
- color: #ffffff;
- font-weight: 500;
- }
- .active-img {
- position: absolute;
- bottom: -1px;
- left: 50%;
- width: 24px;
- margin-left: -12px;
- }
- }
- }
- }
- .userName {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- z-index: 2;
- > div {
- cursor: pointer;
- display: flex;
- align-items: center;
- // background: #242424;
- // border-radius: 40px;
- height: 32px;
- margin-left: 16px;
- color: rgba(255, 255, 255, 0.88);
- padding: 8px;
- &.search-btn {
- border-radius: 20px;
- background: #0087c0;
- width: 221px;
- }
- &.login {
- color: #ffffff;
- font-weight: 400;
- font-size: 14px;
- line-height: 22px;
- a {
- width: 60px;
- line-height: 32px;
- text-align: center;
- border-radius: 2px;
- &:hover {
- background: rgba(255, 255, 255, 0.12);
- color: rgba(255, 255, 255, 0.9);
- }
- &:focus {
- background: rgba(255, 255, 255, 0.08);
- color: rgba(255, 255, 255, 0.7);
- }
- }
- :first-child {
- margin-right: 6px;
- }
- }
- img {
- width: 16px;
- }
- label {
- color: #ffffff;
- font-size: 14px;
- font-weight: 400;
- // font-family: Harmony;
- margin-left: 8px;
- }
- // &:last-child {
- // border-radius: 20px;
- // width: 40px;
- // padding: 0 12px;
- // }
- }
- }
- .el-dropdown {
- color: rgba(255, 255, 255, 0.88);
- .el-dropdown-link {
- display: flex;
- align-items: center;
- }
- .avatar {
- width: 24px;
- height: 24px;
- border-radius: 2px;
- margin: 0 8px;
- }
- .name {
- font-size: 14px;
- line-height: 22px;
- }
- }
- // &-black {
- // border-bottom-color: #ffffff;
- // .svg-icon {
- // color: rgba(0, 0, 0, 0.88) !important;
- // }
- // .logo-projectlist li {
- // color: rgba(0, 0, 0, 0.56) !important;
- // &:hover {
- // color: rgba(0, 0, 0, 0.88) !important;
- // }
- // }
- // .el-dropdown {
- // color: #000000 !important;
- // }
- // }
- }
- </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;
- }
- }
- .login-dialog {
- .el-dialog__header,
- .el-dialog__body {
- padding: 0;
- }
- .el-dialog {
- border: 1px solid #e5e6eb;
- box-shadow: 0px 6px 30px 5px rgba(0, 0, 0, 0.05),
- 0px 16px 24px 2px rgba(0, 0, 0, 0.04),
- 0px 8px 10px -5px rgba(0, 0, 0, 0.08);
- border-radius: 4px;
- overflow: hidden;
- }
- }
- </style>
|