This commit is contained in:
jeremygan2021
2026-03-27 13:27:47 +08:00
parent df261106da
commit 84b243dc52
10 changed files with 464 additions and 350 deletions

View File

@@ -776,22 +776,14 @@
<label>了解我们 URL (手机端底部按钮)</label>
<input type="text" id="wall_learn_more_url" placeholder="https://...">
</div>
<div class="checkbox-wrapper">
<input type="checkbox" id="wall_show_qrcode"> <label for="wall_show_qrcode">显示扫码签到二维码</label>
</div>
<div class="form-group">
<label>显示字段</label>
<div class="checkbox-wrapper">
<input type="checkbox" id="wall_show_name"> <label for="wall_show_name">姓名</label>
</div>
<div class="checkbox-wrapper">
<input type="checkbox" id="wall_show_company"> <label for="wall_show_company">单位名称</label>
</div>
<div class="checkbox-wrapper">
<input type="checkbox" id="wall_show_position"> <label for="wall_show_position">职务</label>
</div>
<div class="checkbox-wrapper">
<input type="checkbox" id="wall_show_vision"> <label for="wall_show_vision">愿景 (Vision)</label>
</div>
<div class="checkbox-wrapper">
<input type="checkbox" id="wall_show_scope"> <label for="wall_show_scope">业务范围 (弹幕)</label>
<label>大屏显示字段(基于签到字段配置)</label>
<p style="font-size: 0.85em; color: var(--text-muted); margin-bottom: 10px;">勾选要在签到大屏上显示的字段,字段名称与签到字段设置同步</p>
<div id="wall_display_fields" style="display: flex; flex-wrap: wrap; gap: 8px;">
<!-- 动态字段将在这里渲染 -->
</div>
</div>
</div>
@@ -1045,6 +1037,9 @@
"vision_2026": {"label": "2026年业务愿景", "show": true, "required": false}
});
// 渲染大屏显示字段
renderWallDisplayFields(config.checkin_field_config || {}, config.wall_config || {});
// DB Config
document.getElementById('db_host').value = config.db_host || '';
document.getElementById('db_port').value = config.db_port || '';
@@ -1054,14 +1049,10 @@
// Wall Config
const wc = config.wall_config || {};
const show = wc.show_fields || {};
document.getElementById('wall_bg_opacity').value = wc.bg_opacity !== undefined ? wc.bg_opacity : 0.3;
document.getElementById('wall_show_title').checked = wc.show_title !== false;
document.getElementById('wall_learn_more_url').value = wc.learn_more_url || '';
document.getElementById('wall_show_name').checked = show.name !== false;
document.getElementById('wall_show_position').checked = show.position !== false;
document.getElementById('wall_show_vision').checked = show.vision_2026 !== false;
document.getElementById('wall_show_scope').checked = show.business_scope !== false;
document.getElementById('wall_show_qrcode').checked = wc.show_qrcode === true;
});
function renderFieldConfig(tbodyId, fieldConfig, orderedKeys) {
@@ -1132,6 +1123,8 @@
Object.keys(fieldConfig).forEach(key => {
const field = fieldConfig[key];
if (!field) return;
const isLocked = (key === 'name' || key === 'phone');
const row = document.createElement('div');
@@ -1166,6 +1159,8 @@
Object.keys(fieldConfig).forEach(key => {
const field = fieldConfig[key];
if (!field) return;
const isLocked = (key === 'name' || key === 'phone');
const row = document.createElement('div');
@@ -1191,6 +1186,63 @@
});
}
/**
* 渲染大屏显示字段复选框
* @param {Object} checkinFieldConfig 签到字段配置
* @param {Object} wallConfig 大屏配置
*/
function renderWallDisplayFields(checkinFieldConfig, wallConfig) {
const container = document.getElementById('wall_display_fields');
container.innerHTML = '';
const showFields = wallConfig.show_fields || {};
Object.keys(checkinFieldConfig).forEach(key => {
const field = checkinFieldConfig[key];
if (!field || !field.show) return;
const isChecked = showFields[key] !== false;
const label = document.createElement('label');
label.className = 'checkbox-wrapper';
label.style.marginBottom = '0';
label.innerHTML = `
<input type="checkbox" class="wall-display-field" data-key="${key}" ${isChecked ? 'checked' : ''}>
<span style="color: white; cursor: pointer;">${field.label}</span>
<span style="color: #888; font-size: 0.85em; margin-left: 4px;">(${key})</span>
`;
container.appendChild(label);
});
// 如果没有可用字段,显示提示
if (container.children.length === 0) {
container.innerHTML = '<p style="color: var(--text-muted); font-size: 0.9em;">请在"签到/大屏字段设置"中配置需要显示的字段</p>';
}
}
/**
* 获取大屏显示字段配置(从 UI
*/
function getWallDisplayFieldsFromUI() {
const config = {};
const checkboxes = document.querySelectorAll('.wall-display-field');
checkboxes.forEach(cb => {
config[cb.dataset.key] = cb.checked;
});
return config;
}
/**
* 刷新大屏显示字段(当签到字段配置改变时调用)
*/
function refreshWallDisplayFields() {
const checkinConfig = getCheckinFieldConfigFromUI();
const wallConfig = {
show_fields: getWallDisplayFieldsFromUI()
};
renderWallDisplayFields(checkinConfig, wallConfig);
}
/**
* 获取报名字段配置(从 UI
*/
@@ -1480,6 +1532,8 @@
renderTicketFields(config);
} else {
renderCheckinFields(config);
// 刷新大屏显示字段配置
refreshWallDisplayFields();
}
closeDeleteModal();
@@ -1546,13 +1600,8 @@
bg_opacity: parseFloat(document.getElementById('wall_bg_opacity').value),
show_title: document.getElementById('wall_show_title').checked,
learn_more_url: document.getElementById('wall_learn_more_url').value,
show_fields: {
name: document.getElementById('wall_show_name').checked,
company_name: document.getElementById('wall_show_company').checked,
position: document.getElementById('wall_show_position').checked,
vision_2026: document.getElementById('wall_show_vision').checked,
business_scope: document.getElementById('wall_show_scope').checked
}
show_qrcode: document.getElementById('wall_show_qrcode').checked,
show_fields: getWallDisplayFieldsFromUI()
},
// DB Config

