<?php
/**
 * HuSNS - 一款免费开源的社交平台
 * 
 * @author  HYR
 * @QQ      281900864
 * @website https://huyourui.com
 * @license MIT
 * @声明    严禁用于违法违规用途
 */// 检查登录状态
$userId = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : null;
if (!$userId) {
    // 使用弹窗登录，不跳转页面
    $this->assign('showLoginModal', true);
}

$currentPage = 'profile';
$pageType = 'profile';
$bodyClass = 'profile-page';
$showTabbar = true;

// 页面特定CSS和JS文件
$pageCssFiles = ['/templates/mobile/app/css/profile.css'];
$pageJsFiles = ['/templates/mobile/app/js/profile.js'];

// 将页面特定资源添加到视图数据中
$this->assign('pageCssFiles', $pageCssFiles);
$this->assign('pageJsFiles', $pageJsFiles);

$this->setLayout('app');
?>

<script>
const BASE_URL = '<?php echo Helper::getBaseUrl(); ?>';
</script>

<div class="profile-content">
    <!-- 用户信息卡片 -->
    <div class="profile-header" id="profileHeader">
        <div class="profile-avatar-container" id="profileAvatar">
            <img src="/templates/mobile/images/avatar_default.png" alt="">
        </div>
        <div class="profile-user-info">
            <div class="profile-username" id="profileUsername">加载中...</div>
            <div class="profile-bio" id="profileBio">这个人很懒，什么都没写</div>
        </div>
        <div class="profile-stats">
            <div class="profile-stat-item">
                <div class="profile-stat-value" id="statPosts">0</div>
                <div class="profile-stat-label">动态</div>
            </div>
            <div class="profile-stat-item">
                <div class="profile-stat-value" id="statFollows">0</div>
                <div class="profile-stat-label">关注</div>
            </div>
            <div class="profile-stat-item">
                <div class="profile-stat-value" id="statFans">0</div>
                <div class="profile-stat-label">粉丝</div>
            </div>
            <div class="profile-stat-item">
                <div class="profile-stat-value" id="statFavorites">0</div>
                <div class="profile-stat-label">收藏</div>
            </div>
        </div>
    </div>
    
    <!-- 功能菜单 -->
    <div class="profile-menu">
        <div class="menu-section">
            <a href="<?php echo $this->url('mobile/user&id=' . $userId); ?>&tab=posts" class="menu-item">
                <span class="menu-icon">📝</span>
                <span class="menu-text">我的动态</span>
                <span class="menu-arrow">›</span>
            </a>
            <a href="<?php echo $this->url('mobile/fans'); ?>" class="menu-item">
                <span class="menu-icon">👥</span>
                <span class="menu-text">我的粉丝</span>
                <span class="menu-arrow">›</span>
            </a>
            <a href="<?php echo $this->url('mobile/editProfile'); ?>" class="menu-item">
                <span class="menu-icon"><span class="iconify" data-icon="mdi:pencil-outline"></span></span>
                <span class="menu-text">编辑资料</span>
                <span class="menu-arrow">›</span>
            </a>
            <?php if ((int)Setting::get('mobile_favorite_enabled', 1) === 1): ?>
            <a href="<?php echo $this->url('mobile/favorites'); ?>" class="menu-item">
                <span class="menu-icon"><span class="iconify" data-icon="mdi:star-outline"></span></span>
                <span class="menu-text">我的收藏</span>
                <span class="menu-arrow">›</span>
            </a>
            <?php endif; ?>
            <?php if ((int)Setting::get('mobile_discover_enabled', 1) === 1): ?>
            <a href="<?php echo $this->url('mobile/discover'); ?>" class="menu-item">
                <span class="menu-icon">🔍</span>
                <span class="menu-text">发现</span>
                <span class="menu-arrow">›</span>
            </a>
            <?php endif; ?>
            <a href="<?php echo $this->url('mobile/notification'); ?>" class="menu-item">
                <span class="menu-icon">🔔</span>
                <span class="menu-text">消息通知</span>
                <span class="menu-badge" style="display:<?php echo isset($unreadCount) && $unreadCount > 0 ? 'inline-block' : 'none'; ?>"><?php echo $unreadCount ?? 0; ?></span>
                <span class="menu-arrow">›</span>
            </a>
            <a href="<?php echo $this->url('mobile/settings'); ?>" class="menu-item">
                <span class="menu-icon">⚙️</span>
                <span class="menu-text">设置</span>
                <span class="menu-arrow">›</span>
            </a>
        </div>
        

        
        <?php if ($userId): ?>
        <!-- 用户菜单 -->
        <div class="menu-section">
            <a href="<?php echo $this->url('mobile/myReports'); ?>" class="menu-item">
                <span class="menu-icon">📋</span>
                <span class="menu-text">我的举报</span>
                <span class="menu-arrow">›</span>
            </a>
        </div>
        <?php endif; ?>
        
        <div class="menu-section">
            <a href="javascript:;" class="menu-item js-disabled" data-tip="功能开发中">
                <span class="menu-icon">❓</span>
                <span class="menu-text">帮助中心</span>
                <span class="menu-arrow">›</span>
            </a>
            <a href="javascript:;" class="menu-item js-disabled" data-tip="功能开发中">
                <span class="menu-icon">📄</span>
                <span class="menu-text">关于我们</span>
                <span class="menu-arrow">›</span>
            </a>
        </div>
    </div>
    
    <?php if ($userId): ?>
    <!-- 退出登录 -->
    <div class="profile-menu">
        <div class="menu-section">
            <a href="javascript:void(0)" class="menu-item" id="logoutBtn" style="color: var(--danger-color);">
                <span class="menu-icon">🚪</span>
                <span class="menu-text">退出登录</span>
                <span class="menu-arrow">›</span>
            </a>
        </div>
    </div>
    <?php else: ?>
    <!-- 登录注册按钮 -->
    <div class="auth-buttons">
        <button class="auth-button login" onclick="openLoginModal()">登录</button>
        <button class="auth-button register" onclick="openRegisterModal()">注册</button>
    </div>
    <?php endif; ?>
</div>