v1.3.1
This commit is contained in:
@@ -932,6 +932,10 @@
|
||||
</div>
|
||||
|
||||
<div class="qr-stats">
|
||||
<div class="qr-stat-item">
|
||||
<div class="qr-stat-value" id="qrViewCount">0</div> <!-- Добавлено -->
|
||||
<div class="qr-stat-label">просмотров</div>
|
||||
</div>
|
||||
<div class="qr-stat-item">
|
||||
<div class="qr-stat-value" id="qrUserRole">—</div>
|
||||
<div class="qr-stat-label">роль</div>
|
||||
@@ -940,10 +944,6 @@
|
||||
<div class="qr-stat-value" id="qrUserSince">—</div>
|
||||
<div class="qr-stat-label">на платформе</div>
|
||||
</div>
|
||||
<div class="qr-stat-item">
|
||||
<div class="qr-stat-value" id="qrUserActivity">0</div>
|
||||
<div class="qr-stat-label">активность</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="qr-actions">
|
||||
@@ -1488,54 +1488,44 @@
|
||||
const modal = document.getElementById('qrModal');
|
||||
if (!modal) {
|
||||
console.error('❌ Модальное окно с id "qrModal" не найдено в DOM');
|
||||
console.log('🔍 Поиск всех элементов с классом qr-modal:', document.querySelectorAll('.qr-modal'));
|
||||
showNotification('Ошибка: модальное окно не найдено', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверяем все необходимые элементы
|
||||
const elements = {
|
||||
qrUserName: document.getElementById('qrUserName'),
|
||||
qrUserUrl: document.getElementById('qrUserUrl'),
|
||||
qrViewCount: document.getElementById('qrViewCount'),
|
||||
qrUserRole: document.getElementById('qrUserRole'),
|
||||
qrUserSince: document.getElementById('qrUserSince'),
|
||||
qrUserActivity: document.getElementById('qrUserActivity'),
|
||||
qrCanvas: document.getElementById('qrCanvas'),
|
||||
qrLogoOverlay: document.getElementById('qrLogoOverlay'),
|
||||
qrLogoIcon: document.getElementById('qrLogoIcon')
|
||||
};
|
||||
// Получаем элементы
|
||||
const qrUserName = document.getElementById('qrUserName');
|
||||
const qrUserUrl = document.getElementById('qrUserUrl');
|
||||
const qrViewCountElement = document.getElementById('qrViewCount'); // Переименовал, чтобы не конфликтовать
|
||||
const qrUserRole = document.getElementById('qrUserRole');
|
||||
const qrUserSince = document.getElementById('qrUserSince');
|
||||
const qrCanvas = document.getElementById('qrCanvas');
|
||||
|
||||
// Проверяем каждый элемент
|
||||
let missingElements = [];
|
||||
for (let [key, element] of Object.entries(elements)) {
|
||||
if (!element) {
|
||||
missingElements.push(key);
|
||||
console.error(`❌ Элемент с id "${key}" не найден`);
|
||||
}
|
||||
}
|
||||
|
||||
if (missingElements.length > 0) {
|
||||
console.error('❌ Отсутствуют элементы:', missingElements.join(', '));
|
||||
// Проверяем наличие критически важных элементов
|
||||
if (!qrUserName || !qrUserUrl || !qrViewCountElement || !qrUserRole || !qrUserSince || !qrCanvas) {
|
||||
console.error('❌ Критические элементы модального окна не найдены');
|
||||
console.log('qrUserName:', qrUserName);
|
||||
console.log('qrUserUrl:', qrUserUrl);
|
||||
console.log('qrViewCountElement:', qrViewCountElement);
|
||||
console.log('qrUserRole:', qrUserRole);
|
||||
console.log('qrUserSince:', qrUserSince);
|
||||
console.log('qrCanvas:', qrCanvas);
|
||||
showNotification('Ошибка отображения QR-кода', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('✅ Все элементы модального окна найдены');
|
||||
|
||||
// Устанавливаем имя пользователя
|
||||
elements.qrUserName.textContent = escapeHtml(currentProfileUser.full_name);
|
||||
qrUserName.textContent = escapeHtml(currentProfileUser.full_name);
|
||||
|
||||
// Формируем URL профиля
|
||||
const profileUrl = window.location.origin + '/user/' + currentProfileUser.id;
|
||||
elements.qrUserUrl.textContent = profileUrl.replace('https://', '').replace('http://', '');
|
||||
qrUserUrl.textContent = profileUrl.replace('https://', '').replace('http://', '');
|
||||
|
||||
// Обновляем счетчик просмотров
|
||||
if (typeof qrViewCount === 'undefined') {
|
||||
window.qrViewCount = 0;
|
||||
// Обновляем счетчик просмотров - используем отдельную переменную
|
||||
if (typeof window.qrViewCounter === 'undefined') {
|
||||
window.qrViewCounter = 0;
|
||||
}
|
||||
window.qrViewCount++;
|
||||
elements.qrViewCount.textContent = window.qrViewCount;
|
||||
window.qrViewCounter++;
|
||||
qrViewCountElement.textContent = window.qrViewCounter;
|
||||
|
||||
// Роль пользователя
|
||||
let roleText = '';
|
||||
@@ -1543,7 +1533,7 @@
|
||||
else if (currentProfileUser.role === 'employer') roleText = '🏢 Работодатель';
|
||||
else if (currentProfileUser.role === 'admin') roleText = '👑 Админ';
|
||||
else roleText = '👤 Пользователь';
|
||||
elements.qrUserRole.textContent = roleText;
|
||||
qrUserRole.textContent = roleText;
|
||||
|
||||
// Дата регистрации
|
||||
if (currentProfileUser.created_at) {
|
||||
@@ -1551,18 +1541,15 @@
|
||||
const date = new Date(currentProfileUser.created_at);
|
||||
const now = new Date();
|
||||
const months = Math.floor((now - date) / (1000 * 60 * 60 * 24 * 30));
|
||||
elements.qrUserSince.textContent = (months > 0 ? months : '< 1') + ' мес';
|
||||
qrUserSince.textContent = (months > 0 ? months : '< 1') + ' мес';
|
||||
} catch (e) {
|
||||
console.error('Ошибка при вычислении даты:', e);
|
||||
elements.qrUserSince.textContent = '—';
|
||||
qrUserSince.textContent = '—';
|
||||
}
|
||||
} else {
|
||||
elements.qrUserSince.textContent = '—';
|
||||
qrUserSince.textContent = '—';
|
||||
}
|
||||
|
||||
// Активность
|
||||
elements.qrUserActivity.textContent = 'активен';
|
||||
|
||||
// Генерируем QR-код
|
||||
try {
|
||||
generateQRCodeWithLogo(profileUrl);
|
||||
@@ -1573,7 +1560,7 @@
|
||||
|
||||
// Показываем модальное окно
|
||||
modal.classList.add('active');
|
||||
console.log('✅ QR-модальное окно открыто');
|
||||
console.log('✅ QR-модальное окно открыто, счетчик:', window.qrViewCounter);
|
||||
}
|
||||
|
||||
// Закрыть модальное окно
|
||||
|
||||
Reference in New Issue
Block a user