header部分功能梳理

This commit is contained in:
unknown 2022-06-13 17:45:13 +08:00
parent 73c8b0a50b
commit a419efb94f
4 changed files with 58 additions and 6 deletions

View File

@ -42,13 +42,14 @@
<script>
import pageUtils from "../utils/pageUtils";
import {Message} from "element-ui";
export default {
name: "Header",
data(){
return {
banner: require("@/assets/logo/banner.jpg"),
banner: "",
osredmLogo: require("@/assets/logo/osredmLogo.svg"),
activeIndex: "", /* 启动默认显示页 */
@ -125,11 +126,62 @@ export default {
getPath(){
var path = this.$route.path
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(){
this.userStateCheck()
this.initPage();
//
this.userName = sessionStorage.getItem("name");
this.userPass = sessionStorage.getItem("pass");
this.userAvatar = require("@/assets/logo/user.jpg");

View File

@ -100,9 +100,9 @@ export default {
Message.warning("用户名或密码错误")
}else {
localStorage.setItem("systemToken",res.token)
sessionStorage.setItem("username", res.username);
sessionStorage.setItem("userId", res.userId);
sessionStorage.setItem("role", res.auth.authority);
localStorage.setItem("username", res.username);
localStorage.setItem("userId", res.userId);
localStorage.setItem("role", res.auth.authority);
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/home") //
}
// Cookies.set("token", res.data.token); // tokenCookie

View File

@ -131,7 +131,7 @@ export default {
Message.warning("系统错误")
}else if (res.status === 0){
localStorage.setItem("systemToken",res.token)
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/home") //
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/login") //
}

View File

@ -41,7 +41,7 @@ export default {
data(){
return{
data: "",
videoTitle: "标题",
videoTitle: "",
videoSrc: "",
videoWidth: "100%",
contentLoading: true,