From 182a77f0cbeb651122a0cfaa523f23a81914ae40 Mon Sep 17 00:00:00 2001 From: mabo Date: Mon, 17 May 2021 11:00:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=A4=B1=E6=95=88=EF=BC=8C?= =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=95=86=E5=93=81=E6=95=B0=E4=B8=8D?= =?UTF-8?q?=E5=8F=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buyer/src/components/header/Header.vue | 4 +++- buyer/src/plugins/request.js | 5 ++++- buyer/src/vuex/store.js | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/buyer/src/components/header/Header.vue b/buyer/src/components/header/Header.vue index af0b69f7..e5a616a0 100644 --- a/buyer/src/components/header/Header.vue +++ b/buyer/src/components/header/Header.vue @@ -45,7 +45,7 @@
-

退出登陆

+

退出登录

@@ -173,6 +173,8 @@ export default { storage.removeItem('accessToken'); storage.removeItem('refreshToken'); storage.removeItem('userInfo'); + storage.removeItem('cartNum'); + this.$store.commit('SET_CARTNUM', 0) this.$router.push('/login'); }, goUserCenter (path) { // 跳转我的订单,我的足迹 diff --git a/buyer/src/plugins/request.js b/buyer/src/plugins/request.js index 383b5098..1b3c8bc9 100644 --- a/buyer/src/plugins/request.js +++ b/buyer/src/plugins/request.js @@ -9,6 +9,7 @@ import { import Storage from './storage'; import config from '@/config'; import router from '../router/index.js'; +import store from '../vuex/store'; import { handleRefreshToken } from '@/api/index'; @@ -80,7 +81,6 @@ service.interceptors.response.use( const errorData = errorResponse.data || {}; if (errorResponse.status === 403) { - isRefreshToken++; if (isRefreshToken === 1) { @@ -96,6 +96,9 @@ service.interceptors.response.use( Storage.removeItem('accessToken'); Storage.removeItem('refreshToken'); Storage.removeItem('userInfo'); + Storage.setItem('cartNum', 0) + store.commit('SET_CARTNUM', 0) + console.log('1111'); Modal.confirm({ title: '请登录', content: '

请登录后执行此操作

', diff --git a/buyer/src/vuex/store.js b/buyer/src/vuex/store.js index 61a5b9f0..105eded6 100644 --- a/buyer/src/vuex/store.js +++ b/buyer/src/vuex/store.js @@ -11,7 +11,7 @@ export default new Vuex.Store({ state: { category: [], // 全部分类 navList: [], - cartNum: storage.getItem('userInfo') ? storage.getItem('cartNum') : 0 + cartNum: storage.getItem('cartNum') || 0 }, getters, actions,