141 lines
11 KiB
HTML
141 lines
11 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}杯赛专栏 - 智联青云{% endblock %}
|
|
{% block content %}
|
|
<div class="space-y-8">
|
|
<!-- 头部区域 -->
|
|
<div class="futuristic-card flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 p-6">
|
|
<div>
|
|
<h1 class="text-2xl font-bold flex items-center bg-gradient-to-r from-blue-600 via-purple-600 to-pink-600 bg-clip-text text-transparent">
|
|
<span class="w-10 h-10 bg-gradient-to-br from-cyan-400 to-blue-600 text-white rounded-xl flex items-center justify-center mr-3 shadow-lg border border-cyan-300/30 animate-pulse-glow">🏆</span>
|
|
杯赛专栏
|
|
</h1>
|
|
<p class="text-slate-400 text-sm mt-1 ml-13">参与官方联考,检验学习成果,赢取荣誉与奖励。</p>
|
|
</div>
|
|
<div class="flex flex-wrap items-center gap-3">
|
|
<a href="{{ url_for('apply_contest') }}" class="btn-futuristic inline-flex items-center px-4 py-2.5 text-sm font-medium">
|
|
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"/></svg>
|
|
申请举办杯赛
|
|
</a>
|
|
{% if user and (user.role == 'admin' or user.role == 'teacher') %}
|
|
<a href="/admin/contests/create" class="btn-futuristic inline-flex items-center px-4 py-2.5 text-sm font-medium">
|
|
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
|
|
发布新杯赛
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 筛选和搜索 -->
|
|
<div class="futuristic-card p-5 flex flex-wrap gap-4 items-center justify-between sticky top-20 z-10 backdrop-blur-lg">
|
|
<div class="flex flex-wrap gap-3 items-center w-full sm:w-auto">
|
|
<div class="relative w-full sm:w-auto">
|
|
<select id="statusFilter" class="input-futuristic w-full sm:w-40 appearance-none px-4 py-2.5 pl-10 border border-cyan-500/30 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-cyan-500/50 focus:border-cyan-500 bg-slate-900/50 hover:bg-slate-800/50 transition-all cursor-pointer text-slate-200" onchange="searchContests()">
|
|
<option value="">所有状态</option>
|
|
<option value="registering">🟢 报名中</option>
|
|
<option value="upcoming">🔵 进行中</option>
|
|
<option value="ended">⚪ 已结束</option>
|
|
</select>
|
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
|
<svg class="h-4 w-4 text-cyan-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"/></svg>
|
|
</div>
|
|
<div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
|
|
<svg class="h-4 w-4 text-cyan-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="flex gap-2 w-full sm:w-auto relative group">
|
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
|
<svg class="h-4 w-4 text-cyan-400 group-focus-within:text-cyan-300 transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>
|
|
</div>
|
|
<input type="text" id="search-contest" placeholder="搜索杯赛名称..." class="input-futuristic flex-1 sm:w-72 pl-10 pr-4 py-2.5 border border-cyan-500/30 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-cyan-500/50 focus:border-cyan-500 bg-slate-900/50 transition-all text-slate-200 placeholder-slate-500" onkeydown="if(event.key==='Enter') searchContests()">
|
|
<button onclick="searchContests()" class="btn-futuristic px-5 py-2.5 text-sm font-medium">
|
|
搜索
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 列表 -->
|
|
<div id="contest-list" class="grid gap-6 grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
|
|
<div class="col-span-full py-20 flex flex-col items-center justify-center text-slate-400">
|
|
<svg class="animate-spin h-8 w-8 text-primary mb-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
|
|
<p>正在加载精彩杯赛...</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
let allContests = [];
|
|
|
|
function renderContests(contests) {
|
|
const container = document.getElementById('contest-list');
|
|
if (contests.length === 0) {
|
|
container.innerHTML = '<div class="col-span-full text-center py-12 text-cyan-400">暂无杯赛</div>';
|
|
return;
|
|
}
|
|
let html = '';
|
|
contests.forEach(c => {
|
|
let statusHtml = '';
|
|
if (c.status === 'registering') {
|
|
statusHtml = '<span class="badge-futuristic absolute top-3 right-3 bg-gradient-to-r from-blue-500 to-cyan-500 text-white text-xs font-bold px-3 py-1.5 shadow-lg flex items-center"><span class="w-1.5 h-1.5 rounded-full bg-white mr-1.5 animate-pulse"></span>报名中</span>';
|
|
} else if (c.status === 'upcoming') {
|
|
statusHtml = '<span class="badge-futuristic absolute top-3 right-3 bg-gradient-to-r from-green-500 to-emerald-500 text-white text-xs font-bold px-3 py-1.5 shadow-lg flex items-center"><span class="w-1.5 h-1.5 rounded-full bg-white mr-1.5 animate-pulse"></span>即将开始</span>';
|
|
} else if (c.status === 'abolished') {
|
|
statusHtml = '<span class="badge-futuristic absolute top-3 right-3 bg-gradient-to-r from-red-500 to-pink-500 text-white text-xs font-bold px-3 py-1.5 shadow-lg flex items-center">已废止</span>';
|
|
} else {
|
|
statusHtml = '<span class="badge-futuristic absolute top-3 right-3 bg-gradient-to-r from-slate-500 to-slate-600 text-white text-xs font-bold px-3 py-1.5 shadow-lg flex items-center">已结束</span>';
|
|
}
|
|
|
|
html += `
|
|
<div class="futuristic-card-dark group overflow-hidden transition-all duration-300 transform hover:scale-105 hover:shadow-2xl hover:shadow-cyan-500/30 cursor-pointer flex flex-col" onclick="location.href='/contests/${c.id}'">
|
|
<div class="h-40 bg-slate-900 relative overflow-hidden">
|
|
<div class="w-full h-full flex items-center justify-center bg-gradient-to-br from-cyan-500/20 via-blue-500/20 to-purple-500/20 text-cyan-400 group-hover:scale-110 transition-transform duration-500">
|
|
<svg class="w-16 h-16 opacity-60 drop-shadow-glow" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/></svg>
|
|
</div>
|
|
${statusHtml}
|
|
<div class="absolute inset-0 bg-gradient-to-t from-cyan-500/30 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div>
|
|
</div>
|
|
<div class="p-5 flex-1 flex flex-col relative">
|
|
<h3 class="text-lg font-bold text-slate-100 mb-2 line-clamp-2 group-hover:text-cyan-400 transition-colors bg-gradient-to-r from-blue-400 via-purple-400 to-pink-400 bg-clip-text group-hover:text-transparent">${c.name}</h3>
|
|
<p class="badge-futuristic text-xs font-bold mb-2 bg-gradient-to-r from-cyan-500 to-blue-500 text-white inline-block px-3 py-1.5 w-max shadow-md">主办方:${c.organizer || '未知'}</p>
|
|
<div class="text-sm text-slate-400 mb-5 flex-1 line-clamp-2 leading-relaxed">${c.description || '暂无简介'}</div>
|
|
|
|
<div class="mt-auto pt-4 border-t border-cyan-500/30 grid grid-cols-2 gap-4">
|
|
<div class="flex flex-col">
|
|
<span class="text-[10px] font-medium text-slate-500 uppercase tracking-wider mb-1">开始时间</span>
|
|
<span class="text-xs font-semibold text-slate-300 flex items-center">
|
|
<svg class="w-3.5 h-3.5 mr-1 text-cyan-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/></svg>
|
|
${c.start_date ? c.start_date.split(' ')[0] : '待定'}
|
|
</span>
|
|
</div>
|
|
<div class="flex flex-col border-l border-cyan-500/30 pl-4">
|
|
<span class="text-[10px] font-medium text-slate-500 uppercase tracking-wider mb-1">参与人数</span>
|
|
<span class="text-xs font-bold text-cyan-400 flex items-center">
|
|
<svg class="w-3.5 h-3.5 mr-1 text-cyan-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/></svg>
|
|
${c.participants} 人
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
});
|
|
container.innerHTML = html;
|
|
}
|
|
|
|
async function searchContests() {
|
|
const keyword = document.getElementById('search-contest').value;
|
|
const url = keyword ? `/api/contests/search?q=${encodeURIComponent(keyword)}` : '/api/contests/search';
|
|
const res = await fetch(url);
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
renderContests(data.data);
|
|
} else {
|
|
alert('搜索失败');
|
|
}
|
|
}
|
|
|
|
// 初始化加载所有杯赛
|
|
searchContests();
|
|
</script>
|
|
{% endblock %} |