brands-api.js 1.42 KB
/**
 * 品牌一览 api
 * @author: ghw<hongwei.gao@yoho.cn>
 * @date: 2016/9/29
 */
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;

/**
 * 分开取数,品牌一览 顶部的轮翻广告及热门品牌数据-PC
 * 顶部的轮翻广告及热门品牌数据
 *  @param string $contentCode 获取广告资源需要的位置码
 */
const getBrandTopData = (contentCode) => {
    return serviceAPI.get('operations/api/v5/resource/get', {
        content_code: contentCode
    });
};

/**
 * 分开取数,获取品牌一览 "按字母'A-Z'分组的品牌列表数据"
 * @param int $channel 频道标识 1:男,2:女,3:潮童,4:创意生活
 */
const getBrandListData = channel => {
    let params = {method: 'app.brand.brandlist'};

    if (!isNaN(channel)) {
        params.yh_channel = channel;
    }
    return api.get('', params);
};

/**
 * 获取品牌简介
 *
 * @param  integer $brandId 品牌ID
 * @param  int 用户ID
 * @return array  品牌介绍信息
 */
const getBrandIntro = (brandId, uid) => {
    return api.get('', {
        method: 'app.brand.getBrandIntro',
        brand_id: brandId,
        uid: uid
    });
};

const getProductByBrand = (brandId, limit) => {
    return api.get('', {
        method: 'web.search.search',
        brand_id: brandId,
        limit: limit
    });
};


module.exports = {
    getBrandTopData,
    getBrandListData,
    getBrandIntro,
    getProductByBrand
};