|
|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import router from './router'
|
|
|
|
|
import store from './store'
|
|
|
|
|
import { Message } from 'element-ui'
|
|
|
|
|
import { Message, MessageBox } from 'element-ui'
|
|
|
|
|
import NProgress from 'nprogress' // progress bar
|
|
|
|
|
import 'nprogress/nprogress.css' // progress bar style
|
|
|
|
|
import {getToken, setToken} from '@/utils/auth' // get token from cookie
|
|
|
|
|
@ -17,28 +17,61 @@ router.beforeEach(async(to, from, next) => {
|
|
|
|
|
|
|
|
|
|
// set page title
|
|
|
|
|
document.title = getPageTitle(to.meta.title)
|
|
|
|
|
|
|
|
|
|
console.log(to.path)
|
|
|
|
|
//osslogin
|
|
|
|
|
if (/^\/oss_login.*/.test(to.path)) {
|
|
|
|
|
if (/\/oss_login.*/g.test(to.path)) {
|
|
|
|
|
if (to.query.token) {
|
|
|
|
|
const ossRes= await ossLogin({
|
|
|
|
|
const ossRes = await ossLogin({
|
|
|
|
|
oss_token: to.query.token
|
|
|
|
|
})
|
|
|
|
|
setToken(ossRes.user.bianma,"difficult_employee_token_h5")
|
|
|
|
|
next({
|
|
|
|
|
path: "/h5",
|
|
|
|
|
replace: true
|
|
|
|
|
})
|
|
|
|
|
if (ossRes.admin?.token && ossRes.user?.user?.bianma) {
|
|
|
|
|
try {
|
|
|
|
|
await MessageBox.confirm('选择入口方式','提示',{
|
|
|
|
|
confirmButtonText: '进入前台',
|
|
|
|
|
cancelButtonText: '进入后台',
|
|
|
|
|
type: "warning",
|
|
|
|
|
showClose: false,
|
|
|
|
|
closeOnClickModal: false
|
|
|
|
|
})
|
|
|
|
|
setToken(ossRes.user.user.bianma,"difficult_employee_token_h5")
|
|
|
|
|
next({
|
|
|
|
|
path: "/h5",
|
|
|
|
|
replace: true
|
|
|
|
|
})
|
|
|
|
|
} catch (err) {
|
|
|
|
|
store.commit('user/SET_TOKEN', ossRes.admin.token)
|
|
|
|
|
setToken(ossRes.admin.token,"difficult_employee_token")
|
|
|
|
|
next({
|
|
|
|
|
path: "/",
|
|
|
|
|
replace: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
} else if (ossRes.user?.user?.bianma) {
|
|
|
|
|
setToken(ossRes.user.user.bianma,"difficult_employee_token_h5")
|
|
|
|
|
next({
|
|
|
|
|
path: "/h5",
|
|
|
|
|
replace: true
|
|
|
|
|
})
|
|
|
|
|
} else if (ossRes.admin?.token) {
|
|
|
|
|
store.commit('user/SET_TOKEN', ossRes.admin.token)
|
|
|
|
|
setToken(ossRes.admin.token,"difficult_employee_token")
|
|
|
|
|
next({
|
|
|
|
|
path: "/",
|
|
|
|
|
replace: true
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// determine whether the user has logged in
|
|
|
|
|
let hasToken = getToken()
|
|
|
|
|
if (/^\/h5.*/.test(to.path)) {
|
|
|
|
|
let hasToken;
|
|
|
|
|
if (/\/h5.*/g.test(to.path)) {
|
|
|
|
|
hasToken = getToken("difficult_employee_token_h5")
|
|
|
|
|
} else {
|
|
|
|
|
hasToken = getToken()
|
|
|
|
|
hasToken = getToken("difficult_employee_token")
|
|
|
|
|
}
|
|
|
|
|
console.log(hasToken)
|
|
|
|
|
|
|
|
|
|
|