brand-api.js 3.01 KB
/**
 * Created by PhpStorm.
 * User: Targaryen
 * Date: 2016/7/19
 * Time: 14:02
 */
'use strict';
const api = global.yoho.API;

const yhChannel = {
    men: {
        channel: '1'
    },
    women: {
        channel: '2'
    },
    lifestyle: {
        channel: '4'
    }
};

module.exports = {

    /**
     * 从接口获取品牌店铺数据
     * @returns {*}
     */
    getShopInfoData(params) {
        let finalParams = {
            method: 'app.shops.getIntro',
            shop_id: params.shopId
        };

        if (params.uid) {
            Object.assign(finalParams, {
                uid: params.uid
            });
        }

        return api.get('', finalParams);
    },

    /**
     * 通过品牌域名获取品牌信息
     * @param params
     */
    getBrandInfoByDomain(params) {
        return api.get('', {
            method: 'web.brand.byDomain',
            domain: params.domain
        });
    },


    getShopsDecoratorList(params) {
        return api.get('', {
            method: 'app.shopsdecorator.getList',

        });
    },

    /**
     * 从接口获取品牌店铺商品数据
     * @returns {*}
     */
    getBrandShopGoodsOriginData(params) {
        return api.get('', {
            method: 'app.search.brand',
            yh_channel: params.channel ? yhChannel[params.channel].channel : '1',
            brand: params.brand,
            shop_id: params.shopId,
            order: params.order,
            limit: params.limit,
            page: params.page,
            gender: params.gender,
            color: params.color,
            price: params.price,
            size: params.size,
            p_d: params.pd,
            sort: params.sort,
            tags_filter: params.tagsFilter
        });
    },

    /**
     * 收藏取消收藏店铺
     * @param params
     * @returns {*}
     */
    collectShopOriginData(params) {
        let finalParams = {
            id: params.shopId,
            fav_id: params.shopId,
            uid: params.uid,
            type: params.type
        };

        if (params.isFav) {
            Object.assign(finalParams, {
                method: 'app.favorite.add'
            });
        } else {
            Object.assign(finalParams, {
                method: 'app.favorite.cancel'
            });
        }
        return api.get('', finalParams);
    },

    /**
     * 从接口获取品牌列表页数据
     * @returns {*}
     */
    getBrandListOriginData(params) {
        return api.get('', {
            method: 'app.brand.newBrandList',
            yh_channel: yhChannel[params.channel].channel
        });
    },

    /**
     * 从接口获取全部分类数据
     * @returns {*}
     */
    getCateListData(params) {
        return api.get('', Object.assign(params, {
            method: 'app.sort.get'
        })
        );
    },

    /**
     * 从接口获取品类资源位数据
     * @returns {*}
     */
    getCateResource(params) {
        return api.get('', Object.assign(params, {
            method: 'app.sort.get'
        })
        );
    }
};