提交 #1

Merged
huxiaofeng666 merged 1 commits from dev-hxf into master 1 year ago
  1. 16
      .hbuilderx/launch.json
  2. 644
      src/pages/questionBank/components/Question.vue

@ -0,0 +1,16 @@
{ // launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote
"version": "0.0",
"configurations": [{
"default" :
{
"launchtype" : "local"
},
"mp-weixin" :
{
"launchtype" : "local"
},
"type" : "uniCloud"
}
]
}

@ -1,146 +1,526 @@
<template> <template>
<view style="margin-top: 100px;"> <view style="margin-top: 100px;">
<view class="flex ai-c jc-c"> <view class="flex ai-c jc-c">
<view class="flex type_box"> <view class="flex type_box jc-sb ai-c">
<view class="type_item" :class="tCurrent==0?'checked':'unchecked'" @tap="sectionChange(0)">答题</view> <view class="type_item" :class="tCurrent==0?'checked':'unchecked'" @tap="sectionChange(0)">答题</view>
<view class="type_item" :class="tCurrent==1?'checked':'unchecked'" @tap="sectionChange(1)">背题</view> <view class="type_item" :class="tCurrent==1?'checked':'unchecked'" @tap="sectionChange(1)">背题</view>
</view> </view>
</view> </view>
<view class="m14lr"> <swiper class="swiper" :current="swiperIndex" :duration="duration" :autoplay="false" :disable-programmatic-animation="true" @change="onChange" @animationfinish="onAnimationfinish">
<text class="tag_box">{{questionList[currentIndex].questionTypeDesc}}</text> <swiper-item v-for="(quesItem,quesIndex) in swiperList" :key="quesIndex">
<text class="fs18">{{questionList[currentIndex].questionDesc}}</text> <scroll-view scroll-y="true" class="swiper-scroll">
</view> <view>
<view class="flex m14lr ai-c mt20" v-for="(item,index) in questionList[currentIndex].optionList" :key="item.op"> <view class="m14lr">
<template v-if="clickAnswer&&item.op===questionList[currentIndex].rightAnswer"> <text class="tag_box">{{quesItem.questionTypeDesc}}</text>
<u-icon name="checkmark-circle-fill" color="#05C341" size="30"></u-icon> <text class="fs18">{{quesItem.questionDesc}}</text>
</template> </view>
<template v-else-if="clickAnswer===item.op&&item.op!==questionList[currentIndex].rightAnswer"> <view class="flex m14lr ai-c mt20" v-for="(item,index) in quesItem.optionList"
<u-icon name="close-circle-fill" color="red" size="30"></u-icon> :key="item.op" @tap="answerQues(item.op,index)">
</template> <template
<template v-else-if="!clickAnswer"> v-if="quesItem.clickAnswer&&item.op===quesItem.rightOp">
<view class="option_item">{{item.op}}</view> <u-icon class="mr15" name="checkmark-circle-fill" color="#05C341" size="30"></u-icon>
</template> </template>
<text class="fs18">{{item.opDesc}}</text> <template
</view> v-else-if="quesItem.clickAnswer===item.op&&item.op!==quesItem.rightAnswer">
</view> <u-icon class="mr15" name="close-circle-fill" color="red" size="30"></u-icon>
</template>
<template v-else-if="!item.chooseOption">
<view class="option_item">{{item.op}}</view>
</template>
<text class="fs18">{{item.opDesc}}</text>
</view>
<view class="m14lr mt30"
v-if="quesItem.clickAnswer&&quesItem.clickAnswer!==quesItem.rightOp || tCurrent===1">
<view class="answer_box">
<text class="fs18 fw600 cor-000">答案:{{quesItem.rightOp}}</text>
<view class="fs18 cor-000" style="text-indent:2em;"> 这里是相关解释文字这里是相关解释文字相关解释文字</view>
</view>
</view>
</view>
</scroll-view>
</swiper-item>
</swiper>
<u-modal :show="tipShow" :title="title" :content="content">
<template #confirmButton>
<view class="p10" >
<u-button :customStyle="{width:'100%',height:'68rpx',borderRadius:'34rpx'}">查看练题结果</u-button>
</view>
</template>
</u-modal>
</view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
tCurrent:0, content:'太棒啦,已答完最后一题',
clickAnswer:undefined, tipShow:false,
questionList:[], title:'提示',
currentIndex:0, tCurrent:0,
} questionList: [],//
}, swiperList: [], //
onshow(){ swiperIndex: 0, //
this.getQuestionList() isChange: false, //
}, topicIndex: 0, //
methods: { duration: 200, //
sectionChange(index){ }
this.tCurrent=index },
}, onLoad() {
getQuestionList(){ this.getQuestionList()
this.questionList=[{ this.renderSwiper(0)
questionId:0, },
questionTypeDesc:'单选', methods: {
questionDesc:'在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?', // swiper
optionList:[{ renderSwiper(index) {
op:'A', let list = [];
opDesc:'注意新手标志' let current = 1;
},{ if (this.questionList[index - 1]) {
op:'B', list.push(this.questionList[index - 1]);
opDesc:'注意新手标志' } else {
},{ current = 0;
op:'C', }
opDesc:'注意新手标志'
},{ list.push(this.questionList[index])
op:'D',
opDesc:'注意新手标志' if (this.questionList[index + 1]) {
}], list.push(this.questionList[index + 1]);
rightOp:'C', }
},{
questionId:1, this.duration = 0;
questionDesc:'在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList:[{ setTimeout(() => {
op:'A', this.swiperList = list;
opDesc:'注意新手标志' this.swiperIndex = current;
},{ setTimeout(() => {
op:'B', this.duration = 200;
opDesc:'注意新手标志' }, 100)
},{ }, 50)
op:'C', },
opDesc:'注意新手标志'
},{ //
op:'D', onChange(e) {
opDesc:'注意新手标志' //
}], if (e.detail.source != "touch") return;
rightOp:'B',
},{ //
questionId:2, this.isChange = true;
questionDesc:'在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?', //
optionList:[{ if (e.detail.current > this.swiperIndex) {
op:'A', this.topicIndex++;
opDesc:'注意新手标志' } else {
},{ //
op:'B', this.topicIndex--;
opDesc:'注意新手标志' }
},{
op:'C', // Vue
opDesc:'注意新手标志' this.swiperIndex = e.detail.current;
},{ },
op:'D', //
opDesc:'注意新手标志' onAnimationfinish(e) {
}], if (!this.isChange) return;
rightOp:'A',
}] this.isChange = false;
} setTimeout(() => {
} this.renderSwiper(this.topicIndex);
} }, 10);
},
//
pickerTopic(index) {
this.topicIndex = index;
this.renderSwiper(index);
},
//
answerQues(op, index) {
if (!this.questionList[this.topicIndex].clickAnswer) {
this.questionList[this.topicIndex].optionList[index].chooseOption = op
this.questionList[this.topicIndex].clickAnswer = op
}
if(this.tCurrent!==1){
if(this.questionList[this.topicIndex].clickAnswer===this.questionList[this.topicIndex].rightOp){
if(this.topicIndex<=this.questionList.length-1){
if(this.topicIndex===this.questionList.length-1){
this.tipShow=true
}else{
this.tipShow=false
}
this.topicIndex ++;
setTimeout(()=>{
this.renderSwiper(this.topicIndex);
},1000)
}
}
}
},
sectionChange(index) {
this.tCurrent = index
this.getQuestionList()
this.renderSwiper(0)
},
getQuestionList() {
this.questionList = [{
questionId: 0,
questionTypeDesc: '单选',
questionDesc: '第一题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'C',
}, {
questionId: 1,
questionTypeDesc: '单选',
questionDesc: '第二题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'B',
}, {
questionId: 2,
questionTypeDesc: '单选',
questionDesc: '第三题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
},
{
questionId: 3,
questionTypeDesc: '单选',
questionDesc: '第四题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
}, {
questionId: 4,
questionTypeDesc: '单选',
questionDesc: '第5题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
},
{
questionId: 5,
questionTypeDesc: '单选',
questionDesc: '第6题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
}, {
questionId: 6,
questionTypeDesc: '单选',
questionDesc: '第7题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
}, {
questionId: 7,
questionTypeDesc: '单选',
questionDesc: '第8题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
}, {
questionId: 8,
questionTypeDesc: '单选',
questionDesc: '第9题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'C',
}, {
questionId: 9,
questionTypeDesc: '单选',
questionDesc: '第10题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'B',
}, {
questionId: 10,
questionTypeDesc: '单选',
questionDesc: '第11题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
},
{
questionId: 11,
questionTypeDesc: '单选',
questionDesc: '第12题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
}, {
questionId: 12,
questionTypeDesc: '单选',
questionDesc: '第13题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
},
{
questionId: 13,
questionTypeDesc: '单选',
questionDesc: '第14题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
}, {
questionId: 14,
questionTypeDesc: '单选',
questionDesc: '第15题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
}, {
questionId: 15,
questionTypeDesc: '单选',
questionDesc: '第16题,在实习期内驾驶机动车的,应当在车身后部粘贴或者悬挂哪种标志?',
optionList: [{
op: 'A',
opDesc: '注意新手标志'
}, {
op: 'B',
opDesc: '注意新手标志'
}, {
op: 'C',
opDesc: '注意新手标志'
}, {
op: 'D',
opDesc: '注意新手标志'
}],
rightOp: 'A',
}
]
if(this.tCurrent===1){
this.questionList=this.questionList.map(item=>{
return{
...item,
clickAnswer:item.rightOp
}
})
}
}
}
}
</script> </script>
<style scoped> <style scoped>
.type_box{ .type_box {
width: 280rpx; width: 280rpx;
height: 72rpx; height: 72rpx;
background-color: #FFFFFF; background-color: #FFFFFF;
border-radius: 8rpx; border-radius: 8rpx;
} }
.type_item{
text-align: center; .type_item {
line-height: 64rpx; text-align: center;
width: 126rpx; line-height: 64rpx;
height: 64rpx; width: 126rpx;
border-radius: 8rpx; height: 64rpx;
border-radius: 8rpx;
} }
.checked{
color: #fff; .checked {
background-color: #05C341; color: #fff;
background-color: #05C341;
} }
.unchecked{
color: #666; .unchecked {
color: #666;
} }
.tag_box{
display: inline-block; .tag_box {
width: 78rpx; display: inline-block;
height: 42rpx; width: 78rpx;
background: #05C341; height: 42rpx;
border-radius: 8rpx; background: #05C341;
text-align: center; border-radius: 8rpx;
line-height: 42rpx; text-align: center;
color: #fff; line-height: 42rpx;
font-size: 12px; color: #fff;
margin-right: 5px; font-size: 12px;
margin-right: 5px;
} }
.option_item{
width: 60rpx; .option_item {
height: 60rpx; width: 60rpx;
border: 1px solid #666; height: 60rpx;
border-radius: 50%; border: 1px solid #666;
text-align: center; border-radius: 50%;
line-height: 60rpx; text-align: center;
margin-right: 30rpx; line-height: 60rpx;
margin-right: 30rpx;
}
.swiper {
height: 100vh;
}
.answer_box {
width: 100%;
padding: 30rpx;
background: #EEEEEE;
border-radius: 20rpx;
} }
</style> </style>

Loading…
Cancel
Save