tiefen_space_h5/app/bill/layout.jsx

91 lines
2.9 KiB
React
Raw Normal View History

2024-07-02 15:09:48 +08:00
"use client";
import { usePathname } from "next/navigation";
import Link from "next/link";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
2024-07-24 17:12:11 +08:00
import { faAngleLeft } from "@fortawesome/free-solid-svg-icons";
2024-07-02 15:09:48 +08:00
import { useRouter } from "next/navigation";
2024-07-24 17:12:11 +08:00
import { useEffect, useState } from "react";
2024-07-02 15:09:48 +08:00
export default function BillLayout({ children }) {
const pathname = usePathname();
const router = useRouter();
2024-07-24 17:12:11 +08:00
const [scrollHeight, setScrollHeight] = useState(0);
useEffect(() => {
setScrollHeight(window.innerHeight - 44);
}, []);
2024-07-02 15:09:48 +08:00
return (
<section className="flex flex-1 flex-col container">
<div className="p-4 fixed top-0 z-10 w-full">
<div className="w-9 h-9 flex items-center justify-center bg-[#FFFFFF1A] rounded-full float-left">
<FontAwesomeIcon
icon={faAngleLeft}
size="xl"
onClick={() => {
2024-07-24 17:12:11 +08:00
router.back();
2024-07-02 15:09:48 +08:00
}}
/>
</div>
<p className="text-base text-center leading-9">收支明细</p>
</div>
{pathname.split("/").length < 4 && (
2024-07-24 17:12:11 +08:00
<div
className="flex flex-col mt-14 px-4 overflow-y-auto"
style={{ maxHeight: scrollHeight }}
>
<div className="tabs tab-boxed w-full py-2 sticky top-0 bg-deepBg">
2024-07-02 15:09:48 +08:00
<Link
className={`tab basis-1/4 ${
pathname === "/bill/recharge"
? "tab-active text-[#FF669E] bg-[#FF61B030] rounded-full"
: "text-[#FFFFFF80]"
}`}
href="recharge"
2024-08-13 11:18:46 +08:00
replace
2024-07-02 15:09:48 +08:00
>
充值
</Link>
<Link
className={`tab basis-1/4 ${
pathname === "/bill/cost"
? "tab-active text-[#FF669E] bg-[#FF61B030] rounded-full"
: "text-[#FFFFFF80]"
}`}
href="cost"
2024-08-13 11:18:46 +08:00
replace
2024-07-02 15:09:48 +08:00
>
消费
</Link>
<Link
className={`tab basis-1/4 ${
pathname === "/bill/income"
? "tab-active text-[#FF669E] bg-[#FF61B030] rounded-full"
: "text-[#FFFFFF80]"
}`}
href="income"
2024-08-13 11:18:46 +08:00
replace
2024-07-02 15:09:48 +08:00
>
收益
</Link>
<Link
className={`tab basis-1/4 ${
pathname === "/bill/withdrawal"
? "tab-active text-[#FF669E] bg-[#FF61B030] rounded-full"
: "text-[#FFFFFF80]"
}`}
href="withdrawal"
2024-08-13 11:18:46 +08:00
replace
2024-07-02 15:09:48 +08:00
>
提现
</Link>
</div>
2024-07-24 17:12:11 +08:00
<div className="flex flex-1">{children}</div>
2024-07-02 15:09:48 +08:00
</div>
)}
2024-08-13 11:18:46 +08:00
{pathname.split("/").length > 3 && (
<div className="mt-14 px-4 flex flex-1">{children}</div>
)}
2024-07-02 15:09:48 +08:00
</section>
);
}