chenxr3 преди 4 години
родител
ревизия
d40d1f8f85

+ 42 - 24
ebc-middle-platform/src/components/loginer.vue

@ -145,31 +145,49 @@ export default {
145 145
      this.loging = true
146 146
      this.$refs.loginForm.validate((valid) => {
147 147
        if (valid) {
148
          this.$test
149
            .post(services.login.LOGIN, {userCode: this.loginForm.userName, passWord: this.loginForm.password})
150
            .then((data) => {
151
              if (data.FLAG === 'SUCCESS') {
152
                if (this.rememberMe) {
153
                  localStorage.setItem(KEY_USER_NAME, data.RESULT.CODE)
154
                } else {
155
                  localStorage.removeItem(KEY_USER_NAME)
156
                }
148
          this.doLogin({userCode: this.loginForm.userName, passWord: this.loginForm.password}).then((data) => {
149
            this.$store.commit('setLogged', true)
150
            if (this.rememberMe) {
151
              localStorage.setItem(KEY_USER_NAME, data.userName)
152
            } else {
153
              localStorage.removeItem(KEY_USER_NAME)
154
            }
155
            const roles = {
156
              permissionList: ['exception']
157
            }
158
            this.$test
159
              .post(services.login.FIND_MENUS, {userCode: data.RESULT.CODE})
160
              .then((data) => {
157 161
158
                const roles = {
159
                  permissionList: ['exception']
160
                }
161
                this.$test
162
                  .post(services.login.FIND_MENUS, {userCode: data.RESULT.CODE})
163
                  .then((data) => {
164
                    localStorage.setItem('menus',  JSON.stringify(data))
165
                    store.dispatch(`permission/${GENERATE_ROUTES}`, roles)
166
                  })
167
                this.$router.push({ name: this.homeName })
168
              } else {
169
                this.$Message.danger(data.MESSAGE)
170
              }
171
              this.loging = false
172
            })
162
                localStorage.setItem('menus',  JSON.stringify(data))
163
                store.dispatch(`permission/${GENERATE_ROUTES}`, roles)
164
              })
165
            this.$router.push({ name: this.homeName })
166
          }).catch((e) => {
167
            this.loging = false
168
            this.$Message.danger(e)
169
          })
170
171
172
173
174
          // this.$test
175
          //   .post(services.login.LOGIN, )
176
          //   .then((data) => {
177
          //     if (data.FLAG === 'SUCCESS') {
178
          //       if (this.rememberMe) {
179
          //         localStorage.setItem(KEY_USER_NAME, data.RESULT.CODE)
180
          //       } else {
181
          //         localStorage.removeItem(KEY_USER_NAME)
182
          //       }
183
          //
184
          //
185
          //       this.$router.push({ name: this.homeName })
186
          //     } else {
187
          //       this.$Message.danger(data.MESSAGE)
188
          //     }
189
          //     this.loging = false
190
          //   })
173 191
        } else {
174 192
          this.loging = false
175 193
          this.$Message.danger(this.$t('aidp.common.input_incorrect', { field: this.$t('aidp.account.username') + this.$t('aidp.common.or') + this.$t('aidp.account.password') }))

+ 5 - 4
ebc-middle-platform/src/modules/ootb/user/store/actions.js

@ -7,6 +7,7 @@ import {
7 7
} from './constants'
8 8
9 9
import { KEY_USER_CODE, KEY_TOKEN } from '@/constants'
10
import services from "../../../../conf/services";
10 11
11 12
/**
12 13
 * 用户登录
@ -17,11 +18,11 @@ import { KEY_USER_CODE, KEY_TOKEN } from '@/constants'
17 18
 */
18 19
export function doLogin({ commit, state }, data) {
19 20
  return new Promise((resolve, reject) => {
20
    http.$http
21
      .post(Services.aidp.LOGIN, data)
21
    http.$test
22
      .post(Services.login.LOGIN, data)
22 23
      .then(ret => {
23
        if (ret.data.code === '0') {
24
          let payload = ret.data.data
24
        if (ret.FLAG === 'SUCCESS') {
25
          let payload = ret
25 26
          commit(LOGIN, payload)
26 27
          window.localStorage.setItem(KEY_USER_CODE, state.userCode)
27 28
          window.localStorage.setItem(KEY_TOKEN, state.token)

+ 3 - 1
ebc-middle-platform/src/router.js

@ -23,6 +23,7 @@ const router = new VueRouter({
23 23
})
24 24
25 25
router.beforeEach((to, from, next) => {
26
  console.log(to, from, next)
26 27
  GLoading.$create().start()
27 28
  /*
28 29
   * 在每次视图切换时检查当前用户是否处于登
@ -36,7 +37,8 @@ router.beforeEach((to, from, next) => {
36 37
   * 单客户端判断。
37 38
   * 参见src/frame.vue和src/store.js文件中的逻辑。
38 39
   */
39
  let isLogged = router.app.$options.store.getters['user/isLogged']
40
  let isLogged = router.app.$options.store.getters.getLogged
41
  // let isLogged = router.app.$options.store.getters['user/isLogged']
40 42
  // router.app.$store.commit('setTitle', to.meta.title)
41 43
  if (to.meta.ignoreAuth === true) {
42 44
    if (isLogged === true && to.path === '/login') {

+ 15 - 1
ebc-middle-platform/src/store.js

@ -62,7 +62,9 @@ const store = new Vuex.Store({
62 62
    map_param: {
63 63
      center: [33.597844, 123.647472],
64 64
      zoom: 11
65
    }
65
    },
66
    reLoad: false,
67
    isLogged: false
66 68
  },
67 69
  mutations: {
68 70
    // 改变语言
@ -87,6 +89,12 @@ const store = new Vuex.Store({
87 89
    },
88 90
    setMapParam(state, token) {
89 91
      state.map_param = token
92
    },
93
    setReLoad(state, token) {
94
      state.reLoad = token
95
    },
96
    setLogged(state, token) {
97
      state.isLogged = token
90 98
    }
91 99
  },
92 100
  getters: {
@ -118,6 +126,12 @@ const store = new Vuex.Store({
118 126
    },
119 127
    getMapParam(state) {
120 128
      return state.map_param
129
    },
130
    getReLoad(state) {
131
      return state.reLoad
132
    },
133
    getLogged(state) {
134
      return state.isLogged
121 135
    }
122 136
  },
123 137
  modules: {