完成海报页面逻辑,及流程整合
This commit is contained in:
@@ -42,32 +42,46 @@ const answerFn = (item, event) => {
|
||||
activeId.value = ''
|
||||
|
||||
} else {
|
||||
// 随机生成海报id
|
||||
userStore.updatePosterId(getRandomNumber([1, 2, 3]))
|
||||
gsap.set('.question-box', { pointerEvents: 'none' })
|
||||
Toast('答题结束')
|
||||
gsap.set('.question-box',{pointerEvents:'none'})
|
||||
}
|
||||
|
||||
if (import.meta.env.VITE_MODE != "dev") {
|
||||
// 提交完成记录
|
||||
subAnswer({}, userStore.token).then((res) => {
|
||||
console.log("key:", res);
|
||||
if (res.code == 0) {
|
||||
userStore.updateDrawKey(res.data);
|
||||
}
|
||||
|
||||
gsap.to('.QuestionPage', {
|
||||
duration: 0.5, autoAlpha: 0, onComplete: () => {
|
||||
emit("QuestionPage", { action: "showResult" });
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
gsap.to('.QuestionPage', {
|
||||
duration: 0.5, autoAlpha: 0, onComplete: () => {
|
||||
emit("QuestionPage", { action: "showResult" });
|
||||
}
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log("答案库", answerList.value);
|
||||
});
|
||||
};
|
||||
|
||||
const mbtiArr = [[], [], [], []]; //四组数组分别存放 E&I,S&T,T&F,J&P四组结果
|
||||
|
||||
|
||||
const showResult = () => {
|
||||
|
||||
gsap.set(".answer-box", { pointerEvents: "none" });
|
||||
|
||||
|
||||
|
||||
if (import.meta.env.VITE_MODE != "dev") {
|
||||
// 提交完成记录
|
||||
subAnswer({}, userStore.token).then((res) => {
|
||||
console.log("key:", res);
|
||||
if (res.code == 0) {
|
||||
userStore.updateDrawKey(res.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
gsap.set(".answer-box", { pointerEvents: "none" })
|
||||
// Toast("你的MBTI测试结果:" + mbti);
|
||||
// resultBtnAni.reverse();
|
||||
gsap.to(".prev-btn", { duration: 0.5, x: "-=20px", autoAlpha: 0 });
|
||||
@@ -85,7 +99,11 @@ const showResult = () => {
|
||||
|
||||
};
|
||||
|
||||
|
||||
// 从数组中随机生成一个数字
|
||||
const getRandomNumber = (arr) => {
|
||||
var randomIndex = Math.floor(Math.random() * arr.length);
|
||||
return arr[randomIndex];
|
||||
}
|
||||
|
||||
// 查看结果事件及动画
|
||||
// const resultBtnAni = gsap.timeline({ paused: true });
|
||||
|
||||
Reference in New Issue
Block a user