diff --git a/api/wallpaper.js b/api/wallpaper.js index 2f4ac74..8186bb1 100644 --- a/api/wallpaper.js +++ b/api/wallpaper.js @@ -20,3 +20,10 @@ export const getWallpaperRecommendList = async () => { method: "get", }); }; + +export const getWallpaperSameList = async (id) => { + return request({ + url: `/api/blessing/wallpaper/same/list?id=${id}`, + method: "get", + }); +}; diff --git a/pages/index/index.vue b/pages/index/index.vue index ac6d801..9057ac2 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -398,7 +398,7 @@ const navToWallpaper = (item) => { item.resourceInfo?.url || item.imageUrl || "", ); uni.navigateTo({ - url: `/pages/wallpaper/detail?id=${item.id}&imageUrl=${imageUrl}`, + url: `/pages/wallpaper/detail?id=${item.targetId}&imageUrl=${imageUrl}`, }); }; diff --git a/pages/wallpaper/detail.vue b/pages/wallpaper/detail.vue index 934bf0b..bff869b 100644 --- a/pages/wallpaper/detail.vue +++ b/pages/wallpaper/detail.vue @@ -106,7 +106,7 @@ import { ref, computed } from "vue"; import { onLoad, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app"; import { getBavBarHeight } from "@/utils/system"; import { getPageDetail } from "@/api/system"; -import { getWallpaperRecommendList } from "@/api/wallpaper"; +import { getWallpaperSameList } from "@/api/wallpaper"; import { getShareToken, saveViewRequest, @@ -145,7 +145,7 @@ onLoad(async (options) => { if (options.imageUrl) { detailData.value.imageUrl = decodeURIComponent(options.imageUrl); } - fetchRecommend(); + fetchRecommend(options.id); }); onShareAppMessage(async () => { @@ -180,6 +180,7 @@ const fetchDetail = async () => { saveViewRequest(shareToken.value, "wallpaper_detail", res.id); if (res) { detailData.value = res; + fetchRecommend(res.id); } } catch (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 { - const res = await getWallpaperRecommendList(); + const res = await getWallpaperSameList(id || detailData.value.id); recommendList.value = res; } catch (e) { console.error("Failed to fetch recommendations", e); @@ -230,8 +232,21 @@ const previewImage = () => { } }; -const onRecommendClick = () => { - goToIndex(); +const onRecommendClick = (item) => { + // 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 = () => {