Commit dd6db7f3 authored by liwei's avatar liwei

liwei

parent 06e3b7e5
<template>
<div id="app">
<router-view/>
<router-view />
</div>
</template>
<script>
import menu from './util/menuList'
import menu from "./util/menuList";
export default {
name: 'App',
data(){
return {
}
name: "App",
data() {
return {};
},
mounted(){
mounted() {
// 权限验证 动态路由
if(window.location.href.indexOf('login') < 0){
if (window.location.href.indexOf("login") < 0) {
let permission = this.$store.state.progressList;
console.log(this.$store.state)
console.log(this.$store.state);
let menuList = [];
this.$router.options.routes[0].children = [];
let routerUserDetail = {
path: '/userDetail/:id',
name:'userDetail',
component: e=>require(['@/components/userDetail'],e),
};
let routerTeacherDetail ={
path: '/teacher/:id',
name:'teacherDetail',
component: e=>require(['@/components/teacherDetail'],e),
};
menu.forEach(i=>{
path: "/userDetail/:id",
name: "userDetail",
component: e => require(["@/components/userDetail"], e)
};
let routerTeacherDetail = {
path: "/teacher/:id",
name: "teacherDetail",
component: e => require(["@/components/teacherDetail"], e)
};
menu.forEach(i => {
let p = false;
let t = [];
i.list.forEach(j=>{
let find = permission.find(x=>{return x.cover === j.cover});
if(find){
i.list.forEach(j => {
let find = permission.find(x => {
return x.cover === j.cover;
});
if (find) {
j.router.meta = {};
j.router.meta.readonly = !!find.readonly;
j.router.meta.delete = !!find.delete;
......@@ -47,13 +47,13 @@ export default {
j.router.meta.classTakeUnlimited = !!find.classTakeUnlimited;
j.router.meta.promoter = !!find.promoter;
t.push(j);
if(find.cover === '3-1'){
if (find.cover === "3-1") {
routerTeacherDetail.meta = {};
routerTeacherDetail.meta.readonly = find.readonly;
routerTeacherDetail.meta.delete = !!find.delete;
this.$router.options.routes[0].children.push(routerTeacherDetail);
}
if(find.cover === '3-2'){
if (find.cover === "3-2") {
routerUserDetail.meta = {};
routerUserDetail.meta.readonly = find.readonly;
routerUserDetail.meta.delete = !!find.delete;
......@@ -63,28 +63,32 @@ export default {
p = true;
}
});
if(p){
if (p) {
i.list = t;
menuList.push(i)
menuList.push(i);
}
});
this.$router.addRoutes([this.$router.options.routes[0]]);//调用add;
this.$store.dispatch('setMenu',menuList)
this.$router.addRoutes([this.$router.options.routes[0]]); //调用add;
this.$store.dispatch("setMenu", menuList);
}
}
}
};
</script>
<style>
#app {
height: 100%;
}
html,body{
height: 100%;
margin: 0;
padding: 0;
}
.el-collapse-item__arrow{margin-left: 0;}
.fl{float: left;}
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
.el-collapse-item__arrow {
margin-left: 0;
}
.fl {
float: left;
}
</style>
This diff is collapsed.
This diff is collapsed.
......@@ -6,80 +6,87 @@
background-color="#333333"
active-text-color="#ffd04b"
:collapse="menuType"
class="el-menu-vertical-demo">
class="el-menu-vertical-demo"
>
<div class="menu-btn" @click="menuType = !menuType">
<i v-if="!menuType" class="iconfont icon-shouqi"></i>
<i v-if="menuType"
class="iconfont icon-zhankai"></i>
<i v-if="menuType" class="iconfont icon-zhankai"></i>
</div>
<el-submenu v-for="(data,index) in menuList" :index="data.value" :key="index">
<template slot="title">
<i :class="'iconfont menu-icon '+data.icon"></i>
<span>{{data.value}}</span>
</template>
<el-menu-item v-for="(item,i) in data.list" :index="item.path" :key="i" class="item">{{item.value}}</el-menu-item>
<el-menu-item
v-for="(item,i) in data.list"
:index="item.path"
:key="i"
class="item"
>{{item.value}}</el-menu-item>
</el-submenu>
</el-menu>
</template>
<script>
export default {
name: "leftMenu",
data(){
return {
menuList:this.$store.state.menuList,
menuType:false
}
export default {
name: "leftMenu",
data() {
return {
menuList: this.$store.state.menuList,
menuType: false
};
},
mounted() {
console.log(this.menuList);
},
methods: {
changeMenuType: function() {
this.$store.state.menuType = !this.$store.state.menuType;
},
methods:{
changeMenuType:function(){
this.$store.state.menuType = !this.$store.state.menuType
},
toPath:function (data) {
this.$router.push({name:data.routerName})
if(this.$store.state.openedTab.indexOf(data) < 0){
this.$store.state.openedTab.push(data);
}
toPath: function(data) {
this.$router.push({ name: data.routerName });
if (this.$store.state.openedTab.indexOf(data) < 0) {
this.$store.state.openedTab.push(data);
}
},
}
}
};
</script>
<style scoped lang="less">
@import "../../util/public";
.el-menu-vertical-demo:not(.el-menu--collapse) {
width: 200px;
@import "../../util/public";
.el-menu-vertical-demo:not(.el-menu--collapse) {
width: 200px;
}
.el-menu {
background: @bg-b;
color: white;
overflow: auto;
height: 100%;
.menu-btn {
height: 35px;
background: @bg-b-s;
line-height: 35px;
/*text-align: center;*/
i {
font-size: 26px;
float: right;
padding: 0 15px;
}
}
.el-menu{
background: @bg-b;
color: white;
overflow: auto;
height: 100%;
.menu-btn{
height: 35px;
background: @bg-b-s;
line-height: 35px;
/*text-align: center;*/
i{
font-size: 26px;
float: right;
padding: 0 15px;
}
.el-submenu {
.menu-icon {
color: white;
font-size: 18px;
position: relative;
right: 5px;
}
.el-submenu{
.menu-icon{
color: white;
font-size: 18px;
position: relative;
right: 5px;
}
.el-menu-item{
background: @main-font-color;
}
.template{
color: black;
}
.el-menu-item {
background: @main-font-color;
}
.template {
color: black;
}
}
}
</style>
<template>
<div class="login">
<div class="wrap-main">
<h1 class="title">唱唱启蒙——后台管理系统</h1>
<el-form :model="login" :rules="loginRules" ref="loginForm">
<el-form-item prop="username">
<el-input v-model="login.username" placeholder="用户名"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input type="password" v-model="login.password" placeholder="密码"></el-input>
</el-form-item>
<el-form-item>
<el-button class="btn" size="medium" type="primary" @click="submitForm">登陆</el-button>
</el-form-item>
</el-form>
</div>
<div class="login">
<div class="wrap-main">
<h1 class="title">唱唱启蒙——后台管理系统</h1>
<el-form :model="login" :rules="loginRules" ref="loginForm">
<el-form-item prop="username">
<el-input v-model="login.username" placeholder="用户名"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input type="password" v-model="login.password" placeholder="密码"></el-input>
</el-form-item>
<el-form-item>
<el-button class="btn" size="medium" type="primary" @click="submitForm">登陆</el-button>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
import { loginApi } from "../../service/api";
import md5 from 'js-md5';
export default {
data(){
return{
login:{
username:'',
password:''
},
loginRules:{
username:[
{ required: true, message: '请输入您的用户名', trigger: 'blur' }
],
password:[
{ required: true, message: '请输入您的密码', trigger: 'blur' }
]
}
}
},
mounted(){
let that = this;
document.onkeydown=keyDownSearch;
function keyDownSearch(e) {
// 兼容FF和IE和Opera
let theEvent = e || window.event;
let code = theEvent.keyCode || theEvent.which || theEvent.charCode;
if (code === 13 && that.$route.name === 'login') {
that.submitForm();//具体处理函数
return false;
}
return true;
}
import { loginApi } from "../../service/api";
import md5 from "js-md5";
export default {
data() {
return {
login: {
username: "",
password: ""
},
methods:{
// 提交
submitForm(){
this.$refs["loginForm"].validate((valid) => {
if (valid) {
let json = {
username:this.login.username,
password:md5(this.login.password)
};
// debugger
loginApi(json).then(res=>{
if(res.teacher_info){
let data=JSON.stringify(res.teacher_info)
localStorage.setItem("phoneNum",data)
}else{
localStorage.setItem("phoneNum","")
}
this.$store.dispatch('setToken',res.token);
this.$store.dispatch('setUserName',res.desc);
this.$store.dispatch('setPermission',JSON.parse(res.roles.menu_ids));
// debugger
window.location.href = '/';
})
loginRules: {
username: [
{ required: true, message: "请输入您的用户名", trigger: "blur" }
],
password: [
{ required: true, message: "请输入您的密码", trigger: "blur" }
]
}
};
},
mounted() {
let that = this;
document.onkeydown = keyDownSearch;
function keyDownSearch(e) {
// 兼容FF和IE和Opera
let theEvent = e || window.event;
let code = theEvent.keyCode || theEvent.which || theEvent.charCode;
if (code === 13 && that.$route.name === "login") {
that.submitForm(); //具体处理函数
return false;
}
return true;
}
},
methods: {
// 提交
submitForm() {
this.$refs["loginForm"].validate(valid => {
if (valid) {
let json = {
username: this.login.username,
password: md5(this.login.password)
};
// debugger
loginApi(json).then(res => {
debugger;
if (res.teacher_info) {
let data = JSON.stringify(res.teacher_info);
localStorage.setItem("phoneNum", data);
} else {
localStorage.setItem("phoneNum", "");
}
})
this.$store.dispatch("setToken", res.token);
this.$store.dispatch("setUserName", res.desc);
this.$store.dispatch(
"setPermission",
JSON.parse(res.roles.menu_ids)
);
// debugger
window.location.href = "/";
});
}
}
});
}
}
};
</script>
<style scoped lang="less">
@import "../../util/public";
.login{
height: 100%;
background: linear-gradient(to bottom right, #ecec7c, #787af4); /* 标准的语法(必须放在最后) */
@import "../../util/public";
.login {
height: 100%;
background: linear-gradient(
to bottom right,
#ecec7c,
#787af4
); /* 标准的语法(必须放在最后) */
}
.wrap-main {
width: 300px;
height: 180px;
padding: 50px 20px;
border-radius: 5px;
box-shadow: 8px 8px 15px rgba(49, 49, 49, 0.5);
position: fixed;
line-height: 50px;
background-color: rgba(255, 255, 255, 0.3);
top: 50%;
left: 50%;
margin-left: -200px;
margin-top: -200px;
.btn {
display: block;
width: 100%;
}
.wrap-main{
width: 300px;
height: 180px;
padding:50px 20px;
border-radius: 5px;
box-shadow: 8px 8px 15px rgba(49, 49, 49, 0.5);
position: fixed;
line-height: 50px;
background-color: rgba(255,255,255,0.3);
top: 50%;
left: 50%;
margin-left: -200px;
margin-top: -200px;
.btn{
display: block;
width: 100%;
}
.title{
position: absolute;
top: -100px;
width: 100%;
text-align: center;
left: 0;
color: white;
font-size: 26px;
text-shadow: 6px 6px 3px rgba(49, 49, 49, 0.5);
}
.title {
position: absolute;
top: -100px;
width: 100%;
text-align: center;
left: 0;
color: white;
font-size: 26px;
text-shadow: 6px 6px 3px rgba(49, 49, 49, 0.5);
}
}
</style>
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment