|
|
@@ -9,6 +9,7 @@ import ReviewImageGalleryModal from "./ReviewImageGalleryModal";
|
|
|
import Image from "next/image";
|
|
|
import { clientFetch } from "@/lib/restApiClient";
|
|
|
import { useCustomToast } from "@utils/hooks/useToast";
|
|
|
+import { getUuId } from "@/utils/helper";
|
|
|
// 分页常量
|
|
|
const PAGE_SIZE = 10;
|
|
|
|
|
|
@@ -19,7 +20,6 @@ interface ReviewModalProps {
|
|
|
productId: string;
|
|
|
// 父组件传入默认Tab all / newest / photos
|
|
|
activeTab: ReviewTabType;
|
|
|
- guestId: string | null;
|
|
|
}
|
|
|
// 模拟后端请求函数,替换为你的真实接口
|
|
|
async function fetchReviewApi(
|
|
|
@@ -127,7 +127,6 @@ const ReviewModal: React.FC<ReviewModalProps> = React.memo(
|
|
|
productId,
|
|
|
onChangeTab,
|
|
|
activeTab,
|
|
|
- guestId,
|
|
|
}) {
|
|
|
// 全部原始评论数据(接口返回完整数据缓存)
|
|
|
const [fullReviewList, setFullReviewList] = useState<ProductReviewList>([]);
|
|
|
@@ -161,7 +160,8 @@ const ReviewModal: React.FC<ReviewModalProps> = React.memo(
|
|
|
async (tab: ReviewTabType, pageNum: number, reset = false) => {
|
|
|
setLoading(true);
|
|
|
try {
|
|
|
- const res = await fetchReviewApi(productId, tab, pageNum, guestId);
|
|
|
+ const uuid = getUuId();
|
|
|
+ const res = await fetchReviewApi(productId, tab, pageNum, uuid);
|
|
|
if (reset) {
|
|
|
// 切换Tab/首次打开,重置列表
|
|
|
setFullReviewList(res.list);
|
|
|
@@ -287,13 +287,14 @@ const ReviewModal: React.FC<ReviewModalProps> = React.memo(
|
|
|
},
|
|
|
}));
|
|
|
try {
|
|
|
+ const uuid = getUuId();
|
|
|
const res = await clientFetch(`/api/shop/reviews/${id}/like`, {
|
|
|
method: "POST",
|
|
|
headers: {
|
|
|
"Content-Type": "application/json",
|
|
|
},
|
|
|
body: JSON.stringify({
|
|
|
- client_id: guestId,
|
|
|
+ client_id: uuid,
|
|
|
}),
|
|
|
});
|
|
|
|