recom.js 1.36 KB
'use strict';

const api = global.yoho.API;
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);

const mayLike = (uid, page, limit, gender, udid, recPos, channel) => {
    return api.get('', {
        method: 'app.search.newLast7day',
        uid: uid,
        page: page,
        limit: limit,
        udid: udid,
        rec_pos: recPos,
        yh_channel: channel,
        gender: gender
    }).then((result) => {

        if (result && result.code === 200) {

            if (result.data.page_total && page <= result.data.page_total) {
                if (result.data.product_list) {

                    return productProcess.processProductList(result.data.product_list);

                } else {
                    return false;
                }
            }

        }
    });
};

const mayLikeKids = (page, limit, channel) => {
    return api.get('', {
        method: 'app.search.kids',
        page: page,
        limit: limit,
        yh_channel: channel
    }).then((result) => {

        if (result && result.code === 200) {

            if (page > result.data.page_total) {
                return;
            }

            if (result.data.product_list) {

                return productProcess.processProductList(result.data.product_list);

            }
        }
    });
};

module.exports = {
    mayLike,
    mayLikeKids
};