fix: scene list

This commit is contained in:
zzc
2026-03-13 03:12:52 +08:00
parent 1865b1cfcd
commit 952acbbf1f
3 changed files with 61 additions and 61 deletions

View File

@@ -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",

View File

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

View File

@@ -540,8 +540,15 @@
@tap="selectScene(scene)"
>
<view class="scene-icon-box" :style="{ background: scene.bgColor }">
<image
v-if="scene.icon && scene.icon.includes('/')"
:src="scene.icon"
mode="aspectFit"
style="width: 52rpx; height: 52rpx"
/>
<uni-icons
:type="scene.icon"
v-else
:type="scene.icon || 'star-filled'"
size="26"
:color="scene.color"
></uni-icons>
@@ -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();