Explorar el Código

未保山东通

chengxiaowen hace 1 año
padre
commit
e32260758c
Se han modificado 2 ficheros con 27 adiciones y 2 borrados
  1. 7 0
      src/api/index.js
  2. 20 2
      src/views/weibao/views/login/index.vue

+ 7 - 0
src/api/index.js

@@ -6,4 +6,11 @@ export function loginApp(data) {
         encrypt:true,
         encrypt:true,
         data
         data
     })
     })
+}
+export function getSsoUser(data) {
+  return encryptRequest({
+      url: '/pmadmin/mini/employee/loginAppSdt',
+      method: 'post',
+      data
+  })
 }
 }

+ 20 - 2
src/views/weibao/views/login/index.vue

@@ -18,7 +18,7 @@
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
-import { loginApp } from '../../../../api/index.js'
+import { loginApp, getSsoUser } from '../../../../api/index.js'
 export default {
 export default {
   components: {},
   components: {},
   name: 'Login',
   name: 'Login',
@@ -30,7 +30,25 @@ export default {
       hiddenBottom:false
       hiddenBottom:false
     }
     }
   },
   },
-  created() {},
+  created() {
+    var href = window.location.href
+    var idx = href.indexOf('code')
+    if (idx >= 0) {
+      const _this = this
+      var idx2 = href.indexOf("#")
+      var account = href.substring(idx + 'code'.length + 1, idx2)
+      getSsoUser({id:account})
+        .then(res => {
+          sessionStorage.setItem('userInfo', JSON.stringify(res.data))
+          sessionStorage.setItem('x-token', res.data.jwtToken)
+          _this.$router.replace('/home')
+        })
+        .catch(error => {
+          alert('登录失败')
+          console.log(error)
+        })
+    }
+  },
   methods: {
   methods: {
     focusOn() {
     focusOn() {
         this.hiddenBottom = true
         this.hiddenBottom = true