123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- <template>
- <div class="navbar">
- <hamburger
- id="hamburger-container"
- :is-active="sidebar.opened"
- class="hamburger-container"
- @toggleClick="toggleSideBar"
- />
- <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
- <div class="right-menu">
- <template v-if="device !== 'mobile'">
- <!-- <search id="header-search" class="right-menu-item" /> -->
- <!-- <notice-todo v-if="userIdentity === 1 && openSoket" /> -->
- <!-- <error-log class="errLog-container right-menu-item hover-effect" /> -->
- <screenfull id="screenfull" class="right-menu-item hover-effect" />
- </template>
- <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
- <div class="avatar-wrapper">
- <img src="https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif" class="user-avatar">
- <span>{{ loginAccount || mobile || name }}</span>
- <template v-if="userIdentity === 2">
- <i v-if="vipInfo.vipStatus !== 3" class="vip-icon " :class="{ close: vipInfo.vipStatus === 0 }" />
- <el-button
- v-if="vipInfo.vipStatus === 3"
- type="primary"
- size="mini"
- class="vip-button"
- @click.stop="toOpenVipPage('open')"
- >开通会员</el-button>
- <el-button
- v-else
- type="primary"
- size="mini"
- class="vip-button xufei"
- @click.stop="toOpenVipPage('xufei')"
- >续费</el-button>
- </template>
- <i class="el-icon-caret-bottom" />
- </div>
- <el-dropdown-menu slot="dropdown" :class="{ user: userIdentity === 2 }">
- <template v-if="userIdentity === 2">
- <el-dropdown-item class="user-info">
- <img src="https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif" class="user-avatar">
- <div class="right-content">
- <div class="name">
- <span>{{ loginAccount || mobile || name }}</span>
- <i class="vip-icon " :class="{ close: vipInfo.vipStatus === 0 || vipInfo.vipStatus === 3 }" />
- </div>
- <div class="info">
- <span v-if="vipInfo.endTime" class="time">到期时间:{{ vipInfo.endTime | formatTime }}</span>
- <span class="record">购买记录</span>
- </div>
- </div>
- </el-dropdown-item>
- <router-link to="/personal/info">
- <el-dropdown-item>个人资料</el-dropdown-item>
- </router-link>
- <router-link to="/personal/account">
- <el-dropdown-item>绑定登录账号</el-dropdown-item>
- </router-link>
- <router-link to="/password/edit">
- <el-dropdown-item>修改密码</el-dropdown-item>
- </router-link>
- <el-dropdown-item v-if="proxyState" divided @click.native="proxyLogout">
- 退出代理
- </el-dropdown-item>
- <el-dropdown-item v-else divided @click.native="logout">
- <span style="display:block;">退出登录</span>
- </el-dropdown-item>
- </template>
- <template v-else>
- <router-link to="/password/edit">
- <el-dropdown-item>修改密码</el-dropdown-item>
- </router-link>
- <el-dropdown-item divided @click.native="logout">
- <span style="display:block;">退出登录</span>
- </el-dropdown-item>
- </template>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- <vip-tip-dialog />
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import { formatDate } from '@/utils'
- import Breadcrumb from '@/components/Breadcrumb'
- import Hamburger from '@/components/Hamburger'
- // import ErrorLog from '@/components/ErrorLog'
- import Screenfull from '@/components/Screenfull'
- // import Search from '@/components/HeaderSearch'
- // import NoticeTodo from './NoticeTodo'
- import VipTipDialog from './VipTipDialog'
- export default {
- filters: {
- formatTime(time) {
- if (!time) {
- return ''
- }
- return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
- }
- },
- components: {
- Breadcrumb,
- Hamburger,
- // ErrorLog,
- Screenfull,
- VipTipDialog
- // NoticeTodo
- // Search
- },
- computed: {
- ...mapGetters([
- 'sidebar',
- 'device',
- 'name',
- 'userIdentity',
- 'openSoket',
- 'proxyState',
- 'mobile',
- 'loginAccount',
- 'vipInfo'
- ]),
- userName() {
- return this.name
- }
- },
- created() {
- console.log(this.vipInfo)
- },
- methods: {
- toggleSideBar() {
- this.$store.dispatch('app/toggleSideBar')
- },
- async logout() {
- this.$message.success('已退出当前账号')
- setTimeout(() => {
- // 退出登录重置用户信息
- this.$store.dispatch('user/logout').then(() => {
- // 重置相关state
- this.$router.replace('/login')
- })
- }, 500)
- },
- proxyLogout() {
- this.$message.success('已退出代理操作')
- setTimeout(() => {
- // 切换到真实登录用户的数据
- this.$store.dispatch('user/proxyLogout')
- this.$store.commit('proxy/CLOSE_PROXY')
- this.$router.replace('/proxy')
- }, 500)
- },
- // 去开通/续费会员
- toOpenVipPage(type) {
- if (type === 'open') {
- this.$router.push('/vip/vip-open')
- } else {
- this.$router.push('/vip/vip-open')
- }
- }
- }
- }
- </script>
- <style scoped>
- .el-dropdown-menu.user >>> .popper__arrow::after {
- border-bottom-color: #2c3e50;
- }
- </style>
- <style lang="scss" scoped>
- .el-dropdown-menu {
- &.user {
- padding-top: 0;
- width: 280px;
- border-radius: 8px;
- }
- }
- .vip-button {
- height: 24px;
- line-height: 24px;
- padding: 0 10px;
- margin-left: 4px;
- &.xufei {
- background: #ff6d6d;
- border-color: #ff6d6d;
- }
- }
- .user-info {
- display: flex;
- justify-content: space-between;
- align-items: center;
- background: #2c3e50;
- color: #f1f1f1;
- padding-top: 12px;
- padding-bottom: 12px;
- margin-bottom: 6px;
- border-radius: 8px 8px 0 0;
- .user-avatar {
- width: 48px;
- height: 48px;
- border-radius: 10px;
- }
- .right-content {
- width: 180px;
- .name {
- font-size: 20px;
- }
- .info {
- font-size: 12px;
- .record {
- margin-left: 6px;
- text-decoration: underline;
- }
- }
- }
- &:hover {
- background: #2c3e50;
- color: #f1f1f1;
- }
- }
- .vip-icon {
- display: inline-block;
- width: 40px;
- height: 32px;
- margin: 0 4px;
- background: url(~@/assets/img/vip-icon-active.png) no-repeat;
- background-size: 40px;
- vertical-align: -5px;
- &.close {
- background: url(~@/assets/img/vip-icon.png) no-repeat;
- }
- }
- .navbar {
- height: 50px;
- overflow: hidden;
- position: relative;
- background: #fff;
- box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
- .hamburger-container {
- line-height: 46px;
- height: 100%;
- float: left;
- cursor: pointer;
- transition: background 0.3s;
- -webkit-tap-highlight-color: transparent;
- &:hover {
- background: rgba(0, 0, 0, 0.025);
- }
- }
- .breadcrumb-container {
- float: left;
- }
- .errLog-container {
- display: inline-block;
- vertical-align: top;
- }
- .right-menu {
- float: right;
- height: 100%;
- line-height: 50px;
- &:focus {
- outline: none;
- }
- .right-menu-item {
- display: inline-block;
- padding: 0 8px;
- height: 100%;
- font-size: 18px;
- color: #5a5e66;
- vertical-align: text-bottom;
- &.hover-effect {
- cursor: pointer;
- transition: background 0.3s;
- // &:hover {
- // background: rgba(0, 0, 0, 0.025);
- // }
- }
- }
- .avatar-container {
- margin-right: 30px;
- .avatar-wrapper {
- // margin-top: 5px;
- position: relative;
- .user-avatar {
- cursor: pointer;
- width: 40px;
- height: 40px;
- border-radius: 10px;
- vertical-align: middle;
- }
- span {
- margin-left: 10px;
- }
- .el-icon-caret-bottom {
- cursor: pointer;
- position: absolute;
- right: -20px;
- top: 25px;
- font-size: 12px;
- }
- }
- }
- }
- }
- </style>
|