From 40caa0a296bf972bd38efa63fee4f512bf0b6f05 Mon Sep 17 00:00:00 2001 From: yezian Date: Tue, 11 Feb 2025 16:29:19 +0800 Subject: [PATCH] anln_1.6 (#34) Co-authored-by: al Reviewed-on: https://git.wishpal.cn/wishpal_ironfan/tiefen_space_h5/pulls/34 --- app/found/index.css | 3 + app/found/page.js | 369 ++++++++++++++++++++++ app/my/setting/bannedList/page.js | 2 +- app/profile/[mid]/page.js | 71 ++++- app/search/conponents/Banner/index.jsx | 20 +- app/search/conponents/HostList/index.jsx | 19 +- app/space/[id]/page.js | 5 +- app/space/createImagePost/page.jsx | 2 +- app/space/createVideoPost/page.jsx | 2 +- app/space/editSpacePost/[zid]/page.jsx | 2 +- app/streamerPosts/[id]/page.jsx | 7 +- app/streamerPosts/createPost/page.jsx | 2 +- app/streamerPosts/editPost/[zid]/page.jsx | 2 +- components/FoundItem/index.js | 134 ++++++++ components/PostItem/index.js | 32 +- components/SeeTiefen/index.js | 49 ++- 16 files changed, 668 insertions(+), 53 deletions(-) create mode 100644 app/found/index.css create mode 100644 app/found/page.js create mode 100644 components/FoundItem/index.js diff --git a/app/found/index.css b/app/found/index.css new file mode 100644 index 0000000..f4b0282 --- /dev/null +++ b/app/found/index.css @@ -0,0 +1,3 @@ +.foundBox .adm-list-item-content-main{ + padding: 0!important; +} \ No newline at end of file diff --git a/app/found/page.js b/app/found/page.js new file mode 100644 index 0000000..3f23271 --- /dev/null +++ b/app/found/page.js @@ -0,0 +1,369 @@ +"use client"; + +import React, { + useEffect, + useRef, + useState, + useImperativeHandle, + forwardRef, +} from "react"; +import { Tabs, Swiper, InfiniteScroll, List } from "antd-mobile"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faRefresh, faAngleLeft } from "@fortawesome/free-solid-svg-icons"; +import FoundItem from "@/components/FoundItem"; +// import { sleep } from "antd-mobile/es/utils/sleep"; +import "./index.css"; +import PostItemSkeleton from "@/components/skeletons/PostItemSkeleton"; +import Link from "next/link"; +import requireAPI from "@/utils/requireAPI"; +import Empty from "@/components/Empty"; +import { get } from "@/utils/storeInfo"; +import StreamerNavigator from "@/components/StreamerNavigator"; +import AddToHome from "@/components/AddToHome"; +import InfiniteScrollContent from "@/components/InfiniteScrollContent"; +import { useRouter } from "next/navigation"; +import OwnImage from "@/components/OwnImage"; +const variables = { + "@active-line-color": "#f00", // 将主题色改为红色 +}; +const tabItems = [ + { key: "commend", title: "推荐" }, + { key: "follow", title: "关注" }, +]; + +export default function Found() { + const router = useRouter(); + const recommPostRef = useRef(); + const followPostRef = useRef(); + const swiperRef = useRef(null); + const [activeIndex, setActiveIndex] = useState(0); + const [account, setAccount] = useState(null); + const [scrollHeight, setScrollHeight] = useState(0); + + // useEffect(() => { + // const info = get("account"); + // console.log("info",info) + // if (info) { + // setStreamerInfo(info); + // } + // }, [] + // ) + const childrenFunc = () => { + if (!activeIndex) { + recommPostRef.current?.doRefresh(); + } else { + followPostRef.current?.doRefresh(); + } + }; + useEffect(() => { + setAccount(get("account")); + }, []); + return ( +
+
+
+ { + router.back(); + }} + /> +
+

发现

