diff --git a/css/float-widget.css b/css/float-widget.css new file mode 100644 index 0000000..d1a702c --- /dev/null +++ b/css/float-widget.css @@ -0,0 +1,242 @@ +/* ============================================ + 右侧浮窗组件 — float-widget + ============================================ */ + +.float-widget { + position: fixed; + right: 20px; + bottom: 100px; + z-index: 9998; + display: flex; + flex-direction: column; + gap: 6px; +} + +/* 单个浮窗按钮 */ +.fw-item { + position: relative; + width: 44px; + height: 44px; + display: flex; + align-items: center; + justify-content: center; + background: rgba(14, 16, 26, 0.88); + border: 1px solid rgba(255, 255, 255, 0.06); + border-radius: 12px; + cursor: pointer; + transition: all 0.25s ease; + backdrop-filter: blur(12px); + -webkit-backdrop-filter: blur(12px); +} + +.fw-item:hover { + background: rgba(30, 41, 59, 0.95); + border-color: rgba(56, 189, 248, 0.15); + transform: translateX(-4px); + box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); +} + +.fw-item svg { + width: 22px; + height: 22px; + opacity: 0.7; + transition: opacity 0.2s ease; +} + +.fw-item:hover svg { + opacity: 1; +} + +/* ---- 弹出面板 ---- */ +.fw-popup { + position: absolute; + right: calc(100% + 12px); + top: 50%; + transform: translateY(-50%); + min-width: 200px; + background: rgba(14, 16, 26, 0.96); + border: 1px solid rgba(255, 255, 255, 0.08); + border-radius: 14px; + padding: 16px 20px; + opacity: 0; + visibility: hidden; + transition: all 0.2s ease; + pointer-events: none; + backdrop-filter: blur(20px); + -webkit-backdrop-filter: blur(20px); + box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); + white-space: nowrap; +} + +/* 小三角 */ +.fw-popup::after { + content: ''; + position: absolute; + right: -6px; + top: 50%; + transform: translateY(-50%) rotate(45deg); + width: 10px; + height: 10px; + background: rgba(14, 16, 26, 0.96); + border-right: 1px solid rgba(255, 255, 255, 0.08); + border-top: 1px solid rgba(255, 255, 255, 0.08); +} + +.fw-item:hover .fw-popup { + opacity: 1; + visibility: visible; + pointer-events: auto; +} + +/* 面板标题 */ +.fw-popup-title { + font-size: 13px; + font-weight: 600; + color: rgba(226, 232, 240, 0.9); + margin-bottom: 12px; + display: flex; + align-items: center; + gap: 6px; +} + +.fw-popup-title svg { + width: 14px; + height: 14px; + opacity: 0.5; +} + +/* ---- QQ 客服样式 ---- */ +.fw-qq-list { + display: flex; + flex-direction: column; + gap: 10px; +} + +.fw-qq-entry { + display: flex; + align-items: center; + gap: 12px; + padding: 8px 12px; + background: rgba(30, 41, 59, 0.3); + border-radius: 8px; + transition: background 0.2s ease; +} + +.fw-qq-entry:hover { + background: rgba(30, 41, 59, 0.5); +} + +.fw-qq-avatar { + width: 32px; + height: 32px; + border-radius: 50%; + background: rgba(56, 189, 248, 0.1); + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; +} + +.fw-qq-avatar svg { + width: 18px; + height: 18px; + opacity: 0.6; +} + +.fw-qq-info { + display: flex; + flex-direction: column; + gap: 2px; +} + +.fw-qq-num { + font-size: 13px; + color: rgba(226, 232, 240, 0.85); + font-weight: 500; +} + +.fw-qq-time { + font-size: 11px; + color: rgba(148, 163, 184, 0.5); +} + +/* 在线状态点 */ +.fw-qq-status { + width: 6px; + height: 6px; + border-radius: 50%; + background: #22C55E; + flex-shrink: 0; + box-shadow: 0 0 6px rgba(34, 197, 94, 0.4); +} + +/* ---- 二维码样式(群聊 / 公众号) ---- */ +.fw-qr { + text-align: center; +} + +.fw-qr img { + width: 140px; + height: 140px; + border-radius: 8px; + background: #fff; + padding: 6px; + margin-bottom: 8px; +} + +.fw-qr-hint { + font-size: 11px; + color: rgba(148, 163, 184, 0.5); +} + +/* ---- 在线客服 —— 无弹出框,直接跳转 ---- */ +.fw-item[data-type="service"] .fw-popup { + padding: 10px 16px; + min-width: auto; +} + +.fw-service-hint { + font-size: 12px; + color: rgba(226, 232, 240, 0.7); +} + +/* ---- 回到顶部按钮融合 ---- */ +.fw-back-top { + opacity: 0; + visibility: hidden; + transition: all 0.25s ease; +} + +.fw-back-top.show { + opacity: 1; + visibility: visible; +} + +.fw-back-top svg { + width: 18px; + height: 18px; +} + +/* ---- 移动端 ---- */ +@media (max-width: 768px) { + .float-widget { + right: 12px; + bottom: 80px; + gap: 4px; + } + + .fw-item { + width: 38px; + height: 38px; + border-radius: 10px; + } + + .fw-item svg { + width: 18px; + height: 18px; + } + + .fw-popup { + display: none !important; + } +} diff --git a/header.html b/header.html index fbed475..2b454f0 100644 --- a/header.html +++ b/header.html @@ -107,6 +107,8 @@ + + diff --git a/js/float-widget.js b/js/float-widget.js new file mode 100644 index 0000000..a3bacaa --- /dev/null +++ b/js/float-widget.js @@ -0,0 +1,140 @@ +/** + * 右侧浮窗组件 — float-widget.js + * 根据后台配置数据动态渲染浮窗按钮 + */ +(function () { + 'use strict'; + + // SVG 图标定义 + var ICONS = { + qq: '', + service: '', + group: '', + wechat: '', + arrowUp: '' + }; + + /** + * 从后台注入的数据或默认 demo 数据 + * window.__FLOAT_WIDGET_DATA__ 可被后台模板覆盖 + */ + var defaultData = [ + { + type: 'qq', + label: 'QQ客服', + items: [ + { qq: '10001', time: '09:00 - 22:00' }, + { qq: '10002', time: '09:00 - 18:00' } + ] + }, + { + type: 'service', + label: '在线客服', + url: 'javascript:;' + }, + { + type: 'group', + label: '交流群', + qrcode: '/web/BlackFruit-web/assets/img/index/qrcode-placeholder.png' + }, + { + type: 'wechat', + label: '公众号', + qrcode: '/web/BlackFruit-web/assets/img/index/qrcode-placeholder.png' + } + ]; + + function getData() { + return window.__FLOAT_WIDGET_DATA__ || defaultData; + } + + function buildQQPopup(item) { + var html = '
-
- 7*24h不间断服务
-{$data.enterprise_telephone|default=''}
-
-
-
-
-