|
@@ -1,7 +1,7 @@
|
|
|
import { login, loginUp } from '@/api/newLogin'
|
|
|
import { getToken, setToken, removeToken, setUserId, TokenKey } from '@/utils/auth'
|
|
|
import { resetRouter } from '@/router'
|
|
|
-
|
|
|
+import { Query } from '@/api/dataIntegration'
|
|
|
const getDefaultState = () => {
|
|
|
return {
|
|
|
token: getToken(),
|
|
@@ -58,9 +58,10 @@ const actions = {
|
|
|
commit('SET_TOKEN', token)
|
|
|
commit('SET_UserType', 1)
|
|
|
commit('SET_UserId', userid)
|
|
|
- sessionStorage.setItem("userName", userInfo.username);
|
|
|
+ setToken("userName", userInfo.username);
|
|
|
setToken(TokenKey, token)
|
|
|
setUserId(userid)
|
|
|
+ setToken('userid', userid)
|
|
|
// let nowDate = new Date();
|
|
|
// let oldDate = new Date(date);
|
|
|
// let diffTime = oldDate - nowDate;
|
|
@@ -77,21 +78,65 @@ const actions = {
|
|
|
// get user info
|
|
|
getInfo ({ commit, state }) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
-
|
|
|
- let data = {
|
|
|
- roles: state.userPoewrList,
|
|
|
- introduction: '',
|
|
|
- avatar: '',
|
|
|
- name: sessionStorage.getItem("userName"),
|
|
|
- token: state.token
|
|
|
- }
|
|
|
-
|
|
|
- const { name, avatar, roles } = data
|
|
|
-
|
|
|
- commit('SET_NAME', name)
|
|
|
- commit('SET_AVATAR', avatar)
|
|
|
- commit('SET_ROLES', roles ? roles : ['admin'])
|
|
|
- resolve(data)
|
|
|
+ Query({
|
|
|
+ id: DATACONTENT_ID.loginId,
|
|
|
+ dataContent: [getToken('userid')]
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 0) {
|
|
|
+ const { listValues } = res.returnData
|
|
|
+ const datas = listValues
|
|
|
+ if (datas && datas.length) {
|
|
|
+ const arrs = [];
|
|
|
+ for (const item of datas) {
|
|
|
+ if (item.ident) {
|
|
|
+ arrs.push(item.ident);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // arrs.push('transit');
|
|
|
+ sessionStorage.setItem('userAuthList', JSON.stringify(arrs));
|
|
|
+ setTimeout(() => {
|
|
|
+ const data = {
|
|
|
+ roles: arrs,
|
|
|
+ introduction: '',
|
|
|
+ avatar: '',
|
|
|
+ name: getToken("userName"),
|
|
|
+ token: state.token
|
|
|
+ }
|
|
|
+
|
|
|
+ const { name, avatar, roles } = data
|
|
|
+
|
|
|
+ commit('SET_NAME', name)
|
|
|
+ commit('SET_AVATAR', avatar)
|
|
|
+ commit('SET_ROLES', roles ? roles : ['admin'])
|
|
|
+ commit('SET_UserPoewrList', roles ? roles : ['admin'])
|
|
|
+ resolve(data)
|
|
|
+ }, 100);
|
|
|
+ } else {
|
|
|
+ sessionStorage.setItem('userAuthList', []);
|
|
|
+ setTimeout(() => {
|
|
|
+ const data = {
|
|
|
+ roles: state.userPoewrList,
|
|
|
+ introduction: '',
|
|
|
+ avatar: '',
|
|
|
+ name: getToken("userName"),
|
|
|
+ token: state.token
|
|
|
+ }
|
|
|
+
|
|
|
+ const { name, avatar, roles } = data
|
|
|
+
|
|
|
+ commit('SET_NAME', name)
|
|
|
+ commit('SET_AVATAR', avatar)
|
|
|
+ commit('SET_ROLES', roles ? roles : ['admin'])
|
|
|
+ commit('SET_UserPoewrList', roles ? roles : ['admin'])
|
|
|
+ resolve(data)
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ reject(res.returnData)
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ reject(err)
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -106,6 +151,7 @@ const actions = {
|
|
|
removeToken(); // must remove token first
|
|
|
removeToken('codeToken');
|
|
|
removeToken('systemSet');
|
|
|
+ removeToken('userid');
|
|
|
resetRouter();
|
|
|
commit('RESET_STATE');
|
|
|
commit('SET_ROLES', [])
|