global-api.js 1.57 KB
/**
 * 全球购API
 * @author: yyq<yanqing.yang@yoho.cn>
 * @date: 2017/4/6
 */

'use strict';

const config = global.yoho.config;

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    getGlobalProductListAsync(params, from) {
        let finalParams = {
            limit: 60
        };

        Object.assign(finalParams, params);

        if (from) {
            finalParams.fromPage = from;
        }

        return this.get({
            url: 'product/api/v2/detail/getlist',
            data: finalParams,
            param: config.apiCache,
            api: global.yoho.GlobalAPI
        });
    }

    getGlobalProductDetailAsync(skn, channelNum) {
        return this.get({
            url: 'product/api/v2/detail/get',
            data: {
                physical_channel: channelNum,
                product_skn: skn
            },
            param: config.apiCache,
            api: global.yoho.GlobalAPI
        });
    }

    getGlobalProductHtmlAsync(skn, channelNum) {
        return this.get({
            url: 'product/api/v1/detail/gethtml',
            data: {
                physical_channel: channelNum,
                product_skn: skn,
                return_type: 'html'
            },
            param: config.apiCache,
            api: global.yoho.GlobalAPI
        });
    }

    getGlobalBrandInfoAsync(brand) {
        return this.get({
            url: 'editor/api/v1/brand/get',
            data: { brandId: brand },
            param: config.apiCache,
            api: global.yoho.GlobalAPI
        });
    }
};