UNPKG

@pisell/pisellos

Version:

一个可扩展的前端模块化SDK框架,支持插件系统

87 lines (86 loc) 2.54 kB
import { Module, PisellCore, ModuleOptions } from '../../types'; import { BaseModule } from '../BaseModule'; import { CartItem, CartModuleAPI, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types'; import { Account } from '../Account'; export * from './types'; export { getProductDeposit } from './utils'; /** * 购物车模块实现 */ export declare class CartModule extends BaseModule implements Module, CartModuleAPI { protected defaultName: string; protected defaultVersion: string; private request; private window; private store; private cacheId; private openCache; private fatherModule; constructor(name?: string, version?: string); /** * 初始化购物车模块 */ initialize(core: PisellCore, options: ModuleOptions): Promise<void>; /** * 添加商品到购物车 */ addItem(params: IAddItemParams): Promise<void>; /** * 更新购物车信息 */ updateItem(params: IUpdateItemParams): Promise<void>; updateItemInitInfo(params: IUpdateItemParams): Promise<void>; /** * 格式化数据到购物车 */ formatCartItem(params: IUpdateItemParams): CartItem; /** * 批量设置购物车数据 */ batchSetItems(items: CartItem[]): Promise<void>; /** * 获取购物车商品 */ getItems(): CartItem[]; /** * 获取购物车商品--通过购物车 id 获取单条 */ getItem(id: string): CartItem | undefined; /** * 根据账户ID获取购物车 */ getCartByAccount(account_id: string | number): CartItem[]; /** * 移除购物车商品 */ removeItem(id: string): Promise<void>; /** * 根据账户ID清除购物车 */ clearCartByAccount(account_id: string): void; /** * 清除购物车商品中的信息 * @param type 清除购物车商品中的信息类型 * @param _id 购物车商品ID */ deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void; /** * 清除购物车 */ clear(): void; storeChange(): void; checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean; /** * 基于rowkey 合并商品,目前只有普通商品需要合并 * * @param {string} rowKey * @param {number} quantity * @return {*} * @memberof CartModule */ mergeCartItemByRowKey(params: { rowKey?: string; quantity?: number; account?: Account; }): boolean; }