global-api.js 1.05 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('api/v2/detail/getlist', finalParams, config.apiCache);
};

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

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

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