Files
learning-system-portal/src/components/PortalHeader.vue
2022-06-01 17:42:57 +08:00

377 lines
13 KiB
Vue

<template>
<div class="portal-header">
<div class="portal-content xcontent">
<div style="display: flex;justify-content: space-between;">
<div style="display: flex;justify-content: flex-start;align-items: center;">
<img src="../assets/logo/logo.png" style="width:221px;height: 30px;" />
<div style="display: flex;justify-content: space-around;margin-left: 20px;">
<div class="top-nav" :class="current == 'index' ? 'current-nav' : ''"><router-link to="/index">首页</router-link></div>
<div class="top-nav" :class="current == 'course' ? 'current-nav' : ''"><router-link to="/course">课程</router-link></div>
<!-- <div class="top-nav" :class="current == 'case' ? 'current-nav' : ''"><router-link to="/case">案例</router-link></div> -->
<div class="top-nav" :class="current == 'article' ? 'current-nav' : ''"><router-link to="/article">文章</router-link></div>
<div class="top-nav" :class="current == 'qa' ? 'current-nav' : ''"><router-link to="/qa">问答</router-link></div>
<div class="top-nav">
<el-dropdown placement="bottom" @command="handleCommand">
<span class="el-dropdown-link" style="color:#000;font-size:16px;cursor: pointer;">专区</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="one">BOE系列公开课</el-dropdown-item>
<el-dropdown-item command="two" divided>Grow180</el-dropdown-item>
<el-dropdown-item command="three" divided>管理者进阶</el-dropdown-item>
<el-dropdown-item command="four" divided>U选小课堂</el-dropdown-item>
<el-dropdown-item command="five" divided>社招新员工</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</div>
<div style="display: flex;justify-content: flex-end;align-items: center;">
<div v-if="goSearch !=10">
<el-input v-show="!hideSearch" placeholder="请输入关键词搜索" style="width: 260px;" @keyup.enter.native="searchJump()" clearable maxlength="20" v-model="keyword" class="input-with-select">
<el-select v-if="current == 'index'" v-model="findType" style="width: 75px;" slot="prepend" placeholder="请选择">
<el-option label="课程" value="1"></el-option>
<!-- <el-option label="案例" value="2"></el-option> -->
<el-option label="文章" value="3"></el-option>
<el-option label="问答" value="4"></el-option>
<!-- <el-option label="专区" value="5"></el-option> -->
</el-select>
<!-- <el-button slot="append" icon="el-icon-search" @click="searchJump()">搜索</el-button> -->
<el-button slot="append" icon="el-icon-search" @click="searchJump()" class="input-with-select-btn"></el-button>
</el-input>
</div>
<div class="person-action" >
<!-- 消息 -->
<el-badge :value="userMsg" :hidden="userMsg == 0" class="message-count">
<el-tooltip content="消息" placement="bottom" effect="light">
<el-link type="primary" :href="`${webBaseUrl}/message`" icon="el-icon-bell" :underline="false"></el-link>
</el-tooltip>
</el-badge>
<div>
<a :href="`${webBaseUrl}${isTiao ? '/uc/study/task' : '/uc/study/courses'}`">
<el-avatar :src="userInfo.avatar" v-if="userInfo.avatar !== '' "></el-avatar>
<div v-else class="uavatar">
<div v-if="sex === 1 "><img src="../../public/images/Avatarman.png" alt=""></div>
<div v-else><img src="../../public/images/Avatarwoman.png" alt=""></div>
</div>
</a>
</div>
<el-link type="primary" style="margin-right:10px;" :href="`${webBaseUrl}${isTiao ? '/uc/study/task' : '/uc/study/courses'}`" :underline="false">个人中心</el-link>
<!-- <el-button @click="logout()" type="text" icon="el-icon-switch-button">退出</el-button> -->
<el-link type="primary" @click="logout()" icon="el-icon-switch-button" :underline="false">退出</el-link>
</div>
<!-- <div style="margin-left: 60px;margin-right: 30px"> -->
<!-- <el-badge :value="userMsg" :hidden="userMsg == 0" class="message-count"> -->
<!-- <el-link type="primary" :href="`${webBaseUrl}/message`" icon="el-icon-bell" :underline="false">消息</el-link> -->
<!-- <el-link type="primary" :href="`${webBaseUrl}/message`" icon="el-icon-bell" :underline="false"></el-link> -->
<!-- </el-badge> -->
<!-- </div> -->
<!-- <div style="margin-left: 20px;"><el-avatar :src="userInfo.avatar" style="vertical-align: middle;width:28px;height:28px;margin-right:2px;"></el-avatar></div> -->
<!-- <div style="margin-left: 5px;"> -->
<!-- <el-dropdown @command="handleUcCommand">
<span class="el-dropdown-link">
{{ userInfo.name }}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="uc">个人中心</el-dropdown-item>
<el-dropdown-item command="logout" divided>退出</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown> -->
<!--管理员-->
<!-- <el-link type="primary" :href="`${webBaseUrl}/course/manage`" :underline="false">个人中心</el-link> -->
<!--学员-->
<!-- <el-link type="primary" :href="`${webBaseUrl}${isTiao ? '/uc/study/task' : '/uc/study/courses'}`" :underline="false">个人中心</el-link> -->
<!-- </div> -->
<!-- <div style="margin-left: 20px;"><el-button @click="logout()" type="text" icon="el-icon-switch-button">退出</el-button></div> -->
</div>
</div>
</div>
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex';
import apiMessage from '@/api/system/message.js';
import apiBoeCourse from '@/api/boe/course.js';
import {
userAvatarText
} from "@/utils/tools.js";
export default {
props: {
current: {
type: String,
default: '',
},
hideSearch:{
type: Boolean,
default: false,
},
goSearch:{
type: Number,
default: 0,
}
},
computed: {
...mapGetters(['userInfo', 'userMsg']),
avatarText(){
return userAvatarText(this.userInfo.name);
}
},
data() {
return {
findType: '1',
keyword: '',
isTiao: false,
sex:'',
};
},
mounted() {
//console.log(this.userInfo,'111');
this.sex = this.userInfo.sex;
this.$store.dispatch('refrashMsg');
this.loadBoeData();
},
methods: {
tomy(){
console.log('lll')
},
loadBoeData() {
let params = {
// keyword:this.keyword,
page: 1,
size: 10
// cmtask_status:this.cmtask_status,
// cmtask_name:this.cmtask_name,
};
apiBoeCourse.cmtaskList(params).then(res => {
if (res.result.count > 0) {
this.isTiao = true;
// this.$router.push('/uc/study/task');// 学习任务
} else {
this.isTiao = false;
// this.$router.push('/uc/study/courses')// 自主学习
}
// this.pageData.list = res.result.list;
});
},
handleCommand(val) {
let urlPre=window.location.protocol+'//'+window.location.host;
// process.env.VUE_APP_BOE_WEB_URL
let obj = {
one: urlPre+'/web/teacherLesson',
two: urlPre+'/grow180/login',
three: this.webBaseUrl + '/study/index',
four: 'https://m.qingxuetang.com/x/?appId=qxtcorp306130',
five: urlPre+'/boe/new-employee/index.html'
};
window.open(obj[val]);
},
handleUcCommand(val) {
if (val == 'uc') {
window.location.href = `${this.webBaseUrl}${this.isTiao ? '/uc/study/task' : '/uc/study/courses'}`;
} else if (val == 'logout') {
this.logout();
}
},
searchJump() {
if(this.current == 'index') {
if (this.findType == '1') {
if(this.keyword==''){return;}
// 课程
location.href=`${this.webBaseUrl}/course?keyword=${this.keyword}`;
//window.open(`${this.webBaseUrl}/course?keyword=${this.keyword}`);
} else if (this.findType == '2') {
if(this.keyword==''){return;}
// 案例
location.href=`${this.webBaseUrl}/case?keyword=${this.keyword}`;
//window.open(`${this.webBaseUrl}/case?keyword=${this.keyword}`);
} else if (this.findType == '3') {
if(this.keyword==''){return;}
//文章
location.href=`${this.webBaseUrl}/article?keyword=${this.keyword}`;
//window.open(`${this.webBaseUrl}/article?keyword=${this.keyword}`);
} else if (this.findType == '4') {
if(this.keyword==''){return;}
// 问答
location.href=`${this.webBaseUrl}/qa?keyword=${this.keyword}`;
//window.open(`${this.webBaseUrl}/qa?keyword=${this.keyword}`);
} else if (this.findType == '5') {
// 专区,专区要单独的写,因为不是一个系统呀
window.open(`${this.webBaseUrl}/zone?keyword=${this.keyword}`);
}
} else {
this.$emit('emitInput',this.keyword)
if(this.goSearch == 1) {
if(this.keyword==''){return;}
// 课程
location.href=`${this.webBaseUrl}/course?keyword=${this.keyword}`;
} else if (this.goSearch == 2) {
if(this.keyword==''){return;}
// 案例
location.href=`${this.webBaseUrl}/case?keyword=${this.keyword}`;
//window.open(`${this.webBaseUrl}/case?keyword=${this.keyword}`);
} else if (this.goSearch == 3) {
if(this.keyword==''){return;}
//文章
location.href=`${this.webBaseUrl}/article?keyword=${this.keyword}`;
//window.open(`${this.webBaseUrl}/article?keyword=${this.keyword}`);
} else if (this.goSearch == 4) {
if(this.keyword==''){return;}
// 问答
location.href=`${this.webBaseUrl}/qa?keyword=${this.keyword}`;
//window.open(`${this.webBaseUrl}/qa?keyword=${this.keyword}`);
} else if (this.goSearch == 5) {
// 专区,专区要单独的写,因为不是一个系统呀
window.open(`${this.webBaseUrl}/zone?keyword=${this.keyword}`);
}
}
},
logout() {
this.$confirm('您确定要退出系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.$store.dispatch('LogOut').then(() => {
//location.href = this.webBaseUrl + '/login';
location.href = process.env.VUE_APP_LOGIN_URL;
});
})
.catch(() => {});
},
//获取未读消息数量
getMsgNum() {
apiMessage.isRead().then(res => {
if (res.status == 200) {
this.msgNum = res.result;
}
});
}
}
};
</script>
<style scoped rel="stylesheet/scss" lang="scss">
::v-deep .el-badge__content.is-fixed {
right: 10px;
}
.portal-header {
margin: 0 auto;
display: flex;
align-items: center;
background-color: #ffffff;
border-bottom: 1px solid #f0f0f0;
// line-height: 56px;
//width: 100%;
// padding: 5px 0px 0px;
}
.portal-content {
margin: 0px auto;
//width: 1050px;
.person-action{
display: flex;
justify-content: flex-end;
align-items: center;
margin-left: 10px;
::v-deep .message-count{
margin-right: 20px;
i{
font-size: 26px;
color:#409EFF;
}
// ::v-deep .el-badge__content.is-fixed {
// right: 48px;
// }
}
.el-avatar{
margin-right: 8px;
}
.el-button{
margin-left: 15px;
margin-top: 1px;
// font-size: 14px;
}
}
}
.top-nav {
text-align: center;
line-height: 56px;
padding: 0px 10px;
white-space:nowrap;
}
.anav {
margin: 10px;
color: #4489ce;
}
.current-nav {
color: #fff;
background: #588afc;
// border-bottom: 4px solid;
}
::v-deep .el-badge {
.el-badge__content {
top: 0px;
}
}
::v-deep .el-input-group__prepend {
border-radius: 0;
}
::v-deep .el-input-group__append {
padding: 0px 5px;
color: #fff;
background: #588afc;
border: 1px solid #588afc;
border-radius: 0;
}
.input-with-select-btn {
font-size: 25px !important;
margin: 0 !important;
padding: 0 !important
}
.message-count a {
color: #858d99;
font-size: 24px;
margin-top: 0px !important;
}
::v-deep .el-badge {
margin-top: 0 !important;
}
::v-deep .el-link.el-link--primary:hover {
color: #588afc;
}
.el-dropdown-link {
cursor: pointer;
color: #666666;
}
.uavatar{
div{
border-radius: 50%;
img{
border-radius: 50%;
width: 40px;
height: 40px;
}
}
// border: 1px solid #73adfe;
// color: #73adfe;
// text-align: center;
width: 40px;
height: 40px;
line-height: 40px;
font-size: 14px;
margin-right: 8px;
border-radius: 50%;
// background: #d9e9ff;
}
</style>