popular-shop.js 1.77 KB
/**
 *  desc: 店铺装修----红人店铺
 */
'use strict';

const api = global.yoho.API;
const singleAPI = global.yoho.SingleAPI;

/**
 * 频道
 * @type {{}}
 */
const yhChannel = {
    boys: 1,
    girls: 2,
    kids: 3,
    lifestyle: 4
};

/**
 *  获取红人店铺 banner
 *  doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/商品列表/店铺装修.md
 *  @param int shopId 店铺id
 */
exports.getBanner = shopId => {
    let params = {
        method: 'app.popular.shop.banner',
        shop_id: shopId
    };

    return api.get('', params, {cache: true, code: 200});
};

/**
 * 获取店铺 介绍
 * @param int shopId 店铺id
 */
exports.getIntro = shopId => {
    let params = {
        method: 'app.shops.getIntro',
        shop_id: shopId
    };

    return api.get('', params, {cache: true, code: 200});
};


/**
 *  查询红人店铺对应的装修元素
 *
 *  @param int shopId 店铺id
 */
exports.getShopsdecorator = shopId => {
    let params = {
        method: 'app.popular.shopsdecorator',
        shop_id: shopId
    };

    return api.get('', params, {cache: true, code: 200});
};

/**
 * 获取店铺下面的所有分类
 * @param {int} shopId 店铺id
 * @param {string} channel 频道
 * @return array
 */
exports.getShopCategory = (shopId, channel, gender) => {
    return api.get('', {
        method: 'app.shop.getSortInfo',
        yh_channel: yhChannel[channel],
        gender: gender || '1,3',
        shop_id: shopId
    });
};

/**
 * 店铺收藏数量
 */
exports.favCount = (shopId, uid, channel, udid) => {
    return singleAPI.get('favorite', {
        method: 'app.favorite.queryFavoriteCountByShopIds',
        favIds: shopId,
        type: 'shop',
        udid: udid,
        uid: uid,
        physical_channel: yhChannel[channel],
    });
};