You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jwl-applet/src/pages/questionBank/components/Question.vue

946 lines
33 KiB

2 years ago
<template>
2 years ago
<view>
<view class="content" v-if="questionList&&questionList.length>0">
<view class="flex ai-c jc-c">
<view class="flex type_box jc-sb ai-c" v-if="navTitle!=='考前密卷'">
<view class="type_item" v-for="(item,index) of tabsList" :key="index"
:class="tCurrent==item.value?'checked':'unchecked'" @tap="sectionChange(item.value)">{{item.label}}</view>
</view>
</view>
<swiper class="swiper mt20" :current="swiperIndex" :duration="duration" :autoplay="false"
2 years ago
@change="onChange" @animationfinish="onAnimationfinish"
2 years ago
@touchend="touchEnd">
2 years ago
<swiper-item v-for="(quesItem,quesIndex) in swiperList" :key="quesIndex.questionId">
2 years ago
<scroll-view scroll-y="true" class="swiper-scroll">
<view>
<view class="m14lr">
<text class="tag_box">{{getQuestType(quesItem.type)}}</text>
<text class="fs18" style="line-height: 42rpx;vertical-align: middle;">{{quesItem.question}}</text>
</view>
<view class="p14" v-if="quesItem.imageUrl">
2 years ago
<image v-show="quesItem.imageUrl" style="width: 100%;height: auto;" mode="widthFix" :lazy-load="true" @load="onoff='1'" :src="quesItem.imageUrl"></image>
2 years ago
</view>
<template v-if="quesItem.type!='3'">
<view class="flex m14lr ai-c mt20" v-for="(item,index) in quesItem.optionList" :key="item.op"
@tap="answerQues(item.opValue,index)">
<template v-if="item.opDesc">
<template v-if="quesItem.clickAnswer&&quesItem.trueAnswer.includes(item.opValue)">
<u-icon class="mr15" name="checkmark-circle-fill" color="#05C341" size="32"></u-icon>
</template>
<template
v-else-if="quesItem.clickAnswer&&quesItem.clickAnswer?.includes(item.opValue)&&!quesItem.trueAnswer.includes(item.opValue)">
<u-icon class="mr15" name="close-circle-fill" color="red" size="32"></u-icon>
</template>
<template v-else-if="!item.chooseOption">
<view class="option_item">{{item.op}}</view>
2 years ago
</template>
2 years ago
<text style="width: calc(100% - 100rpx);display: inline-block;" class="fs18">{{item.opDesc}}</text>
</template>
</view>
<view class="m14lr mt30"
v-if="quesItem.clickAnswer&&!quesItem.trueAnswer.includes(quesItem.clickAnswer) || showBestAnswer">
<view class="answer_box">
<text class="fs18 fw600 cor-000">答案:{{getRightOp(quesItem.trueAnswer)}}</text>
2 years ago
<view v-if="showSkillInfo==='show'&&quesItem.skillInfo" class="fs18 cor-000 mt5">答题技巧{{quesItem.skillInfo}}</view>
</view>
<view class="flex ai-c jc-c mt10">
<view style="height: 6rpx;width: 120rpx;background-color: rgb(232, 232, 232);"></view>
<view class="fs18 fw600 cor-000 p15lr">试题详解</view>
<view style="height: 6rpx;width: 120rpx;background-color: rgb(232, 232, 232);"></view>
</view>
<view class="mt10">
<view class="fw600 cor-000 mb10 flex ai-c">
<view style="background: linear-gradient(90deg, #11DF20 0%, #00B74F 100%);height: 36rpx;width: 8rpx;" class="mr5"></view>题目解析</view>
<view style="text-indent:2em;">{{quesItem.bestAnswer}}</view>
2 years ago
</view>
</view>
</template>
<template v-else>
<view class="flex m14lr ai-c mt20" v-for="(item,index) in quesItem.optionList" :key="item.op"
@tap="answerQues(item.opValue,index)">
<template v-if="item.opDesc">
<template
v-if="quesItem.isChoose&&quesItem.trueAnswer.includes(item.opValue)&&quesItem.clickAnswer&&quesItem.clickAnswer.includes(item.opValue)">
<u-icon class="mr15" name="checkmark-circle-fill" color="#05C341" size="32"></u-icon>
2 years ago
</template>
2 years ago
<template
v-else-if="quesItem.isChoose&&quesItem.clickAnswer&&quesItem.clickAnswer.includes(item.opValue)&&!quesItem.trueAnswer.includes(item.opValue)">
<u-icon class="mr15" name="close-circle-fill" color="red" size="32"></u-icon>
</template>
<template
v-else-if="!quesItem.isChoose||quesItem.clickAnswer&&!quesItem.clickAnswer.includes(item.opValue)&&quesItem.isChoose">
<template v-if="quesItem.isChoose">
<view class="option_item"
:class="quesItem.trueAnswer.includes(item.opValue)&&quesItem.clickAnswer&&!quesItem.clickAnswer.includes(item.opValue)?'right_option':''">
{{item.op}}
</view>
</template>
<template v-else>
<view class="option_item"
:class="quesItem.clickAnswer&&quesItem.clickAnswer.includes(item.opValue)&&!quesItem.isChoose?'checked_option':''">
{{item.op}}
</view>
</template>
</template>
<text style="width: calc(100% - 100rpx);display: inline-block;" class="fs18">{{item.opDesc}}</text>
</template>
</view>
<view class="p14" v-if="tCurrent!=1">
<button :class="quesItem.clickAnswer&&quesItem.clickAnswer.length>1?'dx_checked':'dx_btn'"
@click="duoxuan(quesItem.clickAnswer)">确认</button>
</view>
<view class="m14lr mt30" v-if="isShowAnswer">
<view class="answer_box">
<text class="fs18 fw600 cor-000">答案:{{getRightOp(quesItem.trueAnswer)}}</text>
2 years ago
<view v-if="showSkillInfo==='show'&&quesItem.skillInfo" class="fs18 cor-000"> 答题技巧{{quesItem.skillInfo}}</view>
</view>
<view class="flex ai-c jc-c mt10">
<view style="height: 6rpx;width: 120rpx;background-color: rgb(232, 232, 232);"></view>
<view class="fs18 fw600 cor-000 p15lr">试题详解</view>
<view style="height: 6rpx;width: 120rpx;background-color: rgb(232, 232, 232);"></view>
</view>
<view class="mt10">
<view class="fw600 cor-000 mb10 flex ai-c">
<view style="background: linear-gradient(90deg, #11DF20 0%, #00B74F 100%);height: 36rpx;width: 8rpx;" class="mr5"></view>题目解析</view>
<view style="text-indent:2em;">{{quesItem.bestAnswer}}</view>
</view>
2 years ago
</view>
</template>
</view>
</scroll-view>
</swiper-item>
</swiper>
<view class="wp100 flex jc-sb ai-c p14 bc-fff" v-if="isShowAll" style="position: fixed;bottom: 0;left: 0;">
<view style="width: 220rpx;">
<view v-if="type==='practice'" style="width: 220rpx;height: 80rpx;"></view>
<view v-else-if="type=='exam'" class="btn" style="text-align: center;" @tap="submitPaper">
<u-count-down ref="countDown_1" :time=" timeCount" format="HH:mm:ss" @change="timeChange"></u-count-down>
<text>交卷</text>
</view>
2 years ago
</view>
2 years ago
<view class="text-center flex jc-c ai-c" style="flex-direction: column;" @tap="toCollect">
2 years ago
<u-icon name="star-fill" v-if="collectList.includes(questionList[topicIndex].questionId)"
color="rgb(249,236,141)" size="24"></u-icon>
2 years ago
<u-icon name="star" v-else size="24"></u-icon>
2 years ago
<text class="cor-666">{{collectList.includes(questionList[topicIndex].questionId)?'已收藏':'收藏'}}</text>
2 years ago
</view>
2 years ago
<view class="text-center">
<view style="color: #00B74F;">{{rightList.length}}</view>
<text class="cor-666">答对</text>
2 years ago
</view>
2 years ago
<view class="text-center">
2 years ago
<view style="color: #FF6E02;">{{wrongList.length}}</view>
<text class="cor-666">答错</text>
</view>
<view class="text-center" @tap="popupShow=!popupShow">
<view><text class="cor-333">{{topicIndex+1}}</text><text style="color:#999;">/{{questionList.length}}</text>
2 years ago
</view>
2 years ago
<text class="cor-666">题板</text>
</view>
</view>
<view v-else class="wp100 p14" style="position: fixed;bottom: 30rpx;left: 0;">
<button class="vip_btn" @click="toVip">立即查看全部题目</button>
</view>
<u-modal :show="tipShow">
<view class="relative wp100">
2 years ago
<view class="text-center">
2 years ago
<text>{{title}}</text>
<view class="mt20">{{content}}</view>
2 years ago
</view>
2 years ago
<view style="position: absolute;right:0px;top:0" @tap="cancel">
<u-icon name="close-circle-fill" color="rgb(204,204,204)" size="24"></u-icon>
2 years ago
</view>
</view>
2 years ago
<template #confirmButton>
<view class="p10">
<u-button
:customStyle="{width:'100%',height:'68rpx',borderRadius:'34rpx',color:'#fff',backgroundColor:'#05C341'}"
@click="toResult">查看练题结果</u-button>
2 years ago
</view>
2 years ago
</template>
</u-modal>
<u-modal :show="isSubmit">
<view class="wp100">
2 years ago
<view class="text-center">
2 years ago
<text>确认交卷</text>
<view class="mt20 flex ai-c jc-sb">
<view class="text-center">
<text style="color:#FF6E02">{{questionList.length-rightList.length-wrongList.length}}</text>
<view class="cor-333">未答题数</view>
</view>
<view class="text-center">
<u-count-down ref="countDown_3" class="balckColor" :time="timeCount" format="HH:mm:ss"></u-count-down>
<view>剩余时间</view>
</view>
<view class="text-center">
<text style="color:#333">{{(rightList.length/questionList.length * 100).toFixed(0)}}</text>
<view class="cor-333">考试得分</view>
</view>
</view>
2 years ago
</view>
2 years ago
</view>
<template #confirmButton>
<view class="p10">
<template v-if="isShowAll">
<u-button
:customStyle="{width:'45%',marginRight:'10px',height:'68rpx',lineHeight:'68rpx',borderRadius:'34rpx',color:'#666',border:'1px solid #666',display:'inline-block'}"
@click="continueExam">继续考试</u-button>
<u-button
:customStyle="{width:'45%',marginLeft:'10px',height:'68rpx',lineHeight:'68rpx',borderRadius:'34rpx',color:'#fff',backgroundColor:'#05C341',display:'inline-block'}"
@click="toSubmit">现在交卷</u-button>
</template>
<template v-else>
<u-button
:customStyle="{width:'45%',marginRight:'10px',height:'68rpx',lineHeight:'68rpx',borderRadius:'34rpx',color:'#666',border:'1px solid #666',display:'inline-block'}"
@click="toLeave">确定离开</u-button>
<u-button
:customStyle="{width:'45%',marginLeft:'10px',height:'68rpx',lineHeight:'68rpx',borderRadius:'34rpx',color:'#fff',backgroundColor:'#05C341',display:'inline-block'}"
@click="continueExam">继续考试</u-button>
</template>
2 years ago
</view>
2 years ago
</template>
</u-modal>
<u-popup :show="popupShow" mode="bottom" :closeOnClickOverlay="true" @close="popupShow=false">
<view>
<view class="wp100 flex jc-sb p14 bc-fff">
<view style="width: 220rpx;">
<view v-if="type==='practice'" style="width: 220rpx;height: 80rpx;"></view>
<view v-else-if="type=='exam'" class="btn" style="text-align: center;" @tap="submitPaper">
<u-count-down ref="countDown_2" :time="timeCount" format="HH:mm:ss"></u-count-down>
<text>交卷</text>
</view>
</view>
<view class="text-center flex jc-c ai-c" style="flex-direction: column;" @tap="toCollect">
2 years ago
<u-icon name="star-fill" v-if="collectList.includes(questionList[topicIndex].questionId)"
color="rgb(249,236,141)" size="24"></u-icon>
2 years ago
<u-icon name="star" v-else size="24"></u-icon>
2 years ago
<text class="cor-666">{{collectList.includes(questionList[topicIndex].questionId)?'已收藏':'收藏'}}</text>
2 years ago
</view>
<view class="text-center">
<view style="color: #00B74F;">{{rightList.length}}</view>
<text class="cor-666">答对</text>
</view>
<view class="text-center">
<view style="color: #FF6E02;">{{wrongList.length}}</view>
<text class="cor-666">答错</text>
</view>
<view class="text-center" @tap="popupShow=!popupShow">
<view><text class="cor-333">{{topicIndex+1}}</text><text
style="color:#999;">/{{questionList.length}}</text>
</view>
<text class="cor-666">题板</text>
</view>
2 years ago
</view>
2 years ago
<view class="flex ai-c jc-fs p14" style="flex-wrap: wrap;max-height: 400px;overflow-y: scroll;">
2 years ago
<view v-for="(item,index) of questionList" :key="item.questionId" style="width:20%;" class="flex ai-c jc-c"
2 years ago
@tap="chooseQueston(index)">
<view class="tCircle mb10" :class="{
'active':index == topicIndex,
'success':rightList.includes(item.questionId),
'error':wrongList.includes(item.questionId)
}">
{{index+1}}
</view>
2 years ago
</view>
</view>
</view>
2 years ago
</u-popup>
<!-- <u-popup :show="showVip" mode="bottom" :closeOnClickOverlay="true" :round="16" @close="showVip=false">
<view class="p14" style="z-index: 9;">
<view class="wp100 flex ai-c jc-sb">
<text class="fs30 fw600 cor-000">VIP题库</text>
<u-icon name="close" color="#c2c2c2" size="20" @tap="showVip=false"></u-icon>
</view>
<text class="fs16 cor-666">精准刷题更高效</text>
<view style="width:100%;height: 110rpx;background-image: url(../../static/image/practice/vip_question.png);background-size: 100% 100%;" class="mt15 relative">
<view style="position: absolute;left:0,top:0;height: 110rpx;" class="wp100 flex jc-c ai-c">
<text class="fs16" style="color: #994800;">科一+科四精简500题</text>
</view>
<image style="width: 65rpx;height: 65rpx; position: absolute;right: 20px;top: -5px;" src="../../static/image/practice/vip_include.png"></image>
</view>
<view style="width:100%;height: 110rpx;background-image: url(../../static/image/practice/vip_test.png);background-size: 100% 100%;z-index: 9;" class="mt15 relative">
<view style="position: absolute;left:0,top:0;height: 110rpx;" class="wp100 flex jc-c ai-c">
<text class="fs16" style="color: #994800;">科一+科四考前密卷2套</text>
</view>
<image style="width: 65rpx;height: 65rpx; position: absolute;right: 20px;top: -5px;" src="../../static/image/practice/vip_include.png"></image>
</view>
</view>
<view style="height: 528rpx;width: 100%;background-image: url(../../static/image/practice/vip_bg.jpg);background-size: 100% 100%;margin-top: -65px;position: relative;">
<text style="position: absolute;top: 151px;left:117px;rotate: 16deg;" class="fs25 cor-fff">VIP题库</text>
</view>
<view class="wp100 p14" style="position: absolute;left: 0;bottom:20px">
<view class="sub_btn flex ai-c jc-sb">
<text class="cor-fff fs14">¥<text class="fs24 cor-fff">{{nowPrice}}</text></text>
<image style="width: 276rpx;height: 88rpx;margin-top: -5px;" src="../../static/image/index/buy.png"></image>
</view>
</view>
</u-popup> -->
</view>
<view v-else>
<view class="mt20">
<u-loading-icon text="题目加载中..."></u-loading-icon>
2 years ago
</view>
2 years ago
</view>
</view>
2 years ago
</template>
<script>
2 years ago
import {
mapState,
mapActions
} from 'pinia' //引入映射函数
2 years ago
import storage from '@/jtools/storage';
2 years ago
import useQuestionStore from '@/jtools/store/question' //引入store
import {
2 years ago
querySysConfig,
2 years ago
submitTest
} from '@/jtools/api/question';
2 years ago
export default {
props: {
tabsList: {
type: Array
},
type: {
type: String,
default: 'practice'
},
isSubmit: {
type: Boolean,
default: false
},
isShowAll: {
type: Boolean,
default: true
},
subject: {
type: [String, Number],
default: 1,
},
2 years ago
},
2 years ago
data() {
return {
2 years ago
showSkillInfo:'hidden',
currentType:storage.get('carType') || '1001',
2 years ago
onoff:'0',
2 years ago
navTitle: '',
originArray: '',
showBestAnswer: false,
nowPrice: 68,
showVip: false,
popupShow: false,
content: '太棒啦,已答完最后一题~',
tipShow: false,
title: '提示',
tCurrent: 0,
index: 0,
qIndex: 0,
rightList: [],
wrongList: [],
collectList: storage.get(`collectList_subject${this.subject}`) || [],
questionList: [], //数据源
swiperList: [], // 轮播图数据列表
swiperIndex: 0, // 轮播图当前位置
isChange: false, // 是否切换
topicIndex: 0, // 题目位置
duration: 200, // 动画过渡时长
time: 0,
}
2 years ago
},
2 years ago
created() {
const carType=storage.get('carType') || '1001'
querySysConfig(carType, 'NeedSkillInfo').then(resp=>{
if(resp.code === '0000'){
this.showSkillInfo = resp.data.configValue
}
})
},
2 years ago
computed: {
...mapState(useQuestionStore, ["currentIndex_subject1", "currentIndex_subject4"]), //映射函数,取出tagslist
isShowAnswer() {
// quesItem.isChoose&&quesItem.clickAnswer&&!quesItem.trueAnswer.includes(quesItem.clickAnswer)
if (this.tCurrent == 0) {
if (this.questionList[this.topicIndex].isChoose) {
const arr1 = this.questionList[this.topicIndex].clickAnswer.split('')
const arr2 = this.questionList[this.topicIndex].trueAnswer.split('')
if (!this.isArrEqual(arr1, arr2)) {
return true
} else {
return false
}
} else {
return false
}
} else {
2 years ago
return true
}
2 years ago
},
timeCount() {
2 years ago
const time = 45 * 60 * 1000
2 years ago
return time
2 years ago
}
2 years ago
},
2 years ago
methods: {
...mapActions(useQuestionStore, ['getCurrentIndex']),
getOriginArr(val) {
const arr = JSON.parse(val)
let arr1 = []
arr.forEach(item => {
arr1.push({
isChoose: false,
...item
})
})
this.originArray = JSON.stringify(arr1)
},
toLeave() {
uni.switchTab({
url: '/pages/index/index'
})
},
isShowBest(val) {
this.showBestAnswer = val
},
duoxuan(val) {
if (val && val.length > 1) {
this.questionList[this.topicIndex].isChoose = true
if (this.tCurrent != 1) {
this.originArray = JSON.stringify(this.questionList)
}
const falseList = storage.get(`wrongList_subject${this.subject}`) || []
const trueList = storage.get(`rightList_subject${this.subject}`) || []
if (this.tCurrent !== 1) {
const arr1 = this.questionList[this.topicIndex].clickAnswer.split('')
const arr2 = this.questionList[this.topicIndex].trueAnswer.split('')
if (this.isArrEqual(arr1, arr2)) {
//判断选择的答案和实际的答案是否相同,如果相同,判断如果该题的ID在不在正确的数组中,不在则Push(存储的的同理)
//如果这道题在错误的数组中则把这道题在错误数组中删掉
if (!this.rightList.includes(this.questionList[this.topicIndex].questionId)) {
this.rightList.push(this.questionList[this.topicIndex].questionId)
}
if (!trueList.includes(this.questionList[this.topicIndex].questionId)) {
trueList.push(this.questionList[this.topicIndex].questionId)
storage.set(`rightList_subject${this.subject}`, trueList)
}
if (this.wrongList.includes(this.questionList[this.topicIndex].questionId)) {
const wIndex = this.wrongList.indexOf(this.questionList[this.topicIndex].questionId)
this.wrongList.splice(wIndex, 1)
}
if (falseList.includes(this.questionList[this.topicIndex].questionId)) {
const wIndex = falseList.indexOf(this.questionList[this.topicIndex].questionId)
falseList.splice(wIndex, 1)
storage.set(`wrongList_subject${this.subject}`, falseList)
}
//答对题目 如果不是最后一题,跳下一题
if (this.topicIndex < this.questionList.length - 1) {
this.topicIndex++;
this.qIndex = this.topicIndex
if (this.navTitle === '顺序答题') {
this.getCurrentIndex(this.topicIndex, this.subject)
}
setTimeout(() => {
this.renderSwiper(this.topicIndex);
}, 1000)
} else {
this.qIndex = this.topicIndex + 1
}
if (this.qIndex > this.questionList.length - 1) {
setTimeout(() => {
this.tipShow = true
}, 1000)
} else {
this.tipShow = false
}
} else {
if (!this.wrongList.includes(this.questionList[this.topicIndex].questionId)) {
this.wrongList.push(this.questionList[this.topicIndex].questionId)
}
if (!falseList.includes(this.questionList[this.topicIndex].questionId)) {
falseList.push(this.questionList[this.topicIndex].questionId)
storage.set(`wrongList_subject${this.subject}`, falseList)
}
if (trueList.includes(this.questionList[this.topicIndex].questionId)) {
const rIndex = trueList.indexOf(this.questionList[this.topicIndex].questionId)
trueList.splice(rIndex, 1)
storage.set(`rightList_subject${this.subject}`, trueList)
}
}
2 years ago
}
}
2 years ago
},
timeChange(e) {
this.time = e
if (e.hours == 0 && e.minutes == 0 && e.seconds == 0 && e.milliseconds == 0) {
uni.showToast({
title: "考试结束,将为您自动交卷~",
icon: 'none'
2 years ago
})
2 years ago
setTimeout(() => {
this.toSubmit()
}, 1000)
2 years ago
}
2 years ago
},
//获取正确选项
getRightOp(val) {
let rightOp = ''
this.questionList[this.topicIndex].optionList.forEach(item => {
if (this.questionList[this.topicIndex].trueAnswer.includes(item.opValue)) {
if (rightOp) {
rightOp = rightOp + '、' + item.op
} else {
rightOp = item.op
}
}
})
return rightOp
},
//获取题类型
getQuestType(val) {
if (val == '1') {
return '判断'
} else if (val == '2') {
return '单选'
} else if (val == '3') {
return '多选'
2 years ago
}
2 years ago
},
//开通VIP
toVip() {
uni.navigateTo({
url: "/pages/index/videoVip?subject=" + this.subject
2 years ago
})
2 years ago
},
submitPaper() {
if (this.isShowAll) {
this.$refs.countDown_1.pause();
this.$refs.countDown_2.pause();
}
this.$refs.countDown_3.pause();
this.$emit('update:isSubmit', true)
},
continueExam() {
this.$refs.countDown_1.start();
this.$refs.countDown_2.start();
this.$refs.countDown_3.start();
this.$emit('update:isSubmit', false)
},
//切换题目
chooseQueston(index) {
this.popupShow = false
this.pickerTopic(index)
},
//交卷
toSubmit() {
const restTime = this.time.hours * 60 * 60 + this.time.minutes * 60 + this.time.seconds
const score = (this.rightList.length / this.questionList.length * 100).toFixed(0)
2 years ago
if(this.rightList.length+this.wrongList.length==0){
uni.navigateBack({
delta:1
})
}else{
submitTest({
"carTypeId": storage.get('carType') || '1001',
"score": score,
"testTime": 45 * 60 - restTime,
subject: this.subject
}).then(resp => {
const doNotNum = this.questionList.length - this.rightList.length - this.wrongList.length
const list = JSON.stringify(this.wrongList)
if (resp.code === '0000') {
uni.navigateTo({
url: "/pages/questionBank/examResult?doNotNum=" + doNotNum + "&wrongList=" + list + "&score=" +
score + "&subject=" + this.subject + "&navTitle=" + this.navTitle
})
}
})
}
2 years ago
},
//查看考试结果
toResult() {
const allDoNum = this.wrongList.length + this.rightList.length
const list = JSON.stringify(this.wrongList)
uni.navigateTo({
url: "/pages/questionBank/practiceResult?allDoNum=" + allDoNum + "&wrongList=" + list + "&subject=" + this
.subject + "&navTitle=" + this.navTitle
})
},
toCollect() {
2 years ago
if (this.collectList.includes(this.questionList[this.topicIndex].questionId)) {
const idx = this.collectList.indexOf(this.questionList[this.topicIndex].questionId)
this.collectList.splice(idx, 1)
2 years ago
uni.showToast({
title: "取消收藏",
icon: 'none'
})
} else {
this.collectList.push(this.questionList[this.topicIndex].questionId)
this.questionList[this.topicIndex].isCollect = true
uni.showToast({
title: "已收藏",
icon: 'none'
})
2 years ago
}
2 years ago
storage.set(`collectList_subject${this.subject}`, this.collectList)
},
cancel() {
this.tipShow = false
},
touchEnd(e) {
if (this.topicIndex < this.questionList.length - 1) {
this.index = this.topicIndex
} else {
this.index++
}
},
// 渲染 swiper
renderSwiper(index) {
let list = [];
let current = 1;
if (this.questionList[index - 1]) {
list.push(this.questionList[index - 1]);
} else {
current = 0;
}
list.push(this.questionList[index])
if (this.questionList[index + 1]) {
list.push(this.questionList[index + 1]);
}
this.duration = 0;
setTimeout(() => {
this.swiperList = list;
this.swiperIndex = current;
setTimeout(() => {
this.duration = 200;
}, 100)
}, 50)
},
// 轮播图切换
onChange(e) {
2 years ago
// this.onoff='0'
2 years ago
// 非触摸事件不做轮播图状态更新
if (e.detail.source != "touch") return;
// 标识已切换
this.isChange = true;
// 轮播图当前位置大于原来时则表示为下一题
if (e.detail.current > this.swiperIndex) {
this.topicIndex++;
} else {
// 轮播图当前位置小于原来时则表示为上一题
this.topicIndex--;
}
if (this.navTitle === '顺序答题') {
this.getCurrentIndex(this.topicIndex, this.subject)
}
// 更新轮播图位置数值,为更新时让 Vue 能监听到数据有改变
this.swiperIndex = e.detail.current;
},
// 轮播图动画结束
onAnimationfinish(e) {
if (this.index >= this.questionList.length) {
if (this.isShowAll) {
this.tipShow = true
} else {
this.showVip = true
}
} else {
this.showVip = false
this.tipShow = false
}
if (!this.isChange) return;
this.isChange = false;
setTimeout(() => {
this.renderSwiper(this.topicIndex);
}, 10);
},
// 选择题目
pickerTopic(index) {
this.topicIndex = index;
this.index = this.topicIndex
if (this.navTitle === '顺序答题') {
this.getCurrentIndex(this.topicIndex, this.subject)
}
this.renderSwiper(index);
},
isArrEqual(arr1, arr2) {
return arr1.length === arr2.length && arr1.every((ele) => arr2.includes(ele));
},
//答题
answerQues(op, index) {
const falseList = storage.get(`wrongList_subject${this.subject}`) || []
const trueList = storage.get(`rightList_subject${this.subject}`) || []
2 years ago
if (!this.questionList[this.topicIndex].clickAnswer) {
2 years ago
this.questionList[this.topicIndex].optionList[index].chooseOption =
`${this.questionList[this.topicIndex].optionList[index].chooseOption?this.questionList[this.topicIndex].optionList[index].chooseOption:''}${op}`
this.questionList[this.topicIndex].clickAnswer =
`${this.questionList[this.topicIndex].optionList[index].clickAnswer?this.questionList[this.topicIndex].optionList[index].clickAnswer:''}${op}`
} else {
2 years ago
//如果是多选 点击的选项中不包含该选项则拼接进去,如果包含则能删除
2 years ago
if (this.questionList[this.topicIndex].type == '3' && !this.questionList[this.topicIndex].clickAnswer.includes(
op) && !this.questionList[this.topicIndex].isChoose) {
this.questionList[this.topicIndex].optionList[index].chooseOption =
`${this.questionList[this.topicIndex].optionList[index].chooseOption?this.questionList[this.topicIndex].optionList[index].chooseOption:''}${op}`
this.questionList[this.topicIndex].clickAnswer = `${this.questionList[this.topicIndex].clickAnswer}${op}`
} else if (this.questionList[this.topicIndex].type == '3' && this.questionList[this.topicIndex].clickAnswer
.includes(op) && !this.questionList[this.topicIndex].isChoose) {
this.questionList[this.topicIndex].optionList[index].chooseOption = ''
2 years ago
let reg2 = new RegExp(op); // 不加'g',仅删除字符串里第一个"a"
2 years ago
this.questionList[this.topicIndex].clickAnswer = this.questionList[this.topicIndex].clickAnswer.replace(reg2,
"");
2 years ago
}
2 years ago
}
2 years ago
if (this.tCurrent != 1) {
this.originArray = JSON.stringify(this.questionList)
2 years ago
}
2 years ago
if (this.tCurrent !== 1 && this.questionList[this.topicIndex].type != '3') {
const arr1 = this.questionList[this.topicIndex].clickAnswer.split('')
const arr2 = this.questionList[this.topicIndex].trueAnswer.split('')
if (this.isArrEqual(arr1, arr2)) {
//判断选择的答案和实际的答案是否相同,如果相同,判断如果该题的ID在不在正确的数组中,不在则Push(存储的的同理)
//如果这道题在错误的数组中则把这道题在错误数组中删掉
if (!this.rightList.includes(this.questionList[this.topicIndex].questionId)) {
this.rightList.push(this.questionList[this.topicIndex].questionId)
}
if (!trueList.includes(this.questionList[this.topicIndex].questionId)) {
trueList.push(this.questionList[this.topicIndex].questionId)
storage.set(`rightList_subject${this.subject}`, trueList)
}
if (this.wrongList.includes(this.questionList[this.topicIndex].questionId)) {
const wIndex = this.wrongList.indexOf(this.questionList[this.topicIndex].questionId)
this.wrongList.splice(wIndex, 1)
}
if (falseList.includes(this.questionList[this.topicIndex].questionId)) {
const wIndex = falseList.indexOf(this.questionList[this.topicIndex].questionId)
falseList.splice(wIndex, 1)
storage.set(`wrongList_subject${this.subject}`, falseList)
}
//答对题目 如果不是最后一题,跳下一题
if (this.topicIndex < this.questionList.length - 1) {
this.topicIndex++;
this.qIndex = this.topicIndex
if (this.navTitle === '顺序答题') {
this.getCurrentIndex(this.topicIndex, this.subject)
}
setTimeout(() => {
this.renderSwiper(this.topicIndex);
}, 1000)
} else {
this.qIndex = this.topicIndex + 1
}
if (this.qIndex > this.questionList.length - 1) {
setTimeout(() => {
this.tipShow = true
}, 1000)
} else {
this.tipShow = false
}
} else {
if (!this.wrongList.includes(this.questionList[this.topicIndex].questionId)) {
this.wrongList.push(this.questionList[this.topicIndex].questionId)
}
if (!falseList.includes(this.questionList[this.topicIndex].questionId)) {
falseList.push(this.questionList[this.topicIndex].questionId)
storage.set(`wrongList_subject${this.subject}`, falseList)
}
if (trueList.includes(this.questionList[this.topicIndex].questionId)) {
const rIndex = trueList.indexOf(this.questionList[this.topicIndex].questionId)
trueList.splice(rIndex, 1)
storage.set(`rightList_subject${this.subject}`, trueList)
}
2 years ago
}
2 years ago
}
},
sectionChange(index) {
this.tCurrent = index
// this.getQuestionList()
// this.renderSwiper(0)
this.$emit('changeTab', index)
},
getQuestionList(val, title) {
if (title) {
this.navTitle = title
}
if (val && val.length) {
this.questionList = JSON.parse(val)
} else {
this.questionList = JSON.parse(this.originArray)
}
2 years ago
console.log(this.questionList);
2 years ago
if (this.navTitle === '顺序答题') {
this.pickerTopic(this[`currentIndex_subject${this.subject}`])
} else {
this.pickerTopic(this.topicIndex)
}
2 years ago
}
2 years ago
}
}
2 years ago
</script>
2 years ago
<style scoped lang="scss">
.checked_option {
2 years ago
background-color: #000;
border: 1px solid #000;
2 years ago
color: #fff
}
.type_box {
width: 350rpx;
height: 72rpx;
background-color: #FFFFFF;
border-radius: 8rpx;
}
.type_item {
text-align: center;
line-height: 64rpx;
width: 160rpx;
height: 64rpx;
border-radius: 8rpx;
}
.checked {
color: #fff;
background-color: #05C341;
}
.unchecked {
color: #666;
}
.tag_box {
vertical-align: middle;
display: inline-block;
width: 78rpx;
height: 42rpx;
background: #05C341;
border-radius: 8rpx;
text-align: center;
line-height: 42rpx;
color: #fff;
font-size: 12px;
margin-right: 5px;
}
.option_item {
width: 60rpx;
height: 60rpx;
border: 1px solid #666;
border-radius: 50%;
text-align: center;
line-height: 60rpx;
margin-right: 30rpx;
2 years ago
}
2 years ago
.swiper {
height: 100vh;
}
.answer_box {
width: 100%;
padding: 30rpx;
background: #EEEEEE;
border-radius: 20rpx;
}
.btn {
width: 220rpx;
height: 80rpx;
border-radius: 40rpx;
color: #fff;
background: linear-gradient(90deg, #11DF20 0%, #00B74F 100%);
font-size: 28rpx;
line-height: 80rpx;
2 years ago
}
2 years ago
2 years ago
.tCircle {
width: 80rpx;
height: 80rpx;
background-color: #fff;
border: #ddd solid 1px;
border-radius: 50%;
line-height: 80rpx;
text-align: center;
2 years ago
2 years ago
&.active {
border: #05C341 solid 1px;
}
2 years ago
2 years ago
&.success {
background-color: rgb(236, 247, 241);
color: #05C341;
border: none;
2 years ago
2 years ago
&.active {
border: #05C341 solid 1px;
}
2 years ago
}
2 years ago
&.error {
background-color: #ffeceb;
color: #f84d27;
border: none;
&.active {
border: #f84d27 solid 1px;
}
}
}
.content {
padding-top: calc(var(--window-top) + 10px);
}
.vip_btn {
width: 100%;
height: 100rpx;
line-height: 100rpx;
text-align: center;
font-size: 18px;
color: #fff;
background: linear-gradient(90deg, #FF9804 0%, #E95B0E 100%);
border-radius: 50rpx;
2 years ago
}
2 years ago
.sub_btn {
width: 100%;
2 years ago
height: 110rpx;
border: 4px solid #F59B26;
background: linear-gradient(0deg, #E66501 0%, #F8A42C 100%);
2 years ago
box-shadow: 0rpx 16rpx 20rpx 1rpx rgba(245, 155, 38, 0.78);
2 years ago
border-radius: 55rpx;
padding: 14rpx;
}
2 years ago
.dx_btn {
width: 100%;
2 years ago
height: 100rpx;
line-height: 100rpx;
text-align: center;
2 years ago
color: #fff;
background: rgb(204, 204, 204);
border-radius: 100rpx;
2 years ago
}
2 years ago
.dx_checked {
width: 100%;
2 years ago
height: 100rpx;
line-height: 100rpx;
text-align: center;
2 years ago
color: #fff;
2 years ago
background: #05C341;
2 years ago
border-radius: 100rpx;
2 years ago
}
2 years ago
.right_option {
border-color: #05C341;
2 years ago
background-color: #fff;
color: #05C341
}
2 years ago
</style>