resouces.js 1.09 KB
/**
 * 资源位查询
 *
 * @author: jiangfeng<jeff.jiang@yoho.cn>
 */

'use strict';

const api = global.yoho.ServiceAPI;
const logger = global.yoho.logger;

const Resources = {
    /**
     * 获取新品到着-列表页-banner  资源位
     * @returns {Promise.<T>}
     */
    newProductBanner(channel) {

        let codes = {
            men: '3d3127b220073fbcda738c8ba26561e5',
            women: '2aaf9519b31d1f21c537032f496e7450',
            lifestyle: '422bfdb9b410598e11c3e72bd4ee664e'
        };

        let params = {
            content_code: codes[channel]
        };

        return api.get('/operations/api/v5/resource/get', params).then(result => {
            if (result && result.code === 200 && result.data) {
                let data = result.data;

                if (data.length > 0) {
                    let d = data[0].data;

                    return d ? d[0] : {};
                }
            }

            return {};
        }).catch(e => {
            logger.error('get new product list banner error', e);
            return {};
        });
    }
};

module.exports = Resources;