JS SDK For Easy Design

SDK is responsible for the communication between third-party pages and easy design iframe.

First, after entering the easy design, a group of brandgoodCode will be sent to the third party to represent the product information that needs to be provided by the third party.
The structure is as follows (add as needed):

//Product information (including all original and replaced products), brandgoodid as key
brandGoodList: {
    brandgoodCode1: {
        brandgoodName: string,
        previewImgUrl: string,
        price: number,
    },
    brandgoodCode2: {
        brandgoodName: string,
        previewImgUrl: string,
        price: number,
    }
}

Events exposed in easy design:

// The information of the products to be obtained for easy design is returned to the brandgoodlist (see the code above)
// brandgoodCodes: code list of products needed for easy design
getProductInfo(brandgoodCodes): Promise<brandGoodList>

// One click purchase event
// brandgoodCodes: list of items purchased
onBuy(brandgoodCodes: number[])

// Inform that the third party data has been obtained and the project data loading is completed
onReady()

// Click product details to trigger
// brandgoodCode: product code
onProductDetail(brandgoodCode)

// Click album and rendering button to trigger in non login state
// diffData: replacement data. After login, add the parameter diffdata = {replacement data} after the easy design URL
onLogin(diffData: string)

// Get the current easy design replacement data and click the render to trigger
// diffData: replacement data
onDiff(diffData: string)

For custom style:

toolbarTextStyle:Product list, Atlas and other text styles
toolbarIconStyle:Product list, Atlas and other icon styles
purChaseListName: Text replacement of product list

SDK parameters:

NameRequiredTypeDescription
onBuyfalsesee aboveOne click purchase callback
onReadyfalsesee aboveProject data loading completed
onProductDetailfalsesee aboveProduct details jump
getProductInfofalsesee aboveGet Product Information
onDifffalsesee aboveGet current easy design replacement data
onLoginfalsesee aboveLogin event
classfalsestringIframe class
srctruestringIframe src
domtruedomIframe mount point
customfalsesee aboveCustom style section
// Call method example
// The new SDK initializes iframe and calls open() to open.
sdk = new DesignSDK({
    class,
    src,
    dom,
    custom: {
        toolbarIconStyle: {
            height: '300px'
        },
        toolbarTextStyle: {
            fontSize: '20px'
        },
        purChaseListName: 'nnakjs'
    },
    events: {
        onBuy,
        onReady,
        onProductDetail,
        getProductInfo,
        onDiff,
        onLogin
    }
})

sdk.open();