cart.js 2.82 KB
import { api } from '../../common/api';

export default {
  /**
   * 购物车数据
   * @param params
   * @returns {*}
   */
  getCartData(params) {
    return api.get({
      url: '',
      data: Object.assign({
        method: 'app.Shopping.queryCart'
      }, params)
    });
  },

  /**
   * 加入购物车
   * @param params
   * @returns {*}
   */
  addToShoppingCart(params) {
    return api.get({
      url: '',
      data: Object.assign({
        app_type: getApp().getAppType(),
        method: 'app.Shopping.add',
      }, params)
    });
  },

  /**
   * 选中/取消选中并查询购物车
   * @param params
   * @returns {*}
   */
  selectAndQueryCart(params) {
    return api.get({
      url: '',
      data: Object.assign({
        method: 'app.Shopping.selectedAndQryCart',
        is_support_mlp: 'Y',
        shopping_key: ''
      }, params)
    });
  },

  /**
   * 删除并查询购物车
   * @param params
   * @returns {*}
   */
  removeAndQueryCart(params) {
    return api.get({
      url: '',
      data: Object.assign({
        method: 'app.Shopping.removeAndQryCart',
        is_support_mlp: 'Y',
        shopping_key: ''
      }, params)
    });
  },

  /**
   * 编辑购物车商品数量
   * @param params
   * @param isAdd
   * @returns {*}
   */
  editCartGoodsNum(params, isAdd) {
    if (isAdd) {
      Object.assign(params, {
        method: 'app.Shopping.increase',
        increase_number: 1,
        shopping_key: ''
      });
    } else {
      Object.assign(params, {
        method: 'app.Shopping.decrease',
        decrease_number: 1,
        shopping_key: ''
      });
    }

    return api.get({
      url: '',
      data: params
    });
  },

  /**
   * 编辑购物车套餐数量
   * @param params
   * @param isAdd
   * @returns {*}
   */
  editCartBundleNum(params, isAdd) {
    if (isAdd) {
      Object.assign(params, {
        method: 'app.Shopping.incrBundle',
        increase_number: 1,
      });
    } else {
      Object.assign(params, {
        method: 'app.Shopping.decrBundle',
        decrease_number: 1,
      });
    }

    return api.get({
      url: '',
      data: params
    });
  },

  /**
   * 编辑购物车商品
   * @param params
   * @returns {*}
   */
  editCartGoods(params) {
    return api.get({
      url: '',
      data: Object.assign(params, {
        method: 'app.Shopping.swap'
      })
    });
  },

  /**
   * queryPromotionGifts
   * @param params
   * @returns {*}
   */
  getPromotionGifts(params) {
    return api.get({
      url: '',
      data: Object.assign({
        method: 'app.Shopping.queryPromotionGifts'
      }, params)
    });
  },

  /**
   * 编辑赠品
   * @param params
   * @returns {*}
   */
  editCartGiftGoods(params) {
    return api.get({
      url: '',
      data: Object.assign(params, {
        method: 'app.Shopping.swapGift'
      })
    });
  }
};