diff --git a/app/event/lanternfestival/page.jsx b/app/event/lanternfestival/page.jsx new file mode 100644 index 0000000..af58a20 --- /dev/null +++ b/app/event/lanternfestival/page.jsx @@ -0,0 +1,247 @@ +"use client"; + +import React, { useState, useEffect, useCallback } from "react"; +import { useRouter, useSearchParams } from "next/navigation"; +import webviewBaseRequest from "@/utils/webviewBaseRequest"; +import { Toast } from "antd-mobile"; +import { InfiniteScroll } from "antd-mobile"; +import { setCookie } from "cookies-next"; +import copy from "@/utils/copy"; + +export default function LanternFestival() { + const router = useRouter(); + const searchParams = useSearchParams(); + + const getBase = useCallback( + (webviewBase) => { + let searchParamsObj = null; + let currentBaseCode = searchParams.get("base"); + if (currentBaseCode) { + let currentBase = JSON.parse(currentBaseCode); + searchParamsObj = { ...currentBase }; + } + return searchParamsObj || webviewBase; + }, + [searchParams] + ); + + const [data, setData] = useState([]); + const [more, setMore] = useState(true); + const [offset, setOffset] = useState(0); + const [isFetching, setIsFetching] = useState(true); + const [isLoading, setIsLoading] = useState(false); + + const getData = async () => { + if (isLoading) return; + setIsLoading(true); + const webviewBase = webviewBaseRequest(); + let base = getBase(webviewBase); + try { + const response = await fetch(`/api/activity/zone_discount`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + ...base, + offset: offset, + limit: 10, + }), + }); + const _data = await response.json(); + if (_data.ret === -1) { + Toast.show({ + content: _data.msg, + }); + return; + } + setOffset(_data.data.offset); + if (_data.data.more === 0) setMore(false); + setData((prev) => [...prev, ..._data.data.list]); + } catch (error) { + console.error(error); + } finally { + setIsFetching(false); + setIsLoading(false); + } + }; + + useEffect(() => { + setTimeout(() => { + getData(); + }, 500); + }, []); + + const InfiniteScrollContent = ({ hasMore }) => { + return ( + <> + {hasMore ? ( + <> + 加载中... + + ) : ( + --- 我是有底线的 --- + )} + + ); + }; + + const Card = ({ item }) => { + return ( +
{ + //如果是app内的webview打开 + const userAgent = navigator.userAgent; + if (/FromWebview/i.test(userAgent)) { + window.ReactNativeWebView.postMessage( + JSON.stringify({ + type: "NAVIGATE", + data: { + page: "SpaceIntroduce", + params: { mid: item?.mid }, + }, + }) + ); + return; + } + //如果是h5的iframe打开 + const webviewBase = webviewBaseRequest(); + let base = getBase(webviewBase); + if (base?.b_token !== undefined) { + window.top.location.href = `https://app.tiefen.fun/space/person_space_introduce/${item?.mid}`; + return; + } + //如果直接从浏览器打开 + copy( + `【${item?.name}】『ID:${item?.user_id}』,复制此条消息,打开铁粉空间APP,查看详情https://tiefen.fun/zone/${item?.user_id}` + ); + setCookie("inviter", item?.user_id); + router.push("/"); + }} + > +
+ + +
+
+ +
+

{item?.name}

+
+
+
+

+ 空间原价{" "} + + ¥{item?.original_price / 100} + +

+

+ ¥ + {item?.price / 100} +

+
+
+
+
+ ); + }; + + if (isFetching) { + return ( +
+ +
+ ); + } + + // 获取当前时间 + const currentDate = new Date(); + // 设置活动结束日期:2025年2月18日 + const targetDate = new Date("2025-02-18T00:00:00"); + + // 判断当前时间是否在活动结束时间之后 + if (currentDate >= targetDate) { + return ( +
+ + +
+

+ 活动已结束 +

+
{ + router.push("/"); + }} + > + 下载APP +
+
+ ); + } + + return ( +
+ + +
+
+ {data?.map((item, index) => ( + + ))} +
+ getData()} hasMore={more}> + + +
+ ); +} diff --git a/app/event/springfestival/page.jsx b/app/event/springfestival/page.jsx index 1a23801..21ee067 100644 --- a/app/event/springfestival/page.jsx +++ b/app/event/springfestival/page.jsx @@ -123,20 +123,18 @@ export default function SpringFestival() {
@@ -205,6 +203,14 @@ export default function SpringFestival() {

活动已结束

+
{ + router.push("/"); + }} + > + 下载APP +
); } diff --git a/public/images/lantern_festival_bg.png b/public/images/lantern_festival_bg.png new file mode 100644 index 0000000..f72c545 Binary files /dev/null and b/public/images/lantern_festival_bg.png differ diff --git a/public/images/lantern_festival_title.png b/public/images/lantern_festival_title.png new file mode 100644 index 0000000..cb3acea Binary files /dev/null and b/public/images/lantern_festival_title.png differ