|
|
@@ -0,0 +1,395 @@
|
|
|
+<template>
|
|
|
+ <div class="exam-paper-2">
|
|
|
+ <img
|
|
|
+ class="title"
|
|
|
+ src="@/assets/images/exam-paper-title-2.png"
|
|
|
+ alt=""
|
|
|
+ draggable="false"
|
|
|
+ >
|
|
|
+ <!-- 左上角按钮 -->
|
|
|
+ <div class="btn-group">
|
|
|
+ <button
|
|
|
+ class="return-home"
|
|
|
+ @click="onClickReturnHome"
|
|
|
+ />
|
|
|
+ <button class="game-rule" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="question-inner">
|
|
|
+ <p class="question">
|
|
|
+ {{ questionList[currentQuestionIdx].question }}
|
|
|
+ </p>
|
|
|
+ <button
|
|
|
+ v-for="(option, index) in questionList[currentQuestionIdx].answerOptions"
|
|
|
+ :key="index"
|
|
|
+ :disabled="isSubmitted"
|
|
|
+ class="option"
|
|
|
+ :class="{
|
|
|
+ selected: selectedIdx === index,
|
|
|
+ rightOption: questionList[currentQuestionIdx].rightOptionIdx === index,
|
|
|
+ wrongOption: questionList[currentQuestionIdx].rightOptionIdx !== index,
|
|
|
+ submitted: isSubmitted,
|
|
|
+ notSubmitted: !isSubmitted,
|
|
|
+ }"
|
|
|
+ @click="onClickOption(index)"
|
|
|
+ >
|
|
|
+ <div class="option-text">
|
|
|
+ {{ option }}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-show="isSubmitted && selectedIdx === index && questionList[currentQuestionIdx].rightOptionIdx === index"
|
|
|
+ class="result-tip"
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ class="correct-icon"
|
|
|
+ src="@/assets/images/exam-paper-icon-correct.png"
|
|
|
+ alt=""
|
|
|
+ draggable="false"
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-show="isSubmitted && selectedIdx === index && questionList[currentQuestionIdx].rightOptionIdx !== index"
|
|
|
+ class="result-tip"
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ class="wrong-icon"
|
|
|
+ src="@/assets/images/exam-paper-icon-wrong.png"
|
|
|
+ alt=""
|
|
|
+ draggable="false"
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </button>
|
|
|
+ <div
|
|
|
+ v-show="isSubmitted && questionList[currentQuestionIdx].desc"
|
|
|
+ class="answer-desc"
|
|
|
+ >
|
|
|
+ 答案解析:{{ questionList[currentQuestionIdx].desc }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 底部信息栏 -->
|
|
|
+ <div
|
|
|
+ class="common-info-group"
|
|
|
+ >
|
|
|
+ <div class="info-item bonus-point">
|
|
|
+ <img
|
|
|
+ class="icon"
|
|
|
+ src="@/assets/images/icon_bonus_point.png"
|
|
|
+ alt=""
|
|
|
+ draggable="false"
|
|
|
+ >
|
|
|
+ <span class="number">{{ bonusPoint }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="info-item time-count">
|
|
|
+ <img
|
|
|
+ class="icon"
|
|
|
+ src="@/assets/images/icon_time_count.png"
|
|
|
+ alt=""
|
|
|
+ draggable="false"
|
|
|
+ >
|
|
|
+ <span class="number">{{ timeCountForShow }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <button
|
|
|
+ class="next"
|
|
|
+ @click="onClickNext"
|
|
|
+ >
|
|
|
+ 下一题
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import useSizeAdapt from "@/useFunctions/useSizeAdapt"
|
|
|
+import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from "vue"
|
|
|
+import { useRoute, useRouter } from "vue-router"
|
|
|
+import { useStore } from "vuex"
|
|
|
+import dayjs from 'dayjs'
|
|
|
+import { shuffle } from 'lodash'
|
|
|
+
|
|
|
+const route = useRoute()
|
|
|
+const router = useRouter()
|
|
|
+const store = useStore()
|
|
|
+
|
|
|
+const {
|
|
|
+ windowSizeInCssForRef,
|
|
|
+ windowSizeWhenDesignForRef,
|
|
|
+} = useSizeAdapt(390, 752)
|
|
|
+
|
|
|
+function onClickReturnHome() {
|
|
|
+ router.push({
|
|
|
+ name: 'HomeView',
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 倒计时
|
|
|
+ */
|
|
|
+const timeCount = ref(120)
|
|
|
+let timeCountIntervalId = null
|
|
|
+timeCountIntervalId = setInterval(() => {
|
|
|
+ timeCount.value--
|
|
|
+ if (timeCount.value === 0) {
|
|
|
+ clearInterval(timeCountIntervalId)
|
|
|
+ router.replace({
|
|
|
+ name: 'ExamPaper3',
|
|
|
+ query: {
|
|
|
+ correntCount: correntCount.value,
|
|
|
+ bonusPoint: bonusPoint.value,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}, 1000)
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ clearInterval(timeCountIntervalId)
|
|
|
+})
|
|
|
+const timeCountForShow = computed(() => {
|
|
|
+ return dayjs(timeCount.value * 1000).format('m:ss')
|
|
|
+})
|
|
|
+
|
|
|
+// 积分
|
|
|
+const bonusPoint = ref(0)
|
|
|
+// 答对计数
|
|
|
+const correntCount = ref(0)
|
|
|
+
|
|
|
+/**
|
|
|
+ * 游戏具体逻辑
|
|
|
+ */
|
|
|
+const selectedIdx = ref(null)
|
|
|
+const questionList = ref([
|
|
|
+ {
|
|
|
+ question: '你是sb吗?',
|
|
|
+ answerOptions: [
|
|
|
+ '是',
|
|
|
+ '不是',
|
|
|
+ ],
|
|
|
+ rightOptionIdx: 0,
|
|
|
+ desc: '这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ question: '你是sb吗?',
|
|
|
+ answerOptions: [
|
|
|
+ '是',
|
|
|
+ '不是',
|
|
|
+ ],
|
|
|
+ rightOptionIdx: 0,
|
|
|
+ desc: '这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ question: '你是sb吗?',
|
|
|
+ answerOptions: [
|
|
|
+ '是',
|
|
|
+ '不是',
|
|
|
+ ],
|
|
|
+ rightOptionIdx: 0,
|
|
|
+ desc: '这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本这是一段文本',
|
|
|
+ },
|
|
|
+])
|
|
|
+const currentQuestionIdx = ref(0)
|
|
|
+const isSubmitted = computed(() => {
|
|
|
+ return selectedIdx.value !== null
|
|
|
+})
|
|
|
+const isCorrect = computed(() => {
|
|
|
+ return true
|
|
|
+})
|
|
|
+function onClickOption(idx) {
|
|
|
+ this.selectedIdx = idx
|
|
|
+ if (this.selectedIdx === questionList.value[currentQuestionIdx.value].rightOptionIdx) {
|
|
|
+ bonusPoint.value += 10
|
|
|
+ correntCount.value++
|
|
|
+ }
|
|
|
+}
|
|
|
+function onClickNext() {
|
|
|
+ if (currentQuestionIdx.value < questionList.value.length - 1) {
|
|
|
+ currentQuestionIdx.value++
|
|
|
+ selectedIdx.value = null
|
|
|
+ } else {
|
|
|
+ router.replace({
|
|
|
+ name: 'ExamPaper3',
|
|
|
+ query: {
|
|
|
+ correntCount: correntCount.value,
|
|
|
+ bonusPoint: bonusPoint.value,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.exam-paper-2{
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-image: url(@/assets/images/exam-paper-bg-2.jpg);
|
|
|
+ background-size: cover;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-position: center bottom;
|
|
|
+ >img.title{
|
|
|
+ position: absolute;
|
|
|
+ left: 50%;
|
|
|
+ top: calc(33 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ transform: translate(-50%, 0);
|
|
|
+ width: calc(213 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(62 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ >.btn-group{
|
|
|
+ position: absolute;
|
|
|
+ top: calc(36 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ right: calc(12 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ >button.return-home{
|
|
|
+ background-image: url(@/assets/images/icon_home.png);
|
|
|
+ background-size: contain;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-position: center center;
|
|
|
+ width: calc(40 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(40 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ >button.game-rule{
|
|
|
+ background-image: url(@/assets/images/icon_rules.png);
|
|
|
+ background-size: contain;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-position: center center;
|
|
|
+ width: calc(40 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(40 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ >.question-inner {
|
|
|
+ flex: 1 0 1px;
|
|
|
+ width: calc(100% - 150px * 2);
|
|
|
+ margin-top: 10px;
|
|
|
+ counter-reset: count;
|
|
|
+ position: absolute;
|
|
|
+ left: 50%;
|
|
|
+ top: calc(162 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ transform: translate(-50%, 0);
|
|
|
+ width: calc(284 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: 52%;
|
|
|
+ overflow: auto;
|
|
|
+ > p.question {
|
|
|
+ font-size: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ font-family: Source Han Sans SC, Source Han Sans SC;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #FFFFFF;
|
|
|
+ line-height: 1.5;
|
|
|
+ }
|
|
|
+ > button.option {
|
|
|
+ margin-top: calc(10 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(50 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ padding-left: calc(21 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ padding-right: calc(17 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ font-family: Source Han Sans SC, Source Han Sans SC;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #CCC;
|
|
|
+ counter-increment: count;
|
|
|
+ border-radius: calc(10 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ border: 1px solid #CCCCCC;
|
|
|
+ &.submitted {
|
|
|
+ pointer-events: none;
|
|
|
+ }
|
|
|
+ &.submitted.selected.rightOption {
|
|
|
+ color: #4AFFD4;
|
|
|
+ border: 1px solid #4AFFD4;
|
|
|
+ }
|
|
|
+ &.submitted.selected.wrongOption {
|
|
|
+ color: #FF6A6A;
|
|
|
+ border: 1px solid #FF6A6A;
|
|
|
+ }
|
|
|
+ > .option-text {
|
|
|
+ &::before {
|
|
|
+ content: counter(count, upper-alpha);
|
|
|
+ margin-right: 0.5em;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ > .result-tip {
|
|
|
+ > img.correct-icon {
|
|
|
+ width: calc(42 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(42 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ > img.wrong-icon {
|
|
|
+ width: calc(42 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(42 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ > .answer-desc{
|
|
|
+ margin-top: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ font-family: Source Han Sans SC, Source Han Sans SC;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #FFFFFF;
|
|
|
+ line-height: 1.5;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ >.common-info-group{
|
|
|
+ position: absolute;
|
|
|
+ left: 50%;
|
|
|
+ bottom: calc(131 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ transform: translate(-50%, 0);
|
|
|
+ display: flex;
|
|
|
+ gap: calc(11 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ >.info-item{
|
|
|
+ position: relative;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: flex-end;
|
|
|
+ padding-bottom: calc(3 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ width: calc(143 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(28 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ padding-left: calc(5 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ padding-right: calc(18 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ background: #395953;
|
|
|
+ border-radius: calc(14 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ box-shadow: #16332E calc(2 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef')) calc(3 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef')) 0 0;
|
|
|
+ >.icon{
|
|
|
+ }
|
|
|
+ >.number{
|
|
|
+ font-size: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ font-family: heiti;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #FFFFFF;
|
|
|
+ line-height: calc(23 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ >.bonus-point{
|
|
|
+ >.icon{
|
|
|
+ width: calc(46 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(41 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ >.time-count{
|
|
|
+ >.icon{
|
|
|
+ width: calc(37 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(46 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ >button.next{
|
|
|
+ position: absolute;
|
|
|
+ left: 50%;
|
|
|
+ bottom: calc(45 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ transform: translate(-50%, 0);
|
|
|
+ width: calc(300 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(70 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ background-image: url(@/assets/images/exam-paper-btn-long-bg.png);
|
|
|
+ background-size: contain;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-position: center center;
|
|
|
+ font-size: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ font-family: Source Han Sans SC, Source Han Sans SC;
|
|
|
+ font-weight: 800;
|
|
|
+ color: #FFFFFF;
|
|
|
+ line-height: calc(28 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ padding-bottom: calc(6 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|