index-api.js 1.74 KB
'use strict';

const api = global.yoho.API;

const pendingOrderCount = (uid) => {
    return api.get('', {
        method: 'web.SpaceOrders.getPendingOrderCount',
        uid: uid
    });
};

const unreadMessageCount = (uid, udid)=>{
    return api.get('', {
        method: 'app.home.getInfoNum',
        uid: uid,
        udid: udid
    });
};

const needCommentCount = (uid) =>{
    return api.get('', {
        method: 'show.notCommentRecordCount',
        uid: uid
    });
};

const guessBrand = () => {
    return api.get('', {
        method: 'web.search.favorBrand'
    });
};

const newArrival = () => {
    return api.get('', {
        method: 'web.search.search',
        sales: 'Y',
        outlets: 2,
        stocknumber: 1,
        new: 'Y',
        order: 's_t_desc',
        viewNum: 0
    });
};

/**
 * 优选新品
 *
 * @param int $channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
 * @param $uid 用户ID
 * @param $udid 设备ID
 * @param $rec_pos 位置码
 * @param $limit 数量限制
 * @return array 接口返回的数据
 */
const recommend = (channelNum, uid, udid, pos, limit) => {
    return api.get('', {
        method: 'app.home.newPreference',
        yh_channel: channelNum,
        uid: uid,
        udid: udid,
        rec_pos: pos,
        limit: limit
    });
};

/**
 * 根据节点和运行模式选择静态内容
 * @param $node 20141219-100447
 * @param string $mode
 * @return mixed
 */
const getByNodeContent = (node, mode) => {
    return api.get('', {
        method: 'web.html.content',
        mode: mode,
        node: node
    });
};

module.exports = {
    pendingOrderCount,
    unreadMessageCount,
    needCommentCount,
    guessBrand,
    newArrival,
    recommend,
    getByNodeContent
};