diff --git a/src/store/modules/cart.js b/src/store/modules/cart.js new file mode 100644 index 0000000..a65a55c --- /dev/null +++ b/src/store/modules/cart.js @@ -0,0 +1,29 @@ +import { FetchInitborrowCar } from '@/api/archiveUtilize/archiveUtilize' +// import { getToken, setToken, removeToken } from '@/utils/auth' + +const cart = { + state: { + cartCount: 0 + }, + + mutations: { + SET_CART(state, cartCount) { + state.cartCount = cartCount + } + }, + actions: { + // 获取用户信息 + initborrowCar({ commit }) { + return new Promise((resolve, reject) => { + FetchInitborrowCar().then(res => { + commit('SET_CART', res.content) + resolve(res) + }).catch(error => { + reject(error) + }) + }) + } + } +} + +export default cart