fix: index luck

This commit is contained in:
zzc
2026-02-28 15:21:32 +08:00
parent 3964d33e31
commit fd5bc9d12c
3 changed files with 39 additions and 9 deletions

View File

@@ -13,3 +13,10 @@ export const userSignIn = async () => {
method: "POST",
});
};
export const getUserLuckInfo = async () => {
return request({
url: "/api/blessing/user/luck-info",
method: "GET",
});
};

View File

@@ -150,11 +150,10 @@ const resultData = ref({
const texts = ["好运加载中...", "今日能量汇集中 ✨", "正在计算你的幸运指数..."];
const open = () => {
isAnimating.value = true;
isFlipping.value = false;
showLight.value = false;
loadingText.value = texts[0];
const open = (data = null, skipAnimation = false) => {
if (data) {
resultData.value = { ...resultData.value, ...data };
}
const now = new Date();
const y = now.getFullYear();
@@ -165,7 +164,17 @@ const open = () => {
popup.value.open();
startAnimation();
if (skipAnimation) {
isAnimating.value = false;
isFlipping.value = true; // Ensure flipped state if needed for consistency, though v-else handles view
showLight.value = false;
} else {
isAnimating.value = true;
isFlipping.value = false;
showLight.value = false;
loadingText.value = texts[0];
startAnimation();
}
};
const close = () => {

View File

@@ -257,7 +257,7 @@ import {
getRandomRecommendList,
getCardSpecialTopic,
} from "@/api/system";
import { getUserSignInfo, userSignIn } from "@/api/user";
import { getUserSignInfo, userSignIn, getUserLuckInfo } from "@/api/user";
import calendar from "@/utils/lunar";
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
@@ -479,10 +479,20 @@ const onOpenLucky = async () => {
}
if (signInfo.value.isSignedToday) {
luckyPopupRef.value?.open();
uni.showLoading({ title: "加载中..." });
try {
const luckRes = await getUserLuckInfo();
luckyPopupRef.value?.open(luckRes, true);
} catch (e) {
console.error(e);
uni.showToast({ title: "获取好运信息失败", icon: "none" });
} finally {
uni.hideLoading();
}
return;
}
uni.showLoading({ title: "开启好运...", mask: true });
try {
const res = await userSignIn();
if (res && res.success) {
@@ -493,7 +503,11 @@ const onOpenLucky = async () => {
}
fetchUserSingInfo();
userStore.fetchUserAssets();
luckyPopupRef.value?.open();
// 获取好运信息
const luckRes = await getUserLuckInfo();
luckyPopupRef.value?.open(luckRes, false);
uni.showToast({ title: "获取40积分", icon: "none" });
} else {
uni.showToast({ title: "签到失败", icon: "none" });