+
+ {/* 内容 */} + +
+
+ { + const index = tabItems.findIndex((item) => item.key === key); + setActiveIndex(index); + swiperRef.current?.swipeTo(index); + }} + > + {tabItems.map((item) => ( + + ))} + +
+ null} + ref={swiperRef} + defaultIndex={activeIndex} + onIndexChange={(index) => { + setActiveIndex(index); + }} + > + + {!activeIndex && ( + + )} + + + {!!activeIndex && ( + + )} + + +
+ { + // router.refresh(); + // }} + onClick={childrenFunc} + /> +
+ +
+
+ ); +} +const RecommPostList = forwardRef(({ scrollHeight }, ref) => { + const [loading, setLoading] = useState(false); + const [hasMore, setHasMore] = useState(true); + const [currentSearchKey, setCurrentSearchKey] = useState(2); + const [commenPostList, setCommenPostList] = useState([]); + useEffect(() => { + // getRecommPostList(2).then((res) => { + // setCommenPostList(res); + // setHasMore(true) + // }); + }, []); + useImperativeHandle( + ref, + () => { + return { doRefresh }; + }, + [] + ); + async function doRefresh() { + // await sleep(1000); + // Toast.show({ + // icon: "fail", + // content: "刷新失败", + // }); + // throw new Error("刷新失败"); + window.scrollTo({ + top: 0, + left: 0, + behavior: "smooth", // 可选,平滑滚动效果 + }); + const list = await getRecommPostList(1); + setCommenPostList(list); + setHasMore(true); + } + async function loadMore() { + // debugger + const list = await getRecommPostList(!commenPostList.length ? 2 : 0); + if (list.length == 0) { + setHasMore(false); + } + setCommenPostList([...commenPostList, ...list]); + } + const getRecommPostList = async (type = 2) => { + setLoading(true); + try { + const data = await requireAPI("POST", "/api/streamer/recomm_list", { + body: { op_type: type }, + }); + setLoading(false); + if (data.ret == -1) { + // Toast.show({ + // icon: "fail", + // content: data.msg, + // position: "top", + // }); + return []; + } else { + return data.data.recomm_list; + } + } catch (error) { + setLoading(false); + } + }; + return ( + //
+
+ + {loading && !commenPostList.length && ( +
+ + + + + +
+ )} + {commenPostList?.map((item) => ( + + + + ))} + {/* {commenPostList?.length == 0 && !loading && ( +
+ +
+ )} */} +
+ {/* {!!commenPostList?.length && ( + + )} */} + + + +
+ ); +}); +const FollowPostList = forwardRef(({ scrollHeight }, ref) => { + const [loading, setLoading] = useState(false); + const [hasMore, setHasMore] = useState(false); + const [followPostList, setFollowPostList] = useState([]); + const [currentTime, setCurrentTime] = useState(); + const [offset, setOffset] = useState(0); + const ids = useRef(null); + useEffect(() => { + getFollowIds().then((res) => { + ids.current = res; + getFollowPostList(res, 0); + }); + }, []); + useImperativeHandle( + ref, + () => { + return { doRefresh }; + }, + [] + ); + async function doRefresh() { + // await sleep(1000); + // Toast.show({ + // icon: "fail", + // content: "刷新失败", + // }); + // throw new Error("刷新失败"); + // getRecommPostList(1); + window.scrollTo({ + top: 0, + left: 0, + behavior: "smooth", // 可选,平滑滚动效果 + }); + // setFollowPostList([]); + await getFollowPostList(ids.current, 0); + } + async function loadMore() { + await getFollowPostList(ids.current, offset); + // const newList = [...followPostList, ...list]; + // setFollowPostList(newList); + } + const getFollowIds = async () => { + setLoading(true); + setCurrentTime(Math.floor(new Date().getTime() / 1000)); + const data = await requireAPI( + "POST", + "/api/account_relation/list_follow", + { + body: { offset, limit: 4 }, + }, + true + ); + return data; + }; + const getFollowPostList = async (data, offset) => { + if (data.data.list.length > 0) { + //查关注主播展示资料 + const followsResponse = await requireAPI( + "POST", + "/api/streamer/list_ext_by_mids", + { + body: { + offset, + limit: 4, + mids: data.data.list?.map((item) => item.obj_mid), + }, + } + ); + // debugger; + // console.log("offset", followsResponse.data.offset); + setOffset(followsResponse.data.offset); + setHasMore(followsResponse.data.more); + setLoading(false); + if (data.ret == -1) { + // Toast.show({ + // icon: "fail", + // content: data.msg, + // position: "top", + // }); + } else { + setFollowPostList((old) => { + if (!offset) { + return followsResponse.data.list; + } else { + return [...old, ...followsResponse.data.list]; + } + }); + } + } else { + setLoading(false); + } + }; + + return ( +
+ {/* */} + + {loading && !followPostList.length && ( +
+ + + + + +
+ )} + {followPostList?.map((item, index) => ( + + + + ))} + {!followPostList?.length && ( +
+ +
+ )} +
+ {!!followPostList?.length && ( + + )} + {/*
*/} +
+ ); +}); diff --git a/app/my/setting/bannedList/page.js b/app/my/setting/bannedList/page.js index 2bc9ceb..992bc1e 100644 --- a/app/my/setting/bannedList/page.js +++ b/app/my/setting/bannedList/page.js @@ -156,7 +156,7 @@ export default function BannedList() { }} />
-

