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

@@ -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 = () => {