diff --git a/app/login/page.js b/app/login/page.js index acdada0..2c583be 100644 --- a/app/login/page.js +++ b/app/login/page.js @@ -52,7 +52,7 @@ function Login({ handleLogin }) { const showMobal = useRef(); const [iframePageUrl, setIframePageUrl] = useState(null); useEffect(() => { - const userAgent = navigator.userAgent; + const userAgent = window && window.navigator?.userAgent; //区分设备类型 if (/Android/i.test(userAgent)) { setDeviceType("Android"); diff --git a/app/my/page.js b/app/my/page.js index dc5fea0..7fb248e 100644 --- a/app/my/page.js +++ b/app/my/page.js @@ -29,7 +29,6 @@ const My = () => { null, true ); - console.log("------", data); if (data.ret === -1) { Toast.show({ icon: "fail", @@ -122,7 +121,7 @@ const My = () => { }, { url: `my/refund/refundList`, - iconUrl: "/icons/32DP/wallet.png", + iconUrl: "/icons/32DP/refund.png", title: "退款审核", subTitle: account.data.account.role == 3 ? "创作者功能" : "完善资料后解锁", diff --git a/app/noticeDetail/components/NoticeItem/index.jsx b/app/noticeDetail/components/NoticeItem/index.jsx index 8c8b5ad..c6e5a34 100644 --- a/app/noticeDetail/components/NoticeItem/index.jsx +++ b/app/noticeDetail/components/NoticeItem/index.jsx @@ -63,7 +63,7 @@ export default function NoticeItem({ leftIcon, hasLink, data }) { // } if (links.length > 1) { links[1]?.action === "app_router_path"; - router.push(links[1]?.params); + router.push("/" + links[1]?.params); } else { links[0]?.action === "outward"; router.push(links[0]?.params); diff --git a/app/search/conponents/Banner/index.jsx b/app/search/conponents/Banner/index.jsx new file mode 100644 index 0000000..d6e8244 --- /dev/null +++ b/app/search/conponents/Banner/index.jsx @@ -0,0 +1,81 @@ +import React, { useEffect, useState, useRef, useCallback } from "react"; +import { Toast, Swiper, Image } from "antd-mobile"; +import LoadingMask from "@/components/LoadingMask"; +import { useRouter } from "next/navigation"; +import requireAPI from "@/utils/requireAPI"; +import OwnImage from "@/components/OwnImage"; +import { goToPage } from "@/utils/tools"; +export default function Banner() { + const [bannerList, setBannerList] = useState([]); + const [isLoading, setIsLoading] = useState(false); + const router = useRouter(); + const ref = useRef(null); + useEffect(() => { + const getBannerList = async () => { + setIsLoading(true); + try { + const _data = await requireAPI( + "POST", + "/api/activity_banner/list", + null, + true + ); + if (_data.ret === -1) { + Toast.show({ + icon: "fail", + content: _data.msg, + position: "top", + }); + return; + } + setBannerList(_data.data.list); + } catch (error) { + console.error(error); + } finally { + setIsLoading(false); + } + }; + getBannerList(); + }, []); + const items = useCallback( + (item, index) => ( + +
{ + const links = item?.hyperlinks; + if (links.length > 1) { + router.push( + links.filter((it) => it.inward_action_type === "h5")[0]?.url + ); + } else { + router.push(links[0]?.url); + } + }} + > + +
+
+ ), + [] + ); + return ( +
+ + {bannerList.map((item, index) => items(item, index))} + +
+ ); +} diff --git a/app/search/conponents/HostList/index.jsx b/app/search/conponents/HostList/index.jsx index b60b074..a41d606 100644 --- a/app/search/conponents/HostList/index.jsx +++ b/app/search/conponents/HostList/index.jsx @@ -5,6 +5,7 @@ import { useRouter } from "next/navigation"; import requireAPI from "@/utils/requireAPI"; import OwnImage from "@/components/OwnImage"; import OwnIcon from "@/components/OwnIcon"; +import Banner from "../Banner"; export default function HostList() { const [hostList, setHostList] = useState([]); const [isLoading, setIsLoading] = useState(false); @@ -38,6 +39,10 @@ export default function HostList() { }, []); return (
+ {/* Banner预留位置 */} +
+ +

猜你想看

{/*
{ - if (item.hyperlinks[0].action === "outward") { - window.open(item.hyperlinks[0].url); + const links = item?.hyperlinks; + if (links.length > 1) { + router.push( + links.filter((it) => it.inward_action_type === "h5")[0]?.url + ); } else { - router.push(`space/person_space_introduce/${item.mid}`); + router.push(links[0]?.url); } }} className="grid grid-cols-[48px,calc(100vw-48px-2rem)]" @@ -94,34 +102,37 @@ export default function HostList() { {item.title} - -
- {item?.gender === 1 ? ( - - ) : ( - - )} - - {item.age} - -
-
- - - {item.city} - -
+ {item.age && ( + <> +
+ {item?.gender === 1 ? ( + + ) : ( + + )} + + {item.age} + +
+
+ + + {item.city} + +
+ + )}

{item.text} @@ -131,7 +142,6 @@ export default function HostList() { ))} - {/* Banner预留位置 */}

); } diff --git a/app/space/person_space_introduce/[mid]/page.js b/app/space/person_space_introduce/[mid]/page.js index cc9bf30..a1bd75d 100644 --- a/app/space/person_space_introduce/[mid]/page.js +++ b/app/space/person_space_introduce/[mid]/page.js @@ -175,6 +175,7 @@ export default function PersonSpaceIntroduce() { diff --git a/components/InOtherApp/index.js b/components/InOtherApp/index.js index 8851625..838b29a 100644 --- a/components/InOtherApp/index.js +++ b/components/InOtherApp/index.js @@ -6,7 +6,7 @@ export default function InOtherApp() { //区分是否在微信/微博/qq/支付宝/钉钉内置浏览器中打开 const [isInOtherApp, setIsInOtherApp] = useState(false); useEffect(() => { - const userAgent = navigator.userAgent.toLowerCase(); + const userAgent = window && window.navigator?.userAgent.toLowerCase(); let temIsInOtherApp = userAgent.match(/MicroMessenger/i) == "micromessenger" || userAgent.match(/WeiBo/i) == "weibo" || diff --git a/components/VideoPlayer/index.jsx b/components/VideoPlayer/index.jsx index d10aec8..ae29fd9 100644 --- a/components/VideoPlayer/index.jsx +++ b/components/VideoPlayer/index.jsx @@ -14,7 +14,7 @@ export default function VideoPlayer({ video }) { const [showController, setShowController] = useState(false); const [screenState, setScreenState] = useState(false); const isSliding = useRef(null); - const userAgent = navigator.userAgent; + const userAgent = window && window.navigator?.userAgent; // const currentTime = useMemo(()=>{ // const videoPlayer = document.getElementById("videoPlayer"); // if (videoPlayer) { diff --git a/components/WithAuth/index.js b/components/WithAuth/index.js index 381b62f..054e654 100644 --- a/components/WithAuth/index.js +++ b/components/WithAuth/index.js @@ -1,3 +1,4 @@ +"use client"; import { checkAuth } from "@/utils/auth"; import { useRouter, usePathname, useSearchParams } from "next/navigation"; import { useEffect } from "react"; @@ -10,7 +11,7 @@ export default function WithAuth(WrappedComponent) { const pathname = usePathname(); const searchParams = useSearchParams(); useEffect(() => { - const ua = navigator.userAgent.toLowerCase(); + const ua = window && window.navigator?.userAgent.toLowerCase(); if ( (ua.indexOf("mqqbrowser") > -1 || ua.indexOf("quark") > -1) && ua.indexOf("iphone") > -1 diff --git a/utils/baseRequest.js b/utils/baseRequest.js index 01ad904..fa9fd1f 100644 --- a/utils/baseRequest.js +++ b/utils/baseRequest.js @@ -1,3 +1,4 @@ +"use client"; import { getCookie } from "cookies-next"; import { get } from "./storeInfo"; export default function baseRequest() { @@ -7,7 +8,7 @@ export default function baseRequest() { const mid = getCookie("mid"); const b_ts = new Date().getTime(); let b_dt = 0; - if (/(iPad|iPhone|iPod)/gi.test(navigator.userAgent)) { + if (/(iPad|iPhone|iPod)/gi.test(window && window.navigator?.userAgent)) { b_dt = 1; } const baseRequest = { diff --git a/utils/tools.js b/utils/tools.js index b5ad1a5..40eabc2 100644 --- a/utils/tools.js +++ b/utils/tools.js @@ -1,3 +1,4 @@ +"use client"; import { Toast } from "antd-mobile"; //格式化时间戳 export function formatDeadline(timestamp) { @@ -135,7 +136,7 @@ export function getVideoBase64(url) { canvas.height = video.height; // 判断是否为 iOS 系统 - if (/(iPad|iPhone|iPod)/gi.test(navigator.userAgent)) { + if (/(iPad|iPhone|iPod)/gi.test(window && window.navigator?.userAgent)) { // 在 iOS 系统中,需要手动触发视频加载,然后设置自动播放和静音属性 video.load(); // video.autoplay = true; @@ -182,17 +183,26 @@ export function getcountLines(str) { } // 跳转页面 -// export function goToPage(link) { -// let linkArr = link.split("?"); -// const params = linkArr[1]?.split("&"); -// console.log("params", params); -// if (params == "") return "/my/" + linkArr[0]; -// } +export function goToPage(link) { + let linkArr = link.split("?"); + const params = linkArr[1]?.split("&"); + + if (!params) return linkArr[0]; + // if (linkArr[0].includes("/")) { + // const path = linkArr[0].replace(/^\/+|\/+$/g, ""); + // const pathNames = path.split("/").filter((it) => it != ""); + // return [pathNames[0], { screen: pathNames[1] }]; + // } + const query = params + .map((it) => ({ [it.split("=")[0]]: it.split("=")[1] })) + .reduce((acc, cur) => ({ ...acc, ...cur }), {}); + return [linkArr[0], query]; +} // 尝试使用浏览器打开URL export function openUrlWithBrowser(url) { try { - const userAgent = navigator.userAgent; + const userAgent = window && window.navigator?.userAgent; //区分设备类型 if (/Android/i.test(userAgent)) { var intentUrl = diff --git a/utils/webviewBaseRequest.js b/utils/webviewBaseRequest.js index 629540c..e610b2c 100644 --- a/utils/webviewBaseRequest.js +++ b/utils/webviewBaseRequest.js @@ -1,3 +1,4 @@ +"use client"; import { getCookies } from "cookies-next"; export default function webviewBaseRequest() { @@ -5,7 +6,7 @@ export default function webviewBaseRequest() { const b_ts = new Date().getTime(); const baseRequest = { b_mid: parseInt(cookies.b_mid), - b_did: window && window.navigator?.userAgent.slice(0,65), + b_did: window && window.navigator?.userAgent.slice(0, 65), b_ver: cookies.b_ver, b_dt: parseInt(cookies.b_dt), b_model: cookies.b_model,