lsc 3 days ago
parent
commit
c391358828
4 changed files with 37 additions and 8 deletions
  1. 0 0
      dist/index.html
  2. 1 1
      dist/report.html
  3. 0 0
      dist/static/js/app.2ab3f0d3.js
  4. 36 7
      src/permission.js

File diff suppressed because it is too large
+ 0 - 0
dist/index.html


File diff suppressed because it is too large
+ 1 - 1
dist/report.html


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.2ab3f0d3.js


+ 36 - 7
src/permission.js

@@ -19,12 +19,14 @@ router.beforeEach(async(to, from, next) => {
   // determine whether the user has logged in
   // const hasToken = getToken()
   const hasToken = store.getters.id || getToken()
-  const isWeChat = Cookies.get('isWeChat')
+  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 =
@@ -32,15 +34,38 @@ 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) {
     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'){
-        next({ path: '/' })
-      }else {
+      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: '/' })
+        }
+      } else {
         next('/appStoreCopy')
       }
       NProgress.done()
@@ -64,11 +89,15 @@ router.beforeEach(async(to, from, next) => {
           await store.commit('SET_SHARECOURSEID', '')
           // // 根据角色生成可访问的路线图
           if (courseId) {
-            next({ ...to, query: { courseid: courseId }, replace: true })
+            next({ ...to, query: { courseid: courseId, userid: hasToken }, replace: true })
           } else if (testId) {
-            next({ ...to, query: { courseid: testId }, replace: true })
+            next({ ...to, query: { courseid: testId, userid: hasToken }, replace: true })
           } else if (shareCourseId) {
-            next({ path: '/courseDetail', query: { courseid: shareCourseId, urlType: 1 }, replace: true })
+            next({
+              path: '/courseDetail',
+              query: { courseid: shareCourseId, urlType: 1, userid: hasToken },
+              replace: true
+            })
           } else {
             next({ ...to, replace: true })
           }

Some files were not shown because too many files changed in this diff