Debug: console.log в UserProfileView + selfMarker → Profile

This commit is contained in:
root 2026-08-21 12:03:58 +00:00
parent f6fa3fedab
commit 31a39d7436
2 changed files with 12 additions and 3 deletions

View File

@ -217,11 +217,17 @@ const MapView = {
this.map.removeSource('radius-circle');
}
// маркер "Я"
// маркер "Я" (клик → свой профиль)
this.selfMarkerEl = this.makeMarkerEl(
'<div style="width:18px;height:18px;border-radius:50%;background:#4285F4;border:3px solid white;box-shadow:0 0 0 2px rgba(66,133,244,0.4);"></div>',
'<div style="width:18px;height:18px;border-radius:50%;background:#4285F4;border:3px solid white;box-shadow:0 0 0 2px rgba(66,133,244,0.4);cursor:pointer;"></div>',
18
);
this.selfMarkerEl.addEventListener('click', () => {
const me = API.Store.user;
if (me && (me.id || me.user_id)) {
App.showView('profile');
}
});
this.selfMarkerObj = new maplibregl.Marker({ element: this.selfMarkerEl })
.setLngLat([lng, lat])
.addTo(this.map);

View File

@ -222,6 +222,7 @@ const UserProfileView = {
]);
this.data = user.user || user;
const u = this.data;
console.log('[UserProfile] loaded:', u && u.id, 'stats:', stats);
const init = ((u.name || u.email || '?')[0] || '?').toUpperCase();
const rating = stats.rating_avg ? Number(stats.rating_avg).toFixed(1) : '—';
const reviewsCount = stats.rating_count || 0;
@ -229,10 +230,11 @@ const UserProfileView = {
document.getElementById('up-content').innerHTML = `
<!-- Аватар и имя -->
<div class="card-b" style="display:flex;align-items:center;gap:14px;">
<div class="avatar-b lg" style="${u.photo_url ? `background-image:url(${u.photo_url});background-size:cover;color:transparent;` : ''}">${u.photo_url ? '' : init}</div>
<div class="avatar-b lg" style="${u.photo ? `background-image:url(${u.photo});background-size:cover;color:transparent;` : ''}">${u.photo ? '' : init}</div>
<div style="flex:1;">
<div style="font-weight:700;font-size:18px;">${escapeHtml(u.name || '')}</div>
${u.city ? `<div style="font-size:13px;color:var(--text-dim);">📍 ${escapeHtml(u.city)}</div>` : ''}
${u.age ? `<div style="font-size:13px;color:var(--text-dim);">🎂 ${u.age} лет</div>` : ''}
${reviewsCount > 0 ? `<div style="font-size:13px;color:var(--warn);margin-top:4px;">★ ${rating} · ${reviewsCount} ${pluralRu(reviewsCount, 'отзыв', 'отзыва', 'отзывов')}</div>` : ''}
</div>
</div>
@ -272,6 +274,7 @@ const UserProfileView = {
const revBtn = document.getElementById('up-reviews');
if (revBtn) revBtn.onclick = () => UserReviewsView.render(root, { userId: this.userId, userName: u.name });
} catch (e) {
console.error('[UserProfile] load failed:', e, 'userId:', this.userId);
document.getElementById('up-content').innerHTML = `<div class="empty-b">⚠️ Не удалось загрузить</div>`;
App._toast('Ошибка загрузки профиля', 'err');
}