list.js 1.15 KB
/**
 *  product list Model
 */
'use strict';
const path = require('path');
const api = global.yoho.API;
const camelCase = global.yoho.camelCase;
const prettyFilter = require(path.join(global.utils, '/beautify/filters'));
const processProductList = require(path.join(global.utils, '/beautify/product')).processProductList;


let list = {

    /**
     * 商品搜索
     * @param  {[type]} params [description]
     * @return {[type]}        [description]
     */
    search(params) {
        return api.post('', {
            method: 'app.search.sales',
            limit: 4,
            saleType: 2,
            yh_channel: 3
        }, {
            cache: true,
            code: 200
        })
        .then(result => {
            prettyFilter(result.data.filter);
            result.data.productList = processProductList(result.data.productList);
            result = camelCase(result);
            return result;
        });
    },


    getFilters(params) {
        return api.post('', {
            method: 'app.search.sales'
        }, {
            cache: true,
            code: 200
        })
        .then(result => {

        });
    }
};


module.exports = list;