From 32a8bde33124be49b99f0896ba2fa3a65d2c7843 Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Fri, 26 Jan 2024 03:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5H5=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/user/settled/index.vue | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) 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() }) })