|
@@ -23,11 +23,9 @@ router.beforeEach(async(to, from, next) => {
|
|
|
let isWeChat = Cookies.get('isWeChat')
|
|
|
if (to.query.courseid !== '' && to.query.courseid !== undefined) {
|
|
|
console.log(to.query.courseid)
|
|
|
- isWeChat = '1'
|
|
|
await store.commit('SET_COURSEID', to.query.courseid)
|
|
|
}
|
|
|
if (to.query.testid !== '' && to.query.testid !== undefined) {
|
|
|
- isWeChat = '1'
|
|
|
await store.commit('SET_TESTID', to.query.testid)
|
|
|
}
|
|
|
const shareCourseId =
|
|
@@ -35,38 +33,14 @@ router.beforeEach(async(to, from, next) => {
|
|
|
? window.location.href.split('?shareCourseId=')[1].toString()
|
|
|
: ''
|
|
|
if (shareCourseId) {
|
|
|
- isWeChat = '1'
|
|
|
await store.commit('SET_SHARECOURSEID', shareCourseId)
|
|
|
}
|
|
|
if (hasToken) {
|
|
|
await store.commit('user/SET_ID', hasToken)
|
|
|
if (to.path === '/login' || to.path === '/login2') {
|
|
|
// if is logged in, redirect to the home page
|
|
|
- store.commit('user/SET_ID', hasToken)
|
|
|
if (isWeChat === '1') {
|
|
|
- const courseId = store.getters.courseId
|
|
|
- const testId = store.getters.testId
|
|
|
- const shareCourseId = store.getters.shareCourseId
|
|
|
- await store.commit('SET_TESTID', '')
|
|
|
- await store.commit('SET_COURSEID', '')
|
|
|
- await store.commit('SET_SHARECOURSEID', '')
|
|
|
- if (courseId) {
|
|
|
- next({
|
|
|
- path: '/courseDetail',
|
|
|
- query: { courseid: courseId, userid: hasToken },
|
|
|
- replace: true
|
|
|
- })
|
|
|
- } else if (testId) {
|
|
|
- next({ path: '/testDetail', query: { courseid: testId, userid: hasToken }, replace: true })
|
|
|
- } else if (shareCourseId) {
|
|
|
- next({
|
|
|
- path: '/courseDetail',
|
|
|
- query: { courseid: shareCourseId, urlType: 1, userid: hasToken },
|
|
|
- replace: true
|
|
|
- })
|
|
|
- } else {
|
|
|
- next({ path: '/' })
|
|
|
- }
|
|
|
+ next({ path: '/' })
|
|
|
} else {
|
|
|
next('/appStoreCopy')
|
|
|
}
|
|
@@ -78,7 +52,11 @@ router.beforeEach(async(to, from, next) => {
|
|
|
// console.log('to', {...to} )
|
|
|
if (userinfo) {
|
|
|
console.log(store)
|
|
|
- next()
|
|
|
+ if (isWeChat === '1') {
|
|
|
+ next()
|
|
|
+ } else {
|
|
|
+ next('/appStoreCopy')
|
|
|
+ }
|
|
|
} else {
|
|
|
try {
|
|
|
// 获取用户信息
|