fix: recommend list
This commit is contained in:
@@ -284,10 +284,36 @@ const initSystemAvatars = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
onLoad(() => {
|
||||
onLoad((options) => {
|
||||
initSystemAvatars();
|
||||
loadFrames();
|
||||
loadDecors();
|
||||
|
||||
// 处理推荐跳转参数
|
||||
if (options && options.recommendId && options.type && options.imageUrl) {
|
||||
const recommendItem = {
|
||||
id: options.recommendId,
|
||||
imageUrl: decodeURIComponent(options.imageUrl),
|
||||
};
|
||||
|
||||
if (options.type === "frame") {
|
||||
activeTab.value = "frame";
|
||||
selectedFrame.value = recommendItem;
|
||||
// 如果 frames 列表中有这个 id,更新引用以保持选中状态(可选,但推荐)
|
||||
const found = frames.value.find((f) => f.id === recommendItem.id);
|
||||
if (found) selectedFrame.value = found;
|
||||
} else if (options.type === "decor") {
|
||||
activeTab.value = "decor";
|
||||
selectedDecor.value = recommendItem;
|
||||
const found = decors.value.find((d) => d.id === recommendItem.id);
|
||||
if (found) selectedDecor.value = found;
|
||||
} else if (options.type === "avatar") {
|
||||
currentAvatar.value = recommendItem;
|
||||
// 检查系统头像列表
|
||||
const found = systemAvatars.value.find((a) => a.id === recommendItem.id);
|
||||
if (found) currentAvatar.value = found;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
onReachBottom(() => {
|
||||
@@ -653,11 +679,11 @@ onShareAppMessage(async () => {
|
||||
};
|
||||
}
|
||||
const id = createAvatarId();
|
||||
const shareTokenRes = {
|
||||
shareToken: "iFmK8WjRm6TK",
|
||||
};
|
||||
// const shareTokenRes = await getShareToken("avatar_download", id);
|
||||
// completeCardInfo(id);
|
||||
// const shareTokenRes = {
|
||||
// shareToken: "iFmK8WjRm6TK",
|
||||
// };
|
||||
const shareTokenRes = await getShareToken("avatar_download", id);
|
||||
completeCardInfo(id);
|
||||
return {
|
||||
title: "制作我的新春头像",
|
||||
path: `/pages/avatar/detail?shareToken=${shareTokenRes.shareToken}`,
|
||||
|
||||
@@ -286,17 +286,35 @@ const getCtaText = (type) => {
|
||||
};
|
||||
|
||||
const onCardClick = (card) => {
|
||||
if (card.scene === "avatar_download") {
|
||||
uni.navigateTo({ url: "/pages/avatar/index" });
|
||||
// 构造传递的数据
|
||||
const query = `recommendId=${card.recommendId || ""}&type=${card.type || ""}&imageUrl=${encodeURIComponent(card.imageUrl || "")}`;
|
||||
|
||||
if (
|
||||
card.scene === "avatar_download" ||
|
||||
["frame", "decor", "avatar"].includes(card.type)
|
||||
) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/avatar/index?${query}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Default fallback based on type
|
||||
if (card.type === "card") {
|
||||
// 贺卡制作通常是 Tab 页,通过 Storage 传递参数
|
||||
uni.setStorageSync("RECOMMEND_CARD_DATA", {
|
||||
recommendId: card.recommendId,
|
||||
imageUrl: card.imageUrl,
|
||||
type: card.type,
|
||||
});
|
||||
uni.switchTab({ url: "/pages/make/index" });
|
||||
} else if (card.type === "fortune") {
|
||||
uni.navigateTo({ url: "/pages/fortune/index" });
|
||||
} else {
|
||||
uni.navigateTo({ url: "/pages/avatar/index" });
|
||||
// 默认跳转到头像页
|
||||
uni.navigateTo({
|
||||
url: `/pages/avatar/index?${query}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -403,10 +403,33 @@ onLoad((options) => {
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
const recommendData = uni.getStorageSync("RECOMMEND_CARD_DATA");
|
||||
if (recommendData) {
|
||||
uni.removeStorageSync("RECOMMEND_CARD_DATA");
|
||||
if (recommendData.imageUrl) {
|
||||
const tpl = {
|
||||
id: recommendData.recommendId,
|
||||
imageUrl: recommendData.imageUrl,
|
||||
name: "推荐模板", // 暂时使用通用名称,如果需要可以从接口获取更多信息
|
||||
};
|
||||
|
||||
// 切换到模板 Tab
|
||||
activeTool.value = "template";
|
||||
|
||||
// 应用模板
|
||||
currentTemplate.value = tpl;
|
||||
|
||||
// 如果模板列表中存在,更新引用
|
||||
const found = templates.value.find((t) => t.id === tpl.id);
|
||||
if (found) currentTemplate.value = found;
|
||||
}
|
||||
}
|
||||
|
||||
const tempBlessing = uni.getStorageSync("TEMP_BLESSING_TEXT");
|
||||
if (tempBlessing) {
|
||||
blessingText.value = { content: tempBlessing, id: "" };
|
||||
uni.removeStorageSync("TEMP_BLESSING_TEXT");
|
||||
activeTool.value = "text";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user