)/g, "[" + local.IMAGE + "]").replace(/
<\/p>/g, "").replace(/
/g, "pStartElement").replace(/<\/p>/g, "pCloseElement").replace(/<.+?>/g, "").replace(/pStartElement/g, "
").replace(/pCloseElement/g, "
");
var s = "";
if (i) {
s = "" + '' + '" + '
' + ysf._$text2portrait(a) + "
" + "
" + '' + '
' + '

' + "
";
}
t.innerHTML = s + '';
t.onclick = function() {
if (ysf.isInInviteLayerMode()) {
ysf.open({
invitePatternVo: e.inviteSetting.invitePatternVo,
inviteTemplateId: e.inviteSetting.id
});
} else {
ysf.open();
}
ysf.HAS_QIYU_OPEND = true;
ysf.displayInviteLayer(false);
};
document.body.appendChild(t);
if (i) {
document.querySelector("#YSF-ONLINE-INVITE-LAYER-CLOSE").onclick = function(e) {
e.stopPropagation();
ysf.displayInviteLayer(false);
ysf.INVITE_REJECT = true;
setTimeout((function() {
ysf.displayInviteLayer(true);
}), inviteSetting.intervalTime * 1e3);
};
}
if (e.inviteSetting && e.inviteSetting.switchType === 1 && e.inviteSetting.waitTime) {
setTimeout((function() {
ysf.displayInviteLayer(true);
}), e.inviteSetting.waitTime * 1e3);
}
return t;
};
var i = function(e) {
var t = document.createElement("span");
t.setAttribute("id", "YSF-BTN-CIRCLE");
e.appendChild(t);
};
var o = function(e) {
var t = document.createElement("div"), i = document.createElement("div"), n = document.createElement("span"), o = document.createElement("span");
t.setAttribute("id", "YSF-BTN-BUBBLE");
i.setAttribute("id", "YSF-BTN-CONTENT");
n.setAttribute("id", "YSF-BTN-ARROW");
o.setAttribute("id", "YSF-BTN-CLOSE");
o.onclick = function(e) {
e.stopPropagation();
e.preventDefault();
ysf.NotifyMsgAndBubble({
category: "clearCircle"
});
};
e.appendChild(t);
t.appendChild(i);
t.appendChild(n);
t.appendChild(o);
};
var r = t();
i(r);
o(r);
};
ysf.hasTodayInviteTimes = function(e) {
var t = "YSF_INVITE_SHOW_TIMES";
var i = JSON.parse(localStorage.getItem(t) || "{}")[util.getToday()] || 0;
var n = e && e.switchType === 1 && (i === 0 || e.rejectType === 1 && (!e.timesLimitType || e.timesLimit > i) || e.rejectType === 0 && !ysf.INVITE_REJECT && (!e.timesLimitType || e.timesLimit > i));
return n;
};
ysf.setTodayShowInviteTimes = function() {
var e = "YSF_INVITE_SHOW_TIMES";
var t = JSON.parse(localStorage.getItem(e) || "{}");
var i = util.getToday();
var o = {};
o[i] = t[i] ? t[i] + 1 : 1;
localStorage.setItem(e, JSON.stringify(o));
util.ajax({
url: ysf.DOMAIN + "webapi/invite/num",
method: "get",
data: {
appKey: n.appKey
},
success: function(e) {
console.log("[success]会话邀请次数统计接口");
},
error: function(e) {
console.log("[err]会话邀请次数统计接口", e);
}
});
};
ysf.inviteText = function(e) {
var t = e && e.invitePatternVo;
var i = "";
if (t) {
i = t.robotSwitch === 0 ? t.humanWelcomePrompt : t.robotWelcomePrompt;
}
return i;
};
ysf.isInInviteLayerMode = function() {
return document.querySelector(".YSF-INVITE-LAYER-WRAPPER") && document.querySelector(".YSF-INVITE-LAYER-WRAPPER").style.display !== "none";
};
ysf.isInvitedLayer = function() {
var e = ysf.inviteText(window.inviteSetting);
var t = window.inviteSetting && window.inviteSetting.invitePatternVo && window.inviteSetting.invitePatternVo.mode === 1 && e && ysf.hasTodayInviteTimes(window.inviteSetting) && !ysf.HAS_MESSAGE_COUNT && !n["IN_SESSION"] && !ysf.HAS_QIYU_OPEND && !!n["sessionInvite"];
return t;
};
ysf.displayInviteLayer = function(e) {
e = e && ysf.isInvitedLayer();
if (e) {
ysf.setTodayShowInviteTimes();
}
var t = document.querySelector("#YSF-BTN-HOLDER");
var i = "#YSF-CUSTOM-ENTRY-" + window.__YSFTHEMELAYEROUT__;
var n = document.querySelector(".YSF-INVITE-LAYER-WRAPPER");
var o = document.querySelector("#YSF-INVITE-LAYER-WRAPPER-ENTRY");
var r = document.querySelector(i);
var a = document.querySelector("#YSF-BTN-CIRCLE");
var s = document.querySelector("#YSF-BTN-BUBBLE");
function c(e) {
return e ? "block" : "none";
}
if (ysf.inviteText(window.inviteSetting)) {
n.style.display = c(e);
o.style.display = c(e);
}
r.style.display = c(!e);
if (e) {
t.style.maxHeight = "none";
t.style.maxWidth = "none";
a.style.display = c(false);
s.style.display = c(false);
}
};
ysf.entryPanel = function(e, t) {
var i = document.createElement("div"), o = util.isFrameModule() ? 0 : 1;
if (util.isMobilePlatform()) {
i.setAttribute("id", "YSF-PANEL-MOBILE");
i.onclick = function() {
if (ysf.inviteLayer.isInviteLayerShow()) {
return;
}
ve({
category: "closeIframe"
});
};
} else {
parseInt(e) ? i.setAttribute("id", "YSF-PANEL-CORPINFO") : i.setAttribute("id", "YSF-PANEL-INFO");
}
i.className = "ysf-chat-layer";
document.body.appendChild(i);
i.setAttribute("data-switch", o);
r = i;
try {
Y("status", {
layerOpen: o
});
} catch (e) {}
Te();
if (n.preloadIframe) {
ysf.openInline(ysf.url());
}
if (t && util.isFunction(t.success)) {
t.success();
}
};
ysf.invite = function() {
var e, t, i, o = document.createDocumentFragment();
var r = function() {
if (!!e) {
return;
}
e = document.createElement("div");
e.className = "ysf-online-invite-wrap";
if (i.style && i.style.type) {
e.innerHTML = '';
var t = e.childNodes[0], n = t.childNodes, o = n[0];
if (util.isArray(i.style.oprs)) {
var r = null, l = null;
for (var u = 0; u < i.style.oprs.length; u++) {
r = i.style.oprs[u];
l = document.createElement("a");
if (!r) {
continue;
}
l.style.position = "absolute";
l.style.cursor = "pointer";
l.style.height = r.height + "px";
l.style.width = r.width + "px";
l.style.top = r.top + "px";
l.style.left = r.left + "px";
if (r.type == 3) {
l.onclick = s;
} else if (r.type == 2) {
l.onclick = function(e) {
return function() {
ysf.open({
invited: 1,
templateId: e
});
c();
};
}(r.tplid);
} else if (r.type == 1) {
l.href = r.url;
l.target = "_blank";
}
o.appendChild(l);
}
}
n[1].onclick = s;
n[2].onload = function() {
window.setTimeout(a, 100);
};
} else if (i.style) {
e.innerHTML = '';
var t = e.childNodes[0], n = t.childNodes, f = n[0];
if ("innerText" in f) {
f.innerText = i.style.welcomeText;
} else {
f.textContent = i.style.welcomeText;
}
t.onclick = function() {
ysf.open({
invited: 1
});
c();
};
n[1].onclick = s;
n[2].onload = function() {
window.setTimeout(a, 100);
};
}
};
var a = function() {
e.style.visibility = "visible";
};
var s = function(e) {
e = e || window.event || {};
if (e.stopPropagation) {
e.stopPropagation();
} else {
e.cancelBubble = !0;
}
c();
ysf.INVITE_REJECT = true;
if (i.rejectType != 0) {
window.setTimeout(l, i.intervalTime * 1e3);
}
};
var c = function() {
o.appendChild(e);
e.getElementsByTagName("IMG")[0].src = ysf.CDNROOT + "res/nej_blank.gif";
};
var l = function() {
if (!n["sessionInvite"] || !ysf.hasTodayInviteTimes(window.inviteSetting)) {
return;
}
ysf.setTodayShowInviteTimes();
r();
e.style.visibility = "hidden";
document.body.appendChild(e);
e.getElementsByTagName("IMG")[0].src = i.style && i.style.type ? i.style.bdImageUrl : ysf.CDNROOT + "res/invite/1/bg.png";
};
return function(e) {
if (e && e.invitePatternVo && e.invitePatternVo.mode !== 0) {
return;
}
if (!i) {
i = e || {};
if (util.isMobilePlatform()) {
i.style = i.h5Style;
}
}
var t = function() {
window.setTimeout(l, (i.waitTime || 15) * 1e3);
};
if (n.timestamp) {
t();
} else {
n.onackdone = t;
}
};
}();
ysf.checkOpenLayerSize = function(e, t) {
var i = 360, o = 500;
if (!n.layerSize || util.isMobilePlatform()) {
return;
}
var r = n.layerSize;
var a = parseInt(r.height) > o;
var s = parseInt(r.width) > i;
if (t) {
s && (e.style.width = 0);
a && (e.style.height = 0);
return;
}
if (s) {
e.style.width = util.includes(r.width, "px") ? r.width : r.width + "px";
}
if (a) {
e.style.height = util.includes(r.height, "px") ? r.height : r.height + "px";
}
};
ysf.openLayer = function() {
return function(e) {
var t = document.getElementById("YSF-PANEL-CORPINFO") || document.getElementById("YSF-PANEL-INFO") || document.getElementById("YSF-PANEL-MOBILE"), i = document.getElementById("YSF-BTN-HOLDER"), n = document.getElementById("YSF-IFRAME-LAYER");
if (!t) {
return;
}
i.style.display = "none";
t.className = "ysf-chat-layer ysf-chat-layeropen";
ysf.checkOpenLayerSize(t);
if (util.isMobilePlatform() && n) {
n.className = "ysf-chat-mobile-layeropen" + (e === ysf.INVITE_TPYE ? " ysf-chat-mobile-invite-layer" : "");
}
E = document.body.scrollTop || document.documentElement.scrollTop;
if (document.getElementById("YSF-PANEL-MOBILE")) {
document.body.classList.add("YSF-PANEL-BODY-FIXED");
document.getElementById("YSF-PANEL-MOBILE").addEventListener("touchmove", (function(e) {
e.stopPropagation();
}));
}
t.setAttribute("data-switch", 1);
try {
Y("status", {
layerOpen: 1
});
} catch (e) {}
};
}();
window.windowurl = "";
ysf.openWin = function() {
return function(e, t, i) {
if (util.isMobilePlatform()) {
if (i && i.replace) {
window.location.replace(e);
} else {
window.location.href = e;
}
} else {
window.windowurl = window.open(e, "YSF_SERVICE_" + (n.appKey || "").toUpperCase(), t.param);
if (!window.windowurl && !util.isIe()) {
window.location.href = e;
}
}
};
}();
ysf.openUrl = function() {
return function(e, t, i) {
var o = e.replace(/\/iframe/g, "");
window.windowurl = window.open(o, "YSF_SERVICE_" + (n.appKey || "").toUpperCase(), t.param);
if (!window.windowurl && !util.isIe()) {
if (i && i.replace) {
window.location.replace(o);
} else {
window.location.href = o;
}
}
};
}();
ysf.close = function() {
if (window.windowurl) {
window.windowurl.close();
} else if (i.type === "layer") {
var e = document.getElementById("YSF-PANEL-CORPINFO") || document.getElementById("YSF-PANEL-INFO") || document.getElementById("YSF-PANEL-MOBILE"), t = document.getElementById("YSF-BTN-HOLDER");
delete ysf.openInline.loadStatus;
document.body.removeChild(e);
document.body.removeChild(t);
s = true;
}
};
ysf.NotifyMsgAndBubble = function(e) {
var t = {
clearCircle: function(e) {
var t = "YSF-" + F() + "-MSGNUMBERS", i = document.getElementById("YSF-BTN-CIRCLE"), o = document.getElementById("YSF-BTN-BUBBLE");
o && (o.style.display = "none");
i && (i.style.display = "none");
localStorage.setItem(t, 0);
n["notifyNumber"] = 0;
n["notifyContent"] = "";
f = 0;
},
notifyCircle: function(e) {
var t = "YSF-" + F() + "-MSGNUMBERS";
localStorage.setItem(t, e.data.circleNum);
var i = document.getElementById("YSF-BTN-BUBBLE"), o = document.getElementById("YSF-BTN-CONTENT"), r = document.getElementById("YSF-BTN-CIRCLE");
var a = document.getElementById("YSF-PANEL-CORPINFO") || document.getElementById("YSF-PANEL-INFO") || document.getElementById("YSF-PANEL-MOBILE");
var s = {
image: function(e) {
return "[" + (local.IMAGE || "图片") + "]";
},
audio: function(e) {
return "[" + (local.AUDIO || "音频") + "]";
},
video: function(e) {
return "[" + (local.VIDEO || "视频") + "]";
},
file: function(e) {
return "[" + (local.FILE || "文件") + "]" + e.name;
},
text: function(e) {
return e;
},
rich: function(e) {
return util.replaceRichAndUnescape(e);
},
productinfo: function(e) {
return "[" + (local.PRD_LINK || "商品链接") + "]";
},
staffInviteDetail: function(e) {
return util.replaceRichAndUnescape(e);
},
userJoinEvaluate: function(e) {
return util.replaceRichAndUnescape(e);
}
};
var c = util.isFrameModule() && a && a.getAttribute("data-switch") == 0 && s[e.data.type] && n["sdkCustom"] == 0;
if (!util.isFrameModule() || c) {
r && (r.style.display = "block");
i && (i.style.display = "block");
r && (r.innerHTML = e.data.circleNum > 99 ? "99+" : e.data.circleNum);
o && (o.innerHTML = s[e.data.type](e.data.notifyCnt));
}
}
};
var i = t[e.category];
if (!!i) {
i(e);
}
};
ysf.getUnreadMsg = function() {
return {
type: n["notifyContent"].type,
message: n["notifyContent"].content,
total: n["notifyNumber"]
};
};
ysf.getConversationThrottle = util.throttleDebounce((function() {
je(ysf._onConversation);
}), 2e3);
ysf.initNim = function() {
var e = {
NULL: 0,
INIT: 1,
CONNECTED: 2
};
var t = -1;
var i = 3e3;
var o = e.NULL;
var r = 8e3;
var a = function() {
return {
db: false,
syncBroadcastMsgs: false,
syncExtraTeamInfo: false,
syncFilter: true,
syncFriendUsers: false,
syncFriends: false,
syncRelations: false,
syncRoamingMsgs: false,
syncRobots: false,
syncSessionUnread: false,
syncStickTopSessions: false,
syncSuperTeamRoamingMsgs: false,
syncSuperTeams: false,
syncTeamMembers: false,
syncTeams: false,
defaultLinkUrl: "https://weblink-qiyu.netease.im",
privateConf: {
lbs_web: window.MIN_LBS
},
onmsg: v,
onerror: w,
onconnect: I,
ondisconnect: E,
oncustomsysmsg: h,
onofflinefiltermsgs: T
};
}();
var s = function(e) {
n["yinxin-state"] = e;
};
var c = function() {
return n["yinxin-state"];
};
var l = function(e) {
var t = n["yunxin-user"] || {};
if (window.localStorage) {
var i = "X-" + e.toUpperCase() + "-YSF-INFO", o = localStorage.getItem(i);
if (!o) {
return;
}
var r = util.query2Object(o);
if (!!r.uid) {
t.fid = r.uid;
}
r.source = o;
return r;
}
};
var u = function(e) {
try {
return JSON.parse(e);
} catch (e) {
return null;
}
};
var f = function(e, t) {
if (!t) {
window.setTimeout(m._$bind(this, appkey), i);
return;
}
g(t);
t.appKey = e;
y(t, a);
window.nim = ysf.nim = new NIM(t);
je(ysf._getConversation)();
};
var d = function(e, t) {
util.ajax({
url: ysf.DOMAIN + "webapi/user/create.action?appKey=" + t,
data: e,
method: "post",
fullResult: true,
contentType: "json",
success: function(e) {
var i = e.info;
e.result = {
token: i.token,
account: i.accid,
exchange: i.exchange,
bid: i.bid
};
f(t, e.result);
},
error: function(e) {
console.log(e, "userCreate error");
}
});
};
var m = function(e) {
var t = {
deviceid: n.uid || n.device,
appKey: e,
token: n.uuid || ""
};
if (n.uid) {
t.foreignid = n.uid;
}
if (n.authToken) {
t.authtoken = n.authToken;
}
d(t, e);
};
var p = function(e, t) {
if (!util.isArray(e) || !util.isFunction(t)) {
return;
}
var i = e.length;
var n = 0;
e.forEach((function(e) {
util.loadJS(e, (function() {
n++;
if (n >= i) {
t();
}
}));
}));
};
function g(e) {
var t = n["yunxin-user"];
if (!t) {
n["yunxin-user"] = e;
} else {
y(t, e);
}
}
function y(e, t) {
each(t, (function(t, i) {
e[t] = i;
}));
return e;
}
function _(e) {
var t = e.idClient.split("#")[0];
if (!t) {
console.error("msg idClient without #", e.idClient, e);
return e;
}
return y(e, {
id: e.idClient,
bid: e.from,
sessionid: t
});
}
function v(e, t) {
console.log(e, t, "_cbReceiveMessage");
var i = {
image: "file",
audio: "file",
video: "file"
};
var n = {
60: !0,
90: !0,
95: !0,
72: !0,
200: !0,
65: !0,
203: !0,
121: !0,
59: !0
};
e = _(e);
if (e.type == "custom") {
e.isOffline = t;
h(e, n);
return;
}
S(y(e, {
content: e[i[e.type] || e.type],
reallyType: e.type
}));
}
function h(e, t, i) {
var n = e.content || "";
var o = [ 9, 17, 59, 42, 1002, "-1000", 11056, 108, 11060 ];
try {
n = JSON.parse(n);
if (!!t && !t[n.cmd] && !i) {
return;
}
if (~o.indexOf(n.cmd) || ~o.indexOf(i)) {
return;
}
if (n.cmd == 65) {
n.content = util.replaceRichAndUnescape(n.content);
e.content = JSON.stringify(n);
}
} catch (e) {}
var r = n.sessionid || n.currentSessionId || n.workSheetTemplateVo && n.workSheetTemplateVo.sessionId;
S(y(e, {
cmd: n.cmd,
sessionid: r
}));
}
function S(e) {
ysf._onSessionMessage(e);
if (n["onConversation"]) {
ysf.getConversationThrottle();
}
}
function I(t) {
console.log(t, "_cbConnect2Yunxin");
if (t.ip) {
g({
ip: t.ip
});
}
s(e.CONNECTED);
b();
}
function w(e) {
var t = {
302: function() {
console.error("连接失败");
}
};
var i = t[e.code];
if (util.isFunction(i)) {
i.call(this);
} else if (typeof i == "string") {
t[i].call(this);
}
}
function E() {
s(e.NULL);
}
function T(e) {
e.sort((function(e, t) {
return e.time > t.time;
}));
e.forEach((function(e) {
v(e, true);
}));
}
function b() {
var e = this;
var t = function() {
N({
content: {
cmd: -1e3,
deviceid: F()
}
});
if (e._timeout) {
clearTimeout(e._timeout);
}
e._timeout = setTimeout((function() {
t();
}), r);
};
t();
}
function N(e) {
ysf.nim.sendCustomSysMsg({
to: e.bid || t,
cc: !0,
filter: !0,
scene: "p2p",
content: JSON.stringify(e.content),
done: e.done
});
}
function x() {
ysf.nim && ysf.nim.disconnect();
s(e.NULL);
}
function R() {
return ~ysf.DOMAIN.indexOf("qytest.netease");
}
return {
_$connect: function(t) {
x();
if (c() !== e.NULL) {
return;
}
s(e.INIT);
var i = [ "//res.qiyukf.net/storage/NIM_Web_NIM_v9.8.103.js" ];
p(i, (function() {
m(t);
}));
},
_$disConnect: function() {
x();
}
};
}();
ysf.checkBaiduSelfBuild = function() {
try {
var e = document.referrer;
var t = util.getSearchParams(e, "xst");
if (t && util.includes(e, "baidu.com")) {
return t;
}
return null;
} catch (e) {
return null;
}
};
ysf.config = function(e, t) {
if (!e) {
return;
}
e.reallyUid = e.uid;
j(e);
if (!t) {
each(e, (function(e) {
if (o.indexOf(e) < 0) {
o.push(e);
}
}));
}
if (!!n.appKey) {
if (!t) {
try {
var i = "YSF-" + n["appKey"].toUpperCase() + "-CARD-UID";
var r = localStorage.getItem(i) || "";
var a = e.uid || "";
if (r && r !== a) {
fe({
data: null
});
de({
data: null
});
}
if (a) {
localStorage.setItem(i, a);
}
} catch (e) {
if (typeof console !== "undefined" && console.warn) {
console.warn("[YSF] localStorage unavailable:", e);
}
}
}
O(e.uid);
le({
upToServer: true,
success: e.success,
error: e.error,
local: t || 0
});
Ee();
Ne();
if (n["connectYunxin"]) {
ysf.initNim._$connect(n["appKey"]);
}
}
};
var Oe = function(e, i) {
util.ajax({
url: ysf.DOMAIN + "webapi/user/company/get/getCorpStatus.action",
method: "get",
data: {
appKey: n.appKey,
shopCode: e
},
success: function(e) {
t = e;
if (util.isFunction(i)) {
i();
}
},
error: function(e) {
console.log("[err]平台企业子企业是否开启", e);
if (util.isFunction(i)) {
i();
}
}
});
};
var Fe = function(e) {
each(e, (function(t, i) {
if (i == undefined || i === "" || i === 0 || i === "0") {
delete e[t];
}
}));
};
ysf.url = function(e, i) {
if (!n.appKey) {
return "";
}
var o = {
k: n.appKey,
u: n.uid || "",
d: F(),
uuid: n.uuid,
gid: n.groupid || 0,
sid: n.staffid || 0,
qtype: n.qtype || 0,
welcomeTemplateId: n.welcomeTemplateId || 0,
dvctimer: n.dvctimer || 0,
robotShuntSwitch: n.robotShuntSwitch || 0,
hc: n.hc || 0,
robotId: n.robotId || 0,
pageId: ysf.PAGEID,
shuntId: n.shuntId || 0,
ctm: (new util.Base64).encode(n.uid + "--" + (new Date).getTime()),
wxwId: n.wxworkAppId || "",
language: n.language || "",
isShowBack: n.isShowBack || 0,
shortcutTemplateId: n.shortcutTemplateId || ""
};
if (n.spkf == 1) {
o.spkf = 1;
}
if (n.APPbackPop) {
o.APPbackPop = n.APPbackPop;
}
if (n.APPBridgePermission) {
o.APPBridgePermission = n.APPBridgePermission;
}
if (n.usealipayjs) {
o.usealipayjs = n.usealipayjs;
}
if (n.isCaptureSupported) {
o.isCaptureSupported = n.isCaptureSupported;
}
if (n.isCustomPickSource) {
o.isCustomPickSource = n.isCustomPickSource;
}
if (n.usewxjs) {
o.usewxjs = n.usewxjs;
}
if (n.downloadPageUrl) {
o.downloadPageUrl = n.downloadPageUrl;
}
if (n.customUrl) {
o.customUrl = n.customUrl;
}
if (n.appName) {
o.appName = n.appName;
}
if (n.checkPermission) {
o.checkPermission = n.checkPermission;
}
if (n.disableMultiple) {
o.disableMultiple = n.disableMultiple;
}
if (n.emojiPopoverWidth) {
o.emojiPopoverWidth = n.emojiPopoverWidth;
}
if (i == ysf.INVITE_TPYE) {
o.isInvite = 1;
}
if (window.sdkTemplateId) {
o.templateId = window.sdkTemplateId;
}
if (window.shuntId) {
o.shuntId = window.shuntId;
}
if (e && e.templateId) {
o.templateId = e.templateId;
}
if (e && e.invited) {
o.invited = 1;
}
if (e && e.invitePatternVo && i != ysf.INVITE_TPYE) {
o.invited = 1;
o.inviteTemplateId = e.inviteTemplateId;
o.robotSwitch = e.invitePatternVo.robotSwitch;
o.humanWelcomeTemplateId = e.invitePatternVo.welcomeTemplateId;
o.robotId = e.invitePatternVo.robotId;
o.welcomeTemplateId = e.invitePatternVo.robotWelcomeTemplateId;
o.inviteGroupId = e.invitePatternVo.inviteGroupId;
}
if (!util.isMobilePlatform() && window.__YSFWINTYPE__ == 1 && n.layerSize && n.layerSize.inputHeight) {
o.ipth = n.layerSize.inputHeight;
}
if (e && e.language) {
o.language = e.language;
}
if (n.unconfirm) {
o.unconfirm = n.unconfirm;
}
if (n.debugger) {
o.debugger = n.debugger;
}
if (!util.isMobilePlatform() && window.__YSFWINTYPE__ == 1) {
o.allowNewTab = n.allowNewTab || 0;
}
each({
n: "name",
e: "email",
m: "mobile"
}, (function(e, t) {
var i = n[t];
if (!!i) {
o[e] = i;
}
}));
if (n.customSkin) {
each({
topbarBgColor: "topbarBgColor",
chatPanelBgColor: "chatPanelBgColor",
lMsgColor: "lMsgColor",
rMsgColor: "rMsgColor",
lMsgBgColor: "lMsgBgColor",
rMsgBgColor: "rMsgBgColor",
buttonColor: "buttonColor",
buttonBgColor: "buttonBgColor",
editorColor: "editorColor",
editorBgColor: "editorBgColor",
corpInfoColor: "corpInfoColor",
corpInfoTitleColor: "corpInfoTitleColor",
corpInfoBgColor: "corpInfoBgColor",
tipColor: "tipColor",
linkColor: "linkColor",
borderColor: "borderColor"
}, (function(e, t) {
var i = n.customSkin[t];
if (!!i) {
o[e] = i;
}
}));
}
o.t = encodeURIComponent(n.title || document.title);
if (n.goodsCId) {
o.goodsCId = n.goodsCId;
}
if (n.goodsCName) {
o.goodsCName = n.goodsCName;
}
if (n.goodsId) {
o.goodsId = n.goodsId;
}
if (n.orderId) {
o.orderId = n.orderId;
}
if (n.orderStageType) {
o.orderStageType = n.orderStageType;
}
var r = (e && e.bid || n.bid) && t;
if (ne() && !r) {
delete o.u;
delete o.d;
delete o.n;
delete o.e;
delete o.m;
delete o.authToken;
}
Fe(o);
if (r) {
o.bid = e && e.bid || n.bid;
return ysf.getImRoot(i, 1) + "/trade" + "?" + serialize(o);
}
return ysf.getImRoot(i) + "?" + serialize(o);
};
ysf.track = function(e, t) {
var i = n.appKey, o = F(), r = encodeURIComponent(location.href), a = localStorage.getItem("DA-LANDPAGE") || "", s = (new Date).getTime(), c = e, l = "";
desc = JSON.stringify(t), tp = 1;
var u = function() {
try {
var e = window.__YSFDAROOT__ + "?ak=" + i + "&dv=" + o + "&cup=" + r + "&lp=" + a + "&tm=" + s + "&ct=" + c + "<=" + l + "&tp=" + tp + "&desc=" + desc + "&u=" + window.ysf.PAGEID;
we(e);
} catch (e) {}
};
u();
};
ysf.logoff = function() {
if (activePreviewRequest) {
J(activePreviewRequest, "cancel", false);
}
L();
util.clearLocalItems(util.findLocalItems(/msgnumbers/gi));
o.forEach((function(e) {
delete n[e];
}));
};
ysf.openByLink = function(e) {
var t = ysf.url();
if (!t) {
return;
}
e = e || {};
var i = e.target || e.srcElement;
if (!i || i.tagName != "A") {
return;
}
i.href = t;
};
var Pe = function(e) {
if (e.clear) {
return null;
}
e.title = e.title && e.title.length > 100 ? e.title.slice(0, 100) : e.title;
e.desc = e.desc && e.desc.length > 300 ? e.desc.slice(0, 300) : e.desc;
e.note = e.note && e.note.length > 100 ? e.note.slice(0, 100) : e.note;
var t = {
pageId: ysf.PAGEID,
template: e.template,
cardType: e.cardType,
sendByUser: e.sendByUser,
auto: e.sendByUser === 1 ? 0 : 1,
show: e.sendByUser === 1 ? 1 : e.show,
actionText: e.actionText,
actionTextColor: e.actionTextColor,
sendProToRobot: e.sendProToRobot,
picture: e.picture,
title: e.title,
desc: e.desc,
url: e.url,
note: e.note,
price: e.price,
goodsId: e.goodsId,
goodsCId: e.goodsCId,
goodsCName: e.goodsCName,
intent: e.intent,
payMoney: e.payMoney,
orderId: e.orderId,
orderTime: e.orderTime,
orderSku: e.orderSku,
orderCount: e.orderCount,
orderStatus: e.orderStatus,
orderStageType: e.orderStageType,
floatCardSend: e.floatCardSend || 0,
info: e.info || {},
agentId: e.agentId || ""
};
if (e.tags && util.isArray(e.tags)) {
t.tags = JSON.stringify(e.tags);
}
if (e.sendKefuOffline) {
t.sendKefuOffline = e.sendKefuOffline;
}
if (e.customLabel) {
t.customLabel = JSON.stringify(e.customLabel);
}
if (e.params) {
t.params = e.params;
}
if (!!n.bid) {
t.bid = n.bid;
}
return t;
};
ysf.product = function(e) {
var t = Pe(e);
fe({
data: t,
success: e.success,
error: e.error
});
};
ysf.clearProduct = function(e) {
e = e || {};
ysf.product({
clear: true,
success: e.success,
error: e.error
});
};
var Ce = function(e) {
if (e.clear) {
return null;
}
var t = {
uuid: e.uuid,
type: e.type,
cards: e.cards || [],
floatCards: e.floatCards || [],
auto: e.sendByUser === 1 ? 0 : 1,
sendByUser: e.sendByUser,
sendKefuOffline: e.sendKefuOffline || 0,
sendProToRobot: e.sendProToRobot,
intent: e.intent,
params: e.params || {}
};
if (e.sendByUser === 1) {
if (e.actionText) {
t.actionText = e.actionText;
}
if (e.actionTextColor) {
t.actionTextColor = e.actionTextColor;
}
if (e.hideAction) {
t.hideAction = e.hideAction;
}
}
if (!!n.bid) {
t.bid = n.bid;
}
return t;
};
ysf.cardMessage = function(e) {
if (e.clear) {
de({
data: null,
success: e.success,
error: e.error
});
return;
}
if (!e.cards || e.cards.length === 0) {
console.error("cards is required");
e.error && e.error("cards is required");
return;
}
var t = Ce(e);
de({
data: t,
success: e.success,
error: e.error
});
};
var Le = function(e) {
if (e.data === undefined || e.data === null) {
return null;
}
var t = {
uuid: e.uuid,
data: e.data,
description: e.description || "",
auto: e.sendByUser === 1 ? 0 : 1,
sendByUser: e.sendByUser
};
if (e.sendByUser === 1) {
if (e.actionText) {
t.actionText = e.actionText;
}
if (e.actionTextColor) {
t.actionTextColor = e.actionTextColor;
}
if (e.hideAction) {
t.hideAction = e.hideAction;
}
}
if (!!n.bid) {
t.bid = n.bid;
}
return t;
};
ysf.customMessage = function(e) {
var t = Le(e);
me({
data: t,
success: e.success,
error: e.error
});
};
ysf.sendProduct = function(e) {
var t = e.success;
var i = e.error;
delete e.success;
delete e.error;
var n = Pe(e);
M({
type: "sendProduct",
data: n
}).then(t).catch(i);
};
ysf.sendCardMessage = function(e) {
if (!e.cards || e.cards.length === 0) {
console.error("cards is required");
e.error && e.error("cards is required");
return;
}
var t = e.success;
var i = e.error;
delete e.success;
delete e.error;
var n = Ce(e);
M({
type: "sendCardMessage",
data: n
}).then(t).catch(i);
};
ysf.clearCustomCard = function(e) {
e = e || {};
ysf.cardMessage({
clear: true,
success: e.success,
error: e.error
});
};
ysf.sendCustomMessage = function(e) {
var t = e.success;
var i = e.error;
delete e.success;
delete e.error;
var n = Le(e);
M({
type: "sendCustomMessage",
data: n
}).then(t).catch(i);
};
ysf.open = function(e, t, o) {
w = e;
var r = ysf.url(e, t, o);
if (!r) {
return;
}
var a = t || i.type;
switch (a) {
case "win":
ysf.openWin(r, i, o);
break;
case "layer":
ysf.openInline(r, (function() {
var i = e && e.invitePatternVo && e.invitePatternVo.screenType == 2 && util.isMobilePlatform() ? "" : t;
ysf.openLayer(i);
try {
if (s && n["dvcswitch"] == 0) {
Y("doconnect", {
doconnect: 1
});
s = false;
}
} catch (e) {}
if (n["dvcswitch"] == 0 && n["pushswitch"] == 1 || f > 0) {
Y("dopushmsgread", {
ids: d
});
d = [];
}
if (!s && n["notifyNumber"] > 0) {
Y("doconnect");
}
ysf.NotifyMsgAndBubble({
category: "clearCircle"
});
}));
break;
case "url":
ysf.openUrl(r, i, o);
break;
}
};
ysf.init = function(e, t, i) {
window.inviteSetting = t || {};
var o = function() {
ysf.entry({
src: e,
inviteSetting: t || {}
});
var o = t && t.invitePatternVo && t.invitePatternVo.mode === 2 && t.switchType === 1;
if (util.isFrameModule() || o) {
ysf.entryPanel(n["corpInfo"], i);
}
ysf.showInviteLayerAuto(t);
};
if (util.isFrameModule()) {
setTimeout((function() {
util.ajax({
url: ysf.DOMAIN + "webapi/user/dvcSession.action?appKey=" + n["appKey"] + "&d=" + n["device"] + "&f=" + n["uid"],
method: "post",
success: function(e) {
v = true;
n["dvcswitch"] = e.dvcSwitch;
n["pushswitch"] = e.pushSwitch || 0;
n["pushmsgid"] = e.batchIdList || 0;
if (util.isFrameModule() == "mobileFrame") {
n["dvcswitch"] = 0;
}
o();
if (g && !h) {
h = true;
for (var t = 0; t < y.length; t++) {
var i = y[t], r = i.func, a = i.arg;
r.apply(null, a);
}
}
},
error: function() {
v = true;
n["dvcswitch"] = 0;
n["pushswitch"] = 0;
o();
if (g && !h) {
h = true;
for (var e = 0; e < y.length; e++) {
var t = y[e], i = t.func, r = t.arg;
i.apply(null, r);
}
}
}
});
}), 1e3);
} else {
n["dvcswitch"] = 0;
n["pushswitch"] = 0;
o();
}
};
ysf.reset = function(e) {
if (activePreviewRequest) {
J(activePreviewRequest, "cancel", false);
}
var t = document.getElementById("YSF-PANEL-CORPINFO") || document.getElementById("YSF-PANEL-INFO") || document.getElementById("YSF-PANEL-MOBILE"), i = document.getElementById("YSF-BTN-HOLDER");
delete ysf.openInline.loadStatus;
document.body.removeChild(t);
document.body.removeChild(i);
ysf.init(n["imgSrc"], window.inviteSetting, {
success: e && e.success,
error: e && e.error
});
s = true;
};
util.addEvent(window, "beforeunload", (function() {
var e = "YSFDVC-" + n["device"], t = "YSFMSG-" + n["appKey"], i = Number(localStorage.getItem(e));
if (i > 0) {
localStorage.setItem(e, --i);
}
util.clearLocalItems(util.findLocalItems(new RegExp(t, "ig")));
}));
ysf.on = function() {
var e = {
onload: "load",
unread: 1
};
return function(e) {
var t = Object.prototype.toString.call(e).slice(8, -1);
if (/object/gi.test(t)) {
for (var i in e) {
if ("onload" == i && util.isFunction(e[i])) {
if (!g) {
util.addLoadEventForProxy(e[i]);
} else {
e[i]();
}
} else if ("onLayerload" == i && util.isFunction(e[i])) {
if (ysf.openInline.loadStatus == "loaded") {
e[i]();
} else {
ysf["_" + i] = e[i];
}
} else if (util.isFunction(ysf[i]) && util.isFunction(e[i])) {
ysf["_" + i] = e[i];
}
}
} else {
util.consoleWarn("波比(。・∀・)ノ: 请保持正确的监听姿势...");
}
};
}();
ysf.getPushMessage = function(e) {
Y("dogetpushmsg", {
ids: e
});
};
ysf._unread = function() {};
ysf.unread = function() {
return {
type: n["notifyContent"].type,
message: n["notifyContent"].content,
total: n["notifyNumber"]
};
};
ysf._onLayerload = function() {};
ysf.clearDragresize = function(e) {
try {
var t = window.location.hostname.split(".")[0];
var i = [ "callcenter", "session", "qualitysession", "qualitycallsession", "worksheet", "callflow", "leave", "monitor", "usercenter" ];
if (i.indexOf(e) > -1) {
util.clearLocalItems(util.findLocalItems(new RegExp(t + "-" + e, "ig")));
} else {
for (var n = 0; n < i.length; n++) {
util.clearLocalItems(util.findLocalItems(new RegExp(t + "-" + i[n], "ig")));
}
}
} catch (e) {}
};
ysf.setAuthToken = ysf.setToken = function(e) {
n["authToken"] = e;
le({});
};
ysf.pollAuthToken = function() {
var e = 0;
var t = -1;
var i = 4;
return function(n, o) {
var r = function(i) {
var r = i && i.authToken;
if (!r) {
util.consoleError("result has not token", i);
return;
}
ysf.setAuthToken(i.authToken);
e = 0;
clearInterval(t);
t = setTimeout((function() {
ysf.pollAuthToken(n, o);
}), o.interval);
if (util.isFunction(o.onsuccess)) {
o.onsuccess(i);
}
};
var a = function(t) {
if (e < i) {
e++;
ysf.pollAuthToken(n, o);
}
if (util.isFunction(o.onerror)) {
o.onerror(t);
}
}, s = o.method || "GET";
i = o.tryTime || 4;
if (o.interval === null) {
util.consoleError("pollauthtoken is not set interval", o);
return;
}
util.ajax({
url: n,
method: s,
data: o.data,
success: r,
error: a
});
};
}();
function Ye(e, t) {
var i = ysf[e];
if (!util.isFunction(i)) {
return;
}
if (g) {
return i.apply(null, t);
} else {
switch (e) {
case "onready":
case "onLayerload":
case "onunread":
case "config":
case "product":
case "logoff":
case "setAuthToken":
case "pollAuthToken":
case "onConversation":
case "onSessionMessage":
case "getConversation":
case "cardMessage":
case "customMessage":
y.push({
func: i,
arg: t
});
break;
case "open":
case "url":
case "track":
case "getUnreadMsg":
util.consoleWarn("can not exec" + e + "before sdk ready");
default:
break;
}
}
}
ysf.onready = function(e) {
util.isFunction(e) && e();
};
ysf.onunread = function(e) {
ysf.on({
unread: e
});
};
ysf.onLayerload = function(e) {
ysf.on({
onLayerload: e
});
};
ysf.getConversation = function(e) {
ysf.on({
getConversation: e
});
};
ysf._getConversation = function() {};
ysf.onConversation = function(e) {
ysf.on({
onConversation: e
});
n["onConversation"] = true;
};
ysf._onConversation = function() {};
ysf.onSessionMessage = function(e) {
ysf.on({
onSessionMessage: e
});
};
ysf._onSessionMessage = function() {};
ysf.initData = function() {
each({
DOMAIN: ysf.ROOT + "/",
IMROOT: function() {
var e = "/client/iframe";
if (util.isMobilePlatform() && window.__YSFMODILEWINTYPE__ === 2) {
e = "/client";
} else if (!util.isMobilePlatform() && window.__YSFWINTYPE__ == 1) {
e = "/client/iframe";
} else {
e = "/client";
}
var t = ysf.ROOT + e;
return t;
}(),
RESROOT: ysf.ROOT + "/sdk/",
CDNROOT: "//res.qiyukf.net/sdk/",
INVITE_TPYE: "layer"
}, (function(e, t) {
ysf[e] = t;
}));
};
ysf.buildProxy = Se;
(function() {
ysf.initData();
x();
ysf.PAGEID = N();
window.__YSFAPPPATH__ = "/sdk/";
for (var e = 0; e < _.length; e++) {
try {
var t = _[e], i = t[0], n = Array.prototype.slice.call(t, 1);
Ye(i, n);
} catch (e) {
util.consoleWarn(e);
}
}
})();
}
})();
})();