<?php echo ModuleInclude('public/header'); ?>

<!-- VR票务样式 -->
<link rel="stylesheet" type="text/css"
    href="{{$public_host}}plugins/vr_ticket/static/css/ticket.css?v=<?php echo time(); ?>" />

<!-- 左上角返回按钮（ShopXO AmazeUI 风格） -->
<a href="javascript:history.go(-1);" class="vr-wallet-back-btn" title="返回">
    <i class="am-icon-angle-left"></i>
</a>

<!-- 页面内容 -->
<div class="vr-ticket-wallet-page" id="vrTicketWalletApp">
    <div class="vr-wallet-header">
        <div class="vr-wallet-title">我的电子票</div>
        <div class="vr-wallet-subtitle">
            <?php if (!empty($user)): ?>
                欢迎，<?php echo htmlspecialchars($user['nickname'] ?: $user['username'] ?: '用户'); ?>
                <span style="margin: 0 8px;">|</span>
            <?php endif; ?>
            共 <span id="vrTicketCount">0</span> 张票
        </div>
    </div>

    <!-- 票列表容器 -->
    <div id="vrTicketList" class="vr-ticket-list">
        <!-- 由 JS 动态渲染 -->
    </div>
</div>

<?php echo ModuleInclude('public/footer'); ?>

<!-- 引入票卡片组件样式和JS -->
<link rel="stylesheet" type="text/css"
    href="{{$public_host}}plugins/vr_ticket/static/css/ticket_card.css?v=<?php echo time(); ?>" />
<script src="{{$public_host}}static/common/lib/JsBarcode/JsBarcode.all.min.js"></script>
<script src="{{$public_host}}plugins/vr_ticket/static/js/ticket_card.js?v=<?php echo time(); ?>"></script>

<script>
$(function() {
    // 获取用户 Token（key = 'user_token_data'）
    var token = '<?php echo MySession("user_token_data") ?: ""; ?>';
    
    // 初始化票夹
    VrTicketWallet.init(token);
    
    // 加载票列表
    VrTicketWallet.loadTickets('vrTicketList', function(tickets) {
        $('#vrTicketCount').text(tickets.length);
    });
});
</script>
