142 lines
3.3 KiB
JavaScript
142 lines
3.3 KiB
JavaScript
import Vue from 'vue'
|
|
import Router from 'vue-router'
|
|
import Index from '@/views/index/Index.vue'
|
|
// 导航
|
|
import Nav from '@/components/nav/Nav.vue'
|
|
// 页脚信息
|
|
import FooterInfor from '@/components/footerInfor/FooterInfor.vue'
|
|
// 公司介绍
|
|
import CmpanyIntroduction from '@/views/companyIntroduction/CompanyIntroduction.vue'
|
|
// 联系我们
|
|
import Relation from '@/views/relation/Relation.vue'
|
|
// 个人中心
|
|
import PersonalCenter from '@/views/personalCenter/PersonalCenter.vue'
|
|
// 帮助
|
|
import Help from '@/views/help/Help.vue'
|
|
// 注册
|
|
import Register from '@/views/register/Register.vue'
|
|
// 用户协议
|
|
import UserAgreement from '@/views/userAgreement/UserAgreement.vue'
|
|
// 数据列表
|
|
import DataList from '@/views/dataList/DataList.vue'
|
|
// 数据列表详情
|
|
import ListDetails from '@/views/listDetails/ListDetails.vue'
|
|
// 搜索列表
|
|
import SearchList from '@/views/searchList/SearchList.vue'
|
|
// 数据
|
|
import Datasweb from '@/views/datasweb/Datasweb.vue'
|
|
// 引入测试
|
|
import cs from '@/views/cs.vue'
|
|
|
|
Vue.use(Router)
|
|
|
|
let RouterObj = new Router({
|
|
mode: 'history',
|
|
base: process.env.BASE_URL,
|
|
routes: [{
|
|
path: '/',
|
|
name: 'index',
|
|
component: Index
|
|
},
|
|
{
|
|
path: '/nav',
|
|
name: 'nav',
|
|
component: Nav
|
|
},
|
|
{
|
|
path: '/footerInfor',
|
|
name: 'footerInfor',
|
|
component: FooterInfor
|
|
},
|
|
{
|
|
path: '/companyIntroduction',
|
|
name: 'companyIntroduction',
|
|
component: CmpanyIntroduction
|
|
},
|
|
{
|
|
path: '/relation',
|
|
name: 'relation',
|
|
component: Relation
|
|
},
|
|
{
|
|
path: '/personalCenter',
|
|
name: 'personalCenter',
|
|
component: PersonalCenter
|
|
},
|
|
{
|
|
path: '/help',
|
|
name: 'help',
|
|
component: Help
|
|
},
|
|
{
|
|
path: '/register',
|
|
name: 'register',
|
|
component: Register
|
|
},
|
|
{
|
|
path: '/userAgreement',
|
|
name: 'userAgreement',
|
|
component: UserAgreement
|
|
},
|
|
{
|
|
path: '/dataList',
|
|
name: 'dataList',
|
|
component: DataList
|
|
},
|
|
{
|
|
path: '/listDetails',
|
|
name: 'listDetails',
|
|
component: ListDetails
|
|
},
|
|
{
|
|
path: '/searchList',
|
|
name: 'searchList',
|
|
component: SearchList
|
|
},
|
|
{
|
|
path: '/datasweb',
|
|
name: 'datasweb',
|
|
component: Datasweb
|
|
},
|
|
{
|
|
path: '/cs',
|
|
name: 'cs',
|
|
component: cs
|
|
}
|
|
]
|
|
})
|
|
RouterObj.beforeEach((to, from, next) => {
|
|
console.log(to, 'to')
|
|
console.log(from, 'from')
|
|
if (to.name === 'personalCenter' || to.name === 'datasweb') {
|
|
console.log(sessionStorage.getItem('token'), 'sessionStorage.getItem()')
|
|
if (!sessionStorage.getItem('token')) {
|
|
// alert('您没有该账号的登陆权限,请重新登录后再次操作!')
|
|
Vue.prototype.$alert('您没有该账号的登陆权限,请重新登录后再次操作!', '温馨提示', {
|
|
confirmButtonText: '确定',
|
|
callback: res => {
|
|
console.log(Vue.prototype.$auth, 'Vue.prototype.$auth')
|
|
Vue.prototype.$auth.auth = true
|
|
console.log(Vue.prototype.$auth, 'Vue.prototype.$auth')
|
|
if (from.name !== 'index') {
|
|
next({
|
|
name: 'index',
|
|
params: {
|
|
type: 'loginTrue'
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
// 权限通过时赋值
|
|
// sessionStorage.clear()
|
|
// window.location.reload()
|
|
} else {
|
|
next()
|
|
}
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
export default RouterObj
|