HistorySection.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <template>
  2. <section id="history" ref="timelineRef" class="history">
  3. <div
  4. class="history-container"
  5. :class="[isTimelineVisible ? 'translate-y-0 opacity-100' : 'translate-y-40px opacity-0']"
  6. >
  7. <div class="history-title pf-sc-semibold">发展历程</div>
  8. <div class="history-subtitle pf-sc-regular">从探索到引领,绘家科技每一步都坚实有力</div>
  9. <div class="history-top">
  10. <div class="history-year-wrapper">
  11. <Transition name="year-flow">
  12. <div :key="currentYearData?.year" class="history-year-content">
  13. <span class="history-year-text pf-sc-bold">
  14. {{ currentYearData?.year }}
  15. </span>
  16. </div>
  17. </Transition>
  18. </div>
  19. <div class="history-event-wrapper">
  20. <Transition name="event-fade" mode="out-in">
  21. <div
  22. :key="currentYearData?.year + '-' + currentEventIndex"
  23. class="history-event-content"
  24. >
  25. <div class="history-event-header">
  26. <span class="history-event-month pf-sc-semibold">
  27. {{ currentEventData?.month }}
  28. </span>
  29. <div
  30. v-if="(currentYearData?.events?.length ?? 0) > 1"
  31. class="history-event-controls"
  32. >
  33. <i
  34. class="i-custom-arrow-circle-left history-event-arrow"
  35. :class="[
  36. currentEventIndex === 0
  37. ? 'opacity-30 cursor-not-allowed'
  38. : 'cursor-pointer hover:i-custom-arrow-circle-left-active hover:scale-110 active:scale-95',
  39. ]"
  40. @click="prevEvent"
  41. ></i>
  42. <i
  43. class="i-custom-arrow-circle-right history-event-arrow"
  44. :class="[
  45. currentEventIndex === (currentYearData?.events?.length ?? 0) - 1
  46. ? 'opacity-30 cursor-not-allowed'
  47. : 'cursor-pointer hover:i-custom-arrow-circle-right-active hover:scale-110 active:scale-95',
  48. ]"
  49. @click="nextEvent"
  50. ></i>
  51. </div>
  52. </div>
  53. <div class="history-event-line"></div>
  54. <div class="history-event-desc pf-sc-regular">
  55. {{ currentEventData?.content }}
  56. </div>
  57. </div>
  58. </Transition>
  59. </div>
  60. </div>
  61. <div class="history-timeline lt-sm:hidden">
  62. <div class="history-timeline-track">
  63. <div class="history-timeline-progress" :style="progressStyle"></div>
  64. <div class="history-timeline-nodes">
  65. <div
  66. v-for="(item, index) in historyYears"
  67. :key="item.year"
  68. class="history-timeline-node"
  69. :style="getTimelineNodePositionStyle(index)"
  70. @click="selectYear(index)"
  71. >
  72. <div
  73. class="history-timeline-dot"
  74. :class="getTimelineDotClasses(index)"
  75. :style="getTimelineDotStyle(index)"
  76. ></div>
  77. <span class="history-timeline-year" :class="getTimelineYearTextClasses(index)">
  78. {{ item.year }}
  79. </span>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <div class="history-timeline-mobile lt-sm:flex hidden">
  85. <i
  86. class="i-custom-button-previous-mobile history-mobile-btn"
  87. :class="[
  88. currentYearIndex === 0
  89. ? 'cursor-not-allowed i-custom-button-previous-mobile-disabled'
  90. : 'active:i-custom-button-previous-mobile-active',
  91. ]"
  92. @click="prevYear"
  93. ></i>
  94. <div class="history-mobile-track-container">
  95. <div class="history-mobile-track-line"></div>
  96. <div class="history-mobile-nodes">
  97. <div
  98. v-for="(yearIndex, i) in mobileTimelineIndices"
  99. :key="i"
  100. class="history-mobile-node"
  101. :class="{ invisible: yearIndex < 0 || yearIndex >= historyYears.length }"
  102. @click="yearIndex >= 0 && yearIndex < historyYears.length && selectYear(yearIndex)"
  103. >
  104. <div
  105. class="history-mobile-dot"
  106. :class="{ active: yearIndex === currentYearIndex }"
  107. ></div>
  108. <div class="history-mobile-year" :class="{ active: yearIndex === currentYearIndex }">
  109. {{ historyYears[yearIndex]?.year }}
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. <i
  115. class="i-custom-button-next-mobile history-mobile-btn"
  116. :class="[
  117. currentYearIndex === historyYears.length - 1
  118. ? 'cursor-not-allowed i-custom-button-next-mobile-disabled'
  119. : 'active:i-custom-button-next-mobile-active',
  120. ]"
  121. @click="nextYear"
  122. ></i>
  123. </div>
  124. <div class="history-nav">
  125. <i
  126. class="i-custom-button-previous history-nav-btn"
  127. :class="{
  128. 'opacity-30 cursor-not-allowed hover:i-custom-button-previous!': currentYearIndex === 0,
  129. }"
  130. @click="prevYear"
  131. ></i>
  132. <i
  133. class="i-custom-button-next history-nav-btn"
  134. :class="{
  135. 'opacity-30 cursor-not-allowed hover:i-custom-button-next!':
  136. currentYearIndex === historyYears.length - 1,
  137. }"
  138. @click="nextYear"
  139. ></i>
  140. </div>
  141. </div>
  142. </section>
  143. </template>
  144. <script setup lang="ts">
  145. import { historyYears } from '@/constants/common'
  146. const timelineRef = ref<HTMLElement | null>(null)
  147. const isTimelineVisible = ref(false)
  148. const currentYearIndex = ref(historyYears.length - 1)
  149. const currentEventIndex = ref(0)
  150. const currentYearData = computed(() => {
  151. const data = historyYears[currentYearIndex.value]
  152. return data || historyYears[0]
  153. })
  154. const currentEventData = computed(() => {
  155. const events = currentYearData.value?.events || []
  156. return events[currentEventIndex.value] || events[0]
  157. })
  158. const mobileTimelineIndices = computed(() => {
  159. const total = historyYears.length
  160. if (total <= 0) return []
  161. const prev = currentYearIndex.value - 1
  162. const curr = currentYearIndex.value
  163. const next = currentYearIndex.value + 1
  164. return [prev, curr, next]
  165. })
  166. const progressStyle = computed(() => {
  167. const totalSteps = Math.max(historyYears.length - 1, 1)
  168. if (currentYearIndex.value === totalSteps) {
  169. return {
  170. width: '100%',
  171. }
  172. }
  173. const percentage = currentYearIndex.value / totalSteps
  174. return {
  175. width: `calc(60px + ${percentage} * (100% - 120px))`,
  176. }
  177. })
  178. const nextYear = () => {
  179. if (currentYearIndex.value < historyYears.length - 1) {
  180. currentYearIndex.value++
  181. currentEventIndex.value = 0
  182. }
  183. }
  184. const prevYear = () => {
  185. if (currentYearIndex.value > 0) {
  186. currentYearIndex.value--
  187. currentEventIndex.value = 0
  188. }
  189. }
  190. const nextEvent = () => {
  191. const events = currentYearData.value?.events || []
  192. if (currentEventIndex.value < events.length - 1) {
  193. currentEventIndex.value++
  194. }
  195. }
  196. const prevEvent = () => {
  197. if (currentEventIndex.value > 0) {
  198. currentEventIndex.value--
  199. }
  200. }
  201. const selectYear = (index: number) => {
  202. currentYearIndex.value = index
  203. currentEventIndex.value = 0
  204. }
  205. const getTimelineNodePositionStyle = (index: number) => {
  206. return { left: `${(index / (historyYears.length - 1)) * 100}%` }
  207. }
  208. const getTimelineDotClasses = (index: number) => {
  209. return [
  210. index < currentYearIndex.value
  211. ? 'wh-13px'
  212. : 'wh-16px border-#0F67F8 group-hover:border-[#2563EB] border-1',
  213. index === currentYearIndex.value
  214. ? 'wh-16px scale-150 outline-6px outline-#CEE0FF outline-solid border-none'
  215. : '',
  216. ]
  217. }
  218. const getTimelineDotStyle = (index: number) => {
  219. if (index === currentYearIndex.value) {
  220. return { background: 'linear-gradient(90deg, #779EFF 0%, #0A50FF 100%)' }
  221. }
  222. if (index < currentYearIndex.value) {
  223. return { background: '#FFFFFF' }
  224. }
  225. return {}
  226. }
  227. const getTimelineYearTextClasses = (index: number) => {
  228. return [
  229. index === currentYearIndex.value
  230. ? 'text-#2563EB font-bold pf-sc-bold scale-110'
  231. : 'text-#94A3B8 group-hover:text-[#64748B]',
  232. ]
  233. }
  234. onMounted(() => {
  235. const observer = new IntersectionObserver(
  236. (entries) => {
  237. entries.forEach((entry) => {
  238. if (!entry.isIntersecting) return
  239. isTimelineVisible.value = true
  240. observer.unobserve(entry.target)
  241. })
  242. },
  243. { threshold: 0.1 }
  244. )
  245. if (timelineRef.value) {
  246. observer.observe(timelineRef.value)
  247. }
  248. })
  249. </script>
  250. <style scoped lang="scss">
  251. .history {
  252. @apply overflow-hidden relative py-60px;
  253. @apply lt-sm:pt-60px lt-sm:pb-160px lt-sm:px-32px;
  254. @extend %landing-container;
  255. background-size: cover;
  256. background-position: center;
  257. background-image: url('@/assets/images/history-bg.png');
  258. }
  259. .history-container {
  260. @apply flex flex-col items-center transition-all duration-1000;
  261. }
  262. .history-title {
  263. @apply font-semibold font-s-36px text-#000000 lh-60px text-center mb-4px;
  264. @apply lt-sm:font-s-48px lt-sm:lh-60px;
  265. }
  266. .history-subtitle {
  267. @apply font-s-16px text-#091221/70 text-center lh-30px mb-50px;
  268. @apply lt-sm:font-s-24px lt-sm:lh-40px lt-sm:mb-88px;
  269. }
  270. .history-top {
  271. @apply w-full h-255px flex py-50px items-center;
  272. @apply lt-sm:h-176px;
  273. }
  274. .history-year-wrapper {
  275. @apply relative pl-127px w-600px shrink-0 h-170px overflow-hidden;
  276. @apply lt-sm:hidden;
  277. }
  278. .history-year-content {
  279. @apply absolute left-127px top-0 h-full flex items-center w-full;
  280. }
  281. .history-year-text {
  282. @apply text-170px font-bold text-#0F67F8 select-none leading-none;
  283. -webkit-text-stroke: 1px #2563eb;
  284. text-shadow: 0 0 20px rgba(37, 99, 235, 0.1);
  285. }
  286. .history-event-wrapper {
  287. @apply flex-1 h-full relative overflow-hidden pt-14px;
  288. @apply lt-sm:h-176px lt-sm:pt-0;
  289. }
  290. .history-event-content {
  291. @apply absolute left-0 top-14px w-full flex flex-col pr-114px;
  292. @apply lt-sm:pr-0 static;
  293. }
  294. .history-event-header {
  295. @apply flex justify-between items-center w-full;
  296. @apply lt-sm:h-45px;
  297. }
  298. .history-event-month {
  299. @apply font-s-22px font-semibold lh-30.8px text-#091221 flex-1;
  300. @apply lt-sm:font-s-32px lt-sm:lh-30.8px;
  301. }
  302. .history-event-controls {
  303. @apply flex gap-12px relative z-10;
  304. @apply lt-sm:gap-16px;
  305. }
  306. .history-event-arrow {
  307. @apply wh-32px transition-all;
  308. @apply lt-sm:wh-45px;
  309. }
  310. .history-event-line {
  311. @apply h-2px w-34px bg-#0F67F8 mt-11px origin-left;
  312. @apply lt-sm:h-4px lt-sm:w-68px lt-sm:mt-25px;
  313. }
  314. .history-event-desc {
  315. @apply w-full font-s-20px lh-35px text-#091221/70 mt-26px;
  316. @apply lt-sm:font-s-24px lt-sm:mt-26px lt-sm:lh-normal;
  317. }
  318. .history-timeline {
  319. @apply w-full relative pt-47px pb-60px;
  320. @apply lt-sm:py-0 lt-sm:mt-70px;
  321. }
  322. .history-timeline-track {
  323. @apply relative h-16px w-full bg-white rounded-full px-60px;
  324. @apply lt-sm:h-16px lt-sm:px-60px;
  325. }
  326. .history-timeline-progress {
  327. @apply absolute left-0 top-0 h-full bg-gradient-to-r from-[#60A5FA] to-[#2563EB] rounded-full transition-all duration-500 ease-out z-1;
  328. }
  329. .history-timeline-nodes {
  330. @apply relative h-full w-full;
  331. }
  332. .history-timeline-node {
  333. @apply absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center cursor-pointer group z-2;
  334. }
  335. .history-timeline-dot {
  336. @apply rounded-full transition-all duration-300 relative bg-white;
  337. @apply lt-sm:wh-14px;
  338. }
  339. .history-timeline-year {
  340. @apply absolute top-24px text-16px transition-all duration-300 whitespace-nowrap;
  341. }
  342. .history-nav {
  343. @apply flex gap-24px mt-45px;
  344. @apply lt-sm:hidden;
  345. }
  346. .history-nav-btn {
  347. @apply wh-56px flex-center cursor-pointer;
  348. }
  349. .year-flow-enter-active,
  350. .year-flow-leave-active {
  351. transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  352. }
  353. .year-flow-enter-from {
  354. opacity: 0;
  355. transform: translateY(100%) scale(0.9);
  356. }
  357. .year-flow-leave-to {
  358. opacity: 0;
  359. transform: translateY(-100%) scale(0.9);
  360. }
  361. .event-fade-enter-active,
  362. .event-fade-leave-active {
  363. transition: opacity 0.3s ease;
  364. }
  365. .event-fade-enter-from,
  366. .event-fade-leave-to {
  367. opacity: 0;
  368. }
  369. .history-timeline-mobile {
  370. @apply flex items-center justify-between w-full px-0;
  371. @apply lt-sm:mt-70px;
  372. }
  373. .history-mobile-btn {
  374. @apply shrink-0 cursor-pointer transition-all absolute;
  375. @apply lt-sm:wh-64px z-10;
  376. &.i-custom-button-previous-mobile {
  377. @apply left-0;
  378. }
  379. &.i-custom-button-next-mobile {
  380. @apply right-0;
  381. }
  382. }
  383. .history-mobile-track-container {
  384. @apply relative flex-1;
  385. }
  386. .history-mobile-track-line {
  387. @apply absolute left-0 right-0 bg-white rounded-full;
  388. @apply lt-sm:h-16px lt-sm:top-1/2 lt-sm:translate-y--1/2;
  389. }
  390. .history-mobile-nodes {
  391. @apply hidden relative w-full h-full justify-between items-center z-1;
  392. @apply lt-sm:px-100px lt-sm:h-16px lt-sm:flex;
  393. }
  394. .history-mobile-node {
  395. @apply relative flex flex-col items-center cursor-pointer;
  396. @apply lt-sm:w-60px;
  397. &.invisible {
  398. @apply transition-none;
  399. .history-mobile-dot,
  400. .history-mobile-year {
  401. @apply transition-none;
  402. }
  403. }
  404. }
  405. .history-mobile-dot {
  406. @apply rounded-full bg-white transition-all z-2 border-#0F67F8 border-1;
  407. @apply lt-sm:wh-18px;
  408. &.active {
  409. @apply scale-150 outline-#CEE0FF outline-solid border-none bg-[linear-gradient(90deg,#779EFF_0%,#0A50FF_100%)];
  410. @apply lt-sm:wh-22px lt-sm:outline-8px;
  411. }
  412. }
  413. .history-mobile-year {
  414. @apply hidden absolute text-#091221/60 pf-sc-regular transition-all whitespace-nowrap;
  415. @apply lt-sm:font-s-22px lt-sm:top-58px lt-sm:block;
  416. &.active {
  417. @apply text-#0F67F8 font-semibold scale-110;
  418. }
  419. }
  420. </style>