黑白名单

+

黑名单

{/* 内容 */}
diff --git a/app/profile/[mid]/page.js b/app/profile/[mid]/page.js index 3100638..9883732 100644 --- a/app/profile/[mid]/page.js +++ b/app/profile/[mid]/page.js @@ -28,6 +28,7 @@ export default function PersonSpace() { const router = useRouter(); const [streamerInfo, setStreamerInfo] = useState(null); const [spaceData, setSpaceData] = useState(null); + const [postData, setPostData] = useState(null); const [loading, setLoading] = useState(false); const [visible, setVisible] = useState(false); const [isFollow, setIsFollow] = useState(false); @@ -91,7 +92,27 @@ export default function PersonSpace() { }); return; } - setSpaceData(data.data.list[0]); + if (data.data.list[0].previews.images.length === 0) { + const data2 = await requireAPI("POST", "/api/moment/list_by_mid", { + body: { + mid: Number(mid), + ct_upper_bound: Math.floor(new Date().getTime() / 1000), + offset: 0, + limit: 100, + }, + }); + if (data2.ret === -1) { + Toast.show({ + icon: "fail", + content: data2.msg, + position: "top", + }); + return; + } + setPostData(data2.data.list); + } else { + setSpaceData(data.data.list[0]); + } } catch (error) { // console.error(error); } @@ -366,6 +387,7 @@ export default function PersonSpace() { )}
+ {/* 空间动态 */} {spaceData && !!spaceData?.previews?.images?.length && ( <> @@ -417,6 +439,53 @@ export default function PersonSpace() { )} + {/* 广场动态 */} + {postData && !!postData?.length && ( + <> + +
+
{ + router.push(`/streamerPosts/${mid}`); + }} + > +
+ + 动态({postData.length}) + +
+ +
+
+
+ {postData?.slice(0, 4).map((item, index) => ( +
+ +
+ ))} +
+
+
+ + )} <> diff --git a/app/search/conponents/Banner/index.jsx b/app/search/conponents/Banner/index.jsx index 4c141cd..20af538 100644 --- a/app/search/conponents/Banner/index.jsx +++ b/app/search/conponents/Banner/index.jsx @@ -83,15 +83,17 @@ export default function Banner() { ); return (
- - {bannerList.map((item, index) => items(item, index))} - + {bannerList.length > 0 && ( + + {bannerList.map((item, index) => items(item, index))} + + )}
); } diff --git a/app/search/conponents/HostList/index.jsx b/app/search/conponents/HostList/index.jsx index 6c63a62..2e51763 100644 --- a/app/search/conponents/HostList/index.jsx +++ b/app/search/conponents/HostList/index.jsx @@ -1,3 +1,5 @@ +"use client"; + import React, { useEffect, useState } from "react"; import { List } from "antd-mobile"; import LoadingMask from "@/components/LoadingMask"; @@ -7,6 +9,8 @@ import OwnImage from "@/components/OwnImage"; import OwnIcon from "@/components/OwnIcon"; import Banner from "../Banner"; import baseRequest from "@/utils/baseRequest"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faAngleRight } from "@fortawesome/free-solid-svg-icons"; export default function HostList() { const base = baseRequest(); const [hostList, setHostList] = useState([]); @@ -43,20 +47,17 @@ export default function HostList() {

猜你想看

- {/*
navigation.navigate("Stream")} - className="flex flex-row justify-between items-center" +
router.push("/found")} + className="flex flex-row justify-between items-center text-[#FFFFFF80] " > - 查看更多 + 查看更多 { - router.back(); - }} + size="lg" /> -
*/} +
diff --git a/app/space/[id]/page.js b/app/space/[id]/page.js index 33ae28a..99b37d9 100644 --- a/app/space/[id]/page.js +++ b/app/space/[id]/page.js @@ -158,7 +158,6 @@ export default function PersonSpace() { )[0]; floatingPanel?.scrollTo(0, 0); setOffset(0); - setHasMore(true); if (!postList.length) return; if (streamerInfo) { getPostList(streamerInfo.id, currentKey, 0).then((res) => { @@ -504,7 +503,11 @@ export default function PersonSpace() { ironfanship_price={streamerInfo.ironfanship_price} closeMask={() => { setMaskVisible({ visible: false, type: "" }); + getStreamerInfo(Number(id)).then((res) => { + setStreamerInfo(res); + }); }} + id={streamerInfo.id} handleClick={() => { setCurrentKey("ironFan"); setMaskVisible({ visible: false, type: "" }); diff --git a/app/space/createImagePost/page.jsx b/app/space/createImagePost/page.jsx index c79738e..50848cf 100644 --- a/app/space/createImagePost/page.jsx +++ b/app/space/createImagePost/page.jsx @@ -192,7 +192,7 @@ export default function CreateImagePost() { //提交成功后显示Toast并返回上一页 Toast.show({ icon: "success", - content: "发布成功", + content: "上传成功,请耐心等待审核", position: "top", }); router.back(); diff --git a/app/space/createVideoPost/page.jsx b/app/space/createVideoPost/page.jsx index ddeb6d2..253bc1e 100644 --- a/app/space/createVideoPost/page.jsx +++ b/app/space/createVideoPost/page.jsx @@ -164,7 +164,7 @@ export default function CreateVideoPost() { //提交成功后显示Toast并返回上一页 Toast.show({ icon: "success", - content: "发布成功", + content: "上传成功,请耐心等待审核", position: "top", }); router.back(); diff --git a/app/space/editSpacePost/[zid]/page.jsx b/app/space/editSpacePost/[zid]/page.jsx index 83282d0..4fcac83 100644 --- a/app/space/editSpacePost/[zid]/page.jsx +++ b/app/space/editSpacePost/[zid]/page.jsx @@ -75,7 +75,7 @@ export default function EditSpacePost() { blurCover: is_blurring_cover == 1, }; setFormData({ - content: paid_text + content: is_creating_paid_text ? text.slice(0, text.length - paid_text.length) : text, paidText: paid_text, diff --git a/app/streamerPosts/[id]/page.jsx b/app/streamerPosts/[id]/page.jsx index 761811c..7c69767 100644 --- a/app/streamerPosts/[id]/page.jsx +++ b/app/streamerPosts/[id]/page.jsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react"; import { List, InfiniteScroll, Toast } from "antd-mobile"; -import { useRouter } from "next/navigation"; +import { useRouter, useParams } from "next/navigation"; import requireAPI from "@/utils/requireAPI"; import Empty from "@/components/Empty"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -10,7 +10,8 @@ import { faAngleLeft } from "@fortawesome/free-solid-svg-icons"; import PostItem from "@/components/PostItem"; import { get } from "@/utils/storeInfo"; -export default function StreamerPosts({ id }) { +export default function StreamerPosts() { + const { id } = useParams(); //获取当前时间 const [currentTime, setCurrentTime] = useState(); const [account, setAccount] = useState(null); @@ -33,7 +34,7 @@ export default function StreamerPosts({ id }) { // if (!more) return; try { const body = { - mid: id, + mid: parseInt(id), ct_upper_bound: currentTime, offset: offset, limit: 4, diff --git a/app/streamerPosts/createPost/page.jsx b/app/streamerPosts/createPost/page.jsx index 0665ec8..abed376 100644 --- a/app/streamerPosts/createPost/page.jsx +++ b/app/streamerPosts/createPost/page.jsx @@ -103,7 +103,7 @@ export default function CreatePost() { //提交成功后显示Toast并返回上一页 Toast.show({ icon: "success", - content: "发布成功", + content: "上传成功,请耐心等待审核", position: "top", }); router.back(); diff --git a/app/streamerPosts/editPost/[zid]/page.jsx b/app/streamerPosts/editPost/[zid]/page.jsx index b9dd33f..9664c59 100644 --- a/app/streamerPosts/editPost/[zid]/page.jsx +++ b/app/streamerPosts/editPost/[zid]/page.jsx @@ -132,7 +132,7 @@ export default function EditPost() { //提交成功后显示Toast并返回上一页 Toast.show({ icon: "success", - content: "更新成功", + content: "提交成功,等待审核!", position: "top", }); router.back(); diff --git a/components/FoundItem/index.js b/components/FoundItem/index.js new file mode 100644 index 0000000..27d55f9 --- /dev/null +++ b/components/FoundItem/index.js @@ -0,0 +1,134 @@ +"use client"; + +import React from "react"; +import { useRouter } from "next/navigation"; +import OwnImage from "../OwnImage"; +import OwnIcon from "../OwnIcon"; +export default function FoundItem({ data = {} }) { + const router = useRouter(); + return ( +
{ + router.push("/profile/" + data.mid); + }} + > +
+ +
+
+ + {data?.name} + +
+ {data?.gender === 1 ? ( + + ) : ( + + )} + {data?.age}岁 +
+
+ + {data?.city} +
+
+ + 全网粉丝:{data?.fans}万 + +
+
+
+
+ +
+
+ {data?.album?.images.map((item, index) => { + if (index > 1) return; + return ( +
+ + {index === 1 && data?.album?.images.length > 2 && ( +
+ + +{data?.album?.images.length - 2} + +
+ )} +
+ ); + })} +
+
+ {/* 下方标签区 */} +
+
+ {data?.is_active_within_a_week === 1 && ( + + )} + {data?.tag?.map((item, index) => { + if (index > 2) return; + if (data?.is_active_within_a_week === 1 && index > 1) return; + return ( +
+ {item} +
+ ); + })} +
+
+ {data?.platforms?.map((item, index) => { + if (index > 5) return; + return ( +
+ {index < 5 && ( + + )} + {index === 5 && ( +
+ + +{data?.platforms.length - 5} + +
+ )} +
+ ); + })} +
+
+ {/* 分割线 */} +
+
+ ); +} diff --git a/components/PostItem/index.js b/components/PostItem/index.js index e64c918..3fb2def 100644 --- a/components/PostItem/index.js +++ b/components/PostItem/index.js @@ -14,6 +14,7 @@ import { get } from "@/utils/storeInfo"; import { Inter } from "next/font/google"; import requireAPI from "@/utils/requireAPI"; import { getcountLines } from "@/utils/tools"; +import { formatTimestamp } from "@/utils/tools"; const inter = Inter({ subsets: ["latin"] }); export default function PostItem({ type, @@ -227,7 +228,7 @@ export default function PostItem({ ) : (
140 || - getcountLines(data.paid_text || "") > 1) && ( + getcountLines(data.text || "") > 7) && (
setIsOpenText(!isOpenText)} @@ -339,24 +340,10 @@ export default function PostItem({
) : (
- - {getDays < 3 - ? `${ - getDays === 0 ? "今日" : "new" === 1 ? "昨日" : "前天" - }` - : date.getMonth() + 1 + "-" + date.getDate()} - - - {(date.getHours() > 9 - ? date.getHours() - : "0" + date.getHours()) + - ":" + - (date.getMinutes() > 9 - ? date.getMinutes() - : "0" + date.getMinutes())} - + {formatTimestamp(data.ct)}
)} + {isOwn &&
}
) : type == "post" && account?.mid == data?.mid ? ( <> +
  • { + router.push(`/streamerPosts/editPost/${data.id}`); + }} + > + 编辑 +
  • +
  • handleDelete("post")} diff --git a/components/SeeTiefen/index.js b/components/SeeTiefen/index.js index 2dac9fe..60cbdd4 100644 --- a/components/SeeTiefen/index.js +++ b/components/SeeTiefen/index.js @@ -1,16 +1,45 @@ "use client"; import React, { useState } from "react"; -import { Mask, ProgressBar } from "antd-mobile"; +import { Mask, ProgressBar, Toast } from "antd-mobile"; +import requireAPI from "@/utils/requireAPI"; export default function SeeTiefen({ visible, closeMask, handleClick, ironFanProgress, expenditure, - ironfanship_price + ironfanship_price, + id, }) { - + //刷新铁粉身份(解决主播降价导致的进度满100但未成为铁粉) + const handleFansIdentityRefresh = async () => { + try { + const body = { + zid: id, + }; + const _data = await requireAPI( + "POST", + "/api/zone_moment/fans_identity_refresh", + { + body, + } + ); + if (_data.ret == -1) { + Toast.show({ + icon: "fail", + content: _data.msg, + position: 60, + }); + return; + } + // await getData(); + // setIsIronFanModalVisible(false); + closeMask(false); + } catch (error) { + console.error(error); + } + }; return (
    @@ -18,7 +47,9 @@ export default function SeeTiefen({

    当前铁粉解锁进度: - {ironFanProgress}% + + {ironFanProgress}% +

    {`${ - expenditure / 100 - } / ${ironfanship_price / 100}`}

    + expenditure / 100 + } / ${ironfanship_price / 100}`}

    空间内累计消费达到¥{ironfanship_price / 100}即可成为 铁粉 @@ -42,6 +73,12 @@ export default function SeeTiefen({ > 查看铁粉专享内容

    +

    + 进度已满但还未成为铁粉? +