import { getCartList } from '@/api/shoppingmall/products'
const user = {
  state: {
    getNewShoppingCart: []
  },

  mutations: {
    GET_NEW_SHOPING_CART: (state, cart) => {
      state.getNewShoppingCart = cart
    }
  },

  actions: {
    // 首页获取购物车列表
    loadShoppingCart({ commit }, data) {
      return new Promise((resolve, reject) => {
        getCartList(data)
          .then(response => {
            commit('GET_NEW_SHOPING_CART', response.data)
            resolve()
          })
          .catch(error => {
            reject(error)
          })
      })
    }
    /*    // 添加购物车
    addShoppingCart({ commit }, data) {
      return new Promise((resolve, reject) => {
        saveShoppingCart(data).then(response => {
          commit('ADD_SHOPPING_CART', response.data)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    }*/
  }
}

export default user
