cloudMsg.js
2.9 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
93
94
95
96
97
98
/*
* 云记录
*/
'use strict'
YX.fn.cloudMsg = function () {
this.$cloudMsg = $('#cloudMsg')
this.$cloudMsgContainer = $('#cloudMsgContainer')
this.$cloudMsg.on('click', this.showCloudMsg.bind(this, this.$cloudMsg));
this.$cloudMsgContainer.delegate('.j-backBtn', 'click', this.closeCloudMsgContainer.bind(this));
this.$cloudMsgContainer.delegate('.j-loadMore', 'click', this.loadMoreCloudMsg.bind(this))
this.$cloudMsgContainer.delegate('.j-mbox','click',this.playAudio)
}
/**
* 查看云记录
*/
YX.fn.showCloudMsg = function () {
var that = this
this.$cloudMsgContainer.load('./cloudMsg.html', function() {
that.$cloudMsgContainer.removeClass('hide')
if(readCookie('flag') == 1){
that.$cloudMsgContainer.find(".title").addClass('hide')
}
var id = that.crtSessionAccount,
scene = that.crtSessionType,
param ={
scene:scene,
to:id,
lastMsgId:0,
limit:20,
reverse:false,
asc:false,
done:that.cbCloudMsg.bind(that)
}
that.mysdk.getHistoryMsgs(param)
/** 通话中的设置 */
var tmp = that.myNetcall;
tmp.$goNetcall.toggleClass("hide", !tmp.netcallActive);
300
})
}
YX.fn.closeCloudMsgContainer = function () {
this.$cloudMsgContainer.addClass('hide')
/** 通话中的设置 */
var tmp = this.myNetcall;
tmp.$goNetcall.toggleClass("hide", true);
},
/**
* 加载更多云记录
*/
YX.fn.loadMoreCloudMsg = function () {
var id = this.crtSessionAccount,
scene = this.crtSessionType,
lastItem = $("#cloudMsgList .item").first(),
param ={
scene:scene,
to:id,
beginTime:0,
endTime:parseInt(lastItem.attr('data-time')),
lastMsgId:parseInt(lastItem.attr('data-idServer')),//idServer 服务器用于区分消息用的ID,主要用于获取历史消息
limit:20,
reverse:false,
done:this.cbCloudMsg.bind(this)
}
this.mysdk.getHistoryMsgs(param)
}
/**
* 云记录获取回调
* @param {boolean} error
* @param {object} obj 云记录对象
*/
YX.fn.cbCloudMsg = function (error,obj) {
var $node = $("#cloudMsgList"),
$tip = $("#cloudMsgContainer .u-status span")
if (!error) {
if (obj.msgs.length === 0) {
$tip.html('没有更早的聊天记录')
} else {
if(obj.msgs.length<20){
$tip.html('没有更早的聊天记录')
}else{
$tip.html('<a class="j-loadMore">加载更多记录</a>')
}
var msgHtml = appUI.buildCloudMsgUI(obj.msgs,this.cache)
$(msgHtml).prependTo($node)
}
} else {
console && console.error('获取历史消息失败')
$tip.html('获取历史消息失败')
}
}