diff --git a/pages/user/settled/index.vue b/pages/user/settled/index.vue index fe6e6f7..7bb81e5 100644 --- a/pages/user/settled/index.vue +++ b/pages/user/settled/index.vue @@ -713,7 +713,25 @@ import * as YinhangApi from '@/api/shop/yinhang' import * as InfoApi from '@/api/shop/info' import * as Api from '@/api/page' import store from '@/store' - +import storage from '@/utils/storage' + +import { + ACCESS_TOKEN, + USER_ID +} from '@/store/mutation-types' +const loginSuccess = (commit, { + token, + userId +}) => { + // 过期时间30天 + const expiryTime = 30 * 86400 + // 保存tokne和userId到缓存 + storage.set(USER_ID, userId, expiryTime) + storage.set(ACCESS_TOKEN, token, expiryTime) + // 记录到store全局变量 + commit('SET_TOKEN', token) + commit('SET_USER_ID', userId) +} export default { data() { return { @@ -798,8 +816,10 @@ export default { var systemInfo = graceJS.system(); this.contentHeight = systemInfo.windowHeight * 0.65; }, - async onLoad() { - await this.getUserInfo() + async onLoad(options) { + if (options.token) { + await this.getUserInfo(options.id, options.token) + } this.getDetail() this.getCategory() @@ -813,6 +833,7 @@ export default { store.dispatch('Login', { mobile: result.data.mobile }) + loginSuccess(token, id) resolve() }) })