ShowEmessage.js
4.55 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
$(document).ready(function () {
checkE4Ready(function (htmlstr) {
$(htmlstr).prependTo($('body'));
});
});
function checkE4Ready(cb) {
if (!window.ecCom) {
console && console.log('no ecCom found')
$.post("/social/im/SocialIMInclude.jsp", function (ret) {
ret = $.trim(ret);
if (ret == '') {
console.error("!!license为空或不是e4版本!!");
return;
}
if (ret.indexOf('/social/im/SocialIMMain.jsp') > -1 && typeof cb === 'function') {
cb(ret);
}
});
} else {
window.em_checkJoin().then(function (res) {
if (res.status &&
res.joinStatus
) {
if (res.webSwitch !== "0") {
var WeaTools = ecCom.WeaTools;
WeaTools.callApi('/api/ec/dev/app/getUserInfo', 'GET', {})
.then(function (res) {
if (!res.isAdmin) {
var loadjs = ecCom.WeaTools.loadjs;
var ec_id = ''
var timestamp = 0;
var emUrl = '';
var langType = 'zh';
var lang = localStorage['languageidweaver'];
var langTypeList = JSON.parse(localStorage['languageIdentify'])
for (var index = 0; index < langTypeList.length; index++) {
var element = langTypeList[index];
if (element[lang] !== undefined) {
langType = element[lang];
}
}
WeaTools.callApi('/api/ec/dev/app/test', 'GET', {})
.then(function (res) {
if (!res.status) {
console.log('verify failed')
}
ec_id = res.ec_id
timestamp = new Date().getTime();
emUrl = res.em_url_open + '/open/js/client.js?_key=' + timestamp;
function initEmClient(ec_id) {
WeaTools.callApi('/api/ec/dev/app/getSSOCode', 'GET', {})
.then(function (ssoRes) {
if (!ssoRes.status) {
console.log('get code failed');
}
emClient.ready(function () {
emClient.ecLogin({
ec_id: ec_id, //必填,EC接入EM时,在EM中的唯一标识
// ec_auth_code: JSON.parse(window.localStorage.login).loginCache.id, // 读取当前用户id测试
ec_auth_code: ssoRes.keycode, //必填,实时生成的身份认证code
lang_type: langType,
});
});
}.bind(this));
}
loadjs.isDefined('emClient')
? loadjs.ready('emClient', initEmClient.bind(this, ec_id))
: loadjs(emUrl, 'emClient', initEmClient.bind(this, ec_id));
}.bind(this));
}
}.bind(this))
}
} else {
$.post("/social/im/SocialIMInclude.jsp", function (ret) {
ret = $.trim(ret);
if (ret == '') {
console.error("!!license为空或不是e4版本!!");
return;
}
if (ret.indexOf('/social/im/SocialIMMain.jsp') > -1 && typeof cb === 'function') {
cb(ret);
}
});
}
})
}
}