添加banner

This commit is contained in:
al 2025-01-15 12:03:57 +08:00
parent a3f43bb4e6
commit b1570602ec
12 changed files with 153 additions and 49 deletions

View File

@ -52,7 +52,7 @@ function Login({ handleLogin }) {
const showMobal = useRef(); const showMobal = useRef();
const [iframePageUrl, setIframePageUrl] = useState(null); const [iframePageUrl, setIframePageUrl] = useState(null);
useEffect(() => { useEffect(() => {
const userAgent = navigator.userAgent; const userAgent = window && window.navigator?.userAgent;
//区分设备类型 //区分设备类型
if (/Android/i.test(userAgent)) { if (/Android/i.test(userAgent)) {
setDeviceType("Android"); setDeviceType("Android");

View File

@ -29,7 +29,6 @@ const My = () => {
null, null,
true true
); );
console.log("------", data);
if (data.ret === -1) { if (data.ret === -1) {
Toast.show({ Toast.show({
icon: "fail", icon: "fail",
@ -122,7 +121,7 @@ const My = () => {
}, },
{ {
url: `my/refund/refundList`, url: `my/refund/refundList`,
iconUrl: "/icons/32DP/wallet.png", iconUrl: "/icons/32DP/refund.png",
title: "退款审核", title: "退款审核",
subTitle: subTitle:
account.data.account.role == 3 ? "创作者功能" : "完善资料后解锁", account.data.account.role == 3 ? "创作者功能" : "完善资料后解锁",

View File

@ -63,7 +63,7 @@ export default function NoticeItem({ leftIcon, hasLink, data }) {
// } // }
if (links.length > 1) { if (links.length > 1) {
links[1]?.action === "app_router_path"; links[1]?.action === "app_router_path";
router.push(links[1]?.params); router.push("/" + links[1]?.params);
} else { } else {
links[0]?.action === "outward"; links[0]?.action === "outward";
router.push(links[0]?.params); router.push(links[0]?.params);

View File

@ -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) => (
<Swiper.Item key={index}>
<div
className="w-full h-[200px]"
onClick={() => {
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);
}
}}
>
<OwnImage
className={"w-full h-full"}
outClassName={"w-full h-full"}
src={item.image.images[0].urls[0]}
fit="cover"
position="center"
/>
</div>
</Swiper.Item>
),
[]
);
return (
<div className="flex-1 mt-6">
<Swiper
allowTouchMove
ref={ref}
loop
autoplay
style={{ "--border-radius": "8px" }}
>
{bannerList.map((item, index) => items(item, index))}
</Swiper>
</div>
);
}

View File

@ -5,6 +5,7 @@ import { useRouter } from "next/navigation";
import requireAPI from "@/utils/requireAPI"; import requireAPI from "@/utils/requireAPI";
import OwnImage from "@/components/OwnImage"; import OwnImage from "@/components/OwnImage";
import OwnIcon from "@/components/OwnIcon"; import OwnIcon from "@/components/OwnIcon";
import Banner from "../Banner";
export default function HostList() { export default function HostList() {
const [hostList, setHostList] = useState([]); const [hostList, setHostList] = useState([]);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
@ -38,6 +39,10 @@ export default function HostList() {
}, []); }, []);
return ( return (
<div className="flex-1 mt-6"> <div className="flex-1 mt-6">
{/* Banner预留位置 */}
<div className="my-4">
<Banner />
</div>
<div className="flex flex-row justify-between items-center"> <div className="flex flex-row justify-between items-center">
<p className="text-xl font-medium">猜你想看</p> <p className="text-xl font-medium">猜你想看</p>
{/* <div {/* <div
@ -65,10 +70,13 @@ export default function HostList() {
> >
<div <div
onClick={() => { onClick={() => {
if (item.hyperlinks[0].action === "outward") { const links = item?.hyperlinks;
window.open(item.hyperlinks[0].url); if (links.length > 1) {
router.push(
links.filter((it) => it.inward_action_type === "h5")[0]?.url
);
} else { } else {
router.push(`space/person_space_introduce/${item.mid}`); router.push(links[0]?.url);
} }
}} }}
className="grid grid-cols-[48px,calc(100vw-48px-2rem)]" className="grid grid-cols-[48px,calc(100vw-48px-2rem)]"
@ -94,34 +102,37 @@ export default function HostList() {
<span className="text-base text-white font-medium whitespace-nowrap truncate max-w-[30%]"> <span className="text-base text-white font-medium whitespace-nowrap truncate max-w-[30%]">
{item.title} {item.title}
</span> </span>
{item.age && (
<div className="flex flex-row items-center py-0.5 px-2 ml-1 bg-[#FFFFFF1A] rounded-full"> <>
{item?.gender === 1 ? ( <div className="flex flex-row items-center py-0.5 px-2 ml-1 bg-[#FFFFFF1A] rounded-full">
<OwnIcon {item?.gender === 1 ? (
src="/icons/info/female.png" <OwnIcon
className="w-[14px] h-full" src="/icons/info/female.png"
outClassName="mr-1" className="w-[14px] h-full"
/> outClassName="mr-1"
) : ( />
<OwnIcon ) : (
src="/icons/info/male.png" <OwnIcon
className="w-[14px] h-full" src="/icons/info/male.png"
outClassName="mr-1" className="w-[14px] h-full"
/> outClassName="mr-1"
)} />
<span className="text-white text-xs font-medium ml-0.5"> )}
{item.age} <span className="text-white text-xs font-medium ml-0.5">
</span> {item.age}
</div> </span>
<div className="flex flex-row items-center py-0.5 px-2 ml-1 bg-[#FFFFFF1A] rounded-full"> </div>
<OwnIcon <div className="flex flex-row items-center py-0.5 px-2 ml-1 bg-[#FFFFFF1A] rounded-full">
src="/icons/info/location.png" <OwnIcon
className="w-[14px] h-full" src="/icons/info/location.png"
/> className="w-[14px] h-full"
<span className="text-white text-xs font-medium ml-0.5"> />
{item.city} <span className="text-white text-xs font-medium ml-0.5">
</span> {item.city}
</div> </span>
</div>
</>
)}
</div> </div>
<p className="text-sm text-[#FFFFFF80] whitespace-nowrap truncate w-full"> <p className="text-sm text-[#FFFFFF80] whitespace-nowrap truncate w-full">
{item.text} {item.text}
@ -131,7 +142,6 @@ export default function HostList() {
</List.Item> </List.Item>
))} ))}
</List> </List>
{/* Banner预留位置 */}
</div> </div>
); );
} }

View File

@ -175,6 +175,7 @@ export default function PersonSpaceIntroduce() {
<OwnImage <OwnImage
rounded="rounded" rounded="rounded"
className="h-full" className="h-full"
outClassName="h-full"
fit="cover" fit="cover"
src={data?.streamer_ext?.shorts?.videos[0]?.cover_urls[0]} src={data?.streamer_ext?.shorts?.videos[0]?.cover_urls[0]}
/> />

View File

@ -6,7 +6,7 @@ export default function InOtherApp() {
//区分是否在微信/微博/qq/支付宝/钉钉内置浏览器中打开 //区分是否在微信/微博/qq/支付宝/钉钉内置浏览器中打开
const [isInOtherApp, setIsInOtherApp] = useState(false); const [isInOtherApp, setIsInOtherApp] = useState(false);
useEffect(() => { useEffect(() => {
const userAgent = navigator.userAgent.toLowerCase(); const userAgent = window && window.navigator?.userAgent.toLowerCase();
let temIsInOtherApp = let temIsInOtherApp =
userAgent.match(/MicroMessenger/i) == "micromessenger" || userAgent.match(/MicroMessenger/i) == "micromessenger" ||
userAgent.match(/WeiBo/i) == "weibo" || userAgent.match(/WeiBo/i) == "weibo" ||

View File

@ -14,7 +14,7 @@ export default function VideoPlayer({ video }) {
const [showController, setShowController] = useState(false); const [showController, setShowController] = useState(false);
const [screenState, setScreenState] = useState(false); const [screenState, setScreenState] = useState(false);
const isSliding = useRef(null); const isSliding = useRef(null);
const userAgent = navigator.userAgent; const userAgent = window && window.navigator?.userAgent;
// const currentTime = useMemo(()=>{ // const currentTime = useMemo(()=>{
// const videoPlayer = document.getElementById("videoPlayer"); // const videoPlayer = document.getElementById("videoPlayer");
// if (videoPlayer) { // if (videoPlayer) {

View File

@ -1,3 +1,4 @@
"use client";
import { checkAuth } from "@/utils/auth"; import { checkAuth } from "@/utils/auth";
import { useRouter, usePathname, useSearchParams } from "next/navigation"; import { useRouter, usePathname, useSearchParams } from "next/navigation";
import { useEffect } from "react"; import { useEffect } from "react";
@ -10,7 +11,7 @@ export default function WithAuth(WrappedComponent) {
const pathname = usePathname(); const pathname = usePathname();
const searchParams = useSearchParams(); const searchParams = useSearchParams();
useEffect(() => { useEffect(() => {
const ua = navigator.userAgent.toLowerCase(); const ua = window && window.navigator?.userAgent.toLowerCase();
if ( if (
(ua.indexOf("mqqbrowser") > -1 || ua.indexOf("quark") > -1) && (ua.indexOf("mqqbrowser") > -1 || ua.indexOf("quark") > -1) &&
ua.indexOf("iphone") > -1 ua.indexOf("iphone") > -1

View File

@ -1,3 +1,4 @@
"use client";
import { getCookie } from "cookies-next"; import { getCookie } from "cookies-next";
import { get } from "./storeInfo"; import { get } from "./storeInfo";
export default function baseRequest() { export default function baseRequest() {
@ -7,7 +8,7 @@ export default function baseRequest() {
const mid = getCookie("mid"); const mid = getCookie("mid");
const b_ts = new Date().getTime(); const b_ts = new Date().getTime();
let b_dt = 0; 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; b_dt = 1;
} }
const baseRequest = { const baseRequest = {

View File

@ -1,3 +1,4 @@
"use client";
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
//格式化时间戳 //格式化时间戳
export function formatDeadline(timestamp) { export function formatDeadline(timestamp) {
@ -135,7 +136,7 @@ export function getVideoBase64(url) {
canvas.height = video.height; canvas.height = video.height;
// 判断是否为 iOS 系统 // 判断是否为 iOS 系统
if (/(iPad|iPhone|iPod)/gi.test(navigator.userAgent)) { if (/(iPad|iPhone|iPod)/gi.test(window && window.navigator?.userAgent)) {
// 在 iOS 系统中,需要手动触发视频加载,然后设置自动播放和静音属性 // 在 iOS 系统中,需要手动触发视频加载,然后设置自动播放和静音属性
video.load(); video.load();
// video.autoplay = true; // video.autoplay = true;
@ -182,17 +183,26 @@ export function getcountLines(str) {
} }
// 跳转页面 // 跳转页面
// export function goToPage(link) { export function goToPage(link) {
// let linkArr = link.split("?"); let linkArr = link.split("?");
// const params = linkArr[1]?.split("&"); const params = linkArr[1]?.split("&");
// console.log("params", params);
// if (params == "") return "/my/" + linkArr[0]; 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 // 尝试使用浏览器打开URL
export function openUrlWithBrowser(url) { export function openUrlWithBrowser(url) {
try { try {
const userAgent = navigator.userAgent; const userAgent = window && window.navigator?.userAgent;
//区分设备类型 //区分设备类型
if (/Android/i.test(userAgent)) { if (/Android/i.test(userAgent)) {
var intentUrl = var intentUrl =

View File

@ -1,3 +1,4 @@
"use client";
import { getCookies } from "cookies-next"; import { getCookies } from "cookies-next";
export default function webviewBaseRequest() { export default function webviewBaseRequest() {
@ -5,7 +6,7 @@ export default function webviewBaseRequest() {
const b_ts = new Date().getTime(); const b_ts = new Date().getTime();
const baseRequest = { const baseRequest = {
b_mid: parseInt(cookies.b_mid), 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_ver: cookies.b_ver,
b_dt: parseInt(cookies.b_dt), b_dt: parseInt(cookies.b_dt),
b_model: cookies.b_model, b_model: cookies.b_model,