index.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. "use client";
  2. import { usePathname, useRouter } from "@/i18n";
  3. import clsx from "clsx";
  4. import { FC, PropsWithChildren, ReactNode } from "react";
  5. import "./style.scss";
  6. import { useGlobalStore } from "@/stores";
  7. /**
  8. * @description 底部Tab组件
  9. * @param children 插槽内容
  10. *
  11. */
  12. export interface FooterProps {
  13. children?: ReactNode;
  14. }
  15. const Footer: FC<PropsWithChildren> = () => {
  16. const { token } = useGlobalStore();
  17. const tabList = [
  18. {
  19. iconSpanName: "icon-home",
  20. label: "Início",
  21. path: "/",
  22. },
  23. {
  24. iconSpanName: "icon-qianbao1",
  25. label: "Depósito",
  26. path: "/deposit",
  27. },
  28. {
  29. iconSpanName: "icon-afiliado",
  30. label: "Afiliado",
  31. path: "/affiliate/summary",
  32. },
  33. {
  34. iconSpanName: "icon-tiyu",
  35. label: "Esportes",
  36. path: "/",
  37. },
  38. {
  39. iconSpanName: "icon-yonghu",
  40. label: "Perfil",
  41. path: "/profile",
  42. },
  43. ];
  44. const pathname = usePathname();
  45. const router = useRouter();
  46. const goPage = (path = "/") => {
  47. if(!token && (path == '/deposit' || path == "/profile")) {
  48. router.replace(`/login?redirect=${path}`)
  49. return
  50. }
  51. router.push(path);
  52. };
  53. return (
  54. <div className="footer-box">
  55. <ul>
  56. {tabList.map((item, index) => {
  57. return (
  58. <li
  59. className={clsx(item.path == pathname && "active")}
  60. onClick={() => goPage(item.path)}
  61. key={index}
  62. >
  63. <div className="icon-box">
  64. {index == 2 ? (
  65. <>
  66. <i className="icon-afiliado"></i>
  67. <i className="icon-rs"></i>
  68. </>
  69. ) : (
  70. <span className={clsx("iconfont", item.iconSpanName)}></span>
  71. )}
  72. {index == 3 && <b className="icon-hot"></b>}
  73. </div>
  74. <label>{item.label}</label>
  75. </li>
  76. );
  77. })}
  78. </ul>
  79. </div>
  80. );
  81. };
  82. export default Footer;