header部分功能梳理
This commit is contained in:
parent
73c8b0a50b
commit
a419efb94f
|
@ -42,13 +42,14 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import pageUtils from "../utils/pageUtils";
|
import pageUtils from "../utils/pageUtils";
|
||||||
|
import {Message} from "element-ui";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Header",
|
name: "Header",
|
||||||
|
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
banner: require("@/assets/logo/banner.jpg"),
|
banner: "",
|
||||||
osredmLogo: require("@/assets/logo/osredmLogo.svg"),
|
osredmLogo: require("@/assets/logo/osredmLogo.svg"),
|
||||||
activeIndex: "", /* 启动默认显示页 */
|
activeIndex: "", /* 启动默认显示页 */
|
||||||
|
|
||||||
|
@ -125,11 +126,62 @@ export default {
|
||||||
getPath(){
|
getPath(){
|
||||||
var path = this.$route.path
|
var path = this.$route.path
|
||||||
this.activeIndex = path.split("/")[2]
|
this.activeIndex = path.split("/")[2]
|
||||||
|
},
|
||||||
|
|
||||||
|
// 初始化页面 banner图加载 视图数据加载
|
||||||
|
initPage(){
|
||||||
|
var compId = this.$route.params.compId
|
||||||
|
var compInfo = {
|
||||||
|
compId
|
||||||
|
}
|
||||||
|
this.$api.getComp(compInfo).then((res)=>{
|
||||||
|
if (res.status === 0) {
|
||||||
|
//存在竞赛 但是要检测是否正式上线
|
||||||
|
if (res.data.online === true) {
|
||||||
|
//正式上线 可以显示页面
|
||||||
|
|
||||||
|
//保存banner
|
||||||
|
this.banner = res.data.compBanner
|
||||||
|
}else {
|
||||||
|
// 未正式上线,需要拦截等操作,跳转404
|
||||||
|
Message.warning("该竞赛还未上线");
|
||||||
|
//TODO: 可添加判断是否为白名单用户进行测试工作
|
||||||
|
this.$router.push({
|
||||||
|
path: '/404'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
// 不存在该竞赛 提示 并跳转404
|
||||||
|
Message.warning("不存在该竞赛");
|
||||||
|
this.$router.push({
|
||||||
|
path: '/404'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 用户登录状态判断
|
||||||
|
userStateCheck(){
|
||||||
|
/**
|
||||||
|
* 1. 有信息 拿到token userId 去获取用户信息
|
||||||
|
* 2. 无信息 提示用户登录
|
||||||
|
*/
|
||||||
|
let token = localStorage.getItem("systemToken")
|
||||||
|
let userId = localStorage.getItem("userId")
|
||||||
|
if (userId != null && token != null && userId !== '' && token !== '') {
|
||||||
|
// 获取用户信息
|
||||||
|
}
|
||||||
|
console.log(token)
|
||||||
|
console.log(userId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted(){
|
mounted(){
|
||||||
|
this.userStateCheck()
|
||||||
|
this.initPage();
|
||||||
|
|
||||||
|
//登录相关处理
|
||||||
this.userName = sessionStorage.getItem("name");
|
this.userName = sessionStorage.getItem("name");
|
||||||
this.userPass = sessionStorage.getItem("pass");
|
this.userPass = sessionStorage.getItem("pass");
|
||||||
this.userAvatar = require("@/assets/logo/user.jpg");
|
this.userAvatar = require("@/assets/logo/user.jpg");
|
||||||
|
|
|
@ -100,9 +100,9 @@ export default {
|
||||||
Message.warning("用户名或密码错误")
|
Message.warning("用户名或密码错误")
|
||||||
}else {
|
}else {
|
||||||
localStorage.setItem("systemToken",res.token)
|
localStorage.setItem("systemToken",res.token)
|
||||||
sessionStorage.setItem("username", res.username);
|
localStorage.setItem("username", res.username);
|
||||||
sessionStorage.setItem("userId", res.userId);
|
localStorage.setItem("userId", res.userId);
|
||||||
sessionStorage.setItem("role", res.auth.authority);
|
localStorage.setItem("role", res.auth.authority);
|
||||||
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/home") //跳转至主页
|
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/home") //跳转至主页
|
||||||
}
|
}
|
||||||
// Cookies.set("token", res.data.token); // 放置token到Cookie
|
// Cookies.set("token", res.data.token); // 放置token到Cookie
|
||||||
|
|
|
@ -131,7 +131,7 @@ export default {
|
||||||
Message.warning("系统错误")
|
Message.warning("系统错误")
|
||||||
}else if (res.status === 0){
|
}else if (res.status === 0){
|
||||||
localStorage.setItem("systemToken",res.token)
|
localStorage.setItem("systemToken",res.token)
|
||||||
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/home") //跳转至主页
|
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/login") //跳转至主页
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ export default {
|
||||||
data(){
|
data(){
|
||||||
return{
|
return{
|
||||||
data: "",
|
data: "",
|
||||||
videoTitle: "标题",
|
videoTitle: "",
|
||||||
videoSrc: "",
|
videoSrc: "",
|
||||||
videoWidth: "100%",
|
videoWidth: "100%",
|
||||||
contentLoading: true,
|
contentLoading: true,
|
||||||
|
|
Loading…
Reference in New Issue