diff --git a/src/assets/images/home-banner2.jpg b/src/assets/images/home-banner2.jpg new file mode 100644 index 0000000..760e3b0 Binary files /dev/null and b/src/assets/images/home-banner2.jpg differ diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 34aa94a..7cd3d87 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -3,8 +3,10 @@ import type { Treaty } from "@elysiajs/eden"; import type { InfiniteScrollCustomEvent } from "@ionic/vue"; import type { Action } from "./"; import type { TreatyQuery } from "@/api/types"; -import { chevronForwardOutline, eyeOutline, timeOutline } from "ionicons/icons"; +import { chevronForwardOutline, eyeOutline, megaphoneOutline, timeOutline } from "ionicons/icons"; import { client, safeClient } from "@/api"; +import banner2 from "@/assets/images/home-banner2.jpg?url"; +import banner1 from "@/assets/images/home-banner.jpg?url"; import { actions } from "./"; type NewsItem = Treaty.Data["data"][number]; @@ -18,11 +20,58 @@ const [query] = useResetRef({ const data = ref([]); const isFinished = ref(false); +const banners = ref([ + { id: 1, image: banner1, title: "横幅1" }, + { id: 2, image: banner2, title: "横幅2" }, +]); +const currentBannerIndex = ref(0); + +// 公告数据 +interface Announcement { + id: number; + title: string; + onClick?: () => void; +} + +const announcements = ref([ + { + id: 1, + title: "欢迎使用我们的服务平台,祝您投资顺利!", + onClick: () => { + console.log("点击了第一条公告"); + }, + }, +]); + +// 横幅自动切换 +let bannerTimer: ReturnType | null = null; +function startBannerCarousel() { + bannerTimer = setInterval(() => { + currentBannerIndex.value = (currentBannerIndex.value + 1) % banners.value.length; + }, 3000); +} + +function stopBannerCarousel() { + if (bannerTimer) { + clearInterval(bannerTimer); + bannerTimer = null; + } +} + +onMounted(() => { + startBannerCarousel(); +}); + +onUnmounted(() => { + stopBannerCarousel(); +}); + async function fetchNews() { const { data: responseData } = await safeClient(client.api.news.get({ query: { ...query.value } })); data.value.push(...(responseData.value?.data || [])); isFinished.value = responseData.value?.pagination.hasNextPage === false; } + async function handleInfinite(event: InfiniteScrollCustomEvent) { if (isFinished.value) { event.target.complete(); @@ -35,6 +84,7 @@ async function handleInfinite(event: InfiniteScrollCustomEvent) { event.target.complete(); }, 500); } + function handleQuickAction(action: Action) { switch (action.id) { case "check_in": @@ -67,8 +117,50 @@ function handleNewsClick(news: NewsItem) {
+
- 首页横幅 +
+ + + +
+ +
+
+
+
+ + +
+ +
+
+
+ {{ announcement.title }} +
+
+
@@ -149,128 +241,52 @@ function handleNewsClick(news: NewsItem) {