var $commonParam = {}; $commonParam.accessLimitAndCopyright ={"code":1,"msg":"success","data":{"template":"'; $("body").append(autoOnlineServiceHtml + autoOnlineServiceCss + ''); $('.' + $ifRaMeClass).height($onlineConfig.defaultH - $("#moveHeader").height()); $.onlineServicePos($onlineConfig.node, $onlineConfig.defaultW, $onlineConfig.defaultH); $("." + $onlineConfig.node).on('mousedown', function (event) { var $this = $(this), _top = $this.offset().top, _left = $this.offset().left,//获取div位置偏移量 divX = event.clientX, divY = event.clientY, //获取鼠标位置 $winWith = $(document).width(), $winHeight = $(document).height(); isFlag = true; if (document.attachEvent) { $this[0].attachEvent('onselectstart', function () { return false; }); } $(document).mousemove(function (e) { if (isFlag) { var divMoveX = e.clientX, divMoveY = e.clientY; var $scrollTop = $(document).scrollTop(), $scrollLeft = $(document).scrollLeft();//滚动条高度 var posLeft = divMoveX - divX + _left - $scrollLeft, posTop = divMoveY - divY + _top - $scrollTop; var intValH = $winHeight - $onlineConfig.defaultH, intValW = $winWith - $onlineConfig.defaultW; posTop = posTop < 0 ? 0 : (posTop > intValH ? intValH : posTop); posLeft = posLeft > intValW ? intValW : posLeft; //右限制 posLeft = posLeft < 0 ? 0 : posLeft; //左边的偏移量小于0的时候设置 左边的位置为0 $this.css({'left': posLeft, 'top': posTop}); } }).mouseup(function () { isFlag = false; $(document).off("mousemove"); }) }); }, minOnlineService: function ($onlineConfig) { if ($("." + $onlineConfig.minNode).length > 0) { $("." + $onlineConfig.minNode).remove(); } $onlineConfig.badge = parseInt($commonParam.AutoOnlineService.badge); var minHtml = '
' + '
' + $commonParam.AutoOnlineService.customer_min_name + '
' + '
'; if ($onlineConfig.badge > 0) { minHtml += '
' + $onlineConfig.badge + '
'; } minHtml += '
'; $("body").append(minHtml + '
'); $.onlineServicePos($onlineConfig.minNode, 225,42); }, mobileOnlineService: function ($onlineConfig) { if ($("." + $onlineConfig.mobileNode).length > 0) { $("." + $onlineConfig.mobileNode).remove(); } $onlineConfig.badge = parseInt($commonParam.AutoOnlineService.badge); var mobileHtml = '
' + ''; if ($onlineConfig.badge > 0) { mobileHtml += '
' + $onlineConfig.badge + '
'; } mobileHtml += '
'; $("body").append(mobileHtml + '
'); $.onlineServicePos($onlineConfig.mobileNode, 50,50); } }) $(function () { if ($commonParam.accessLimitAndCopyright.code == 1) {$("body").append($commonParam.accessLimitAndCopyright.data.template)} if (parseInt($commonParam.AutoOnlineService.status) == 1) { var $serviceConfig = {'checkMobile': $.checkMobile(), 'node': 'online_service_container', 'minNode': 'minOnlineServer', 'mobileNode': 'mobileOnlineServer',}; var $defaultStyle=parseInt($commonParam.AutoOnlineService.customer_style_default); if ($serviceConfig.checkMobile) { $.mobileOnlineService($serviceConfig); } else { switch ($defaultStyle) { case 3 : $.mobileOnlineService($serviceConfig); break; case 2 : $.minOnlineService($serviceConfig); break; default : $.maxOnlineService($serviceConfig); break; } } $(document).on("click", '#chat_min_btn', function () { $("#" + $serviceConfig.node).off('mousedown').remove(); if ($serviceConfig.checkMobile) { $.mobileOnlineService($serviceConfig); } else { switch ($defaultStyle) { case 3 : $.mobileOnlineService($serviceConfig); break; default : $.minOnlineService($serviceConfig); break; } } }) $(document).on("click", '#chat_close', function () { $("#" + $serviceConfig.node).off('mousedown').remove(); $("#" + $serviceConfig.minNode).remove(); }) $(document).on("click", '#' + $serviceConfig.minNode+' .online-service-min', function () { $("#" + $serviceConfig.minNode).remove(); $.maxOnlineService($serviceConfig); }) $(document).on("click", '#' + $serviceConfig.mobileNode, function () { $("#" + $serviceConfig.mobileNode).remove(); $.maxOnlineService($serviceConfig); }) } })