display: none;" + "}" + "/* 大图标悬浮效果 */" + "#customCustomerIcon:not(.small-icon):hover {" + " transform: translate(-50%, -50%) scale(1.15);" + " box-shadow: 0 0 60px rgba(255, 0, 128, 1), 0 0 80px rgba(255, 107, 0, 0.8);" + "}" + "/* 小图标悬浮效果(仅轻微放大,位置不变) */" + "#customCustomerIcon.small-icon:hover {" + " transform: translate(0, -50%) scale(1.1);" + " box-shadow: 0 0 20px rgba(255, 0, 128, 1);" + "}" + "@keyframes strongPulse {" + " 0% width: 100%; height: 100%; opacity: 0.8;" + " 50% width: 180%; height: 180%; opacity: 0;" + " 100% width: 100%; height: 100%; opacity: 0.8;" + "}" + "/* 隐藏原客服小图标 */" + "#customerServerTip {" + " display: none !important;" + "}"; document.head.appendChild(style); } // 4. 创建图标(根据Cookie初始化大/小状态) function createCustomerIcon() { createCustomerIconStyle(); const icon = document.createElement('div'); icon.id = 'customCustomerIcon'; // 初始状态:Cookie标记为小图标则显示小图标,否则显示大图标 if (hasSwitchedToSmall) { icon.classList.add('small-icon'); icon.innerText = '客服'; } else { icon.innerText = '在线咨询'; } icon.title = '点击联系客服'; document.body.appendChild(icon); return icon; } // 5. 仅执行“大→小”切换(无反向切换) function switchToSmallIcon() { if (!hasSwitchedToSmall) { customerIcon.classList.add('small-icon'); customerIcon.innerText = '客服'; CookieUtil.set('customerIconState', 'small'); // 写入Cookie hasSwitchedToSmall = true; } } // 6. 保留原始结构:加载客服脚本 _s = document.createElement('script'); _s.src = "http://kefu.sffdj.com/customerServer.js"; _s.onload = function() { // 先读取Cookie初始化状态 initIconState(); var option = { "authInit": true, openUrl: 'http://kefu.sffdj.com', token: '7c99d1e133d274412da9e362a146b346', kefuid: '', isShowTip: false, mobileIcon: '', pcIcon: '', windowStyle: 'center' }; var canCustomerServer = new initCustomerServer(option); canCustomerServer.init(); // 创建图标 customerIcon = createCustomerIcon(); // 绑定点击事件:仅切换为小图标 + 打开客服弹窗(小图标点击仅开弹窗,不切换) customerIcon.addEventListener('click', function() { // 第一步:如果是大图标,切换为小图标(小图标点击无此操作) switchToSmallIcon(); // 第二步:打开客服弹窗(无论大小图标,点击都只做这一件事) try { canCustomerServer.getCustomeServer(); } catch (e) { // 跨域降级:新窗口打开 // 修复:替换模板字符串为字符串拼接 const customerUrl = option.openUrl + "?token=" + option.token; window.open(customerUrl, 'customerService', 'width=800,height=600,top=100,left=100,scrollbars=yes'); } }); }; // 脚本加载失败容错(逻辑一致) _s.onerror = function() { initIconState(); customerIcon = createCustomerIcon(); customerIcon.addEventListener('click', function() { switchToSmallIcon(); // 修复:替换模板字符串为字符串拼接 const customerUrl = "http://kefu.sffdj.com?token=7c99d1e133d274412da9e362a146b346"; window.open(customerUrl, 'customerService', 'width=800,height=600,top=100,left=100,scrollbars=yes'); }); }; document.head.appendChild(_s); })();