sale-api.js 2.48 KB
/*
 * @Author: Targaryen
 * @Date:   2016-05-25 18:03:34
 * @Last Modified by:   Targaryen
 * @Last Modified time: 2016-05-26 11:10:37
 */

'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const TARAPI = require(`${library}/tar-api`).TARAPI;
const api = new API();
const tarApi = new TARAPI();
const sign = require(`${library}/sign`);
const _ = require('lodash');

/**
 * 获取商品列表 promise 对象
 * @return {[type]} [description]
 */
exports.getSaleGoodsList = (params) => {
    let tempParams = {
        method: 'app.search.sales',
        p_d: _.isEmpty(params.p_d) ? null : params.p_d,
        limit: _.isEmpty(params.limit) ? null : params.limit,
        order: _.isEmpty(params.order) ? 's_t_desc' : params.order,
        page: _.isEmpty(params.page) ? 1 : params.page,
        gender: _.isEmpty(params.gender) ? null : params.gender,
        sort: _.isEmpty(params.sort) ? null : params.sort,
        brand: _.isEmpty(params.brand) ? null : params.brand,
        color: _.isEmpty(params.color) ? null : params.color,
        size: _.isEmpty(params.size) ? null : params.size,
        saleType: _.isEmpty(params.saleType) ? null : params.saleType,
        breakSize: _.isEmpty(params.breakSize) ? null : params.breakSize,
        breakSort: _.isEmpty(params.breakSort) ? null : params.breakSort,
        productPool: _.isEmpty(params.productPool) ? null : params.productPool,
        price: _.isEmpty(params.price) ? null : params.price,
        productSize: '384x511',
        yh_channel: 1
    };

    let finalParams = {};

    _.forEach(tempParams, function(value, key) {
        if (!_.isEmpty(value)) {
            finalParams[key] = value;
        }
    });

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

/**
 * 断码区分类信息数据 promise 对象
 * @return {[type]} [description]
 */
exports.getSalebreakingYardsSortList = () => {
    return api.get('', sign.apiSign({
        method: 'app.sale.getBreakingSort',
        yh_channel: 1
    }));
};

/**
 * 获取折扣专区活动列表 promise 对象
 * @return {[type]} [description]
 */
exports.getSaleActivityList = () => {
    return tarApi.getActivity('', sign.apiSign({
        method: 'app.activity.get',
        sort: 2,
        plateform: 2
    }));
};

/**
 * 获取Sale首页顶部 banner promise 对象
 * @return {[type]} [description]
 */
exports.getSaleBannerList = () => {
    return tarApi.getBanner('', sign.apiSign({
        content_code: '7c2b77093421efa8ae9302c91460db73'
    }));
};