From 952acbbf1f1c89de24fdf8325179aac892b69fcb Mon Sep 17 00:00:00 2001 From: zzc <1761997216@qq.com> Date: Fri, 13 Mar 2026 03:12:52 +0800 Subject: [PATCH] fix: scene list --- pages/fortune/index.vue | 2 +- pages/index/index.vue | 37 ++++++++++-------- pages/make/index.vue | 83 +++++++++++++++++++---------------------- 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/pages/fortune/index.vue b/pages/fortune/index.vue index a5a5ac3..3064789 100644 --- a/pages/fortune/index.vue +++ b/pages/fortune/index.vue @@ -185,7 +185,7 @@ onShareAppMessage(async () => { const shareToken = await getShareToken("fortune_draw", cardId.value); getRewardByShare(); return { - title: "马年运势我已经抽过了,你的会是什么?", + title: "今日运势我已经抽过了,你的会是什么?", path: `${cardId.value ? `/pages/fortune/detail?shareToken=${shareToken}` : `/pages/fortune/index?shareToken=${shareToken}`}`, imageUrl: "https://file.lihailezzc.com/resource/8dd026d76ef7a63d123b7fd698fb989b.png", diff --git a/pages/index/index.vue b/pages/index/index.vue index c07ed08..b27648d 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -302,6 +302,7 @@ import { getCardSpecialTopic, getShareReward, } from "@/api/system"; +import { getGreetingSceneList } from "@/api/card"; import { getUserSignInfo, userSignIn, getUserLuckInfo } from "@/api/user"; import calendar from "@/utils/lunar"; import { getShareToken, saveViewRequest } from "@/utils/common.js"; @@ -410,22 +411,7 @@ const lunarDate = computed(() => { }; }); -const sceneList = ref([ - { id: 3, name: "每日问候", icon: "/static/icon/yunshi.png", scene: "daily" }, - { - id: 2, - name: "生日纪念", - icon: "/static/icon/guashi.png", - scene: "birthday", - }, - { id: 4, name: "情感表达", icon: "/static/icon/hongbao.png", scene: "love" }, - { - id: 1, - name: "节日祝福", - icon: "/static/icon/celebrate.png", - scene: "holiday", - }, -]); +const sceneList = ref([]); const wallpaperList = ref([]); const avatarList = ref([]); @@ -437,18 +423,21 @@ onLoad((options) => { fetchUserSingInfo(); // 获取用户签到信息 fetchHomeData(); fetchSpecialTopic(); + fetchSceneList(); }); onShow(() => { fetchHomeData(); fetchUserSingInfo(); fetchSpecialTopic(); + fetchSceneList(); }); onPullDownRefresh(() => { fetchHomeData(); fetchUserSingInfo(); fetchSpecialTopic(); + fetchSceneList(); }); const specialTopic = ref(null); @@ -466,6 +455,22 @@ const fetchSpecialTopic = async () => { } }; +const fetchSceneList = async () => { + try { + const res = await getGreetingSceneList(); + if (res && Array.isArray(res)) { + sceneList.value = res.map((item) => ({ + id: item.id, + name: item.sceneName, + icon: item.imageUrl, + scene: item.scene, + })); + } + } catch (e) { + console.error("fetchSceneList error", e); + } +}; + const navToSpecial = () => { if (specialTopic.value && specialTopic.value.scene) { uni.navigateTo({ diff --git a/pages/make/index.vue b/pages/make/index.vue index e3fc80c..7096df2 100644 --- a/pages/make/index.vue +++ b/pages/make/index.vue @@ -540,8 +540,15 @@ @tap="selectScene(scene)" > + @@ -568,6 +575,7 @@ import { getCardTemplateTitleList, getCardMusicList, } from "@/api/make"; +import { getGreetingSceneList } from "@/api/card"; import { getShareReward, msgCheckApi, watchAdReward } from "@/api/system"; import { checkAbilityAndHandle, getUnlockLabel } from "@/utils/ability.js"; import { @@ -974,6 +982,7 @@ onLoad((options) => { if (options.author) { signatureName.value = decodeURIComponent(options.author); } + fetchSceneList(); }); const loadData = () => { @@ -985,51 +994,37 @@ const loadData = () => { const currentScene = ref(""); const scenePopup = ref(null); -const scenes = [ - { - name: "节日祝福", - value: "holiday", - icon: "notification-filled", - color: "#FF3B30", - bgColor: "#FFF5F5", - }, - { - name: "生日纪念", - value: "birthday", - icon: "calendar-filled", - color: "#FF9500", - bgColor: "#FFF8E5", - }, - { - name: "每日问候", - value: "daily", - icon: "star-filled", - color: "#FFCC00", - bgColor: "#FFFBE6", - }, - { - name: "情绪表达", - value: "emotion", - icon: "heart-filled", - color: "#FF2D55", - bgColor: "#FFF0F5", - }, - { - name: "人际关系", - value: "relationship", - icon: "gift-filled", - color: "#FF5E3A", - bgColor: "#FFF2F0", - }, - { - name: "职场祝福", - value: "workplace", - icon: "shop-filled", - color: "#8B572A", - bgColor: "#F9F0E6", - }, +const scenes = ref([]); + +const SCENE_PALETTE = [ + { color: "#FF3B30", bgColor: "#FFF5F5" }, + { color: "#FF9500", bgColor: "#FFF8E5" }, + { color: "#FFCC00", bgColor: "#FFFBE6" }, + { color: "#FF2D55", bgColor: "#FFF0F5" }, + { color: "#FF5E3A", bgColor: "#FFF2F0" }, + { color: "#8B572A", bgColor: "#F9F0E6" }, ]; +const fetchSceneList = async () => { + try { + const res = await getGreetingSceneList("daily"); + if (res && Array.isArray(res)) { + scenes.value = res.map((item, index) => { + const style = SCENE_PALETTE[index % SCENE_PALETTE.length]; + return { + name: item.sceneName, + value: item.scene, + icon: item.imageUrl, + color: style.color, + bgColor: style.bgColor, + }; + }); + } + } catch (e) { + console.error("fetchSceneList error", e); + } +}; + const selectScene = (scene) => { currentScene.value = scene.value; scenePopup.value.close();