Explorar el Código

test01页面做测试环境单点登录功能

黄梓星 hace 2 años
padre
commit
b622d8d6f9
Se han modificado 1 ficheros con 15 adiciones y 12 borrados
  1. 15 12
      src/views/test01.vue

+ 15 - 12
src/views/test01.vue

@@ -1,31 +1,34 @@
 <template>
   <div id="test01">
     <!-- test01 -->
-    <p>{{ cookies.name }}</p>
-    <p>{{ cookies.value }}</p>
   </div>
 </template>
 
 <script>
 import axios from 'axios'
+import { getToken, setToken, removeToken } from '@/utils/auth'
 export default {
   data () {
-    return {
-      cookies: {}
-    }
+    return {}
   },
   created() {
-    axios.get('https://test-sy.derom.com/ruoyi-admin/login/getCookie').then(res => {
-      if (res.data.code === 200) {
-        let arr = res.data.cookies
-        this.cookies = arr.find(item => item.name == 'yonyou_uid')
-      }
-    })
+    this.jump()
   },
   mounted() {
   },
   methods: {
-
+    jump() {
+      axios.post('https://test-sy.derom.com/ruoyi-admin/login/sso').then(res => {
+        if (res.data.code === 200) {
+          let token = res.data.token
+          setToken(token)
+          this.$store.commit('SET_TOKEN', token)
+          this.$store.dispatch("GetInfo").then(() => {})
+          this.$store.dispatch("GenerateRoutes").then(() => {})
+          this.$router.push({ path: "/system/user" })
+        }
+      })
+    }
   }
 }
 </script>