戴艳蓉 3 years ago
parent
commit
732eff5200
1 changed files with 16 additions and 7 deletions
  1. 16 7
      src/store/modules/user.js

+ 16 - 7
src/store/modules/user.js

@@ -5,11 +5,13 @@ import {
   removeToken,
   getAd,
   setAd,
+  removeAd,
   getGoodsNum,
   setGoodsNum,
+  removeGoodsNum,
   getGoodsUnit,
-  setGoodsUnit
-
+  setGoodsUnit,
+  removeGoodsUnit,
 } from '@/utils/auth'
 
 const state = {
@@ -63,9 +65,14 @@ const actions = {
 
           if (response.code === 0) {
             const { data } = response
-            console.log(data);
             commit('SET_TOKEN', data.token)
             setToken(data.token)
+            removeAd();
+            commit('SET_AD', {})
+            removeGoodsNum(),
+            commit('SET_GOODSNUM', "")
+            removeGoodsUnit(),
+            commit('SET_GOODSUNIT', "")
           }
           resolve(response)
         })
@@ -83,7 +90,12 @@ const actions = {
       commit('SET_ROLES', [])
       removeToken()
       commit('SET_HAS', '')
-
+      removeAd();
+      commit('SET_AD', {})
+      removeGoodsNum(),
+      commit('SET_GOODSNUM', "")
+      removeGoodsUnit(),
+      commit('SET_GOODSUNIT', "")
       // reset visited views and cached views
       // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485
       dispatch('tagsView/delAllViews', null, { root: true })
@@ -101,7 +113,6 @@ const actions = {
     })
   },
   set_ad({ commit }, item) {
-    // const { username, password } = userInfo
     return new Promise((resolve, reject) => {
       let key = JSON.parse(JSON.stringify(item))
       setAd(key)
@@ -110,7 +121,6 @@ const actions = {
     })
   },
   set_goodsNum({ commit }, item) {
-    console.log(item);
     return new Promise((resolve, reject) => {
       let key = item
       setGoodsNum(key)
@@ -119,7 +129,6 @@ const actions = {
     })
   },
   set_goodsUnit({ commit }, item) {
-    // console.log(item);
     return new Promise((resolve, reject) => {
       let key = item
       setGoodsUnit(key)