//官网客服切换 //引入方法 type:空或uat (function(global){'use strict';var _Base64=global.Base64;var version="2.3.2";var buffer;if(typeof module!=='undefined'&&module.exports){try{buffer=require('buffer').Buffer}catch(err){}}var b64chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';var b64tab=function(bin){var t={};for(var i=0,l=bin.length;i>>6))+fromCharCode(0x80|(cc&0x3f))):(fromCharCode(0xe0|((cc>>>12)&0x0f))+fromCharCode(0x80|((cc>>>6)&0x3f))+fromCharCode(0x80|(cc&0x3f)))}else{var cc=0x10000+(c.charCodeAt(0)-0xD800)*0x400+(c.charCodeAt(1)-0xDC00);return(fromCharCode(0xf0|((cc>>>18)&0x07))+fromCharCode(0x80|((cc>>>12)&0x3f))+fromCharCode(0x80|((cc>>>6)&0x3f))+fromCharCode(0x80|b=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;var utob=function(u){return u.replace(re_utob,cb_utob)};var cb_encode=function(ccc){var padlen=[0,2,1][ccc.length%3],ord=ccc.charCodeAt(0)<<16|((ccc.length>1?ccc.charCodeAt(1):0)<<8)|((ccc.length>2?ccc.charCodeAt(2):0)),chars=[b64chars.charAt(ord>>>18),b64chars.charAt((ord>>>12)&63),padlen>=2?'=':b64chars.charAt((ord>>>6)&63),padlen>=1?'=':b64chars.charAt(ord&63)];return chars.join('')};var btoa=global.btoa?function(b){return global.btoa(b)}:function(b){return b.replace(/[\s\S]{1,3}/g,cb_encode)};var _encode=buffer?buffer.from&&buffer.from!==Uint8Array.from?function(u){return(u.constructor===buffer.constructor?u:buffer.from(u)).toString('base64')}:function(u){return(u.constructor===buffer.constructor?u:new buffer(u)).toString('base64')}:function(u){return btoa(utob(u))};var encode=function(u,urisafe){return!urisafe?_encode(String(u)):_encode(String(u)).replace(/[+\/]/g,function(m0){return m0=='+'?'-':'_'}).replace(/=/g,'')};var encodeURI=function(u){return encode(u,true)};var re_btou=new RegExp(['[\xC0-\xDF][\x80-\xBF]','[\xE0-\xEF][\x80-\xBF]{2}','[\xF0-\xF7][\x80-\xBF]{3}'].join('|'),'g');var cb_btou=function(cccc){switch(cccc.length){case 4:var cp=((0x07&cccc.charCodeAt(0))<<18)|((0x3f&cccc.charCodeAt(1))<<12)|((0x3f&cccc.charCodeAt(2))<<6)|(0x3f&cccc.charCodeAt(3)),offset=cp-0x10000;return(fromCharCode((offset>>>10)+0xD800)+fromCharCode((offset&0x3FF)+0xDC00));case 3:return fromCharCode(((0x0f&cccc.charCodeAt(0))<<12)|((0x3f&cccc.charCodeAt(1))<<6)|(0x3f&cccc.charCodeAt(2)));default:return fromCharCode(((0x1f&cccc.charCodeAt(0))<<6)|(0x3f&cccc.charCodeAt(1)))}};var btou=function(b){return b.replace(re_btou,cb_btou)};var cb_decode=function(cccc){var len=cccc.length,padlen=len%4,n=(len>0?b64tab[cccc.charAt(0)]<<18:0)|(len>1?b64tab[cccc.charAt(1)]<<12:0)|(len>2?b64tab[cccc.charAt(2)]<<6:0)|(len>3?b64tab[cccc.charAt(3)]:0),chars=[fromCharCode(n>>>16),fromCharCode((n>>>8)&0xff),fromCharCode(n&0xff)];chars.length-=[0,0,2,1][padlen];return chars.join('')};var atob=global.atob?function(a){return global.atob(a)}:function(a){return a.replace(/[\s\S]{1,4}/g,cb_decode)};var _decode=buffer?buffer.from&&buffer.from!==Uint8Array.from?function(a){return(a.constructor===buffer.constructor?a:buffer.from(a,'base64')).toString()}:function(a){return(a.constructor===buffer.constructor?a:new buffer(a,'base64')).toString()}:function(a){return btou(atob(a))};var decode=function(a){return _decode(String(a).replace(/[-_]/g,function(m0){return m0=='-'?'+':'/'}).replace(/[^A-Za-z0-9\+\/]/g,''))};var noConflict=function(){var Base64=global.Base64;global.Base64=_Base64;return Base64};global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict};if(typeof Object.defineProperty==='function'){var noEnum=function(v){return{value:v,enumerable:false,writable:true,configurable:true}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,'fromBase64',noEnum(function(){return decode(this)}));Object.defineProperty(String.prototype,'toBase64',noEnum(function(urisafe){return encode(this,urisafe)}));Object.defineProperty(String.prototype,'toBase64URI',noEnum(function(){return encode(this,true)}))}}if(global['Meteor']){window.Base64=global.Base64}if(typeof module!=='undefined'&&module.exports){module.exports.Base64=global.Base64}else if(typeof define==='function'&&define.amd){define([],function(){return global.Base64})}})(typeof self!=='undefined'?self:typeof window!=='undefined'?window:typeof global!=='undefined'?global:this); function chatUtil() {} chatUtil.isPc = function (){ if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) { return false; } else { return true; } } chatUtil.isAndroid = function() { var _userAgentInfo = navigator.userAgent, _isAndroid = _userAgentInfo.indexOf('Android') > -1 || _userAgentInfo.indexOf('Linux') > -1 || navigator.platform.indexOf('Linux') > -1; return _isAndroid; }; //检测iphonex chatUtil.isIphonex = function(){ var isIphonex = (window.screen.height === 812 && window.screen.width === 375) || (window.screen.height === 896 && window.screen.width === 414); return isIphonex; }; //检测微信 chatUtil.isWeixin = function(){ var userAgentInfo = window.navigator.userAgent; var ua = userAgentInfo.toLowerCase(); var isWeixin = ua.match(/MicroMessenger/i) == 'micromessenger'; return isWeixin; }; var resetHeight = function(cutHt){ var _cutHt = cutHt ? cutHt : 0; var _headerHt = $(".qihoo_chatpup .header").outerHeight(true); $("#liveFrame").height($(window).height() - _headerHt - _cutHt); }; var setIframeHeight = function(){ $(window).resize(function () { resetHeight(); }); }; chatUtil.chatTextClick = function (data) { if(!chatUtil.isAndroid()) { setTimeout(function () { var _srollTop = $("body").scrollTop(); if(_srollTop>200) { resetHeight(_srollTop); $('html,body').animate({scrollTop: 0}, 0); }else{ $('html,body').animate({scrollTop: $(window).height()}, 0); } }, 300); } }; chatUtil.chatTextBlur = function (data) { if(!chatUtil.isAndroid()) { resetHeight(); $('html,body').animate({scrollTop: $(window).height()}, 0); } }; var initJieLive = function() { //PC端客服 var showLive = function (d) { var app_clientId = localStorage.getItem("app_clientId"); if (app_clientId) { d.clientId = app_clientId; } else { localStorage.setItem("app_clientId", d.clientId); } $(".kefu").show(); if(d.platform == "Imcc") { d.accessId = d.accessId ? d.accessId : "Q3bjHo"; $(".kefu").attr("onclick","") $(".kefu").on("click", function () { var imNumber = d.accessId; //接入号码,请按正确修改 var hastab = false; //是否存在右侧标签页,( true 存在,不存在不需要该参数。) var isstatic = false; //true=弹出框不可隐藏,false弹出框可隐藏 var openid = ""; //访问者唯一标识(可选参数,默认为0或者为空) var params = { imUserNick: d.userName, imUserNumber: d.clientId, hostImNumber: d.accessId, showIcon: "2", //可以转人工不用登录 crmUrl: d.crmUrl }; //自定义参数, JSON字符串格式UTF8编码经base64转码 new WebchatPop(imNumber, hastab, isstatic, openid, Base64.encode(JSON.stringify(params))) .ready(function (webchat) { $("#adaptation").prepend('×'), $("#close").on("click", function () { $("#adaptation").remove() }) webchat.show() }); }); } }; //手机端客服 var appendChatDiv = function () { var html = ''+ '
'+ '
'+ '
'+ ' '+ '
360借条
'+ '
正在加载...
'; if($(".qihoo_chatpup").length ==0) { $("body").append(html); $(document).on("click", "#chat-close", function () { $(".qihoo_chatpup").hide(); }); } }; //云软点击弹出框 window.imccChatClick = function (parm) { if(!window._loadLiveConfig){ alert("页面尚未加载完,请稍后点击咨询"); return false; } var iframeSrc = "https://support.360-jr.com/live.html?appMobileNo=&userNo=&source=&pkg=jietiaogw&chatFrom=generalize"; if(window._api_type == "uat"){ iframeSrc = "http://support.uat.360-jr.com/live.html?appMobileNo=&userNo=&source=&pkg=jietiaogw&chatFrom=generalize"; } if(parm){ if(parm.appMobileNo){ iframeSrc = iframeSrc.replace('appMobileNo=', 'appMobileNo='+parm.appMobileNo) } if(parm.userNo){ iframeSrc = iframeSrc.replace('userNo=', 'userNo='+parm.userNo) } if(parm.source){ iframeSrc = iframeSrc.replace('source=', 'source='+parm.source) } // if(parm.pkg){ // iframeSrc = iframeSrc.replace('pkg=jietiaogw', 'pkg='+parm.pkg) // } } var _iframeHt = $(window).height() - $(".qihoo_chatpup .header").outerHeight(true); var $iframe = $(''); $iframe.attr("src", iframeSrc); if($("#live-iframe-box #liveFrame").length == 0) { $("#live-iframe-box").append($iframe); } var liveFrame = document.getElementById("liveFrame"); liveFrame.onload = function () { $(".loading").hide(); setIframeHeight(); }; $(".qihoo_chatpup").show(); }; window._loadLiveConfig = false; //判断载入聊天配置文件时候加载完毕 var getLiveConfig = function() { var BASE_API = "https://dispatch.360-jr.com/api/help"; if(window._api_type == "uat"){ BASE_API = "https://dispatch-test.360jie.com.cn/api/help"; } $.ajax({ type: "get", url: BASE_API + '/webjsonphelpDoLive', data: { pkg: "jietiaogw", appMobileNo: "", userNo: "" }, dataType: "jsonp", jsonp: "callback", success: function (data) { if(chatUtil.isPc()) { showLive(data.result.data); }else{ appendChatDiv(); window._livePlatform = data.result.data.platform; } window._loadLiveConfig = true; }, error: function (err) { setTimeout(function () { getLiveConfig(); }, 1000); } }); }; getLiveConfig(); }; (function (){ $(".kefu").hide(); var _api_type = $("#360JieChat").data("type"); window._api_type = _api_type; // if(chatUtil.isPc()) { // var _url = "https://imcc.360-jr.com"; // if (_api_type == "uat") { // _url = "https://imcc-sandbox.360-jr.com"; // } // var script = document.createElement('script'); // script.async = "async"; // script.src = _url + "/webchat_new/static/js/webchat_pop.js"; // script.onload = function () { // initJieLive(); // }; // document.getElementsByTagName("head")[0].appendChild(script); // }else{ initJieLive(); // } })(); window.addEventListener('message',function(e){ if(!e.origin || !e.data) return; try{ var _obj = JSON.parse(e.data); if(_obj.func && chatUtil[_obj.func]){ chatUtil[_obj.func].call(this, _obj); } }catch(e){ console.log(e); } },false);