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

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    pendingOrderCount(uid) {
        let options = {
            method: 'web.SpaceOrders.getPendingOrderCount',
            uid: uid
        };

        return this.get({data: options});
    }

    unreadMessageCount(uid, udid) {
        let options = {
            method: 'app.home.getInfoNum',
            uid: uid,
            udid: udid
        };

        return this.get({data: options});
    }

    needCommentCount(uid) {
        let options = {
            method: 'show.notCommentRecordCount',
            uid: uid
        };

        return this.get({data: options});
    }

    guessBrand() {
        let options = {
            method: 'web.search.favorBrand'
        };

        return this.get({data: options});
    }

    newArrival() {
        let options = {
            method: 'web.search.search',
            sales: 'Y',
            outlets: 2,
            stocknumber: 1,
            new: 'Y',
            order: 's_t_desc',
            viewNum: 0
        };

        return this.get({data: options});
    }

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

        return this.get({data: options});
    }

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

        return this.get({data: options});
    }
};