AccountBottomHrefSwiper.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. "use client";
  2. import { useEffect, useRef } from "react";
  3. import { Swiper, SwiperSlide } from "swiper/react";
  4. // 只导入 Autoplay 即可!loop 内置了
  5. import { Autoplay } from "swiper/modules";
  6. import "swiper/css";
  7. const AccountBottomHrefSwiper = () => {
  8. const swiperRef = useRef<any>(null);
  9. const footerCategorySlides = [
  10. { url: "/new-arrival.html", title: "New Arrival" },
  11. { url: "/hd-lace-wig.html", title: "HD Lace" },
  12. { url: "/effortless-wig.html", title: "Ready To Go Wigs" },
  13. { url: "/ombrecolorwigs.html", title: "Color" },
  14. { url: "/lace-frontal-wig.html", title: "Lace Frontal Wigs" },
  15. { url: "/closure-wigs.html", title: "Closure Wigs" },
  16. ];
  17. // 登录/注册/找回密码页面隐藏
  18. useEffect(() => {
  19. const path = window.location.pathname;
  20. const hidePaths = [
  21. "/customer/account/login",
  22. "/customer/account/forgotpassword",
  23. "/customer/account/create",
  24. ];
  25. if (hidePaths.some((p) => path.includes(p))) {
  26. const el = document.querySelector(".footer-bottom-category");
  27. if (el) el.remove();
  28. }
  29. }, []);
  30. return (
  31. <div className="footer-bottom-category bg-white py-3">
  32. <p className="underline text-center font-bold bg-[#eee] leading-8 ">
  33. HOW TO GET MORE POINTS?
  34. </p>
  35. <div className="footer-bottom-category-list container mx-auto px-4 bg-[#fff8f2] height-12.5 flex items-center ">
  36. <Swiper
  37. ref={swiperRef}
  38. // ✅ 只需要 Autoplay
  39. modules={[Autoplay]}
  40. // ✅ loop 直接写,不需要模块!
  41. // loop={true}
  42. slidesPerView="auto"
  43. spaceBetween={12}
  44. autoplay={{
  45. delay: 1000,
  46. disableOnInteraction: false,
  47. }}
  48. className="footer-bottom-category-swiper"
  49. >
  50. {footerCategorySlides.map((item, index) => (
  51. <SwiperSlide key={index} className="!w-auto footer-bottom-category-item whitespace-nowrap px-4 py-2 text-sm text-gray-700 rounded-lg border border-solid border-[#b32400]">
  52. <a
  53. href={item.url}
  54. className=" "
  55. >
  56. {item.title}
  57. </a>
  58. </SwiperSlide>
  59. ))}
  60. </Swiper>
  61. </div>
  62. </div>
  63. );
  64. };
  65. export default AccountBottomHrefSwiper;