|
@@ -1,7 +1,5 @@
|
|
|
import { login, loginUp, getInfo } from '@/api/login'
|
|
|
import { getToken, setToken, removeToken, setUserId } from '@/utils/auth'
|
|
|
-import { resetRouter } from '@/router'
|
|
|
-import { result } from 'lodash'
|
|
|
|
|
|
const getDefaultState = () => {
|
|
|
return {
|
|
@@ -42,7 +40,7 @@ const mutations = {
|
|
|
|
|
|
const actions = {
|
|
|
// user login
|
|
|
- login({ commit }, userInfo) {
|
|
|
+ login ({ commit }, userInfo) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
login(userInfo).then(response => {
|
|
|
const { returnData } = response
|
|
@@ -66,7 +64,7 @@ const actions = {
|
|
|
},
|
|
|
|
|
|
// get user info
|
|
|
- getInfo({ commit, state }) {
|
|
|
+ getInfo ({ commit, state }) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
let data = {
|
|
@@ -87,10 +85,10 @@ const actions = {
|
|
|
},
|
|
|
|
|
|
// user logout
|
|
|
- logout({ commit, state }) {
|
|
|
+ logout ({ commit, state }) {
|
|
|
console.log(state)
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- loginUp({"UserId":state.UserId,"UserType":state.UserType}).then(result => {
|
|
|
+ loginUp({ "UserId": state.UserId, "UserType": state.UserType }).then(result => {
|
|
|
sessionStorage.removeItem("userName");
|
|
|
removeToken() // must remove token first
|
|
|
resetRouter()
|
|
@@ -110,7 +108,7 @@ const actions = {
|
|
|
},
|
|
|
|
|
|
// remove token
|
|
|
- resetToken({ commit }) {
|
|
|
+ resetToken ({ commit }) {
|
|
|
return new Promise(resolve => {
|
|
|
removeToken() // must remove token first
|
|
|
commit('RESET_STATE')
|