Merge pull request !12 from Sky_ID/lwh
This commit is contained in:
Sky_ID 2022-06-15 03:15:57 +00:00 committed by Gitee
commit df62e6fb3e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
11 changed files with 694 additions and 17 deletions

View File

@ -31,6 +31,7 @@
/* 面板 */
.admin-content {
width: 100%;
display: flex;
flex-direction: column; /* 纵向排列 */
margin: 0 2vw 2vw;
@ -48,7 +49,7 @@
}
.card-admin {
width: 83vw;
width: 100%;
background-color: white;
box-shadow: 0px 4px 10px 0 rgba(0,0,0,0.15);
margin-bottom: 3vw;

View File

@ -28,7 +28,10 @@
<i class="el-icon-user-solid"></i>
<span slot="title">用户权限管理</span>
</el-menu-item>
<el-menu-item index="compManage">
<i class="el-icon-tickets"></i>
<span slot="title">竞赛管理</span>
</el-menu-item>
<!-- </el-submenu>-->
</el-menu>
</div>
@ -61,6 +64,9 @@ export default {
case "userManage":
pageUtils.openPage(this.$router,"/admin/userManage")
break;
case "compManage":
pageUtils.openPage(this.$router,"/admin/compManage")
break;
}
},
@ -82,6 +88,7 @@ export default {
<style>
.el-menu-item {
margin: 10px 0;
font-size: 0.9rem !important;
}

View File

@ -4,17 +4,24 @@
<el-image :src="banner" style="width: 100%; height: auto;"/>
<!-- 用户信息 -->
<div class="user-info">
<div class="user-info" v-if="isLogin">
<el-dropdown class="user-info-dropdown" trigger="hover">
<span class="el-dropdown-link"><img :src="userAvatar" /></span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>userName</el-dropdown-item> <!-- -->
<el-dropdown-item>{{userName}}</el-dropdown-item> <!-- -->
<!-- <el-dropdown-item>{{ userName }}</el-dropdown-item> -->
<el-dropdown-item divided @click.native="logout()">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div class="user-info" v-if="!isLogin">
<a style="color: white; cursor: pointer" @click="toLogin()">登录</a>
<a style="color: white;"> / </a>
<a style="color: white;cursor: pointer" @click="toRes()">注册</a>
</div>
<!--导航栏-->
<!--TODO: 需要根据设定动态更改-->
<el-menu :default-active="activeIndex" class="nav" mode="horizontal" @select="handleSelect">
@ -42,13 +49,15 @@
<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: "", /* 启动默认显示页 */
@ -56,6 +65,7 @@ export default {
userPass: "",
userAvatar: "", /* 用户头像 */
rankIf: true, /* 权限识别 */
isLogin: false //
};
},
@ -108,10 +118,11 @@ export default {
type: "warning",
})
.then(() => {
sessionStorage.removeItem("name");
sessionStorage.removeItem("pass");
sessionStorage.removeItem("rank");
this.$router.push("/login");
localStorage.removeItem("systemToken");
localStorage.removeItem("username");
localStorage.removeItem("userId");
localStorage.removeItem("role");
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/login") //
})
.catch(() => {});
},
@ -125,14 +136,88 @@ 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 !== '') {
//
var user = {
userId
}
this.$api.getUserDataByUserId(user).then((res) =>{
console.log(res)
if (res.status == 0) {
//
this.userAvatar = res.data.userDetails.profilePhoto
this.userName = res.data.user.name
this.isLogin = true
}else {
Message.warning("登录失败,请重新登录")
}
}).catch(function (res){
console.log(res)
})
}
console.log(token)
console.log(userId)
},
toLogin(){
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/login")
},
toRes(){
pageUtils.openPage(this.$router,"/" +this.$route.params.compId +"/register")
}
},
mounted(){
this.userStateCheck()
this.initPage();
//
this.userName = sessionStorage.getItem("name");
this.userPass = sessionStorage.getItem("pass");
this.userAvatar = require("@/assets/logo/user.jpg");
/* var userRank = sessionStorage.getItem("rank");
if (userRank == 1) {
this.rankIf = true;

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

@ -0,0 +1,134 @@
<template>
<div>
<el-table
:data="tableData.slice((currentPage-1)*PageSize,currentPage*PageSize)"
:row-style="{height:'100px'}"
style="height: auto"
>
<el-table-column
fixed
prop="compNum"
label="序号"
min-width="20px">
</el-table-column>
<el-table-column
prop="compId"
label="竞赛ID"
min-width="70px">
</el-table-column>
<el-table-column
prop="compName"
label="竞赛名称"
min-width="150px">
</el-table-column>
<el-table-column
prop="online"
label="是否上线"
min-width="50px"
:filters="[{ text: '已上线', value: true }, { text: '未上线', value: false }]"
:filter-method="filterTag"
filter-placement="bottom-end">
<template slot-scope="scope">
<el-tag
:type="scope.row.online === true ? 'success' : 'warning'"
disable-transitions>{{scope.row.online === true ? '已上线' : '未上线'}}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
size="mini"
@click="handleEdit(scope.row.compId, scope.row)">编辑</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.row.compId, scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination @size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="pageSizes"
:page-size="PageSize" layout="prev, pager, next"
background
:total="totalCount"
style="margin-top: 10px">
</el-pagination>
</div>
</template>
<script>
import {Message} from "element-ui";
export default {
name: "compTable",
data(){
return{
tableData:"",
//
currentPage:1,
// ()
totalCount:1,
//
pageSizes:[1,2,3,4],
//
PageSize:10
}
},
methods:{
filterTag(value, row) {
return row.online === value;
},
handleEdit(index, row) {
console.log(index, row);
},
handleDelete(index, row) {
console.log(index, row);
},
initPage(){
this.$api.getAllComp().then((res)=>{
console.log(res)
if (res.status == 0) {
//
this.tableData = res.data
}else if (res.status == 10){
Message.warning("系统查询错误")
}else {
Message.warning("权限不足或其他错误")
}
})
},
//
//
handleSizeChange(val) {
//
this.PageSize=val
//
this.currentPage=1
},
//
handleCurrentChange(val) {
//
this.currentPage=val
},
},
mounted() {
this.initPage()
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,380 @@
<template>
<div class="admin-content">
<el-breadcrumb class="breadcrumb-admin" separator="/">
<el-breadcrumb-item>后台管理</el-breadcrumb-item>
<el-breadcrumb-item>竞赛管理</el-breadcrumb-item>
<el-breadcrumb-item>竞赛详情</el-breadcrumb-item>
</el-breadcrumb>
<div class="card-admin" style="text-align: left">
<div class="card-style">
<div>
<div>
<h4>竞赛基本信息</h4>
<div>
<el-form label-position="right" label-width="80px" :model="compInfo" :rules="rules">
<el-form-item label="竞赛ID" prop="compId">
<el-input v-model="compInfo.compId"></el-input>
</el-form-item>
<el-form-item label="竞赛名称" prop="compName">
<el-input v-model="compInfo.compName"></el-input>
</el-form-item>
<el-form-item label="Banner图" prop="compBanner">
<el-upload
class="upload-demo"
drag
action="https://jsonplaceholder.typicode.com/posts/"
multiple>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">只能上传jpg/png文件且不超过2Mb</div>
</el-upload>
<!-- <el-input v-model="compInfo.compBanner"></el-input>-->
</el-form-item>
<el-form-item label="是否上线" prop="online">
<el-switch v-model="compInfo.online"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" >保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-divider></el-divider>
<div>
<h4>主页信息</h4>
<div>
<el-form label-position="right" label-width="80px" :model="homeInfo" :rules="rules">
<el-form-item label="首页视频" prop="compBanner">
<el-upload
class="upload-demo"
drag
action="https://jsonplaceholder.typicode.com/posts/"
multiple>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<!-- <div class="el-upload__tip" slot="tip">只能上传jpg/png文件且不超过2Mb</div>-->
</el-upload>
<!-- <el-input v-model="compInfo.compBanner"></el-input>-->
</el-form-item>
<el-form-item label="是否显示" prop="show">
<el-switch v-model="homeInfo.show"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" >保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-divider></el-divider>
<div>
<h4>赛事指南信息</h4>
<div>
<el-form label-position="right" label-width="80px" :model="guideInfo" :rules="rules">
<el-form-item label="是否显示" prop="show">
<el-switch v-model="guideInfo.show"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" >保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-divider></el-divider>
<div>
<h4>通知公告信息</h4>
<div>
<el-form label-position="right" label-width="80px" :model="guideInfo" :rules="rules">
<el-form-item label="是否显示" prop="show">
<el-switch v-model="noticeInfo.show"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" >保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-divider></el-divider>
<div>
<h4>参赛报名信息</h4>
<div>
<el-form label-position="right" label-width="80px" :model="applyInfo" :rules="rules">
<el-form-item label="是否显示" prop="show">
<el-switch disabled v-model="applyInfo.show"></el-switch>
</el-form-item>
</el-form>
</div>
</div>
<el-divider></el-divider>
<div>
<h4>提案提交信息</h4>
<div>
<el-form label-position="right" label-width="80px" :model="submitInfo" :rules="rules">
<el-form-item label="是否显示" prop="show">
<el-switch disabled v-model="submitInfo.show"></el-switch>
</el-form-item>
<el-form-item label="在线脚本" prop="onlineScript">
<el-switch v-model="submitInfo.onlineScript"></el-switch>
</el-form-item>
<el-form-item label="脚本接口" prop="onlineInter" v-if="submitInfo.onlineScript">
<el-input v-model="submitInfo.onlineInter"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" >保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-divider></el-divider>
<div>
<h4>数据统计信息</h4>
<div>
<el-form label-position="right" label-width="80px" :model="chartInfo" :rules="rules">
<el-form-item label="是否显示" prop="show">
<el-switch v-model="chartInfo.show"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" >保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-divider></el-divider>
<div>
<h4>排行榜</h4>
<div>
<el-form label-position="right" label-width="80px" :model="rankInfo" :rules="rules">
<el-form-item label="是否显示" prop="show">
<el-switch v-model="rankInfo.show"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" >保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-divider></el-divider>
<div>
<h4>交流互动信息</h4>
<div>
<el-form label-position="right" label-width="100px" :model="chatInfo" :rules="rules">
<el-form-item label="交流互动图" prop="imgUrl">
<el-upload
class="upload-demo"
drag
action="https://jsonplaceholder.typicode.com/posts/"
multiple>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
</el-upload>
</el-form-item>
<el-form-item label="参赛资讯链接" prop="urlOne" >
<el-input v-model="chatInfo.urlOne"></el-input>
</el-form-item>
<el-form-item label="参赛资讯图" prop="logoOne">
<el-upload
class="upload-icon "
drag
action="https://jsonplaceholder.typicode.com/posts/"
multiple>
<i class="el-icon-plus uploader-icon"></i>
</el-upload>
</el-form-item>
<el-form-item label="选手交流链接" prop="urlOne" >
<el-input v-model="chatInfo.urlTwo"></el-input>
</el-form-item>
<el-form-item label="选手交流图" prop="logoTwo">
<el-upload
class="upload-icon "
drag
action="https://jsonplaceholder.typicode.com/posts/"
multiple>
<i class="el-icon-plus uploader-icon"></i>
</el-upload>
</el-form-item>
<el-form-item label="专家答疑链接" prop="urlOne" >
<el-input v-model="chatInfo.urlThree"></el-input>
</el-form-item>
<el-form-item label="专家答疑图" prop="logoThree">
<el-upload
class="upload-icon "
drag
action="https://jsonplaceholder.typicode.com/posts/"
multiple>
<i class="el-icon-plus uploader-icon"></i>
</el-upload>
</el-form-item>
<el-form-item label="是否显示" prop="show">
<el-switch v-model="chatInfo.show"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" >保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-divider></el-divider>
<div>
<h4>联系我们信息</h4>
<div>
<el-form label-position="right" label-width="100px" :model="chatInfo" :rules="rules">
<el-form-item label="联系我们图" prop="imgUrl">
<el-upload
class="upload-demo"
drag
action="https://jsonplaceholder.typicode.com/posts/"
multiple>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
</el-upload>
</el-form-item>
<el-form-item label="是否显示" prop="show">
<el-switch v-model="chatInfo.show"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" >保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "CompEdit",
data(){
return{
rules: {
compId: [
{ required: true, message: '请输入竞赛ID', trigger: 'blur' },
],
compName: [
{ required: true, message: '请输入竞赛名称', trigger: 'blur' }
],
},
compInfo:{
compId:'',
compName:"",
compBanner:"",
online:false
},
homeInfo:{
compId:'',
video:'',
show:false
},
guideInfo:{
content:'',
contentMd:'',
show: false
},
noticeInfo:{
show: false,
},
applyInfo:{
show: true,
},
submitInfo:{
show: true,
onlineScript: false,
onlineInter:'',
},
chartInfo:{
show: false,
},
rankInfo:{
show: false,
},
chatInfo:{
show: true,
urlOne:"",
urlTwo:"",
urlThree:"",
logoOne:"",
logoTwo:"",
logoThree:"",
imgUrl:"",
}
}
},
methods:{
},
mounted() {
}
}
</script>
<style src="@/assets/css/common.css" scoped/>
<style lang="scss" scoped>
.card-style{
margin: 20px;
}
.upload-icon {
/deep/.el-upload-dragger{
width: 100px;
height: 100px;
text-align: center;
align-items: center; /* 水平居中 */
justify-content: center !important; /* 垂直居中 */
}
.uploader-icon {
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
}
}
</style>

