|
|
|
@ -3,15 +3,15 @@ import storage from '@/utils/storage' |
|
|
|
import * as LoginApi from '@/api/login' |
|
|
|
|
|
|
|
// 登陆成功后执行
|
|
|
|
const loginSuccess = (commit, { token, userId }) => { |
|
|
|
const loginSuccess = (commit, { token, accountId }) => { |
|
|
|
// 过期时间30天
|
|
|
|
const expiryTime = 30 * 86400 |
|
|
|
// 保存tokne和userId到缓存
|
|
|
|
storage.set(USER_ID, userId, expiryTime) |
|
|
|
storage.set(USER_ID, accountId, expiryTime) |
|
|
|
storage.set(ACCESS_TOKEN, token, expiryTime) |
|
|
|
// 记录到store全局变量
|
|
|
|
commit('SET_TOKEN', token) |
|
|
|
commit('SET_USER_ID', userId) |
|
|
|
commit('SET_USER_ID', accountId) |
|
|
|
} |
|
|
|
|
|
|
|
const user = { |
|
|
|
@ -40,6 +40,7 @@ const user = { |
|
|
|
.then(response => { |
|
|
|
console.log("login ret:",response) |
|
|
|
const result = response.data |
|
|
|
console.log("user rest:",result) |
|
|
|
loginSuccess(commit, result) |
|
|
|
resolve(response) |
|
|
|
}) |
|
|
|
|