fix: index luck
This commit is contained in:
@@ -13,3 +13,10 @@ export const userSignIn = async () => {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getUserLuckInfo = async () => {
|
||||||
|
return request({
|
||||||
|
url: "/api/blessing/user/luck-info",
|
||||||
|
method: "GET",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -150,11 +150,10 @@ const resultData = ref({
|
|||||||
|
|
||||||
const texts = ["好运加载中...", "今日能量汇集中 ✨", "正在计算你的幸运指数..."];
|
const texts = ["好运加载中...", "今日能量汇集中 ✨", "正在计算你的幸运指数..."];
|
||||||
|
|
||||||
const open = () => {
|
const open = (data = null, skipAnimation = false) => {
|
||||||
isAnimating.value = true;
|
if (data) {
|
||||||
isFlipping.value = false;
|
resultData.value = { ...resultData.value, ...data };
|
||||||
showLight.value = false;
|
}
|
||||||
loadingText.value = texts[0];
|
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const y = now.getFullYear();
|
const y = now.getFullYear();
|
||||||
@@ -165,7 +164,17 @@ const open = () => {
|
|||||||
|
|
||||||
popup.value.open();
|
popup.value.open();
|
||||||
|
|
||||||
|
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();
|
startAnimation();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const close = () => {
|
const close = () => {
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ import {
|
|||||||
getRandomRecommendList,
|
getRandomRecommendList,
|
||||||
getCardSpecialTopic,
|
getCardSpecialTopic,
|
||||||
} from "@/api/system";
|
} from "@/api/system";
|
||||||
import { getUserSignInfo, userSignIn } from "@/api/user";
|
import { getUserSignInfo, userSignIn, getUserLuckInfo } from "@/api/user";
|
||||||
import calendar from "@/utils/lunar";
|
import calendar from "@/utils/lunar";
|
||||||
|
|
||||||
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
|
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
|
||||||
@@ -479,10 +479,20 @@ const onOpenLucky = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (signInfo.value.isSignedToday) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uni.showLoading({ title: "开启好运...", mask: true });
|
||||||
try {
|
try {
|
||||||
const res = await userSignIn();
|
const res = await userSignIn();
|
||||||
if (res && res.success) {
|
if (res && res.success) {
|
||||||
@@ -493,7 +503,11 @@ const onOpenLucky = async () => {
|
|||||||
}
|
}
|
||||||
fetchUserSingInfo();
|
fetchUserSingInfo();
|
||||||
userStore.fetchUserAssets();
|
userStore.fetchUserAssets();
|
||||||
luckyPopupRef.value?.open();
|
|
||||||
|
// 获取好运信息
|
||||||
|
const luckRes = await getUserLuckInfo();
|
||||||
|
luckyPopupRef.value?.open(luckRes, false);
|
||||||
|
|
||||||
uni.showToast({ title: "获取40积分", icon: "none" });
|
uni.showToast({ title: "获取40积分", icon: "none" });
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: "签到失败", icon: "none" });
|
uni.showToast({ title: "签到失败", icon: "none" });
|
||||||
|
|||||||
Reference in New Issue
Block a user