var openZoosUrl = function(text, isMobile) {
ksChatLink = 'https://hztk5.kuaishang.cn/bs/im.htm?cas=59076___799223&fi=67689&ism=1';
* 若强行打开新窗口,则放开设置,不设置则手机不打开新窗口,pc打开新窗口,此设置只对当前自定义事件有效
* 若想全局生效,包括快商通默认的打开聊天窗口事件,则将此变量ksUserDefinedOpenNewChatWin定义在ks.j前即可
*/
var ksUserDefinedOpenNewChatWin = true;
function checkQueryString(a, b) {
if (!a) return false;
return new RegExp("(^|&)" + b + "=([^&]*)(&|$)", "i").test(a)
}
function getQueryString(a, b) {
var c = a.indexOf('?');
if (c == -1) return '';
a = a.substr(c + 1, a.length);
var d = new RegExp("(^|&)" + b + "=([^&]*)(&|$)", "i");
var r = a.match(d);
if (r != null) return unescape(r[2]);
return ''
}
if (isMobile && ksChatLink.indexOf('ism=1') == -1) {
if (ksChatLink.indexOf('?') == -1) {
ksChatLink += '?ism=1'
} else {
ksChatLink += '&ism=1'
}
}
var openNewChatWin, _ksChatLink = ksChatLink;
var localArr = ksChatLink.split("?");
localArr.push("");
if (typeof ksUserDefinedOpenNewChatWin != 'undefined' && ksUserDefinedOpenNewChatWin == true) {
openNewChatWin = true
} else if (checkQueryString(localArr[1], 'ism')) {
openNewChatWin = false
} else {
openNewChatWin = true
}
function ksOpenLink() {
var a = '';
try {
var b = getQueryString(ksChatLink, 'cas');
if (b) {
var c = '';
var d = document.cookie.match(new RegExp('(^| )' + b + '_KS_' + b + '=([^;]*)(;|$)'));
if (d != null) {
c = unescape(d[2])
}
if (c) {
a += '&vi=' + c
}
}
} catch (e) {}
var f = "";
try {
if (opener.document.referrer.length > 0) {
f = opener.document.referrer
}
} catch (e) {
f = document.referrer
}
if (!f || f.length == 0) {
f = document.referrer
}
a += '&dp=' + encodeURIComponent(window.location.href);
if (f) a += '&ref=' + encodeURIComponent(f);
if (text) a += '&sText=' + encodeURIComponent(text);
if (ksChatLink.indexOf('?') == -1) {
a = '?' + a.substring(1)
}
ksChatLink += a;
if (!openNewChatWin) {
window.location.href = ksChatLink
} else {
var g = window.open(ksChatLink, '_blank');
if (g) {
try {
g.focus()
} catch (e) {}
} else {
window.location.href = ksChatLink
}
}
}
if (typeof KS != 'undefined') {
var p = {};
if (text) p['sText'] = text;
if (openNewChatWin) p['oTarget'] = '_blank';
try {
if (typeof KS.openChatWin == 'function') {
if (openNewChatWin && _ksChatLink.indexOf('kuaishang') == -1 && !KS.customUrl) {
KS.customUrl = _ksChatLink
}
KS.openChatWin(p)
} else if (typeof KS.openChatLink == 'function') {
KS.openChatLink(p)
} else {
ksOpenLink()
}
} catch (e) {
ksOpenLink()
}
} else {
ksOpenLink()
}
};