|
|
|
@ -1,11 +1,12 @@
|
|
|
|
|
import { login, logout, getInfo, refreshToken } from '@/api/login'
|
|
|
|
|
import { getToken, setToken, removeToken, setExpiresIn, getClientToken, setClientToken, removeClientToken } from '@/utils/auth'
|
|
|
|
|
import { singleSigngetInfo, enterpriseLogout } from "@/api/jin_ji_hu/login"
|
|
|
|
|
import { getToken, setToken, removeToken, setExpiresIn, getClientToken, setClientToken, removeClientToken, getUSerToken, setUserToken, removeUSerToken } from '@/utils/auth'
|
|
|
|
|
import { singleSigngetInfo, enterpriseLogout, governmentGetInfo } from "@/api/jin_ji_hu/login"
|
|
|
|
|
|
|
|
|
|
const user = {
|
|
|
|
|
state: {
|
|
|
|
|
token: getToken(),
|
|
|
|
|
clientToken: getClientToken(),
|
|
|
|
|
userToken: getUSerToken(),
|
|
|
|
|
id: '',
|
|
|
|
|
name: '',
|
|
|
|
|
avatar: '',
|
|
|
|
@ -25,6 +26,9 @@ const user = {
|
|
|
|
|
SET_CLIENTTOKEN: (state, token) => {
|
|
|
|
|
state.clientToken = token
|
|
|
|
|
},
|
|
|
|
|
SET_USERTOKEN: (state, token) =>{
|
|
|
|
|
state.userToken = token
|
|
|
|
|
},
|
|
|
|
|
SET_EXPIRES_IN: (state, time) => {
|
|
|
|
|
state.expires_in = time
|
|
|
|
|
},
|
|
|
|
@ -82,6 +86,7 @@ const user = {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 企业端登录
|
|
|
|
|
SingleSignOnGetInfo({ commit, state },info) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
singleSigngetInfo({clientToken: info.clientToken}).then(res => {
|
|
|
|
@ -106,10 +111,28 @@ const user = {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 政务端登录
|
|
|
|
|
governmentLogin({ commit, state },info) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
governmentGetInfo(info).then(res => {
|
|
|
|
|
// console.log(res);
|
|
|
|
|
setUserToken(info.userToken)
|
|
|
|
|
commit('SET_USERTOKEN', res.data.token)
|
|
|
|
|
setToken(res.data.token)
|
|
|
|
|
commit('SET_TOKEN', res.data.token)
|
|
|
|
|
resolve()
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
// reject(error)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取用户信息
|
|
|
|
|
GetInfo({ commit, state }) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
getInfo().then(res => {
|
|
|
|
|
// console.log(res);
|
|
|
|
|
const user = res.user
|
|
|
|
|
const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
|
|
|
|
|
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
|
|
|
|