Files
aida_front/src/views/AwardPage/components/TimeLine.vue

371 lines
7.8 KiB
Vue
Raw Normal View History

2026-01-20 16:41:37 +08:00
<template>
<div
ref="containerRef"
class="timeline-container container flex flex-col align-center"
>
2026-02-04 10:57:25 +08:00
<div class="timeline-title">{{ $t('AwardsPage.competitionTimeline') }}</div>
<div class="desc">{{ $t('AwardsPage.shapingTheFuture') }}</div>
2026-02-02 15:48:50 +08:00
<div
class="timeline-point"
ref="timelineRef"
>
<!-- 顶部标签行 -->
<div class="grid-row labels-row">
2026-01-20 16:41:37 +08:00
<div
2026-02-02 15:48:50 +08:00
class="grid-cell label-cell"
2026-01-20 16:41:37 +08:00
v-for="item in points"
:key="'label-' + item.time"
>
2026-02-04 10:57:25 +08:00
<div class="main-label">{{ $t(item.label) }}</div>
2026-01-20 16:41:37 +08:00
<div
class="sub-label"
v-if="item.subLabel"
>
2026-02-04 10:57:25 +08:00
{{ $t(item.subLabel) }}
2026-01-20 16:41:37 +08:00
</div>
</div>
</div>
2026-02-02 15:48:50 +08:00
<!-- 图标行 -->
<div class="grid-row icons-row">
2026-01-20 16:41:37 +08:00
<div class="timeline-line"></div>
2026-02-02 15:48:50 +08:00
<div
class="grid-cell icon-cell"
2026-01-20 16:41:37 +08:00
v-for="item in points"
:key="'icon-' + item.time"
2026-02-02 15:48:50 +08:00
>
<img
src="@/assets/images/award/point.png"
class="point-icon"
/>
</div>
2026-01-20 16:41:37 +08:00
</div>
2026-02-02 15:48:50 +08:00
<!-- 时间行 -->
<div class="grid-row times-row">
2026-01-20 16:41:37 +08:00
<div
2026-02-02 15:48:50 +08:00
class="grid-cell time-cell"
2026-01-20 16:41:37 +08:00
v-for="item in points"
:key="'time-' + item.time"
>
2026-02-04 10:57:25 +08:00
{{ $t(item.time) }}
2026-01-20 16:41:37 +08:00
</div>
</div>
2026-02-02 15:48:50 +08:00
<!-- 描述行 -->
<div class="grid-row descs-row">
2026-01-20 16:41:37 +08:00
<div
2026-02-02 15:48:50 +08:00
class="grid-cell desc-cell"
2026-01-20 16:41:37 +08:00
v-for="item in points"
:key="'desc-' + item.time"
>
<div class="txt">
2026-02-04 10:57:25 +08:00
{{ $t(item.desc) }}
2026-01-20 16:41:37 +08:00
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
2026-02-04 10:57:25 +08:00
import { nextTick, onBeforeUnmount, onMounted, ref, computed } from 'vue'
import { useI18n } from 'vue-i18n'
2026-01-20 16:41:37 +08:00
import { gsap } from 'gsap'
2026-02-04 10:57:25 +08:00
const { t } = useI18n()
2026-01-20 16:41:37 +08:00
const containerRef = ref<HTMLElement | null>(null)
2026-02-02 15:48:50 +08:00
const timelineRef = ref<HTMLElement | null>(null)
2026-01-20 16:41:37 +08:00
const hasAnimated = ref(false)
const points = ref([
{
2026-02-04 10:57:25 +08:00
label: 'AwardsPage.timelineApplicationLabel',
subLabel: 'AwardsPage.timelineDeadlineLabel',
time: 'AwardsPage.timeJul15',
desc: 'AwardsPage.applicationDeadlineDesc'
2026-01-20 16:41:37 +08:00
},
{
2026-02-04 10:57:25 +08:00
label: 'AwardsPage.twentyFinalistsAnnounced',
subLabel: 'AwardsPage.announcedLabel',
time: 'AwardsPage.timeAug30',
desc: 'AwardsPage.twentyFinalistsDesc'
2026-01-20 16:41:37 +08:00
},
{
2026-02-04 10:57:25 +08:00
label: 'AwardsPage.finalistSubmission',
subLabel: 'AwardsPage.submissionLabel',
time: 'AwardsPage.timeSept30',
desc: 'AwardsPage.finalistSubmissionDesc'
2026-01-20 16:41:37 +08:00
},
{
2026-02-04 10:57:25 +08:00
label: 'AwardsPage.receivingOutfits',
subLabel: 'AwardsPage.fromFinalistsLabel',
time: 'AwardsPage.timeOctober',
desc: 'AwardsPage.receivingOutfitsDesc'
2026-01-30 17:21:11 +08:00
},
{
2026-02-04 10:57:25 +08:00
label: 'AwardsPage.awardCeremony',
subLabel: 'AwardsPage.ceremonyLabel',
time: 'AwardsPage.timeNov12',
desc: 'AwardsPage.awardCeremonyDesc'
2026-02-02 15:48:50 +08:00
}
2026-01-20 16:41:37 +08:00
])
const playAnimation = () => {
if (!containerRef.value || hasAnimated.value) return
const title = containerRef.value.querySelector('.timeline-title')
const subtitle = containerRef.value.querySelector('.desc')
const line = containerRef.value.querySelector('.timeline-line')
const timeline = containerRef.value.querySelector('.timeline-point')
const tl = gsap.timeline()
2026-01-30 17:21:11 +08:00
// 我们使用一个统一的开始 label使横线、timeline 裁剪与所有文字同时启动,
// 点图标在它们完成后立即开始。
tl.addLabel('start')
// 整体 timeline 的裁剪展开(与 start 同步)
2026-01-20 16:41:37 +08:00
if (timeline) {
tl.fromTo(
timeline,
{
clipPath: 'inset(0 100% 0 0)'
},
{
clipPath: 'inset(0 0% 0 0)',
2026-02-02 15:48:50 +08:00
duration: 1.3,
2026-01-20 16:41:37 +08:00
ease: 'power1.out'
2026-01-30 17:21:11 +08:00
},
'start'
2026-01-20 16:41:37 +08:00
)
}
2026-01-30 17:21:11 +08:00
// 线条动画(与 start 同步)
2026-01-20 16:41:37 +08:00
if (line) {
tl.from(
line,
{
scaleX: 0,
transformOrigin: '0% 50%',
duration: 1.3,
ease: 'power1.out'
},
2026-01-30 17:21:11 +08:00
'start'
)
}
// 标题与副标题(与 start 同步)
if (title && subtitle) {
tl.from(
[title, subtitle],
{
scaleX: 0,
autoAlpha: 0.5,
transformOrigin: '50% 50%',
duration: 0.6,
stagger: 0.1,
ease: 'power2.out'
},
'start'
)
}
2026-02-02 15:48:50 +08:00
// 行内文字(标签、时间、描述、图标)与 start 同步开始
const textItems = containerRef.value.querySelectorAll('.grid-cell')
2026-01-30 17:21:11 +08:00
if (textItems && textItems.length) {
tl.from(
textItems,
{
2026-02-02 15:48:50 +08:00
// autoAlpha: 0.5,
duration: 0.7,
2026-01-30 17:21:11 +08:00
stagger: 0.08,
ease: 'power2.out'
},
'start'
)
}
2026-01-20 16:41:37 +08:00
hasAnimated.value = true
}
let observer: IntersectionObserver | null = null
onMounted(async () => {
await nextTick()
if (!containerRef.value) return
observer = new IntersectionObserver(
2026-02-02 15:48:50 +08:00
entries => {
entries.forEach(entry => {
2026-01-20 16:41:37 +08:00
if (entry.isIntersecting) {
playAnimation()
}
})
},
{ threshold: 0.3 }
)
observer.observe(containerRef.value)
})
onBeforeUnmount(() => {
if (observer && containerRef.value) {
observer.unobserve(containerRef.value)
}
observer = null
})
</script>
<style scoped lang="less">
.timeline-container {
background: url('@/assets/images/award/timeline_bg.png') no-repeat;
background-size: 100% 100%;
position: relative;
2026-02-02 15:48:50 +08:00
padding: 12.8rem 0 15.9rem;
2026-01-20 16:41:37 +08:00
width: 100%;
color: #fff;
.timeline-title {
font-family: 'PoppinsBold';
font-weight: 600;
font-size: 4rem;
text-align: center;
vertical-align: middle;
}
.logo {
margin: 2.4rem 0 2.2rem 0;
}
.desc {
font-family: 'Arial';
font-size: 3rem;
font-weight: 400;
color: #f95750;
}
.timeline-point {
overflow: hidden;
will-change: clip-path;
flex: 1;
width: 100%;
2026-02-02 15:48:50 +08:00
margin-top: 11rem;
padding: 0 13.8rem;
2026-01-20 16:41:37 +08:00
position: relative;
z-index: 2;
2026-02-02 15:48:50 +08:00
// 主网格布局5列
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-template-rows: auto auto auto auto;
grid-column-gap: 0;
grid-row-gap: 0;
// 所有 grid 子行的通用样式
.grid-row {
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-column: 1 / -1;
2026-01-20 16:41:37 +08:00
}
2026-02-02 15:48:50 +08:00
.grid-cell {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
// 图标行
2026-01-20 16:41:37 +08:00
.icons-row {
2026-02-02 15:48:50 +08:00
align-items: center;
height: 6.4rem;
2026-01-20 16:41:37 +08:00
position: relative;
z-index: 2;
2026-02-02 15:48:50 +08:00
margin-bottom: 1.6rem;
2026-01-20 16:41:37 +08:00
.timeline-line {
2026-02-02 15:48:50 +08:00
position: absolute;
top: 50%;
2026-01-20 16:41:37 +08:00
left: -22rem;
2026-02-02 15:48:50 +08:00
right: -21.2rem;
2026-01-20 16:41:37 +08:00
height: 0.15rem;
background: linear-gradient(
90deg,
rgba(199, 52, 44, 0) 0%,
rgba(199, 52, 44, 0.719626) 25.96%,
#c7342c 51.44%,
rgba(199, 52, 44, 0.762376) 75.96%,
rgba(199, 52, 44, 0) 100%
);
transform: translateY(-50%);
z-index: 1;
2026-02-02 15:48:50 +08:00
pointer-events: none;
}
.icon-cell {
position: relative;
.point-icon {
width: 6.4rem;
height: 6.4rem;
display: block;
position: relative;
z-index: 2;
}
}
}
// 标签行
.labels-row {
margin-bottom: 8rem;
position: relative;
z-index: 2;
.label-cell {
flex-direction: column;
color: #fff;
font-family: 'PoppinsBold';
font-weight: 600;
font-size: 2.8rem;
white-space: pre-line;
justify-content: center;
min-height: 6rem;
// .sub-label {
// font-family: 'Arial';
// font-weight: 400;
// font-size: 1.4rem;
// color: rgba(255, 255, 255, 0.8);
// margin-top: 0.4rem;
// }
2026-01-20 16:41:37 +08:00
}
}
2026-02-02 15:48:50 +08:00
// 时间行
2026-01-20 16:41:37 +08:00
.times-row {
margin-bottom: 6rem;
z-index: 2;
position: relative;
2026-02-02 15:48:50 +08:00
.time-cell {
2026-01-20 16:41:37 +08:00
color: #f95750;
font-family: 'Arial';
font-weight: 400;
font-size: 2.8rem;
line-height: 4.5rem;
}
}
2026-02-02 15:48:50 +08:00
// 描述行
2026-01-20 16:41:37 +08:00
.descs-row {
2026-02-02 15:48:50 +08:00
.desc-cell {
2026-01-20 16:41:37 +08:00
.txt {
font-family: 'Arial';
font-weight: 400;
font-size: 2rem;
text-align: center;
color: #e0e0e0;
2026-02-02 15:48:50 +08:00
width: 100%;
max-width: 31.2rem;
min-height: 10.2rem;
2026-01-30 17:21:11 +08:00
white-space: pre-line;
2026-02-02 15:48:50 +08:00
display: flex;
align-items: center;
justify-content: center;
2026-01-20 16:41:37 +08:00
}
}
}
}
}
</style>