|
@@ -0,0 +1,65 @@
|
|
|
|
|
+"use client"
|
|
|
|
|
+
|
|
|
|
|
+import {useState} from "react"
|
|
|
|
|
+import Image from "next/image"
|
|
|
|
|
+import {Pagination} from "antd"
|
|
|
|
|
+import Link from "next/link";
|
|
|
|
|
+
|
|
|
|
|
+interface ProductGridProps {
|
|
|
|
|
+ products: ProductItem[]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export default function ProductGrid({ products }: ProductGridProps) {
|
|
|
|
|
+ const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL as string
|
|
|
|
|
+
|
|
|
|
|
+ // 分页控制
|
|
|
|
|
+ const [currentPage, setCurrentPage] = useState(1)
|
|
|
|
|
+ const pageSize = 6
|
|
|
|
|
+
|
|
|
|
|
+ // 当前页数据
|
|
|
|
|
+ const startIndex = (currentPage - 1) * pageSize
|
|
|
|
|
+ const currentProducts = products.slice(startIndex, startIndex + pageSize)
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div className="flex flex-col gap-6">
|
|
|
|
|
+ {/* 产品网格 */}
|
|
|
|
|
+ <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 sm:gap-6">
|
|
|
|
|
+ {currentProducts.map((product) => (
|
|
|
|
|
+ <div
|
|
|
|
|
+ key={product.productId}
|
|
|
|
|
+ className="bg-white rounded-lg overflow-hidden shadow-lg hover:shadow-xl transition-all duration-300 hover:scale-[1.02]"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div className="p-2">
|
|
|
|
|
+ <Image
|
|
|
|
|
+ className={"h-60 object-contain"}
|
|
|
|
|
+ src={product.productUrl ? BASE_URL + product.productUrl : "/assets/productions/2.png"}
|
|
|
|
|
+ alt={product.productName}
|
|
|
|
|
+ width={1000}
|
|
|
|
|
+ height={1000}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="p-4 sm:py-6 text-center">
|
|
|
|
|
+ <h3 className="text-sm sm:text-base lg:text-lg font-medium text-gray-900 mb-3 sm:mb-4 leading-tight min-h-[2.5rem] sm:min-h-[3rem] flex items-center justify-center">
|
|
|
|
|
+ {product.productName}
|
|
|
|
|
+ </h3>
|
|
|
|
|
+ <Link href={`/products/${product.productId}`} className="bg-blue-500 hover:bg-blue-600 text-white px-4 sm:px-6 py-2 sm:py-2.5 rounded-lg font-medium transition-all duration-200 text-sm sm:text-base hover:scale-105 active:scale-95">
|
|
|
|
|
+ 了解详情
|
|
|
|
|
+ </Link>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 分页器 */}
|
|
|
|
|
+ <div className="flex justify-center">
|
|
|
|
|
+ <Pagination
|
|
|
|
|
+ current={currentPage}
|
|
|
|
|
+ pageSize={pageSize}
|
|
|
|
|
+ total={products.length}
|
|
|
|
|
+ onChange={(page) => setCurrentPage(page)}
|
|
|
|
|
+ showSizeChanger={false}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+}
|