MiddleImageSwiper.tsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. import { Swiper, SwiperSlide } from "swiper/react";
  2. // import { Pagination } from "swiper/modules";
  3. import { OpenAddToCartModalButton } from "@/components/common/AddToCartModal/OpenAddToCartModalButton";
  4. import type {HomeProduct,HomeSectionImage} from "@/types/home/type"
  5. import Link from "next/link";
  6. import Image from "next/image";
  7. interface zeroWearProps {
  8. zeroWear: HomeProduct[];
  9. zeroWearImage:HomeSectionImage[]
  10. }
  11. // const productList = [
  12. // {
  13. // id: 1,
  14. // img: "https://picsum.photos/400/500?random=1",
  15. // title: "14-36 In Water Wave Hum...",
  16. // price: 143.35,
  17. // },
  18. // {
  19. // id: 2,
  20. // img: "https://picsum.photos/400/500?random=2",
  21. // title: "14-36 In Water Wave Hum.",
  22. // price: 143.35,
  23. // },
  24. // {
  25. // id: 3,
  26. // img: "https://picsum.photos/400/500?random=3",
  27. // title: "14-36 In Water Wave Hum...",
  28. // price: 143.35,
  29. // },
  30. // {
  31. // id: 4,
  32. // img: "https://picsum.photos/400/500?random=4",
  33. // title: "14-36 In Water Wave Hum.",
  34. // price: 143.35,
  35. // },
  36. // ];
  37. const MiddleImageSwiper = ({ zeroWear,zeroWearImage }: zeroWearProps) => {
  38. // zeroWear=[
  39. // {
  40. // "id": 55766,
  41. // "sku": "STW--4*7BobWig--RTG-10, #4--STW--5*5BobWig--12",
  42. // "name": "[Pack Deal] 10in Natural Black 7*4 Bob Wig and 12in Chocolate Brown 5*5 Bob Wig",
  43. // "slug": null,
  44. // "type": "flexible_variant",
  45. // "price": '368',
  46. // "min_price":'368' ,
  47. // "special_price": null,
  48. // "image_url": "https://img.asteriahair.com/media/catalog/product/2/_/2_wigs_package_deal_natural_black_bob_wig_and_natural_black_bob_wig_1.jpg",
  49. // "is_new": false,
  50. // "is_featured": false,
  51. // "short_description": "Asteria Hair [Pack Deal] 10in Natural Black Ready To Go 7*4 Lace Bob Wig and 12in Chocolate Brown 5*5 Lace Closure Bob Wig.",
  52. // "rating": 5,
  53. // "review_count": 2
  54. // },
  55. // {
  56. // "id": 55811,
  57. // "sku": "LD--13*4Wig--24,LB--5*7Wig--RTG--20",
  58. // "name": "[Pack Deal] 2 Long Length Wig 24Inch Loose Deep 13*4 Lace Wig and 20Inch Body Wave Ready To Go Closure Wig",
  59. // "slug": null,
  60. // "type": "flexible_variant",
  61. // "price": "830",
  62. // "min_price": "830",
  63. // "special_price": null,
  64. // "image_url": "https://img.asteriahair.com/media/catalog/product/l/d/ld_body.png",
  65. // "is_new": false,
  66. // "is_featured": false,
  67. // "short_description": "Asteria Hair [Pack Deal] 2 Long Length Wig 24Inch Loose Deep 13*4 Lace Wig and 20Inch Body Wave Ready To Go 5*7 Closure Wig.",
  68. // "rating": 5,
  69. // "review_count": 13
  70. // },
  71. // {
  72. // "id": 55651,
  73. // "sku": "STW--4*7Wig--RTG--16,A025--STW--13*4Bob--RTG--12",
  74. // "name": "[Pack Deal] 2 Ready To Go Wig 100% Glueless Straight Texture",
  75. // "slug": null,
  76. // "type": "flexible_variant",
  77. // "price": "400",
  78. // "min_price": "400",
  79. // "special_price": null,
  80. // "image_url": "https://img.asteriahair.com/media/catalog/product/b/o/bob_.png",
  81. // "is_new": false,
  82. // "is_featured": false,
  83. // "short_description": "Asteria Hair [Pack Deal] 2 Ready To Go Wig 100% Glueless Straight Texture, straight 7*5 ready to go lace wig 16inch and zigzag style 13*4 ready to go lace bob wig 12inch.",
  84. // "rating": 5,
  85. // "review_count": 11
  86. // },
  87. // {
  88. // "id": 55681,
  89. // "sku": "Curly--HDLaceFrontWig--20--250%,LB--4*7BobWig--RTG-10",
  90. // "name": "[Pack Deal] 20in 250% Density Curly 13*4 HD Lace Wig and 10Inch 7*4 Ready To Go Body Wave Bob Human Hair Wig",
  91. // "slug": null,
  92. // "type": "flexible_variant",
  93. // "price": "650",
  94. // "min_price": "650",
  95. // "special_price": null,
  96. // "image_url": "https://img.asteriahair.com/media/catalog/product/j/c/jc_rtg_lb_.png",
  97. // "is_new": false,
  98. // "is_featured": false,
  99. // "short_description": "Asteria Hair [Pack Deal] 20in 250% Density Curly 13*4 HD Lace Wig and 10in 7*4 Ready To Go Body Wave Bob Human Hair Lace Wig.",
  100. // "rating": 5,
  101. // "review_count": 4
  102. // },
  103. // {
  104. // "id": 55982,
  105. // "sku": "JC-5*7Wig-24-180%-RTG,NHC-RTG-LB-4*7BOB-12",
  106. // "name": "[Pack Deal]2 Ready To Go Wigs Curly 5*7 Lace Wig 24 Inch And BOB Body Wave Wig 4*7 Lace Wigs 12 Inch",
  107. // "slug": null,
  108. // "type": "flexible_variant",
  109. // "price": '738',
  110. // "min_price": '738',
  111. // "special_price": null,
  112. // "image_url": "https://img.asteriahair.com/media/catalog/product/1/_/1_6_16.png",
  113. // "is_new": false,
  114. // "is_featured": false,
  115. // "short_description": "This value pack includes two ready-to-wear wigs: a 24-inch curly style with 5*7 lace front and a 12-inch body wave bob with 4*7 lace, both made from human hair for instant perfection and versatile styling.",
  116. // "rating": 0,
  117. // "review_count": 0
  118. // },
  119. // {
  120. // "id": 55984,
  121. // "sku": "NHC-RTG-LB-4*7BOB-12,NHC-RTG-STW-4*7BOB-10",
  122. // "name": "[Pack Deal]Ready To Go Wigs Bob Straight Wig 4*7 Lace Wigs 10 Inch And BOB Body Wave Wig 4*7 Lace Wigs 12 Inch",
  123. // "slug": null,
  124. // "type": "flexible_variant",
  125. // "price": '398',
  126. // "min_price": '398',
  127. // "special_price": null,
  128. // "image_url": "https://img.asteriahair.com/media/catalog/product/1/_/1_7.png",
  129. // "is_new": false,
  130. // "is_featured": false,
  131. // "short_description": "This value pack includes two ready-to-wear bob wigs: a 10-inch straight style and a 12-inch body wave style, both featuring a 4*7 lace construction and made from human hair, allowing you to effortlessly switch between two fashionable looks.",
  132. // "rating": 0,
  133. // "review_count": 0
  134. // }
  135. // ]
  136. if (!zeroWear || zeroWear.length === 0) return null;
  137. const productList = zeroWear
  138. const WearImage = zeroWearImage;
  139. const bgImage = WearImage?.[0]?.image;
  140. console.log(WearImage);
  141. return (
  142. <div className={`w-full px-12 mx-auto `}
  143. >
  144. <div className="w-full flex rounded-lg bg-no-repeat bg-size-[100%_100%] "
  145. style={{
  146. backgroundImage: bgImage
  147. ? `url(${bgImage})`
  148. : undefined,
  149. }}
  150. >
  151. <div className="w-[777px] h-full">
  152. {/* <img
  153. src={WearImage[0].image || 'https://cdn.asteriahair.com/uploads/202602/11/20260211095330_7ec9031a4ab36e44.gif'}
  154. alt={WearImage[0].title || 'ZEROWEAR hair banner'}
  155. className="w-full h-auto object-cover block"
  156. /> */}
  157. </div>
  158. <div className="py-4 px-4 pl-0 relative max-w-[1080px] ">
  159. <div className="w-full relative">
  160. <Swiper
  161. // modules={[Pagination]}
  162. spaceBetween={16}
  163. slidesPerView={3.2}
  164. // pagination={{
  165. // type: "progressbar",
  166. // el: ".my-progress-bar",
  167. // }}
  168. className="mySwiper middle-image-swiper"
  169. // breakpoints={{
  170. // 480: { slidesPerView: 1 },
  171. // 768: { slidesPerView: 2 },
  172. // }}
  173. >
  174. {productList.map((item) => (
  175. <SwiperSlide key={item.id}>
  176. <div className="bg-white rounded overflow-hidden flex flex-col">
  177. {/* <img
  178. src={item.image_url}
  179. alt={item.name}
  180. className="w-full aspect-[3/4] object-cover"
  181. /> */}
  182. <Link href={`/${item.urlKey}.html`} className="relative aspect-[3/4] w-full overflow-hidden rounded-sm block">
  183. <Image
  184. src={item.image_url}
  185. alt={item.name}
  186. fill
  187. className="object-cover"
  188. />
  189. </Link>
  190. <div className="p-2 flex flex-col gap-2">
  191. <Link href={`/${item.urlKey}.html`} className="text-sm text-gray-800 truncate">
  192. {item.name}
  193. </Link>
  194. {/* 价格 + 购物车图标 */}
  195. <div className="flex items-center justify-between">
  196. <div className="flex items-center gap-1">
  197. <span className="font-semibold">${item.min_price}</span>
  198. <span className="text-xs text-gray-500 line-through">
  199. ${item.price}
  200. </span>
  201. </div>
  202. {/* 购物车图标 */}
  203. <OpenAddToCartModalButton
  204. productId={item.id}
  205. icon={
  206. <svg
  207. xmlns="http://www.w3.org/2000/svg"
  208. width="32"
  209. height="32"
  210. viewBox="0 0 32 32"
  211. fill="none"
  212. >
  213. <rect
  214. x="0"
  215. y="0"
  216. width="32"
  217. height="32"
  218. rx="8"
  219. fill="#036141"
  220. ></rect>
  221. <path
  222. stroke="rgba(255, 255, 255, 1)"
  223. stroke-width="1.3333333333333333"
  224. stroke-linejoin="round"
  225. stroke-linecap="round"
  226. d="M6.40039 7.79993L8.03372 7.79993L8.73372 10.5999M8.73372 10.5999L11.0671 19.9333L23.2004 19.9333L25.5337 10.5999L8.73372 10.5999Z"
  227. ></path>
  228. <ellipse
  229. cx="11.066040515899658"
  230. cy="23.199928283691406"
  231. rx="1.4000248908996582"
  232. ry="1.4000015258789062"
  233. stroke="rgba(255, 255, 255, 1)"
  234. stroke-width="1.3333333333333333"
  235. stroke-linejoin="round"
  236. stroke-linecap="round"
  237. ></ellipse>
  238. <ellipse
  239. cx="23.1998291015625"
  240. cy="23.199928283691406"
  241. rx="1.4000244140625"
  242. ry="1.4000015258789062"
  243. stroke="rgba(255, 255, 255, 1)"
  244. stroke-width="1.3333333333333333"
  245. stroke-linejoin="round"
  246. stroke-linecap="round"
  247. ></ellipse>
  248. <path
  249. stroke="rgba(255, 255, 255, 1)"
  250. stroke-width="1.3333333333333333"
  251. stroke-linejoin="round"
  252. stroke-linecap="round"
  253. d="M15.2656 15.2665L18.999 15.2665"
  254. ></path>
  255. <path
  256. stroke="rgba(255, 255, 255, 1)"
  257. stroke-width="1.3333333333333333"
  258. stroke-linejoin="round"
  259. stroke-linecap="round"
  260. d="M17.1348 17.1332L17.1348 13.3999"
  261. ></path>
  262. </svg>
  263. }
  264. />
  265. </div>
  266. </div>
  267. </div>
  268. </SwiperSlide>
  269. ))}
  270. </Swiper>
  271. {/* <div className="my-progress-bar mt-5 w-full h-1 bg-gray-200 rounded-full bottom-0 [top:unset]"></div> */}
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. );
  277. };
  278. export default MiddleImageSwiper;