49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
import { getDepList } from '@/api/report'
|
|
import { apiUserInfo } from '@/api/login'
|
|
import * as dd from 'dingtalk-jsapi'
|
|
const user = {
|
|
state: {
|
|
deplist: [],
|
|
info: dd.other ? (JSON.parse(localStorage.getItem('info')) || {}) : {},
|
|
auth: JSON.parse(localStorage.getItem('auth')) || {}
|
|
|
|
},
|
|
mutations: {
|
|
SET_USER_INFO: (state, info) => {
|
|
dd.other && localStorage.setItem('info', JSON.stringify(info))
|
|
state.info = info
|
|
console.log('state.info: ', state.info)
|
|
},
|
|
SET_USER_AUTH: (state, auth) => {
|
|
dd.other && localStorage.setItem('auth', JSON.stringify(auth))
|
|
state.auth = auth
|
|
console.log('state.auth: ', state.auth)
|
|
},
|
|
SET_DEPLIST: (state, list = []) => {
|
|
state.deplist = list
|
|
}
|
|
|
|
},
|
|
actions: {
|
|
GET_USERINFO: async ({ commit }) => {
|
|
let res = await apiUserInfo()
|
|
console.log('GET_USERINFO: ', res)
|
|
if (res.code === 200) {
|
|
commit('SET_USER_INFO', res.user)
|
|
commit('SET_USER_AUTH', res.data)
|
|
return 1
|
|
} else {
|
|
this.$message.error(res.msg0)
|
|
return 0
|
|
}
|
|
},
|
|
GET_DEPLIST: async ({ commit }) => {
|
|
let data = await getDepList({type: 1})
|
|
commit('SET_DEPLIST', data.code === 200 ? data.data : [])
|
|
return data
|
|
}
|
|
}
|
|
}
|
|
|
|
export default user
|