fix: bizhi detail

This commit is contained in:
zzc
2026-02-26 14:35:42 +08:00
parent fe562ecec9
commit 9137a3410b
3 changed files with 29 additions and 7 deletions

View File

@@ -20,3 +20,10 @@ export const getWallpaperRecommendList = async () => {
method: "get", method: "get",
}); });
}; };
export const getWallpaperSameList = async (id) => {
return request({
url: `/api/blessing/wallpaper/same/list?id=${id}`,
method: "get",
});
};

View File

@@ -398,7 +398,7 @@ const navToWallpaper = (item) => {
item.resourceInfo?.url || item.imageUrl || "", item.resourceInfo?.url || item.imageUrl || "",
); );
uni.navigateTo({ uni.navigateTo({
url: `/pages/wallpaper/detail?id=${item.id}&imageUrl=${imageUrl}`, url: `/pages/wallpaper/detail?id=${item.targetId}&imageUrl=${imageUrl}`,
}); });
}; };

View File

@@ -106,7 +106,7 @@ import { ref, computed } from "vue";
import { onLoad, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app"; import { onLoad, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
import { getBavBarHeight } from "@/utils/system"; import { getBavBarHeight } from "@/utils/system";
import { getPageDetail } from "@/api/system"; import { getPageDetail } from "@/api/system";
import { getWallpaperRecommendList } from "@/api/wallpaper"; import { getWallpaperSameList } from "@/api/wallpaper";
import { import {
getShareToken, getShareToken,
saveViewRequest, saveViewRequest,
@@ -145,7 +145,7 @@ onLoad(async (options) => {
if (options.imageUrl) { if (options.imageUrl) {
detailData.value.imageUrl = decodeURIComponent(options.imageUrl); detailData.value.imageUrl = decodeURIComponent(options.imageUrl);
} }
fetchRecommend(); fetchRecommend(options.id);
}); });
onShareAppMessage(async () => { onShareAppMessage(async () => {
@@ -180,6 +180,7 @@ const fetchDetail = async () => {
saveViewRequest(shareToken.value, "wallpaper_detail", res.id); saveViewRequest(shareToken.value, "wallpaper_detail", res.id);
if (res) { if (res) {
detailData.value = res; detailData.value = res;
fetchRecommend(res.id);
} }
} catch (e) { } catch (e) {
console.error("Failed to fetch detail", e); console.error("Failed to fetch detail", e);
@@ -190,9 +191,10 @@ const fetchDetail = async () => {
} }
}; };
const fetchRecommend = async () => { const fetchRecommend = async (id) => {
if (!id && !detailData.value.id) return;
try { try {
const res = await getWallpaperRecommendList(); const res = await getWallpaperSameList(id || detailData.value.id);
recommendList.value = res; recommendList.value = res;
} catch (e) { } catch (e) {
console.error("Failed to fetch recommendations", e); console.error("Failed to fetch recommendations", e);
@@ -230,8 +232,21 @@ const previewImage = () => {
} }
}; };
const onRecommendClick = () => { const onRecommendClick = (item) => {
goToIndex(); // Update detailData with new item info
detailData.value = {
...detailData.value,
id: item.id,
imageUrl: item.imageUrl,
title: item.title,
};
// Refresh recommendations for the new item
fetchRecommend(item.id);
// Scroll to top or just update view
uni.pageScrollTo({
scrollTop: 0,
duration: 300,
});
}; };
const goToGreeting = () => { const goToGreeting = () => {