This commit is contained in:
Andy Leong
2024-01-20 02:35:49 +08:00
parent fc0d5fce8c
commit 28dc4ec60d
11 changed files with 709 additions and 479 deletions

View File

@@ -4,7 +4,7 @@ import { Toast } from "vant";
import { data } from "@/data";
import { debounceTap, FYShuffle, mostValue, judgeBigScreen } from "@/plugins";
import { useMainStore } from "@/store";
import { subAnswer } from '@/api'
import { subAnswer } from "@/api";
// 页面配置初始化
const emit = defineEmits(["QuestionPage"]);
@@ -99,16 +99,14 @@ const showResult = (event) => {
console.log("MBTI:", mbti);
userStore.updateMBTI(mbti);
// 提交完成记录
subAnswer({}, userStore.token).then(
res => {
console.log('key:', res);
if (import.meta.env.VITE_MODE != "dev") {
// 提交完成记录
subAnswer({}, userStore.token).then((res) => {
console.log("key:", res);
if (res.code == 0) {
}
}
)
});
}
// Toast("你的MBTI测试结果:" + mbti);
resultBtnAni.reverse();
@@ -148,11 +146,9 @@ const questionEntry = gsap.timeline({
paused: true,
onStart: () => {
gsap.set(".answer-box", { pointerEvents: "none" });
},
onComplete: () => {
gsap.set(".answer-box", { pointerEvents: "none" });
},
});
const questionOut = gsap.timeline({
@@ -160,20 +156,17 @@ const questionOut = gsap.timeline({
onStart: () => {
gsap.set(".answer-box", { pointerEvents: "none" });
},
onComplete: () => {
},
onComplete: () => {},
});
// 查看结果事件及动画
const resultBtnAni = gsap.timeline({ paused: true });
onMounted(() => {
// 适配
if (!judgeBigScreen()) {
gsap.set('.answer-box', { scale: 0.9, marginTop: '-20px' })
gsap.set(".answer-box", { scale: 0.9, marginTop: "-20px" });
}
resultBtnAni.from(".showResult-btn", { y: 200, autoAlpha: 0 });
questionEntry
.from(".question", { y: 100, autoAlpha: 0 })
@@ -193,22 +186,23 @@ onMounted(() => {
duration: 2,
ease: "slow(0.7,0.7,false)",
onStart: () => {
gsap.to('.question-bg', {
backgroundPosition: '0px 0px',
gsap.to(".question-bg", {
backgroundPosition: "0px 0px",
duration: 1,
ease: "slow(0.7,0.7,false)",
})
});
},
onComplete: () => {
gsap.set(".answer-box", { pointerEvents: "initial" });
if (currentId.value != 0) {
gsap.to(".prev-btn", { duration: 0.5, x: "+=20px", autoAlpha: 1 });
}
}
},
},
0.5
).to('.answer-0', { duration: 1, y: '-=10px', repeat: -1, yoyo: true })
.to('.answer-1', { duration: 1, y: '+=10px', repeat: -1, yoyo: true })
)
.to(".answer-0", { duration: 1, y: "-=10px", repeat: -1, yoyo: true })
.to(".answer-1", { duration: 1, y: "+=10px", repeat: -1, yoyo: true });
questionEntry.play();
questionOut
@@ -222,11 +216,11 @@ onMounted(() => {
duration: 1.5,
ease: "slow(0.7,0.7,false)",
onStart: () => {
gsap.to('.question-bg', {
backgroundPosition: '0px 835px',
gsap.to(".question-bg", {
backgroundPosition: "0px 835px",
duration: 0.75,
ease: "slow(0.7,0.7,false)",
})
});
},
})
.to(
@@ -239,7 +233,7 @@ onMounted(() => {
ease: "slow(0.7,0.7,false)",
},
1.5
)
);
});
</script>
@@ -255,9 +249,16 @@ onMounted(() => {
</div>
</div>
<div class="answer-box">
<div class="answer" v-for="(item, index) in questionList[currentId].answer" :class="'answer-' + index"
:key="index">
<div class="answer-bg" :class="activeId == item.aid ? 'active' : ''"></div>
<div
class="answer"
v-for="(item, index) in questionList[currentId].answer"
:class="'answer-' + index"
:key="index"
>
<div
class="answer-bg"
:class="activeId == item.aid ? 'active' : ''"
></div>
<div class="answer-text">
<div class="content-before"></div>
<div class="content-after"></div>