Ver Fonte

sso单点跳转更改

黄梓星 há 2 anos atrás
pai
commit
0a713aac51
1 ficheiros alterados com 17 adições e 4 exclusões
  1. 17 4
      src/views/test01.vue

+ 17 - 4
src/views/test01.vue

@@ -11,17 +11,23 @@ import { getToken, setToken, removeToken } from '@/utils/auth'
 import { sso } from '@/api/sso/ssoLogin';
 export default {
   data () {
-    return {}
+    return {
+    }
   },
   created() {
-    this.jump()
   },
   mounted() {
+    this.$nextTick(() => {
+      this.jump()
+    })
   },
   methods: {
     jump() {
       let userInfo = JSON.parse(localStorage.getItem('userInfo'))
       // console.log('拿到userInfo了不:', userInfo)
+      // console.log('路径拿到了不:', this.GetQueryString('path'))
+      var jumpPath = this.GetQueryString('path')
+      console.log('jumpPath', jumpPath)
       // axios.post('https://test-sy.derom.com/drp-admin/login/sso', userInfo).then(res => {
       sso(userInfo).then(res => {
         if (res.code === 200) {
@@ -29,10 +35,17 @@ export default {
           setToken(token)
           this.$store.commit('SET_TOKEN', token)
           this.$store.dispatch("GetInfo").then(() => {})
-          this.$store.dispatch("GenerateRoutes").then(() => {})
-          this.$router.push({ path: "/system/user" })
+          this.$store.dispatch("GenerateRoutes").then(
+            this.$router.push({ path: jumpPath }).catch(()=>{})
+          )
+          // this.$router.push({ path: "/" })
         }
       })
+    },
+    GetQueryString(name) {
+      var  reg = new  RegExp( "(^|&)" + name + "=([^&]*)(&|$)" );
+      var  r = window.location.search.substr(1).match(reg);
+      if (r!= null ) return   unescape(r[2]); return  null ;
     }
   }
 }