登录功能完成
This commit is contained in:
parent
3bee267219
commit
3dcb2d0a4f
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<header>
|
<header v-loading="loading">
|
||||||
<div id="topnavbar">
|
<div id="topnavbar">
|
||||||
<div class="logo logo2 cursor">
|
<div class="logo logo2 cursor">
|
||||||
<img src="../../../static/images/logo.png" alt="">
|
<img src="../../../static/images/logo.png" alt="">
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
<div id="topnanv" v-show="!collapse || navShow">
|
<div id="topnanv" v-show="!collapse || navShow">
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="content clearfix">
|
<ul class="content clearfix">
|
||||||
<li class="dropdown" v-for="(item,index) in menu" :key="index">
|
<template v-if="userName">
|
||||||
|
<li class="dropdown" v-for="(item,index) in adminMenu" :key="index">
|
||||||
<a href="javascript:void(0);" @click="routerTurn(item.path)">{{item.name}}<img v-show="item.children.length" src="../../../static/images/arrow-down.png" alt=""></a>
|
<a href="javascript:void(0);" @click="routerTurn(item.path)">{{item.name}}<img v-show="item.children.length" src="../../../static/images/arrow-down.png" alt=""></a>
|
||||||
<ul class="sub-menu" v-show="item.children.length">
|
<ul class="sub-menu" v-show="item.children.length">
|
||||||
<li v-for="(item1,index1) in item.children" :key="index1">
|
<li v-for="(item1,index1) in item.children" :key="index1">
|
||||||
|
|
@ -29,12 +30,25 @@
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<li class="dropdown" v-for="(item,index) in menu" :key="index">
|
||||||
|
<a href="javascript:void(0);" @click="routerTurn(item.path)">{{item.name}}<img v-show="item.children.length" src="../../../static/images/arrow-down.png" alt=""></a>
|
||||||
|
<ul class="sub-menu" v-show="item.children.length">
|
||||||
|
<li v-for="(item1,index1) in item.children" :key="index1">
|
||||||
|
<a href="javascript:void(0);" @click="routerTurn(item1.path)">{{item1.name}}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="dropdown">
|
||||||
<el-dropdown trigger="click">
|
<el-dropdown trigger="click">
|
||||||
<span class="el-dropdown-link userClass">
|
<span class="el-dropdown-link userClass">
|
||||||
<a href="javascript:void(0);" @click="routerTurn('login')">登录</a>
|
<a href="javascript:void(0);" @click="routerTurn('login')">登录</a>
|
||||||
</span>
|
</span>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</li>
|
</li>
|
||||||
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -55,8 +69,63 @@ export default {
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
|
loading: false,
|
||||||
collapse:true,
|
collapse:true,
|
||||||
menu:[
|
menu:[
|
||||||
|
{
|
||||||
|
name:"首页",
|
||||||
|
path:"home",
|
||||||
|
children:[]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:"数据检索",
|
||||||
|
path:"",
|
||||||
|
children:[
|
||||||
|
{
|
||||||
|
name:"数据检索",
|
||||||
|
path:"dataSearch",
|
||||||
|
children:[]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:"航次详情",
|
||||||
|
path:"voyagedetail",
|
||||||
|
children:[]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:"统计分析",
|
||||||
|
path:"analyse",
|
||||||
|
children:[]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:"数据资源",
|
||||||
|
path:"",
|
||||||
|
children:[
|
||||||
|
{
|
||||||
|
name:"海洋地球物理与物理海洋信息库",
|
||||||
|
path:"physicalIndex",
|
||||||
|
children:[]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:"海洋生物样品信息库",
|
||||||
|
path:"biologyIndex",
|
||||||
|
children:[]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:"深海海洋视频音像信息库",
|
||||||
|
path:"phoneVideoIndex",
|
||||||
|
children:[]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:"关于我们",
|
||||||
|
path:"",
|
||||||
|
children:[]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
adminMenu: [
|
||||||
{
|
{
|
||||||
name:"首页",
|
name:"首页",
|
||||||
path:"home",
|
path:"home",
|
||||||
|
|
@ -173,24 +242,19 @@ export default {
|
||||||
name:"关于我们",
|
name:"关于我们",
|
||||||
path:"",
|
path:"",
|
||||||
children:[]
|
children:[]
|
||||||
},
|
}
|
||||||
// {
|
|
||||||
// name:"个人中心",
|
|
||||||
// path:"personalCenter",
|
|
||||||
// children:[]
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name:"登录",
|
|
||||||
// path:"login",
|
|
||||||
// children:[]
|
|
||||||
// },
|
|
||||||
|
|
||||||
],
|
],
|
||||||
nowPathName: '',
|
nowPathName: '',
|
||||||
navShow:false
|
navShow:false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
userName() {
|
||||||
|
return sessionStorage.getItem('userName') || this.$store.state.user.name
|
||||||
|
}
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
|
console.log(this.userName)
|
||||||
this.getLoginInfo()
|
this.getLoginInfo()
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
|
|
@ -234,11 +298,14 @@ export default {
|
||||||
},
|
},
|
||||||
// 退出登录
|
// 退出登录
|
||||||
onLogout() {
|
onLogout() {
|
||||||
|
this.loading = true
|
||||||
loginOut().then(res => {
|
loginOut().then(res => {
|
||||||
|
this.$store.commit('SET_NAME', '')
|
||||||
|
sessionStorage.setItem('userName', '')
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
path: 'login'
|
path: 'login'
|
||||||
})
|
})
|
||||||
this.getLoginInfo()
|
location.reload()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 获取登录信息
|
// 获取登录信息
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import getters from './getters'
|
||||||
import app from './modules/app'
|
import app from './modules/app'
|
||||||
import settings from './modules/settings'
|
import settings from './modules/settings'
|
||||||
import sample from '@/store/modules/sample'
|
import sample from '@/store/modules/sample'
|
||||||
// import user from './modules/user'
|
import user from './modules/user'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
|
|
@ -12,8 +12,8 @@ const store = new Vuex.Store({
|
||||||
modules: {
|
modules: {
|
||||||
app,
|
app,
|
||||||
settings,
|
settings,
|
||||||
sample
|
sample,
|
||||||
// user
|
user
|
||||||
},
|
},
|
||||||
getters
|
getters
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
const user = {
|
||||||
|
state: {
|
||||||
|
name: ''
|
||||||
|
},
|
||||||
|
|
||||||
|
mutations: {
|
||||||
|
SET_NAME: (state, name) => {
|
||||||
|
state.name = name
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default user
|
||||||
|
|
@ -53,11 +53,12 @@ service.interceptors.response.use(
|
||||||
message: res.errorMsg,
|
message: res.errorMsg,
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
})
|
})
|
||||||
|
sessionStorage.setItem('userName', '')
|
||||||
} else if (res.errorCode === 0) {
|
} else if (res.errorCode === 0) {
|
||||||
return res
|
return res
|
||||||
} else {
|
} else {
|
||||||
Message({
|
Message({
|
||||||
message: '系统错误',
|
message: res.errorMsg,
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ export default {
|
||||||
loginCode: '1234'
|
loginCode: '1234'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onLogin() {
|
onLogin() {
|
||||||
if (!this.loginName) return this.$message.warning('请输入用户名')
|
if (!this.loginName) return this.$message.warning('请输入用户名')
|
||||||
|
|
@ -67,6 +69,8 @@ export default {
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.$router.back()
|
this.$router.back()
|
||||||
|
this.$store.commit('SET_NAME', this.loginName)
|
||||||
|
sessionStorage.setItem('userName', this.loginName)
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.errorMsg)
|
this.$message.error(res.errorMsg)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue