完成逻辑

This commit is contained in:
Andy Leong
2024-02-06 22:25:55 +08:00
parent 98d301a749
commit 2ae9dc33f4
10 changed files with 17 additions and 30 deletions

View File

@@ -46,6 +46,11 @@ const answerFn = (item, event) => {
userStore.updatePosterId(getRandomNumber([1, 2, 3]))
gsap.set('.question-box', { pointerEvents: 'none' })
Toast('答题结束')
Toast.loading({
message: '结果生成中',
duration: 0,
forbidClick: true,
})
if (import.meta.env.VITE_MODE != "dev") {
// 提交完成记录
@@ -55,14 +60,18 @@ const answerFn = (item, event) => {
userStore.updateDrawKey(res.data);
}
gsap.to('.QuestionPage', {
duration: 0.5, autoAlpha: 0, onComplete: () => {
emit("QuestionPage", { action: "showResult" });
}
})
setTimeout(() => {
Toast.clear()
gsap.to('.QuestionPage', {
duration: 0.5, autoAlpha: 0, onComplete: () => {
emit("QuestionPage", { action: "showResult" });
}
})
}, 1000)
});
} else {
setTimeout(() => {
Toast.clear()
gsap.to('.QuestionPage', {
duration: 0.5, autoAlpha: 0, onComplete: () => {
emit("QuestionPage", { action: "showResult" });
@@ -72,32 +81,11 @@ const answerFn = (item, event) => {
}
}
console.log("答案库", answerList.value);
});
};
const showResult = () => {
gsap.set(".answer-box", { pointerEvents: "none" })
gsap.to(".prev-btn", { duration: 0.5, x: "-=20px", autoAlpha: 0 });
questionOut.timeScale(2);
questionOut.restart();
questionOut.eventCallback("onComplete", () => {
gsap.to(".QuestionPage", {
duration: 0.5,
autoAlpha: 0,
onComplete: () => {
emit("QuestionPage", { action: "showResult" });
},
});
});
};
// 从数组中随机生成一个数字
const getRandomNumber = (arr) => {
var randomIndex = Math.floor(Math.random() * arr.length);
@@ -107,9 +95,9 @@ const getRandomNumber = (arr) => {
// 查看结果事件及动画
// const resultBtnAni = gsap.timeline({ paused: true });
onMounted(() => {
gsap.from('.question-bg',{duration:0.5,autoAlpha:0,})
gsap.from('.question-box',{duration:0.5,scale:0.4,autoAlpha:0,})
gsap.to('.question-lantern-icon',{duration:5,transformOrigin:'100% 0%',rotation:'10deg',repeat:-1,yoyo:true,ease:'none'})
gsap.from('.question-bg', { duration: 0.5, autoAlpha: 0, })
gsap.from('.question-box', { duration: 0.5, scale: 0.4, autoAlpha: 0, })
gsap.to('.question-lantern-icon', { duration: 5, transformOrigin: '100% 0%', rotation: '10deg', repeat: -1, yoyo: true, ease: 'none' })
});
@@ -246,7 +234,6 @@ onMounted(() => {
width: 100%;
font-family: 'DouyinSansBold';
font-size: 35px;
font-family: "DOUYINSANSBOLD";
color: rgb(255, 255, 255);
text-align: center;
padding: 10px;