service-api.js 1007 Bytes
/**
 * 前端Ajax请求封装
 * @author LQ <qi.li@yoho.cn>
 * @date 2017/03/14
 */

var $ = require('yoho-jquery');

var reqUrls = {
    history: '/service/history',
    evaluate: '/service/evaluate',
    leaveMsg: '/service/leaveMsg',
    reason: '/service/queryReason'
};

var _ajax = function(method, reqUrl, params) {
    return $.ajax({
        type: method || 'GET',
        url: reqUrl,
        data: params
    });
};

/**
 * 历史消息
 * @param params 参数对象
 */
exports.history = function(params) {
    return _ajax('POST', reqUrls.history, params);
};

/**
 * 保存评价
 * @param params 参数对象
 */
exports.evaluate = function(params) {
    return _ajax('POST', reqUrls.evaluate, params);
};

/**
 * 评价原因
 * @param params 参数对象
 */
exports.reason = function(params) {
    return _ajax('POST', reqUrls.reason, params);
};

/**
 * 留言
 * @param params 参数对象
 */
exports.leaveMsg = function(params) {
    return _ajax('POST', reqUrls.leaveMsg, params);
};