chenxr3 4 anni fa
parent
commit
d40d1f8f85

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

145
      this.loging = true
145
      this.loging = true
146
      this.$refs.loginForm.validate((valid) => {
146
      this.$refs.loginForm.validate((valid) => {
147
        if (valid) {
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
        } else {
191
        } else {
174
          this.loging = false
192
          this.loging = false
175
          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') }))
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
} from './constants'
7
} from './constants'
8
8
9
import { KEY_USER_CODE, KEY_TOKEN } from '@/constants'
9
import { KEY_USER_CODE, KEY_TOKEN } from '@/constants'
10
import services from "../../../../conf/services";
10
11
11
/**
12
/**
12
 * 用户登录
13
 * 用户登录
17
 */
18
 */
18
export function doLogin({ commit, state }, data) {
19
export function doLogin({ commit, state }, data) {
19
  return new Promise((resolve, reject) => {
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
      .then(ret => {
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
          commit(LOGIN, payload)
26
          commit(LOGIN, payload)
26
          window.localStorage.setItem(KEY_USER_CODE, state.userCode)
27
          window.localStorage.setItem(KEY_USER_CODE, state.userCode)
27
          window.localStorage.setItem(KEY_TOKEN, state.token)
28
          window.localStorage.setItem(KEY_TOKEN, state.token)

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

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

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

62
    map_param: {
62
    map_param: {
63
      center: [33.597844, 123.647472],
63
      center: [33.597844, 123.647472],
64
      zoom: 11
64
      zoom: 11
65
    }
65
    },
66
    reLoad: false,
67
    isLogged: false
66
  },
68
  },
67
  mutations: {
69
  mutations: {
68
    // 改变语言
70
    // 改变语言
87
    },
89
    },
88
    setMapParam(state, token) {
90
    setMapParam(state, token) {
89
      state.map_param = token
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
  getters: {
100
  getters: {
118
    },
126
    },
119
    getMapParam(state) {
127
    getMapParam(state) {
120
      return state.map_param
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
  modules: {
137
  modules: {