store.js
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
'use strict';
const tip = require('plugin/tip');
const socketConf = require('./socket-config');
const conversation = socketConf.conversationMessage;
const slice = Array.prototype.slice;
// EventEmitter
//--------------------------------------------------------
const EventEmitter = function() {};
EventEmitter.prototype = {
on() {
var args, ref;
args = arguments.length >= 1 ? slice.call(arguments, 0) : [];
return (ref = $(this)).on.apply(ref, args);
},
off() {
var args, ref;
args = arguments.length >= 1 ? slice.call(arguments, 0) : [];
return (ref = $(this)).off.apply(ref, args);
},
trigger() {
var args, ref;
args = arguments.length >= 1 ? slice.call(arguments, 0) : [];
return (ref = $(this)).triggerHandler.apply(ref, args);
}
};
EventEmitter.prototype.constructer = EventEmitter;
function buildAPPUid(data) {
}
// api interface
//--------------------------------------------------------
let api = {
/**
* 留言
* @param {int} conversation 会话id
* @param {str} content 内容
* @return jqXhr
*/
leaveMsg: function(content) {
return $.post('/service/leavemsg/save.json', {
conversationId: conversation.conversationId,
content,
});
},
/**
* 获取订单
* TODO:
* 1. 目前接口不支持分页
*/
fetchOrders: function(type) {
let url = `/service/im/${type}-list`;
return $.get(url);
},
// 获取10条历史记录
msghistory: function(uid, encryptedUid, endTime) {
let url = '/service/im/fetchHistory';
let data = {
uid,
encryptedUid
};
endTime && (data.endTime = endTime);
return $.get(url, data);
},
saveEvalute: function(data) {
return $.post('/service/im/saveEvalute', data);
}
};
module.exports = {
EventEmitter,
api
};