View File

@ -0,0 +1,31 @@
<template>
<div class="admin-content">
<el-breadcrumb class="breadcrumb-admin" separator="/">
<el-breadcrumb-item>后台管理</el-breadcrumb-item>
<el-breadcrumb-item>竞赛管理</el-breadcrumb-item>
</el-breadcrumb>
<div style="margin-bottom: 10px; text-align: right">
<el-button plain @click="goToEdit">新增竞赛</el-button>
</div>
<div class="card-admin">
<comp-table style="margin: 20px;">
</comp-table>
</div>
</div>
</template>
<script>
import CompTable from "@/components/compTable";
export default {
name: "CompManage",
components: {CompTable}
}
</script>
<style src="@/assets/css/common.css" scoped/>
<style scoped>
</style>

View File

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

View File

@ -160,6 +160,22 @@ let routes = [
meta: {
title: '红山开源社区'
},
},
{
// 竞赛管理
path: "compManage",
component: () => import("@/pages/Admin/CompManage"),
meta: {
title: '红山开源社区'
},
},
{
// 竞赛管理
path: "compEdit/:compId",
component: () => import("@/pages/Admin/CompEdit"),
meta: {
title: '红山开源社区'
},
}
]
},

View File

@ -55,6 +55,17 @@ export const register = data => {
})
};
export const getUserDataByUserId = data => {
return axios({
headers:{
"Authorization": localStorage.getItem("systemToken")
},
url: '/user/getUserVoByUserId',
method: 'post',
data
})
};
export const chatContentUpdate = data => {
return axios({
@ -78,6 +89,16 @@ export const homeContentUpdate = data => {
data
})
};
export const getAllComp = () => {
return axios({
headers:{
"Authorization": localStorage.getItem("systemToken")
},
url: '/admin/getAllComp',
method: 'get'
})
};
// 默认全部倒出
// 根据需要进行
export default {
@ -88,5 +109,7 @@ export default {
login,
register,
chatContentUpdate,
homeContentUpdate
homeContentUpdate,
getUserDataByUserId,
getAllComp
}