client-api.js 1.46 KB
/**
 * 客服用户端 api
 *
 * @author: liqi <qi.li@yoho.cn>
 * @date: 2016/11/4
 */

'use strict';

let config = require('../../../config/common');

let api = new global.yoho.ApiBase(config.domains.bjIm, {
    name: 'bjIm',
    cache: global.yoho.cache,
    useCache: false
});

// api urls
let urls = {
    lastTen: '/api/cs/queryUserLastTenOrdersNgoodsInfo',
    msgHistory: '/api/conversationMessage/pageList',
    csSetting: '/api/cs/queryByType',
    qas: ''  // TODO  没有接口功能暂缓
};

/**
 * 用户最近10笔订单
 * @function getLastTenOrders
 * @param { number } uid 用户ID
 * @return { Object } 最近10条订单
 */
const getLastTenOrders = (uid, imgSize) => {
    return api.get(urls.lastTen, {
        method: '',
        uid,
        imgSize
    });
};

/**
 * 常见问题
 * @function getQas
 * @return { Object } 问答列表
 */
const getQas = () => {
    return api.get(urls.qas, {
        method: ''
    });
};


/**
 * 客服设置
 * @param { number } type
 * @return { Object } 客服设置
 */
const getCsSetting = (type) => {
    return api.get(urls.csSetting, {
        method: '',
        type
    });
};


/**
 * 最近聊天记录
 * @function getMsgHistory
 * @param { number } uid 用户id
 * @return { Array } 历史聊天记录
 */
const getMsgHistory = (uid) => {
    return api.get(urls.msgHistory, {
        uid,
        method: ''
    });
};

module.exports = {
    getQas,
    getCsSetting,
    getMsgHistory,
    getLastTenOrders
};