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

'use strict';

const globalApi = global.yoho.GlobalAPI;
const config = global.yoho.config;

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

    Object.assign(finalParams, params);

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

    return globalApi.get('product/api/v2/detail/getlist', finalParams, config.apiCache);
};

const getGlobalProductDetailAsync = (skn, channelNum) => {
    return globalApi.get('product/api/v2/detail/get', {
        physical_channel: channelNum,
        product_skn: skn
    }, config.apiCache);
};

const getGlobalProductHtmlAsync = (skn, channelNum) => {
    return globalApi.get('product/api/v1/detail/gethtml', {
        physical_channel: channelNum,
        product_skn: skn,
        return_type: 'html'
    }, config.apiCache);
};

module.exports = {
    getGlobalProductListAsync,
    getGlobalProductDetailAsync,
    getGlobalProductHtmlAsync
};