LAPTOP-FO2T5SIU\35838 6 月之前
父节点
当前提交
041aceed8a
共有 3 个文件被更改,包括 62 次插入20 次删除
  1. 6 5
      src/router/index.js
  2. 37 1
      src/store/modules/user.js
  3. 19 14
      src/views/singleLogin/ssoLogin.vue

+ 6 - 5
src/router/index.js

@@ -355,6 +355,11 @@ export const constantRoutes = [
                 component: () => import('@/views/workbench/index'),
                 hidden: true
             },
+            {
+                path: '/workflow/myProcess',
+                component: () => import('@/views/workflow/myProcess.vue'),
+                hidden: true
+            }
         ]
     },
 
@@ -398,11 +403,7 @@ export const constantRoutes = [
         component: () => import('@/views/life-line/components/mapCharts/mapEchartsNew.vue'),
         hidden: false
     },
-    {
-        path: '/workflow/myProcess',
-        component: () => import('@/views/workflow/myProcess.vue'),
-        hidden: true
-    }
+
 
 ]
 

+ 37 - 1
src/store/modules/user.js

@@ -150,7 +150,43 @@ const actions = {
             removeToken()
             resolve()
         })
-    }
+    },
+    ssoLogin({ commit }, userInfo) {
+        const { username, password, validateCode, captchaId, url, controller } = userInfo
+        return new Promise((resolve, reject) => {
+            const postData = {
+                username: username,
+                password: password,
+                code: validateCode,
+                rememberMe: true
+            }
+            if (captchaId) {
+                postData.captchaId = captchaId
+            }
+            channel.baseRequest(controller || 'pub', url, postData, 'loginSecret').then((res) => {
+                if (res.data[constant.KEY_RESULT]) {
+                    const { data } = res
+                    const user = data[constant.KEY_USER]
+                    const biz = data[constant.KEY_BIZ]
+                    // console.log('login data', data)
+                    common.setUser(user)
+                    common.setBiz(biz)
+                    common.setUserType(data[constant.KEY_USER_TYPE])
+                    if (user && user.isInit === '1') {
+                        commit('SET_TOKEN', data[constant.KEY_TOKEN])
+                        setToken(data[constant.KEY_TOKEN])
+                        common.setMenu(data[constant.KEY_USER_MENU])
+                    } else {
+                        reject({ isInit: '0' })
+                    }
+                }
+                resolve(res.data)
+            }).catch((err, x) => {
+                reject(err)
+                // console.log('store/user/action/login/login/err', err, x)
+            })
+        })
+    },
 }
 
 export default {

+ 19 - 14
src/views/singleLogin/ssoLogin.vue

@@ -16,10 +16,10 @@ export default {
     },
     watch: {},
     created() {
-        alert(this.$route.query)
-        console.log('this.$route', this.$route)
+        // console.log('this.$route', this.$route)
+        // console.log('window.location.href', window.location.href)
         // 第三方平台登录
-        // this.getLoginByToken()
+        this.getLoginByToken()
     },
     methods: {
         // 第三方平台单点登录系统
@@ -35,19 +35,24 @@ export default {
             } else {
                 // 免密登录
                 const postForm = {
-                    url: 'login',
-                    code: '1',
-                    userName: token.loginid
+                    url: 'loginSecret',
+                    username: token.loginid,
+                    password: '',
+                    validateCode: ''
                 }
-                this.baseRequest('loginSecret', postForm).then((res) => {
-                    if (res.result) {
-                        this.$router.push({ path: '/backstage?menuIndex=1281203683157082112' })
-                    } else {
-                        this.$message(res.msg)
-                    }
-                }).catch((e) => {
+                this.$store
+                    .dispatch('user/ssoLogin', postForm)
+                    .then((res) => {
+                        if (res.result) {
+                            this.$router.push({ path: '/workbench' })
+                        } else {
+                            this.$message(res.msg)
+                            this.$router.push({ path: '/login' }).catch(() => {})
+                        }
+                    }).catch((e) => {
+                        this.$router.push({ path: '/login' }).catch(() => {})
                     // console.log(e)
-                })
+                    })
             }
         },
         baseRequest(opUrl, postData) {