View File

@@ -571,25 +571,8 @@
</div>
</div>
<div class="input-group hidden" id="group-company">
<label id="label-company">单位名称</label>
<input type="text" id="form-company" placeholder="点此输入">
</div>
<div class="input-group hidden" id="group-position">
<label id="label-position">职务</label>
<input type="text" id="form-position" placeholder="点此输入">
</div>
<div class="input-group hidden" id="group-business">
<label id="label-business">公司主要经营 / 业务</label>
<textarea id="form-business" rows="2" placeholder="点此输入"></textarea>
</div>
<div class="input-group hidden" id="group-vision">
<label id="label-vision">2026年业务愿景</label>
<textarea id="form-vision" rows="3" placeholder="点此输入 (为了业务更好对接,最好表述清晰)"></textarea>
</div>
<!-- 动态签到字段容器 - 根据 checkin_field_config 自动生成 -->
<div id="dynamic-checkin-fields"></div>
<input type="hidden" id="form-location" value="">
@@ -730,6 +713,52 @@
}
}
/**
* 动态渲染签到表单字段
* 根据 checkin_field_config 配置生成字段 HTML
*/
function renderDynamicCheckinFields() {
const container = document.getElementById('dynamic-checkin-fields');
if (!container) return;
const fc = CONFIG.checkin_field_config || {};
container.innerHTML = '';
// 定义字段显示顺序
const fieldOrder = ['company_name', 'position', 'business_scope', 'vision_2026'];
// 按顺序添加字段
fieldOrder.forEach(key => {
const field = fc[key];
if (!field) return;
const div = document.createElement('div');
div.className = 'input-group' + (field.show ? '' : ' hidden');
div.id = 'group-' + key;
const isTextarea = (key === 'business_scope' || key === 'vision_2026');
let placeholder = '点此输入';
if (key === 'business_scope') placeholder = '点此输入';
if (key === 'vision_2026') placeholder = '点此输入 (为了业务更好对接,最好表述清晰)';
if (isTextarea) {
const rows = key === 'vision_2026' ? 3 : 2;
div.innerHTML = `
<label id="label-${key}">${field.label || key}</label>
<textarea id="form-${key}" rows="${rows}" placeholder="${placeholder}"></textarea>
`;
} else {
div.innerHTML = `
<label id="label-${key}">${field.label || key}</label>
<input type="text" id="form-${key}" placeholder="${placeholder}">
`;
}
container.appendChild(div);
});
}
function applyConfigUI() {
const smsGroup = document.getElementById('sms-verification-group');
if (smsGroup) {
@@ -740,38 +769,8 @@
}
}
// Apply field config (Show/Hide/Required)
const fc = CONFIG.checkin_field_config || {};
const fields = [
{ key: 'company_name', groupId: 'group-company', inputId: 'form-company', labelId: 'label-company' },
{ key: 'position', groupId: 'group-position', inputId: 'form-position', labelId: 'label-position' },
{ key: 'business_scope', groupId: 'group-business', inputId: 'form-business', labelId: 'label-business' },
{ key: 'vision_2026', groupId: 'group-vision', inputId: 'form-vision', labelId: 'label-vision' }
];
fields.forEach(field => {
const conf = fc[field.key] || { show: false, required: false, label: '' };
const group = document.getElementById(field.groupId);
const input = document.getElementById(field.inputId);
const label = document.getElementById(field.labelId);
if (group && input) {
// Visibility
if (conf.show) {
group.classList.remove('hidden');
} else {
group.classList.add('hidden');
}
// Required
input.required = conf.required === true;
// Label
if (label && conf.label) {
label.textContent = conf.label;
}
}
});
// 动态渲染字段
renderDynamicCheckinFields();
}
function updateCheckinButtonState() {
@@ -979,11 +978,14 @@
setVal('form-name', user.name);
setVal('form-phone', user.phone);
setVal('form-company', user.industry_company);
// Clear other optional fields to avoid carrying over data if user switches
setVal('form-position', user.position); // Note: user.position might not exist in search result
setVal('form-business', user.business_scope);
setVal('form-vision', user.vision_2026);
// 动态字段填充
const fc = CONFIG.checkin_field_config || {};
Object.keys(fc).forEach(key => {
if (key === 'name' || key === 'phone') return;
// 特殊映射company_name 字段填充 industry_company 的值
const fieldKey = (key === 'company_name') ? 'industry_company' : key;
setVal('form-' + key, user[fieldKey] || '');
});
// Display preview
if (document.getElementById('display-name')) document.getElementById('display-name').textContent = user.name;
@@ -1014,18 +1016,22 @@
return el ? el.value : '';
};
// 构建 payload
const payload = {
gsdh_id: getVal('gsdh-id'),
name: getVal('form-name'),
phone: getVal('form-phone'),
verification_code: getVal('form-verification-code'),
company_name: getVal('form-company'),
position: getVal('form-position'),
business_scope: getVal('form-business'),
vision_2026: getVal('form-vision'),
location: getVal('form-location')
};
// 动态收集签到字段数据
const fc = CONFIG.checkin_field_config || {};
Object.keys(fc).forEach(key => {
if (key === 'name' || key === 'phone') return;
payload[key] = getVal('form-' + key);
});
try {
const response = await fetch('/api/checkin', {
method: 'POST',

View File

@@ -217,6 +217,35 @@
-webkit-text-fill-color: transparent;
}
.card-position {
font-size: 1.2rem;
color: var(--primary-color);
margin-bottom: 15px;
}
.card-vision {
font-size: 1.4rem;
color: #dbe4ff;
font-style: italic;
margin-top: 15px;
}
.card-scope {
font-size: 1.2rem;
color: #dbe4ff;
margin-top: 10px;
}
.card-custom-field {
font-size: 1.2rem;
color: #dbe4ff;
margin-top: 10px;
padding: 8px 15px;
background: rgba(255,255,255,0.05);
border-radius: 8px;
display: inline-block;
}
/* Stats Counter */
.stats-counter {
position: absolute;
@@ -241,6 +270,53 @@
color: #aaa;
}
/* 二维码容器 */
.qrcode-container {
position: fixed;
top: 50%;
right: 40px;
transform: translateY(-50%);
z-index: 25;
animation: fadeInUp 0.6s ease-out;
}
.qrcode-box {
background: rgba(10, 20, 40, 0.9);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 2px solid rgba(0, 242, 255, 0.5);
border-radius: 16px;
padding: 20px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 242, 255, 0.2);
}
.qrcode-title {
font-size: 1rem;
font-weight: bold;
color: #fff;
text-align: center;
margin-bottom: 12px;
text-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
}
.qrcode-image {
width: 150px;
height: 150px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.2);
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(-50%) translateX(20px);
}
to {
opacity: 1;
transform: translateY(-50%) translateX(0);
}
}
/* Mobile Learn More Button */
.mobile-btn-container {
display: none;
@@ -298,9 +374,6 @@
height: 60px;
font-size: 1.5rem;
}
#card-extra {
font-size: 1rem !important;
}
.stats-counter {
bottom: 10px;
right: 10px;
@@ -309,6 +382,23 @@
.stats-number {
font-size: 1.5rem;
}
.qrcode-container {
position: fixed;
top: auto;
bottom: 80px;
right: 50%;
transform: translateX(50%);
}
.qrcode-box {
padding: 12px;
}
.qrcode-title {
font-size: 0.9rem;
}
.qrcode-image {
width: 100px;
height: 100px;
}
}
</style>
@@ -332,25 +422,24 @@
<div class="spotlight-container">
<div class="spotlight-card" id="card">
<div class="user-info">
{% if show.name != false %}
<div class="user-info" id="card-header">
<div class="user-avatar-large" id="card-avatar">?</div>
<div>
<span id="card-name" style="font-weight: bold; color: white;"></span>
{% if show.position != false %}
<span id="card-position" style="font-size: 0.8em; margin-left: 10px; color: var(--primary-color);"></span>
{% endif %}
</div>
{% endif %}
</div>
{% if show.company_name != false %}
<div class="company-name" id="card-company"></div>
{% endif %}
{% if show.vision_2026 != false or show.business_scope != false %}
<div id="card-extra" style="font-size: 1.4rem; color: #dbe4ff; font-style: italic; margin-top: 20px;"></div>
{% endif %}
<div id="card-fields" style="margin-top: 20px;">
<!-- 动态字段将在这里渲染 -->
</div>
</div>
</div>
<!-- 扫码签到二维码 -->
<div class="qrcode-container" id="qrcode-container" style="display: none;">
<div class="qrcode-box">
<div class="qrcode-title">扫码签到</div>
<img src="/static/qrcode.png" alt="签到二维码" class="qrcode-image" id="wall-qrcode">
</div>
</div>
@@ -378,8 +467,10 @@
const isMobile = () => window.innerWidth <= 768;
const SHOW_VISION = {{ 'true' if show.vision_2026 != false else 'false' }};
const SHOW_SCOPE = {{ 'true' if show.business_scope != false else 'false' }};
// 大屏显示字段配置(从后端获取)
const WALL_SHOW_FIELDS = {{ config.wall_config.show_fields | tojson if config.wall_config and config.wall_config.show_fields else '{}' }};
const CHECKIN_FIELD_CONFIG = {{ config.checkin_field_config | tojson if config.checkin_field_config else '{}' }};
const WALL_CONFIG = {{ config.wall_config | tojson if config.wall_config else '{}' }};
// --- State ---
let allUsers = []; // All fetched users
@@ -400,6 +491,18 @@
if (isGridMode) arrangeGrid();
});
// 控制二维码显示/隐藏
const qrcodeContainer = document.getElementById('qrcode-container');
if (qrcodeContainer) {
// 如果 show_qrcode 为 true 则显示,默认为 false
if (WALL_CONFIG.show_qrcode === true) {
qrcodeContainer.style.display = 'block';
}
}
// 随机图标列表
const RANDOM_ICONS = ['🎯', '⭐', '🌟', '💫', '✨', '🎊', '🎉', '🎈', '🚀', '💎', '🏆', '🎖️', '🌈', '🦄', '🎪', '🎨', '🎭', '🎪', '🎯', '🎲'];
// --- Class: UserBubble ---
class UserBubble {
constructor(user) {
@@ -408,15 +511,23 @@
this.element = document.createElement('div');
this.element.className = 'user-bubble';
// Content
const name = user.name || '嘉宾';
// Dynamic font size based on name length
const showName = WALL_SHOW_FIELDS.name !== false;
let bubbleContent;
let fontSize = '0.9rem';
if (name.length > 3) fontSize = '0.7rem';
if (name.length > 4) fontSize = '0.6rem';
if (showName) {
const name = user.name || '嘉宾';
if (name.length > 3) fontSize = '0.7rem';
if (name.length > 4) fontSize = '0.6rem';
bubbleContent = name;
} else {
const randomIndex = Math.floor(Math.random() * RANDOM_ICONS.length);
bubbleContent = RANDOM_ICONS[randomIndex];
fontSize = '1.5rem';
}
this.element.innerHTML = `
<div class="bubble-avatar" style="font-size: ${fontSize}">${name}</div>
<div class="bubble-avatar" style="font-size: ${fontSize}">${bubbleContent}</div>
`;
// Interaction: Click to show in spotlight
@@ -665,29 +776,58 @@
const card = document.getElementById('card');
card.classList.remove('active');
// Wait for fade out
setTimeout(() => {
if(document.getElementById('card-name')) document.getElementById('card-name').textContent = user.name;
if(document.getElementById('card-position')) document.getElementById('card-position').textContent = user.position || '';
if(document.getElementById('card-company')) document.getElementById('card-company').textContent = user.company_name || '嘉宾';
if(document.getElementById('card-avatar')) document.getElementById('card-avatar').textContent = user.name ? user.name.charAt(0) : '?';
const showName = WALL_SHOW_FIELDS.name !== false;
const cardHeader = document.getElementById('card-header');
const extraDiv = document.getElementById('card-extra');
if (extraDiv) {
if (SHOW_VISION && user.vision_2026) {
extraDiv.textContent = "🎯 " + user.vision_2026;
extraDiv.style.display = 'block';
} else if (SHOW_SCOPE && user.business_scope) {
extraDiv.textContent = user.business_scope;
extraDiv.style.display = 'block';
} else {
extraDiv.style.display = 'none';
}
if (showName) {
cardHeader.style.display = 'flex';
if(document.getElementById('card-name')) document.getElementById('card-name').textContent = user.name || '';
if(document.getElementById('card-avatar')) document.getElementById('card-avatar').textContent = user.name ? user.name.charAt(0) : '?';
} else {
cardHeader.style.display = 'none';
}
renderCardFields(user);
card.classList.add('active');
}, 800);
}
/**
* 根据配置动态渲染卡片字段
*/
function renderCardFields(user) {
const container = document.getElementById('card-fields');
container.innerHTML = '';
let html = '';
Object.keys(WALL_SHOW_FIELDS).forEach(key => {
if (!WALL_SHOW_FIELDS[key]) return;
const fieldConfig = CHECKIN_FIELD_CONFIG[key];
if (!fieldConfig) return;
const fieldValue = user[key] || '';
if (!fieldValue) return;
if (key === 'company_name') {
html += `<div class="company-name">${fieldValue}</div>`;
} else if (key === 'vision_2026') {
html += `<div class="card-vision">🎯 ${fieldValue}</div>`;
} else if (key === 'business_scope') {
html += `<div class="card-scope">${fieldValue}</div>`;
} else if (key === 'position') {
html += `<div class="card-position">${fieldValue}</div>`;
} else {
html += `<div class="card-custom-field">${fieldValue}</div>`;
}
});
container.innerHTML = html;
}
function startSpotlight() {
if (isMobile()) return;
if (spotlightInterval) clearInterval(spotlightInterval);