登录失效,购物车商品数不变问题

master
mabo 2021-05-17 11:00:02 +08:00
parent 9df8a753d4
commit 182a77f0cb
3 changed files with 8 additions and 3 deletions

View File

@ -45,7 +45,7 @@
</div> </div>
<div class="sign-out" @click="signOutFun"> <div class="sign-out" @click="signOutFun">
<Icon type="md-exit"></Icon> <Icon type="md-exit"></Icon>
<p>退出登</p> <p>退出登</p>
</div> </div>
</div> </div>
</DropdownMenu> </DropdownMenu>
@ -173,6 +173,8 @@ export default {
storage.removeItem('accessToken'); storage.removeItem('accessToken');
storage.removeItem('refreshToken'); storage.removeItem('refreshToken');
storage.removeItem('userInfo'); storage.removeItem('userInfo');
storage.removeItem('cartNum');
this.$store.commit('SET_CARTNUM', 0)
this.$router.push('/login'); this.$router.push('/login');
}, },
goUserCenter (path) { // goUserCenter (path) { //

View File

@ -9,6 +9,7 @@ import {
import Storage from './storage'; import Storage from './storage';
import config from '@/config'; import config from '@/config';
import router from '../router/index.js'; import router from '../router/index.js';
import store from '../vuex/store';
import { import {
handleRefreshToken handleRefreshToken
} from '@/api/index'; } from '@/api/index';
@ -80,7 +81,6 @@ service.interceptors.response.use(
const errorData = errorResponse.data || {}; const errorData = errorResponse.data || {};
if (errorResponse.status === 403) { if (errorResponse.status === 403) {
isRefreshToken++; isRefreshToken++;
if (isRefreshToken === 1) { if (isRefreshToken === 1) {
@ -96,6 +96,9 @@ service.interceptors.response.use(
Storage.removeItem('accessToken'); Storage.removeItem('accessToken');
Storage.removeItem('refreshToken'); Storage.removeItem('refreshToken');
Storage.removeItem('userInfo'); Storage.removeItem('userInfo');
Storage.setItem('cartNum', 0)
store.commit('SET_CARTNUM', 0)
console.log('1111');
Modal.confirm({ Modal.confirm({
title: '请登录', title: '请登录',
content: '<p>请登录后执行此操作</p>', content: '<p>请登录后执行此操作</p>',

View File

@ -11,7 +11,7 @@ export default new Vuex.Store({
state: { state: {
category: [], // 全部分类 category: [], // 全部分类
navList: [], navList: [],
cartNum: storage.getItem('userInfo') ? storage.getItem('cartNum') : 0 cartNum: storage.getItem('cartNum') || 0
}, },
getters, getters,
actions, actions,