|
@@ -6,48 +6,53 @@ import "swiper/css/scrollbar";
|
|
|
import "swiper/css/navigation";
|
|
import "swiper/css/navigation";
|
|
|
import Image from "next/image";
|
|
import Image from "next/image";
|
|
|
import { OpenAddToCartModalButton } from "@/components/common/AddToCartModal/OpenAddToCartModalButton";
|
|
import { OpenAddToCartModalButton } from "@/components/common/AddToCartModal/OpenAddToCartModalButton";
|
|
|
|
|
+import {HomeProduct} from "@/types/home/type"
|
|
|
|
|
+interface trendingProps {
|
|
|
|
|
+ trending: HomeProduct[];
|
|
|
|
|
+}
|
|
|
|
|
+// // 商品数据,每个卡片携带videoUrl视频地址
|
|
|
|
|
+// type ProductItem = {
|
|
|
|
|
+// id: number;
|
|
|
|
|
+// img: string;
|
|
|
|
|
+// title: string;
|
|
|
|
|
+// price: number;
|
|
|
|
|
+// videoUrl: string;
|
|
|
|
|
+// };
|
|
|
|
|
|
|
|
-// 商品数据,每个卡片携带videoUrl视频地址
|
|
|
|
|
-type ProductItem = {
|
|
|
|
|
- id: number;
|
|
|
|
|
- img: string;
|
|
|
|
|
- title: string;
|
|
|
|
|
- price: number;
|
|
|
|
|
- videoUrl: string;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const productList: ProductItem[] = [
|
|
|
|
|
- {
|
|
|
|
|
- id: 1,
|
|
|
|
|
- img: "/img/hair-video-1.jpg",
|
|
|
|
|
- title: "14-36 In Water Wave Human Hair HD Inv...",
|
|
|
|
|
- price: 146.1,
|
|
|
|
|
- videoUrl: "/video/hair-demo-1.mp4",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 2,
|
|
|
|
|
- img: "/img/hair-video-2.jpg",
|
|
|
|
|
- title: "14-36 In Water Wave Human Hair HD Inv...",
|
|
|
|
|
- price: 146.1,
|
|
|
|
|
- videoUrl: "/video/hair-demo-2.mp4",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 3,
|
|
|
|
|
- img: "/img/hair-video-3.jpg",
|
|
|
|
|
- title: "14-36 In Water Wave Human Hair HD Inv...",
|
|
|
|
|
- price: 146.1,
|
|
|
|
|
- videoUrl: "/video/hair-demo-3.mp4",
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: 4,
|
|
|
|
|
- img: "/img/hair-video-4.jpg",
|
|
|
|
|
- title: "14-36 In Water Wave Human Hair HD Inv...",
|
|
|
|
|
- price: 146.1,
|
|
|
|
|
- videoUrl: "/video/hair-demo-4.mp4",
|
|
|
|
|
- },
|
|
|
|
|
-];
|
|
|
|
|
|
|
+// const productList: ProductItem[] = [
|
|
|
|
|
+// {
|
|
|
|
|
+// id: 1,
|
|
|
|
|
+// img: "/img/hair-video-1.jpg",
|
|
|
|
|
+// title: "14-36 In Water Wave Human Hair HD Inv...",
|
|
|
|
|
+// price: 146.1,
|
|
|
|
|
+// videoUrl: "/video/hair-demo-1.mp4",
|
|
|
|
|
+// },
|
|
|
|
|
+// {
|
|
|
|
|
+// id: 2,
|
|
|
|
|
+// img: "/img/hair-video-2.jpg",
|
|
|
|
|
+// title: "14-36 In Water Wave Human Hair HD Inv...",
|
|
|
|
|
+// price: 146.1,
|
|
|
|
|
+// videoUrl: "/video/hair-demo-2.mp4",
|
|
|
|
|
+// },
|
|
|
|
|
+// {
|
|
|
|
|
+// id: 3,
|
|
|
|
|
+// img: "/img/hair-video-3.jpg",
|
|
|
|
|
+// title: "14-36 In Water Wave Human Hair HD Inv...",
|
|
|
|
|
+// price: 146.1,
|
|
|
|
|
+// videoUrl: "/video/hair-demo-3.mp4",
|
|
|
|
|
+// },
|
|
|
|
|
+// {
|
|
|
|
|
+// id: 4,
|
|
|
|
|
+// img: "/img/hair-video-4.jpg",
|
|
|
|
|
+// title: "14-36 In Water Wave Human Hair HD Inv...",
|
|
|
|
|
+// price: 146.1,
|
|
|
|
|
+// videoUrl: "/video/hair-demo-4.mp4",
|
|
|
|
|
+// },
|
|
|
|
|
+// ];
|
|
|
|
|
|
|
|
-const Trending = () => {
|
|
|
|
|
|
|
+const Trending = ({ trending }: trendingProps) => {
|
|
|
|
|
+ if (!trending || trending.length === 0) return null;
|
|
|
|
|
+ const productList = trending
|
|
|
// 视频弹窗状态
|
|
// 视频弹窗状态
|
|
|
const [openVideoModal, setOpenVideoModal] = useState(false);
|
|
const [openVideoModal, setOpenVideoModal] = useState(false);
|
|
|
const [currentVideoSrc, setCurrentVideoSrc] = useState("");
|
|
const [currentVideoSrc, setCurrentVideoSrc] = useState("");
|
|
@@ -134,13 +139,13 @@ const Trending = () => {
|
|
|
{/* 图片区域 + 中间播放按钮 */}
|
|
{/* 图片区域 + 中间播放按钮 */}
|
|
|
<div className="relative rounded-xl w-full aspect-[4/5] overflow-hidden rounded-xl">
|
|
<div className="relative rounded-xl w-full aspect-[4/5] overflow-hidden rounded-xl">
|
|
|
<img
|
|
<img
|
|
|
- src={item.img}
|
|
|
|
|
- alt={item.title}
|
|
|
|
|
|
|
+ src={item.image_url}
|
|
|
|
|
+ alt={item.name}
|
|
|
className="w-full h-full object-cover"
|
|
className="w-full h-full object-cover"
|
|
|
/>
|
|
/>
|
|
|
{/* 居中圆形播放按钮 */}
|
|
{/* 居中圆形播放按钮 */}
|
|
|
<button
|
|
<button
|
|
|
- onClick={() => handlePlayClick(item.videoUrl)}
|
|
|
|
|
|
|
+ onClick={() => handlePlayClick("/video/hair-demo-1.mp4"||item.videoUrl)}
|
|
|
className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2
|
|
className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2
|
|
|
w-24 h-24 rounded-full bg-white/60 backdrop-blur-sm
|
|
w-24 h-24 rounded-full bg-white/60 backdrop-blur-sm
|
|
|
flex items-center justify-center transition hover:bg-white/80"
|
|
flex items-center justify-center transition hover:bg-white/80"
|
|
@@ -161,12 +166,12 @@ const Trending = () => {
|
|
|
{/* 底部文字价格区域 */}
|
|
{/* 底部文字价格区域 */}
|
|
|
<div className="p-3 flex flex-col rounded-xl mt-3 bg-[#f0f8f5] gap-3">
|
|
<div className="p-3 flex flex-col rounded-xl mt-3 bg-[#f0f8f5] gap-3">
|
|
|
<p className="text-base text-gray-900 truncate">
|
|
<p className="text-base text-gray-900 truncate">
|
|
|
- {item.title}
|
|
|
|
|
|
|
+ {item.name}
|
|
|
</p>
|
|
</p>
|
|
|
{/* 价格 + 购物车图标 */}
|
|
{/* 价格 + 购物车图标 */}
|
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center justify-between">
|
|
|
<div className="flex items-center gap-1">
|
|
<div className="flex items-center gap-1">
|
|
|
- <span className="font-semibold">${item.price}</span>
|
|
|
|
|
|
|
+ <span className="font-semibold">${item.min_price}</span>
|
|
|
<span className="text-xs text-gray-500 line-through">
|
|
<span className="text-xs text-gray-500 line-through">
|
|
|
${item.price}
|
|
${item.price}
|
|
|
</span>
|
|
</span>
|