简介
MSHOP SDK 为主题提供给开发者使用的功能库,适用于直接运行在店铺页面上的 JavaScript(如 【自定义代码】 插件)
SDK 组成
入口对象
declare global {
/** 商城SDK调用入口对象 */
export namespace mshop {
/** 当前库的版本号 */
const version: string;
/** 店铺信息 */
const shopInfo: ShopInfo;
/** IO功能 */
const io: {
/** http请求 */
http: IHttp,
/** http请求拦截器 */
interceptor: IHttpInterceptor,
};
/** 全局事件处理器实例 */
const events: GlobalEventEmitter;
/** 先派发后注册的再次派发策略类型 */
const eventEmitterEnsureTypes: typeof EventEmitterEnsureTypes;
/** 事件处理器的实现类 */
const EventEmitterType: typeof EventEmitter;
/** 所有商城标准接口 */
const api: APIs;
/** 工具函数封装 */
const tool: Tools;
/** 拦截器实现类 */
const interceptors: Interceptors;
/** 标准结果定义 */
const results: IResults;
/** HTTP 错误类型 */
const httpErrorFlags: typeof HttpErrorFlags;
// ...其他模块
/** ui模块 */
namespace ui {
/** 购物车模块ui接口 */
const cart: ICart;
/** 商品模块ui接口 */
const product: IProduct;
// ...其他UI模块
}
}
}使用方法
购物车模块
1. 购物车事件调用示例
2. 加购和批量加购调用示例
3. 加购拦截器调用示例
商品模块
1. 详情页获取商品信息用例以及监听商品sku变化
商城标准接口
购物车api调用示例
Last updated